Update loading + add image configuration if exist + upgrade packages

This commit is contained in:
Thomas Fransolet 2023-11-02 13:24:24 +01:00
parent 0c80aadd9e
commit 87f1443f0c
12 changed files with 82 additions and 55 deletions

View File

@ -1,12 +1,12 @@
buildscript { buildscript {
ext.kotlin_version = '1.6.10' ext.kotlin_version = '1.7.10'
repositories { repositories {
google() google()
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.1.0' classpath 'com.android.tools.build:gradle:7.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
} }
} }
@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app') project.evaluationDependsOn(':app')
} }
task clean(type: Delete) { tasks.register("clean", Delete) {
delete rootProject.buildDir delete rootProject.buildDir
} }

View File

@ -3,7 +3,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart'; import 'package:fluttertoast/fluttertoast.dart';
import 'package:manager_api/api.dart'; import 'package:manager_api/api.dart';
import 'package:mqtt_client/mqtt_browser_client.dart'; //import 'package:mqtt_client/mqtt_browser_client.dart';
import 'package:mqtt_client/mqtt_client.dart'; import 'package:mqtt_client/mqtt_client.dart';
import 'package:mqtt_client/mqtt_server_client.dart'; import 'package:mqtt_client/mqtt_server_client.dart';
import 'package:tablet_app/Helpers/DeviceInfoHelper.dart'; import 'package:tablet_app/Helpers/DeviceInfoHelper.dart';
@ -22,9 +22,9 @@ class MQTTHelper {
TabletAppContext tabletAppContext = appContext.getContext(); TabletAppContext tabletAppContext = appContext.getContext();
if(kIsWeb) { if(kIsWeb) {
tabletAppContext.clientBrowserMQTT!.updates!.listen((List<MqttReceivedMessage<MqttMessage>> c) async { /*tabletAppContext.clientBrowserMQTT!.updates!.listen((List<MqttReceivedMessage<MqttMessage>> c) async {
handleMessage(appContext, c); handleMessage(appContext, c);
}); });*/
} else { } else {
tabletAppContext.clientMQTT!.updates!.listen((List<MqttReceivedMessage<MqttMessage>> c) async { tabletAppContext.clientMQTT!.updates!.listen((List<MqttReceivedMessage<MqttMessage>> c) async {
handleMessage(appContext, c); handleMessage(appContext, c);
@ -141,7 +141,7 @@ class MQTTHelper {
.withWillQos(MqttQos.atLeastOnce); .withWillQos(MqttQos.atLeastOnce);
if(kIsWeb) { if(kIsWeb) {
tabletAppContext.clientBrowserMQTT = MqttBrowserClient.withPort(hostToTake!.replaceAll('http://', ''), 'tablet_app_'+identifier!, 1883); /*tabletAppContext.clientBrowserMQTT = MqttBrowserClient.withPort(hostToTake!.replaceAll('http://', ''), 'tablet_app_'+identifier!, 1883);
tabletAppContext.clientBrowserMQTT!.logging(on: false); tabletAppContext.clientBrowserMQTT!.logging(on: false);
tabletAppContext.clientBrowserMQTT!.keepAlivePeriod = 20; tabletAppContext.clientBrowserMQTT!.keepAlivePeriod = 20;
tabletAppContext.clientBrowserMQTT!.onDisconnected = onDisconnected; tabletAppContext.clientBrowserMQTT!.onDisconnected = onDisconnected;
@ -176,7 +176,7 @@ class MQTTHelper {
} catch (e) { } catch (e) {
print('Exception clientBrowserMQTT: $e'); print('Exception clientBrowserMQTT: $e');
tabletAppContext.clientBrowserMQTT!.disconnect(); tabletAppContext.clientBrowserMQTT!.disconnect();
} }*/
} else { } else {
tabletAppContext.clientMQTT = MqttServerClient.withPort(hostToTake!.replaceAll('http://', ''), 'tablet_app_'+identifier!, 1883); tabletAppContext.clientMQTT = MqttServerClient.withPort(hostToTake!.replaceAll('http://', ''), 'tablet_app_'+identifier!, 1883);
tabletAppContext.clientMQTT!.logging(on: false); tabletAppContext.clientMQTT!.logging(on: false);
@ -218,7 +218,8 @@ class MQTTHelper {
isInstantiated = true; isInstantiated = true;
return kIsWeb ? tabletAppContext.clientBrowserMQTT : tabletAppContext.clientMQTT!; //return kIsWeb ? tabletAppContext.clientBrowserMQTT : tabletAppContext.clientMQTT!;
return tabletAppContext.clientMQTT!;
} }
Future<void> updateDevice(dynamic appContext) async { Future<void> updateDevice(dynamic appContext) async {

View File

@ -1,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:manager_api/api.dart'; import 'package:manager_api/api.dart';
import 'package:mqtt_client/mqtt_browser_client.dart'; //import 'package:mqtt_client/mqtt_browser_client.dart';
import 'package:mqtt_client/mqtt_server_client.dart'; import 'package:mqtt_client/mqtt_server_client.dart';
import 'package:tablet_app/client.dart'; import 'package:tablet_app/client.dart';
import 'dart:convert'; import 'dart:convert';
@ -9,7 +9,7 @@ import 'dart:convert';
class TabletAppContext with ChangeNotifier{ class TabletAppContext with ChangeNotifier{
Client? clientAPI; Client? clientAPI;
MqttServerClient? clientMQTT; MqttServerClient? clientMQTT;
MqttBrowserClient? clientBrowserMQTT; //MqttBrowserClient? clientBrowserMQTT;
String? id; String? id;
String? host; String? host;
ConfigurationDTO? configuration; ConfigurationDTO? configuration;

View File

@ -5,7 +5,7 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:fluttertoast/fluttertoast.dart'; import 'package:fluttertoast/fluttertoast.dart';
import 'package:manager_api/api.dart'; import 'package:manager_api/api.dart';
import 'package:mqtt_client/mqtt_browser_client.dart'; //import 'package:mqtt_client/mqtt_browser_client.dart';
import 'package:mqtt_client/mqtt_server_client.dart'; import 'package:mqtt_client/mqtt_server_client.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:tablet_app/Components/Buttons/rounded_button.dart'; import 'package:tablet_app/Components/Buttons/rounded_button.dart';
@ -39,7 +39,7 @@ class _ConfigViewWidget extends State<ConfigViewWidget> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final appContext = Provider.of<AppContext>(context); final appContext = Provider.of<AppContext>(context);
SystemChrome.setEnabledSystemUIOverlays([]); SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
Size size = MediaQuery.of(context).size; Size size = MediaQuery.of(context).size;
TabletAppContext tabletAppContext = appContext.getContext(); TabletAppContext tabletAppContext = appContext.getContext();
@ -137,7 +137,7 @@ class _ConfigViewWidget extends State<ConfigViewWidget> {
return Center( return Center(
child: Container( child: Container(
height: size.height * 0.2, height: size.height * 0.2,
child: kIsWeb ? LoadingCommon() : Loading() child: LoadingCommon()
) )
); );
} }
@ -205,11 +205,11 @@ class _ConfigViewWidget extends State<ConfigViewWidget> {
var identifier = kIsWeb ? "WEB TEST" : await DeviceInfoHelper.getDeviceDetails(); var identifier = kIsWeb ? "WEB TEST" : await DeviceInfoHelper.getDeviceDetails();
if(kIsWeb) { if(kIsWeb) {
tabletAppContext.clientBrowserMQTT = new MqttBrowserClient(url.replaceAll('http://', ''),'tablet_app_'+ identifier!); //tabletAppContext.clientBrowserMQTT = new MqttBrowserClient(url.replaceAll('http://', ''),'tablet_app_'+ identifier!);
} else } else
{ {
// mobile specific // mobile specific
tabletAppContext!.clientMQTT = new MqttServerClient(url.replaceAll('http://', ''),'tablet_app_'+ identifier!); tabletAppContext.clientMQTT = new MqttServerClient(url.replaceAll('http://', ''),'tablet_app_'+ identifier!);
} }
setState(() { setState(() {

View File

@ -33,15 +33,18 @@ class MainViewWidget extends StatefulWidget {
class _MainViewWidget extends State<MainViewWidget> { class _MainViewWidget extends State<MainViewWidget> {
Size sizeScreen = new Size(1080.0, 1920.0); // Tablet resolution Size sizeScreen = new Size(1080.0, 1920.0); // Tablet resolution
SectionDTO? sectionSelected; SectionDTO? sectionSelected;
late ConfigurationDTO configurationDTO;
int rowCount = 4; int rowCount = 4;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final appContext = Provider.of<AppContext>(context); final appContext = Provider.of<AppContext>(context);
SystemChrome.setEnabledSystemUIOverlays([]); SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
Size size = MediaQuery.of(context).size; Size size = MediaQuery.of(context).size;
configurationDTO = appContext.getContext().configuration;
if (!MQTTHelper.instance.isInstantiated) if (!MQTTHelper.instance.isInstantiated)
MQTTHelper.instance.connect(appContext); MQTTHelper.instance.connect(appContext);
@ -87,7 +90,16 @@ class _MainViewWidget extends State<MainViewWidget> {
child: Container( child: Container(
height: size.height, height: size.height,
width: size.width, width: size.width,
color: appContext.getContext().configuration == null ? kBackgroundGrey : appContext.getContext().configuration.secondaryColor != null ? new Color(int.parse(appContext.getContext().configuration.secondaryColor.split('(0x')[1].split(')')[0], radix: 16)): kBackgroundGrey, color: configurationDTO.imageId == null ? configurationDTO.secondaryColor != null ? new Color(int.parse(configurationDTO.secondaryColor!.split('(0x')[1].split(')')[0], radix: 16)): kBackgroundGrey : null,
decoration: configurationDTO.imageId != null ? BoxDecoration(
image: new DecorationImage(
fit: BoxFit.cover,
colorFilter: new ColorFilter.mode(Colors.grey.withOpacity(0.7), BlendMode.color),
image: new NetworkImage(
configurationDTO.imageSource!,
),
),
) : null,
child: Column( child: Column(
children: [ children: [
Container( Container(
@ -177,12 +189,15 @@ class _MainViewWidget extends State<MainViewWidget> {
width: kIsWeb ? size.width *0.08: 185.0, width: kIsWeb ? size.width *0.08: 185.0,
child: FittedBox( child: FittedBox(
child: FloatingActionButton.extended( child: FloatingActionButton.extended(
backgroundColor: kBackgroundColor,
focusColor: kBackgroundColor,
splashColor: kBackgroundColor,
onPressed: () { onPressed: () {
setState(() { setState(() {
sectionSelected = null; sectionSelected = null;
}); });
}, },
icon: Icon(Icons.arrow_back), icon: Icon(Icons.arrow_back, color: Colors.grey),
label: Text("Menu") label: Text("Menu")
), ),
), ),
@ -194,10 +209,19 @@ class _MainViewWidget extends State<MainViewWidget> {
body: Container( body: Container(
height: size.height, height: size.height,
width: size.width, width: size.width,
color: appContext.getContext().configuration == null ? kBackgroundGrey : appContext.getContext().configuration.secondaryColor != null ? new Color(int.parse(appContext.getContext().configuration.secondaryColor.split('(0x')[1].split(')')[0], radix: 16)): kBackgroundGrey, color: configurationDTO.imageId == null ? configurationDTO.secondaryColor != null ? new Color(int.parse(appContext.getContext().configuration.secondaryColor.split('(0x')[1].split(')')[0], radix: 16)): kBackgroundGrey : null,
decoration: configurationDTO.imageId != null ? BoxDecoration(
image: new DecorationImage(
fit: BoxFit.cover,
colorFilter: new ColorFilter.mode(Colors.grey.withOpacity(0.7), BlendMode.color),
image: new NetworkImage(
configurationDTO.imageSource!,
),
),
) : null,
child: Stack( child: Stack(
children: [ children: [
if (appContext.getContext().configuration != null) LanguageSelection(), if (configurationDTO != null) LanguageSelection(),
Center( Center(
child: Container( child: Container(
height: kIsWeb ? size.height : size.height * 0.85, height: kIsWeb ? size.height : size.height * 0.85,
@ -264,7 +288,7 @@ class _MainViewWidget extends State<MainViewWidget> {
} else { } else {
return Center( return Center(
child: Container( child: Container(
child: kIsWeb ? LoadingCommon() : Loading() child: LoadingCommon()
) )
); );
} }

View File

@ -82,7 +82,7 @@ class _MapViewWidget extends State<MapViewWidget> {
} else { } else {
return Center( return Center(
child: Container( child: Container(
child: kIsWeb ? LoadingCommon() : Loading() child: LoadingCommon()
) )
); );
} }

View File

@ -142,7 +142,7 @@ class _PreviousViewWidget extends State<PreviousViewWidget> with TickerProviderS
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
SystemChrome.setEnabledSystemUIOverlays([]); SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
Size size = MediaQuery Size size = MediaQuery
.of(context) .of(context)
.size; .size;

View File

@ -22,6 +22,8 @@ class _SliderViewWidget extends State<SliderViewWidget> {
CarouselController? sliderController; CarouselController? sliderController;
int currentIndex = 1; int currentIndex = 1;
late ConfigurationDTO configurationDTO;
@override @override
void initState() { void initState() {
sliderController = CarouselController(); sliderController = CarouselController();
@ -43,6 +45,8 @@ class _SliderViewWidget extends State<SliderViewWidget> {
Size size = MediaQuery.of(context).size; Size size = MediaQuery.of(context).size;
final appContext = Provider.of<AppContext>(context); final appContext = Provider.of<AppContext>(context);
configurationDTO = appContext.getContext().configuration;
return Stack( return Stack(
children: [ children: [
Column( Column(
@ -70,7 +74,7 @@ class _SliderViewWidget extends State<SliderViewWidget> {
height: MediaQuery.of(context).size.height, height: MediaQuery.of(context).size.height,
margin: EdgeInsets.symmetric(horizontal: 5.0), margin: EdgeInsets.symmetric(horizontal: 5.0),
decoration: BoxDecoration( decoration: BoxDecoration(
color: appContext.getContext().configuration == null ? kBackgroundGrey : appContext.getContext().configuration.secondaryColor != null ? new Color(int.parse(appContext.getContext().configuration.secondaryColor.split('(0x')[1].split(')')[0], radix: 16)): kBackgroundGrey, color: configurationDTO.imageId == null ? configurationDTO.secondaryColor != null ? new Color(int.parse(configurationDTO.secondaryColor!.split('(0x')[1].split(')')[0], radix: 16)): kBackgroundGrey : null,
borderRadius: BorderRadius.circular(10.0), borderRadius: BorderRadius.circular(10.0),
//border: Border.all(width: 0.3, color: kSecondGrey), //border: Border.all(width: 0.3, color: kSecondGrey),
), ),

View File

@ -1,5 +1,5 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:html'; //import 'dart:html';
import 'dart:ui' as ui; import 'dart:ui' as ui;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
@ -18,7 +18,7 @@ class WebView extends StatefulWidget {
} }
class _WebViewWidget extends State<WebView> { class _WebViewWidget extends State<WebView> {
final IFrameElement _iframeElement = IFrameElement(); //final IFrameElement _iframeElement = IFrameElement();
//WebView _webView; //WebView _webView;
WebDTO webDTO = WebDTO(); WebDTO webDTO = WebDTO();
WebViewController? controller; WebViewController? controller;
@ -31,14 +31,14 @@ class _WebViewWidget extends State<WebView> {
print(webDTO); print(webDTO);
if(kIsWeb) { if(kIsWeb) {
_iframeElement.src = webDTO.source_!; /*_iframeElement.src = webDTO.source_!;
_iframeElement.style.border = 'none'; _iframeElement.style.border = 'none';
//ignore: undefined_prefixed_name //ignore: undefined_prefixed_name
ui.platformViewRegistry.registerViewFactory( ui.platformViewRegistry.registerViewFactory(
webDTO.source_!, //use source as registered key to ensure uniqueness webDTO.source_!, //use source as registered key to ensure uniqueness
(int viewId) => _iframeElement, (int viewId) => _iframeElement,
); );*/
} else { } else {
controller = WebViewController() controller = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted) ..setJavaScriptMode(JavaScriptMode.unrestricted)
@ -94,7 +94,6 @@ class _WebViewWidget extends State<WebView> {
key: UniqueKey(), key: UniqueKey(),
viewType: webDTO.source_!, viewType: webDTO.source_!,
) : ) :
//WebViewWidget(controller: controller!) WebViewWidget(controller: controller!) :
Text("sousou"):
Center(child: Text("La page internet ne peut pas être affichée, l'url est incorrecte ou vide")); Center(child: Text("La page internet ne peut pas être affichée, l'url est incorrecte ou vide"));
} //_webView } //_webView

View File

@ -23,7 +23,7 @@ void main() async {
localContext = await DatabaseHelper.instance.getData(); localContext = await DatabaseHelper.instance.getData();
} }
if(localContext != null) { if(localContext != null && localContext.host != null) {
print("we've got an local db !"); print("we've got an local db !");
localContext.clientAPI = new Client(localContext.host!); localContext.clientAPI = new Client(localContext.host!);
isConfig = localContext.configuration != null; isConfig = localContext.configuration != null;

View File

@ -7,10 +7,10 @@ version: '1.0.0'
description: 'OpenAPI API client' description: 'OpenAPI API client'
homepage: 'homepage' homepage: 'homepage'
environment: environment:
sdk: '>=2.12.0 <3.0.0' sdk: ">=3.1.0 <4.0.0"
dependencies: dependencies:
http: '>=0.13.0 <0.14.0' http: '^1.1.0'
intl: '^0.17.0' intl: '^0.18.0'
meta: '^1.1.8' meta: '^1.1.8'
dev_dependencies: dev_dependencies:
test: '>=1.16.0 <1.18.0' test: '>=1.16.0 <1.18.0'

View File

@ -15,10 +15,10 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at # Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.4.0+4 version: 1.5.0+5
environment: environment:
sdk: ">=2.17.0 <3.0.0" sdk: ">=3.1.0 <4.0.0"
dependencies: dependencies:
flutter: flutter:
@ -26,43 +26,42 @@ dependencies:
# Specific Mobile # Specific Mobile
sqflite: # Specific mobile and macOS sqflite: # Specific mobile and macOS
webview_flutter: ^4.0.1 # Specific mobile # old : ^3.0.4 webview_flutter: ^4.4.1 # Specific mobile # old : ^3.0.4
google_maps_flutter: ^2.0.1 # Specific mobile google_maps_flutter: ^2.5.0 # Specific mobile
youtube_player_flutter: ^8.1.1 # Specific mobile youtube_player_flutter: ^8.1.2 # Specific mobile
# Specific Web # Specific Web
google_maps_flutter_web: ^0.4.0+5 # Specific WEB google_maps_flutter_web: ^0.5.4+2 # Specific WEB
youtube_player_iframe: ^4.0.1 # Handle mobile and web here => TO TEST youtube_player_iframe: ^4.0.4 # Handle mobile and web here => TO TEST
flare_flutter: ^3.0.1 flare_flutter: ^3.0.2
provider: ^6.0.4 provider: ^6.0.5
http: ^0.13.5 http: ^1.1.0
auto_size_text: ^3.0.0 auto_size_text: ^3.0.0
fluttertoast: fluttertoast:
device_info: ^2.0.2 # DISCONTINUED device_info: ^2.0.2 # DISCONTINUED
enum_to_string: ^2.0.1 enum_to_string: ^2.0.1
carousel_slider: ^4.0.0 carousel_slider: ^4.2.1
mqtt_client: ^9.6.8 mqtt_client: ^10.0.0
photo_view: ^0.14.0 photo_view: ^0.14.0
confetti: ^0.7.0 confetti: ^0.7.0
flutter_launcher_icons: ^0.10.0 # All but web flutter_launcher_icons: ^0.13.1 # All but web
flutter_svg_provider: ^1.0.3 flutter_svg_provider: ^1.0.6
openapi_generator_cli: ^4.0.0 openapi_generator_cli: ^4.13.1
openapi_generator: ^4.0.0 openapi_generator: ^4.13.1
openapi_generator_annotations: ^4.0.0 openapi_generator_annotations: ^4.13.1
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.0 cupertino_icons: ^1.0.6
manager_api: manager_api:
path: manager_api path: manager_api
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
build_runner: build_runner:
openapi_generator: ^4.0.0 openapi_generator: ^4.13.1
# For information on the generic Dart part of this file, see the # For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec # following page: https://dart.dev/tools/pub/pubspec