Clean code + add pick location

This commit is contained in:
Thomas Fransolet 2024-03-14 14:41:55 +01:00
parent 15a11b9eb7
commit 8824609fad
17 changed files with 263 additions and 38 deletions

View File

@ -2,7 +2,9 @@ import 'package:flutter/material.dart';
import 'package:manager_app/constants.dart';
class LoadingCommon extends StatefulWidget {
const LoadingCommon({Key? key}) : super(key: key);
double? iconSize;
LoadingCommon({Key? key, this.iconSize}) : super(key: key);
@override
State<LoadingCommon> createState() => _LoadingCommonState();
@ -17,6 +19,7 @@ class _LoadingCommonState extends State<LoadingCommon> with TickerProviderStateM
duration: const Duration(milliseconds: 5000),
vsync: this,
)..repeat();
super.initState();
}
@ -41,7 +44,7 @@ class _LoadingCommonState extends State<LoadingCommon> with TickerProviderStateM
return Center(
child: RotationTransition(
turns: Tween(begin: 0.0, end: 3.0).animate(_controller!),
child: Icon(Icons.museum_outlined, color: kPrimaryColor, size: size.height*0.1),
child: Icon(Icons.museum_outlined, color: kPrimaryColor, size: widget.iconSize == null ? size.height*0.1 : widget.iconSize!),
),
);
}

View File

