From 17538eb2234d016282c9078dc9e435008ce5542e Mon Sep 17 00:00:00 2001 From: Thomas Fransolet Date: Wed, 24 Apr 2024 09:36:55 +0200 Subject: [PATCH] Fix map select point + add version number on mainview + section detail image video + fix quizz --- lib/Screens/MainView/main_view.dart | 21 ++++++++ lib/Screens/MainView/section_page_detail.dart | 9 ++-- lib/Screens/Map/google_map_view.dart | 12 ++--- lib/Screens/Map/map_box_view.dart | 4 +- lib/Screens/Quizz/quizz_view.dart | 10 ++-- lib/Services/downloadService.dart | 48 +++++++++++-------- macos/Flutter/GeneratedPluginRegistrant.swift | 2 + pubspec.yaml | 9 ++-- 8 files changed, 74 insertions(+), 41 deletions(-) diff --git a/lib/Screens/MainView/main_view.dart b/lib/Screens/MainView/main_view.dart index 359a665..e4c3fce 100644 --- a/lib/Screens/MainView/main_view.dart +++ b/lib/Screens/MainView/main_view.dart @@ -12,6 +12,7 @@ import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_widget_from_html/flutter_widget_from_html.dart'; import 'package:manager_api/api.dart'; +import 'package:package_info/package_info.dart'; import 'package:path_provider/path_provider.dart'; import 'package:provider/provider.dart'; import 'package:tablet_app/Components/loading_common.dart'; @@ -176,6 +177,22 @@ class _MainViewWidget extends State { ) : getGridSections(appContext, textColor), ), ), + Positioned( + bottom: 0, + right: 0, + child: Padding( + padding: const EdgeInsets.all(4.0), + child: FutureBuilder( + future: getPlatformInfo(), + builder: (context, AsyncSnapshot snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + return Text(snapshot.data.version, style: TextStyle(fontSize: 8)); + } + return SizedBox(); + } + ), + ) + ) /*if(configurationDTO.weatherCity != null && configurationDTO.weatherCity!.length > 2 && configurationDTO.weatherResult != null) Positioned( bottom: 0, @@ -381,6 +398,10 @@ class _MainViewWidget extends State { } } + + getPlatformInfo() async { + return await PackageInfo.fromPlatform(); + } } boxDecoration(AppContext appContext, SectionDTO section, bool isSelected) { diff --git a/lib/Screens/MainView/section_page_detail.dart b/lib/Screens/MainView/section_page_detail.dart index d155764..b35a30a 100644 --- a/lib/Screens/MainView/section_page_detail.dart +++ b/lib/Screens/MainView/section_page_detail.dart @@ -17,6 +17,7 @@ import 'package:tablet_app/Screens/MainView/main_view.dart'; import 'package:tablet_app/Screens/Map/geo_point_filter.dart'; import 'package:tablet_app/Screens/Map/map_context.dart'; import 'package:html/parser.dart' show parse; +import 'package:tablet_app/Screens/Menu/menu_view.dart'; import 'package:tablet_app/app_context.dart'; import 'package:tablet_app/constants.dart'; @@ -109,11 +110,11 @@ class _SectionPageDetailState extends State { decoration: boxDecoration(appContext, widget.sectionDTO, true), ) : Container( decoration: BoxDecoration( - color: widget.sectionDTO.imageSource == null ? kBackgroundLight : null, // default color if no image + color: widget.sectionDTO.imageSource == null && widget.sectionDTO.type != SectionType.Video ? kBackgroundLight : null, // default color if no image shape: BoxShape.rectangle, - image: widget.sectionDTO.imageSource != null ? new DecorationImage( - fit: BoxFit.cover, - image: ImageCustomProvider.getImageProvider(appContext, widget.sectionDTO.imageId!, widget.sectionDTO.imageSource!), + image: widget.sectionDTO.imageSource != null || widget.sectionDTO.type == SectionType.Video ? new DecorationImage( + fit: widget.sectionDTO.type == SectionType.Video && widget.sectionDTO.imageId == null ? BoxFit.contain : BoxFit.cover, + image: ImageCustomProvider.getImageProvider(appContext, widget.sectionDTO.imageId, widget.sectionDTO.type == SectionType.Video ? getYoutubeThumbnailUrl(widget.sectionDTO) : widget.sectionDTO.imageSource!), ): null, ), ), diff --git a/lib/Screens/Map/google_map_view.dart b/lib/Screens/Map/google_map_view.dart index b781907..48f0af4 100644 --- a/lib/Screens/Map/google_map_view.dart +++ b/lib/Screens/Map/google_map_view.dart @@ -67,6 +67,7 @@ class _GoogleMapViewState extends State { onTap: () { //setState(() { mapContext.setSelectedPoint(point); + mapContext.setSelectedPointForNavigate(point); //}); }, infoWindow: InfoWindow.noText)); @@ -97,8 +98,6 @@ class _GoogleMapViewState extends State { pointsToShow = widget.geoPoints; - GeoPointDTO? selectedPointNavigate = mapContext.getSelectedPointForNavigate() as GeoPointDTO?; - /*if(!init) { print("getmarkers in build");*/ getMarkers(widget.language, mapContext); @@ -157,10 +156,9 @@ class _GoogleMapViewState extends State { }, markers: markers, onTap: (LatLng location) { - //setState(() { - print(location); - mapContext.setSelectedPoint(null); - // }); + print(location); + mapContext.setSelectedPoint(null); + mapContext.setSelectedPointForNavigate(null); }, ), ), @@ -177,7 +175,7 @@ class _GoogleMapViewState extends State { target: LatLng(double.tryParse(geopoint.latitude!)!, double.tryParse(geopoint.longitude!)!), tilt: 0.0, bearing: 0.0, - zoom: 15.0 + zoom: 16.0 ) )); } diff --git a/lib/Screens/Map/map_box_view.dart b/lib/Screens/Map/map_box_view.dart index 66b40e4..abd7166 100644 --- a/lib/Screens/Map/map_box_view.dart +++ b/lib/Screens/Map/map_box_view.dart @@ -42,6 +42,7 @@ class AnnotationClickListener extends mapBox.OnPointAnnotationClickListener { try{ var markerToShow = markersList.firstWhere((ml) => "${parse(ml.title!.first.value).documentElement!.text}${ml.latitude}${ml.longitude}" == annotation.textField); mapContext.setSelectedPoint(markerToShow); + mapContext.setSelectedPointForNavigate(markerToShow); } catch(e) { print("ISSSUE setSelectedMarker"); print(e); @@ -179,6 +180,7 @@ class _MapBoxViewState extends State { onTapListener: (listener) { // close on tap mapContext.setSelectedPoint(null); + mapContext.setSelectedPointForNavigate(null); }, cameraOptions: mapBox.CameraOptions( center: mapBox.Point(coordinates: widget.mapDTO!.longitude != null && widget.mapDTO!.latitude != null ? mapBox.Position(double.tryParse(widget.mapDTO!.longitude!)!, double.tryParse(widget.mapDTO!.latitude!)!) : mapBox.Position(4.865105, 50.465503)).toJson(), @@ -196,7 +198,7 @@ class _MapBoxViewState extends State { mapboxMap?.easeTo( mapBox.CameraOptions( center: mapBox.Point(coordinates: mapBox.Position(double.tryParse(geoPoint.longitude!)!, double.tryParse(geoPoint.latitude!)!)).toJson(), - zoom: 15, + zoom: 16, bearing: 0, pitch: 3), mapBox.MapAnimationOptions(duration: 2000, startDelay: 0)); diff --git a/lib/Screens/Quizz/quizz_view.dart b/lib/Screens/Quizz/quizz_view.dart index 58f8cb7..75934a9 100644 --- a/lib/Screens/Quizz/quizz_view.dart +++ b/lib/Screens/Quizz/quizz_view.dart @@ -88,13 +88,13 @@ class _QuizzView extends State { var test = goodResponses/quizzDTO.questions!.length; if(0 == test || test < 0.25) - levelToShow = quizzDTO.badLevel!; + levelToShow = quizzDTO.badLevel; if(test>=0.25 && test < 0.5) - levelToShow = quizzDTO.mediumLevel!; + levelToShow = quizzDTO.mediumLevel; if(test>=0.5 && test < 0.75) - levelToShow = quizzDTO.goodLevel!; + levelToShow = quizzDTO.goodLevel; if(test>=0.75 && test <= 1) - levelToShow = quizzDTO.greatLevel!; + levelToShow = quizzDTO.greatLevel; return Column( mainAxisAlignment: MainAxisAlignment.spaceAround, // @@ -122,7 +122,7 @@ class _QuizzView extends State { ), ), ), - if (!showResponses && levelToShow!.label != null && levelToShow.label!.firstWhere((translation) => translation.language == appContext.getContext().language).resourceId != null) + if (levelToShow != null && !showResponses && levelToShow.label != null && levelToShow.label!.firstWhere((translation) => translation.language == appContext.getContext().language).resourceId != null) Container( //height: size.height * 0.2, //width: size.width * 0.25, diff --git a/lib/Services/downloadService.dart b/lib/Services/downloadService.dart index 1666319..d3330ba 100644 --- a/lib/Services/downloadService.dart +++ b/lib/Services/downloadService.dart @@ -4,7 +4,8 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:manager_api/api.dart'; -//import 'package:ota_update/ota_update.dart'; +import 'package:ota_update/ota_update.dart'; +import 'package:package_info/package_info.dart'; //import 'package:package_info_plus/package_info_plus.dart'; import 'package:provider/provider.dart'; import 'package:tablet_app/Models/tabletContext.dart'; @@ -30,29 +31,36 @@ class _DownloadConfigurationWidgetState extends State tryOtaUpdate() async { try { - //print('ABI Platform: ${await OtaUpdate().getAbi()}'); - //final info = await PackageInfo.fromPlatform(); + print('ABI Platform: ${await OtaUpdate().getAbi()}'); + final info = await PackageInfo.fromPlatform(); - /*var test = info.version; + var test = info.version; var test0 = info.appName; var test1 = info.buildNumber; - var test2 = info.buildSignature; - var test3 = info.installerStore; - var test4 = info.packageName;*/ + var test4 = info.packageName; + var versionDispo = 13; + var versionDispoURL = 'https://drive.usercontent.google.com/download?id=1rO8eZBvmDcmARTOtUeGfeuN1buvafg6Z&export=download&authuser=0&confirm=t&uuid=8f923b32-bf10-4f98-abd6-7995cdc2af5e&at=APZUnTUSU7f9pLr8nN4hgW7wvEv6%3A1713883987919'; + + + if(int.parse(test1) <= versionDispo) { + OtaUpdate() + .execute( + versionDispoURL, + destinationFilename: 'app-release_version_2_0_7.apk', + //FOR NOW ANDROID ONLY - ABILITY TO VALIDATE CHECKSUM OF FILE: + //sha256checksum: 'd6da28451a1e15cf7a75f2c3f151befad3b80ad0bb232ab15c20897e54f21478', + ) + .listen( + (OtaEvent event) { + print("OtaEvent"); + print(event); + //setState(() => currentEvent = event); + }, + ); + } //LINK CONTAINS APK OF FLUTTER HELLO WORLD FROM FLUTTER SDK EXAMPLES - /*OtaUpdate() - .execute( - 'https://drive.google.com/file/d/1geAwa_GBiK_lNx_KE4PzzUfybjFFLZsX/view?usp=drive_link', - destinationFilename: 'myinfomate.apk', - //FOR NOW ANDROID ONLY - ABILITY TO VALIDATE CHECKSUM OF FILE: - //sha256checksum: 'd6da28451a1e15cf7a75f2c3f151befad3b80ad0bb232ab15c20897e54f21478', - ) - .listen( - (OtaEvent event) { - setState(() => currentEvent = event); - }, - );*/ + /**/ // ignore: avoid_catches_without_on_clauses } catch (e) { print('Failed to make OTA update. Details: $e'); @@ -70,7 +78,7 @@ class _DownloadConfigurationWidgetState extends State statuses = await [ Permission.requestInstallPackages, ].request(); - tryOtaUpdate(); + //tryOtaUpdate(); } ExportConfigurationDTO? exportConfigurationDTO; diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index c63a011..b416da9 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -9,6 +9,7 @@ import audio_session import firebase_core import firebase_storage import just_audio +import package_info import path_provider_foundation import shared_preferences_foundation import sqflite @@ -20,6 +21,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) FLTFirebaseStoragePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseStoragePlugin")) JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin")) + FLTPackageInfoPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) diff --git a/pubspec.yaml b/pubspec.yaml index 131e86a..10b5187 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ 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. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 2.0.6+12 +version: 2.0.6+13 environment: sdk: ">=3.1.0 <4.0.0" @@ -34,10 +34,11 @@ dependencies: google_maps_flutter_web: ^0.5.4+3 # Specific WEB youtube_player_iframe: ^4.0.4 # Handle mobile and web here => TO TEST - mapbox_maps_flutter: ^1.0.0 + mapbox_maps_flutter: ^1.1.0 ota_update: ^6.0.0 - #package_info_plus: ^6.0.0 + package_info: ^2.0.2 + #package_info_plus: ^8.0.0 # chewie version casse couille qr_flutter: ^4.1.0 flare_flutter: ^3.0.2 @@ -46,7 +47,7 @@ dependencies: auto_size_text: ^3.0.0 fluttertoast: device_info: ^2.0.2 # DISCONTINUED - #device_info_plus: ^10.0.1 // chewie version casse couille, retourne à la 1.0.0 qui fout la merde + #device_info_plus: ^10.0.1 # chewie version casse couille, retourne à la 1.0.0 qui fout la merde enum_to_string: ^2.0.1 carousel_slider: ^4.2.1 mqtt_client: ^10.0.0