@ -83,7 +83,7 @@ class MultiStringInputContainer extends StatelessWidget {
},
child: Container(
constraints: BoxConstraints(maxHeight: 100),
constraints: BoxConstraints(maxHeight: 60),
decoration: BoxDecoration(
color: color,
borderRadius: BorderRadius.circular(50),

View File

@ -209,11 +209,13 @@ class _ArticleConfigState extends State<ArticleConfig> {
child: InkWell(
onTap: () async {
var result = await showNewOrUpdateContentSlider(null, appContext, context, true, false);
if(result != null) {
setState(() {
result.order = articleDTO.contents!.length;
articleDTO.contents!.add(result);
widget.onChanged(jsonEncode(articleDTO).toString());
});
}
},
child: Container(
height: MediaQuery.of(context).size.width * 0.04,

View File

@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import 'package:location_picker_flutter_map/location_picker_flutter_map.dart';
import 'package:manager_app/Components/dropDown_input_container.dart';
import 'package:manager_app/Components/loading_common.dart';
import 'package:manager_app/Components/multi_string_input_container.dart';
import 'package:manager_app/Components/rounded_button.dart';
import 'package:manager_app/Components/string_input_container.dart';
@ -43,7 +45,55 @@ void showNewOrUpdateGeoPoint(MapDTO mapDTO, GeoPointDTO? inputGeoPointDTO, Funct
Text("Point géographique", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)),
Column(
children: [
Row(
Container(
width: size.width *0.75,
height: 350,
child: FlutterLocationPicker(
initZoom: 14,
initPosition: geoPointDTO.latitude == null && geoPointDTO.longitude == null ? LatLong(50.429333, 4.891434) : LatLong(double.parse(geoPointDTO.latitude!), double.parse(geoPointDTO.longitude!)),
minZoomLevel: 5,
maxZoomLevel: 17,
markerIcon: const Icon(
Icons.location_pin,
color: kPrimaryColor,
size: 50,
),
loadingWidget: LoadingCommon(iconSize: 40.0),
searchBarHintColor: kPrimaryColor,
mapLoadingBackgroundColor: kSecond,
zoomButtonsBackgroundColor: kPrimaryColor,
zoomButtonsColor: Colors.white,
locationButtonBackgroundColor: kPrimaryColor,
locationButtonsColor: Colors.white,
countryFilter: "be, fr",
trackMyPosition: false,
searchBarHintText: "Chercher une localisation",
searchBarTextColor: Colors.black,
searchBarBackgroundColor: Colors.white,
showSelectLocationButton : true,
selectLocationButtonText: "Choisir cette localisation",
selectedLocationButtonTextstyle: const TextStyle(fontSize: 18, color: kPrimaryColor),
mapLanguage: 'fr',
onError: (e) => print(e),
selectLocationButtonLeadingIcon: const Icon(Icons.check, color: kPrimaryColor),
onPicked: (pickedData) {
print("onPicked");
geoPointDTO.latitude = pickedData.latLong.latitude.toString();
geoPointDTO.longitude = pickedData.latLong.longitude.toString();
print(geoPointDTO.latitude);
print(geoPointDTO.longitude);
},
onChanged: (pickedData) {
print("onChanged");
print(pickedData.latLong.latitude);
print(pickedData.latLong.longitude);
print(pickedData.address);
print(pickedData.addressData);
},
showContributorBadgeForOSM: false,
),
),
/*Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
SizedBox(
@ -69,7 +119,7 @@ void showNewOrUpdateGeoPoint(MapDTO mapDTO, GeoPointDTO? inputGeoPointDTO, Funct
),
)
],
),
),*/
Container(
height: size.height * 0.2,
width: double.infinity,

View File

@ -65,6 +65,7 @@ class _ListViewCard extends State<ListViewCardContent> {
decoration: boxDecoration(widget.listItems[widget.index], widget.appContext),
padding: const EdgeInsets.all(10),
margin: EdgeInsets.symmetric(vertical: 10, horizontal: 10),
//child: widget.listItems[widget.index].resourceUrl != null && !(widget.listItems[widget.index].resourceType == ResourceType.ImageUrl || widget.listItems[widget.index].resourceType == ResourceType.Image) ? Text(widget.listItems[widget.index].resourceType.toString()) : SizedBox(),
),
),
/*Padding(
@ -94,10 +95,12 @@ class _ListViewCard extends State<ListViewCardContent> {
widget.showDescriptionTranslations
);
if(result != null) {
setState(() {
widget.listItems[widget.index] = result;
widget.onChanged(widget.listItems);
});
}
},
child: Padding(
padding: const EdgeInsets.all(8.0),

View File

@ -7,7 +7,7 @@ import 'package:manager_app/app_context.dart';
import 'package:manager_app/constants.dart';
import 'package:manager_api_new/api.dart';
Future<ContentDTO> showNewOrUpdateContentSlider(ContentDTO? inputContentDTO, AppContext appContext, BuildContext context, bool showTitle, bool showDescription) async {
Future<ContentDTO?> showNewOrUpdateContentSlider(ContentDTO? inputContentDTO, AppContext appContext, BuildContext context, bool showTitle, bool showDescription) async {
ContentDTO contentDTO = new ContentDTO();
if (inputContentDTO != null) {

View File

@ -103,11 +103,13 @@ class _SliderConfigState extends State<SliderConfig> {
child: InkWell(
onTap: () async {
var result = await showNewOrUpdateContentSlider(null, appContext, context, true, true);
if(result != null) {
setState(() {
result.order = sliderDTO.contents!.length;
sliderDTO.contents!.add(result);
widget.onChanged(jsonEncode(sliderDTO).toString());
});
}
},
child: Container(
height: MediaQuery.of(context).size.width * 0.04,

View File

@ -166,6 +166,7 @@ Future<List<ResourceDTO?>?> create(ResourceDTO resourceDTO, List<File>? files, L
resourceDTO.instanceId = managerAppContext.instanceId;
try {
print("Trying to create resource");
// ADD LOADING
resourceDTO.dateCreation = DateTime.now();
ResourceDTO? newResource = await managerAppContext.clientAPI!.resourceApi!.resourceCreate(resourceDTO);
print("created resource");
@ -180,9 +181,9 @@ Future<List<ResourceDTO?>?> create(ResourceDTO resourceDTO, List<File>? files, L
UploadTask uploadTask = ref.putData(platformFile.bytes!, metadata);
uploadTask.then((res) {
res.ref.getDownloadURL().then((urlImage) {
res.ref.getDownloadURL().then((urlRessource) {
showNotification(Colors.green, kWhite, 'La ressource a été créée avec succès', context, null);
newResource.url = urlImage;
newResource.url = urlRessource;
(appContext.getContext() as ManagerAppContext).clientAPI!.resourceApi!.resourceUpdate(newResource);
createdResources.add(newResource);
index++;

View File

@ -291,12 +291,7 @@ class _LoginScreenState extends State<LoginScreen> {
} else if (snapshot.connectionState == ConnectionState.none) {
return Text("No data");
} else {
return Center(
child: Container(
height: size.height * 0.1,
child: LoadingCommon()
)
);
return SizedBox();
}
}
)
@ -374,7 +369,7 @@ class _LoginScreenState extends State<LoginScreen> {
},
): Container(
height: size.height * 0.1,
child: LoadingCommon()
child: LoadingCommon(iconSize: 40)
),
],
)

View File

@ -84,6 +84,7 @@ class _MyAppState extends State<MyApp> {
],*/
theme: ThemeData(
primarySwatch: Colors.blue,
primaryColor: kPrimaryColor,
scaffoldBackgroundColor: kBackgroundColor,
//fontFamily: "Vollkorn",
textTheme: TextTheme(bodyLarge: TextStyle(color: kBodyTextColor)),

View File

@ -8,6 +8,7 @@ import Foundation
import audio_session
import firebase_core
import firebase_storage
import geolocator_apple
import just_audio
import package_info_plus
import pasteboard
@ -21,6 +22,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin"))
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
FLTFirebaseStoragePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseStoragePlugin"))
GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin"))
JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
PasteboardPlugin.register(with: registry.registrar(forPlugin: "PasteboardPlugin"))

View File

@ -141,10 +141,10 @@ packages:
dependency: "direct main"
description:
name: intl
sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d"
sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf
url: "https://pub.dev"
source: hosted
version: "0.18.1"
version: "0.19.0"
io:
dependency: transitive
description:

View File

@ -10,7 +10,7 @@ environment:
sdk: ">=3.1.0 <4.0.0"
dependencies:
http: '^1.1.0'
intl: '^0.18.0'
intl: '^0.19.0'
meta: '^1.1.8'
dev_dependencies:
test: '>=1.16.0 <1.18.0'

View File

@ -289,6 +289,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.1.4"
dio:
dependency: transitive
description:
name: dio
sha256: "49af28382aefc53562459104f64d16b9dfd1e8ef68c862d5af436cc8356ce5a8"
url: "https://pub.dev"
source: hosted
version: "5.4.1"
drag_and_drop_lists:
dependency: "direct main"
description:
@ -422,6 +430,38 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.3"
flutter_compass:
dependency: transitive
description:
name: flutter_compass
sha256: be642484f9f6975c1c6edff568281b001f2f1e604de27ecea18d97eebbdef22f
url: "https://pub.dev"
source: hosted
version: "0.8.0"
flutter_map:
dependency: transitive
description:
name: flutter_map
sha256: cda8d72135b697f519287258b5294a57ce2f2a5ebf234f0e406aad4dc14c9399
url: "https://pub.dev"
source: hosted
version: "6.1.0"
flutter_map_cancellable_tile_provider:
dependency: transitive
description:
name: flutter_map_cancellable_tile_provider
sha256: ae18dd59faf74f3eca1d28f83e59b47741bbff962e123bbebe9335c04d432f44
url: "https://pub.dev"
source: hosted
version: "2.0.0"
flutter_map_location_marker:
dependency: transitive
description:
name: flutter_map_location_marker
sha256: c880c0ce6e6f64ade72f72d4d95b54ea75827818350af5596b301e0cbb350dcd
url: "https://pub.dev"
source: hosted
version: "8.0.5"
flutter_plugin_android_lifecycle:
dependency: transitive
description:
@ -520,6 +560,54 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.9.0+2"
geolocator:
dependency: transitive
description:
name: geolocator
sha256: f4efb8d3c4cdcad2e226af9661eb1a0dd38c71a9494b22526f9da80ab79520e5
url: "https://pub.dev"
source: hosted
version: "10.1.1"
geolocator_android:
dependency: transitive
description:
name: geolocator_android
sha256: "136f1c97e1903366393bda514c5d9e98843418baea52899aa45edae9af8a5cd6"
url: "https://pub.dev"
source: hosted
version: "4.5.2"
geolocator_apple:
dependency: transitive
description:
name: geolocator_apple
sha256: "2f2d4ee16c4df269e93c0e382be075cc01d5db6703c3196e4af20a634fe49ef4"
url: "https://pub.dev"
source: hosted
version: "2.3.6"
geolocator_platform_interface:
dependency: transitive
description:
name: geolocator_platform_interface
sha256: "009a21c4bc2761e58dccf07c24f219adaebe0ff707abdfd40b0a763d4003fab9"
url: "https://pub.dev"
source: hosted
version: "4.2.2"
geolocator_web:
dependency: transitive
description:
name: geolocator_web
sha256: "102e7da05b48ca6bf0a5bda0010f886b171d1a08059f01bfe02addd0175ebece"
url: "https://pub.dev"
source: hosted
version: "2.2.1"
geolocator_windows:
dependency: transitive
description:
name: geolocator_windows
sha256: "53da08937d07c24b0d9952eb57a3b474e29aae2abf9dd717f7e1230995f13f0e"
url: "https://pub.dev"
source: hosted
version: "0.2.3"
glob:
dependency: transitive
description:
@ -580,10 +668,10 @@ packages:
dependency: transitive
description:
name: intl
sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d"
sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf
url: "https://pub.dev"
source: hosted
version: "0.18.1"
version: "0.19.0"
io:
dependency: transitive
description:
@ -632,6 +720,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.4.8"
latlong2:
dependency: transitive
description:
name: latlong2
sha256: "18712164760cee655bc790122b0fd8f3d5b3c36da2cb7bf94b68a197fbb0811b"
url: "https://pub.dev"
source: hosted
version: "0.9.0"
leak_tracker:
dependency: transitive
description:
@ -656,6 +752,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.1"
lists:
dependency: transitive
description:
name: lists
sha256: "4ca5c19ae4350de036a7e996cdd1ee39c93ac0a2b840f4915459b7d0a7d4ab27"
url: "https://pub.dev"
source: hosted
version: "1.0.1"
location_picker_flutter_map:
dependency: "direct main"
description:
name: location_picker_flutter_map
sha256: f120dff8807f4b4b1c47934ea08ed56b8b88a174c5124efffeaa0b5703674bd6
url: "https://pub.dev"
source: hosted
version: "3.0.1"
logger:
dependency: transitive
description:
name: logger
sha256: b3ff55aeb08d9d8901b767650285872cb1bb8f508373b3e348d60268b0c7f770
url: "https://pub.dev"
source: hosted
version: "2.1.0"
logging:
dependency: transitive
description:
@ -703,6 +823,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.11.0"
mgrs_dart:
dependency: transitive
description:
name: mgrs_dart
sha256: fb89ae62f05fa0bb90f70c31fc870bcbcfd516c843fb554452ab3396f78586f7
url: "https://pub.dev"
source: hosted
version: "2.0.0"
mime:
dependency: transitive
description:
@ -919,6 +1047,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.7.3"
polylabel:
dependency: transitive
description:
name: polylabel
sha256: "41b9099afb2aa6c1730bdd8a0fab1400d287694ec7615dd8516935fa3144214b"
url: "https://pub.dev"
source: hosted
version: "1.0.1"
pool:
dependency: transitive
description:
@ -927,6 +1063,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.5.1"
proj4dart:
dependency: transitive
description:
name: proj4dart
sha256: c8a659ac9b6864aa47c171e78d41bbe6f5e1d7bd790a5814249e6b68bc44324e
url: "https://pub.dev"
source: hosted
version: "2.1.0"
provider:
dependency: "direct main"
description:
@ -1132,6 +1276,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.2"
unicode:
dependency: transitive
description:
name: unicode
sha256: "0f69e46593d65245774d4f17125c6084d2c20b4e473a983f6e21b7d7762218f1"
url: "https://pub.dev"
source: hosted
version: "0.3.1"
url_launcher:
dependency: transitive
description:
@ -1356,6 +1508,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.0.9"
wkt_parser:
dependency: transitive
description:
name: wkt_parser
sha256: "8a555fc60de3116c00aad67891bcab20f81a958e4219cc106e3c037aa3937f13"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
xdg_directories:
dependency: transitive
description:

View File

@ -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.0+4
version: 2.0.1+5
environment:
sdk: ">=3.1.0 <4.0.0"
@ -45,6 +45,8 @@ dependencies:
pdf: ^3.10.4
multi_select_flutter: ^4.1.3
youtube_player_iframe: ^4.0.4
location_picker_flutter_map: ^3.0.1
#msix: ^2.1.3
#window_size:
# git:

View File

@ -8,6 +8,7 @@
#include <firebase_core/firebase_core_plugin_c_api.h>
#include <firebase_storage/firebase_storage_plugin_c_api.h>
#include <geolocator_windows/geolocator_windows.h>
#include <pasteboard/pasteboard_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h>
@ -16,6 +17,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
registry->GetRegistrarForPlugin("FirebaseCorePluginCApi"));
FirebaseStoragePluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FirebaseStoragePluginCApi"));
GeolocatorWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("GeolocatorWindows"));
PasteboardPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("PasteboardPlugin"));
UrlLauncherWindowsRegisterWithRegistrar(

View File

@ -5,6 +5,7 @@
list(APPEND FLUTTER_PLUGIN_LIST
firebase_core
firebase_storage
geolocator_windows
pasteboard
url_launcher_windows
)