diff --git a/assets/images/logo_mp4.png b/assets/images/logo_mp4.png new file mode 100755 index 0000000..6ce22b6 Binary files /dev/null and b/assets/images/logo_mp4.png differ diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 8a9a4b2..5d23c25 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -32,6 +32,8 @@ PODS: - Toast (4.0.0) - wakelock (0.0.1): - Flutter + - webview_flutter_wkwebview (0.0.1): + - Flutter DEPENDENCIES: - camera_avfoundation (from `.symlinks/plugins/camera_avfoundation/ios`) @@ -46,6 +48,7 @@ DEPENDENCIES: - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/ios`) - sqflite (from `.symlinks/plugins/sqflite/ios`) - wakelock (from `.symlinks/plugins/wakelock/ios`) + - webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/ios`) SPEC REPOS: trunk: @@ -78,6 +81,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/sqflite/ios" wakelock: :path: ".symlinks/plugins/wakelock/ios" + webview_flutter_wkwebview: + :path: ".symlinks/plugins/webview_flutter_wkwebview/ios" SPEC CHECKSUMS: camera_avfoundation: 3125e8cd1a4387f6f31c6c63abb8a55892a9eeeb @@ -95,6 +100,7 @@ SPEC CHECKSUMS: sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904 Toast: 91b396c56ee72a5790816f40d3a94dd357abc196 wakelock: d0fc7c864128eac40eba1617cb5264d9c940b46f + webview_flutter_wkwebview: 2e2d318f21a5e036e2c3f26171342e95908bd60a PODFILE CHECKSUM: b634fd49380cdd3837626153fb977533b1916433 diff --git a/lib/config/global_style.dart b/lib/config/global_style.dart index 807d719..8ec2e87 100644 --- a/lib/config/global_style.dart +++ b/lib/config/global_style.dart @@ -8,6 +8,8 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; class GlobalStyle { + static const double cardHeightMultiplication = 1.70; // higher is more longer + // appBar static const Color appBarIconThemeColor = Colors.black; static const double appBarElevation = 0; @@ -171,4 +173,15 @@ class GlobalStyle { static const TextStyle detailFoodSubOptions = TextStyle(color: BLACK77, fontSize: 12); + + static const TextStyle horizontalTitle = + TextStyle(fontSize: 18, fontWeight: FontWeight.bold); + + static const TextStyle cardTitle = + TextStyle(fontSize: 14, color: Colors.black, fontWeight: FontWeight.bold); + + static const TextStyle textPromo = TextStyle( + fontSize: 12, + color: BLACK77, + ); } diff --git a/lib/db/box_photo.dart b/lib/db/box_photo.dart index 8fc6b16..aa1f049 100644 --- a/lib/db/box_photo.dart +++ b/lib/db/box_photo.dart @@ -1,13 +1,12 @@ import 'package:objectbox/objectbox.dart'; import 'package:intl/intl.dart'; -import 'package:mobdr/objectbox.g.dart'; import 'package:mobdr/service/shared_prefs.dart'; // ignore_for_file: public_member_api_docs @Entity() -class Photo { +class VisitPhoto { // specify the id @Id() int id = 0; @@ -22,7 +21,7 @@ class Photo { String tags; int uploaded; - Photo( + VisitPhoto( {this.id = 0, required this.id_visite, required this.id_photo_typologie, @@ -46,7 +45,7 @@ class Photo { String get dateFormat => DateFormat('dd.MM.yyyy hh:mm:ss').format(date_photo); - Photo copyWith({ + VisitPhoto copyWith({ int? id, int? id_visite, int? id_photo_typologie, @@ -59,7 +58,7 @@ class Photo { String? tags, int? uploaded, }) { - return Photo( + return VisitPhoto( id: id ?? this.id, id_visite: id_visite ?? this.id_visite, id_photo_typologie: id_photo_typologie ?? this.id_photo_typologie, diff --git a/lib/db/box_concurrent.dart b/lib/db/box_photo_competitor.dart similarity index 83% rename from lib/db/box_concurrent.dart rename to lib/db/box_photo_competitor.dart index 7cc5bc1..12a2291 100644 --- a/lib/db/box_concurrent.dart +++ b/lib/db/box_photo_competitor.dart @@ -4,7 +4,7 @@ import 'package:mobdr/objectbox.g.dart'; // ignore_for_file: public_member_api_docs @Entity() -class Concurrent { +class EtabCompetitor { // specify the id @Id() int id = 0; @@ -13,13 +13,13 @@ class Concurrent { int id_etab; String nom; - Concurrent( + EtabCompetitor( {this.id = 0, required this.id_concurrence_lien, required this.id_etab, required this.nom}); - Concurrent.fromJson(Map json) + EtabCompetitor.fromJson(Map json) : id_concurrence_lien = json['id_concurrence_lien'], id_etab = json['id_etab'], nom = json['nom']; diff --git a/lib/db/box_visite.dart b/lib/db/box_visit.dart similarity index 100% rename from lib/db/box_visite.dart rename to lib/db/box_visit.dart diff --git a/lib/db/box_visite_tag.dart b/lib/db/box_visit_tag.dart similarity index 100% rename from lib/db/box_visite_tag.dart rename to lib/db/box_visit_tag.dart diff --git a/lib/events.dart b/lib/events.dart new file mode 100644 index 0000000..35cee84 --- /dev/null +++ b/lib/events.dart @@ -0,0 +1,28 @@ +import 'package:event_bus_plus/event_bus_plus.dart'; + +class FollowAppEvent extends AppEvent { + FollowAppEvent(this.username, {String? id}); + + final String username; + + @override + List get props => [username]; +} + +class NewComment extends AppEvent { + NewComment(this.text, {String? id}); + + final String text; + + @override + List get props => [text]; +} + +class UrlEvent extends AppEvent { + UrlEvent(this.url); + + final String url; + + @override + List get props => [url]; +} diff --git a/lib/main.dart b/lib/main.dart index d879d1d..0e8b5c9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -11,11 +11,14 @@ import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; + import 'package:path_provider/path_provider.dart'; import 'objectbox.dart'; import 'package:wakelock/wakelock.dart'; +import 'package:event_bus_plus/event_bus_plus.dart'; + import 'package:mobdr/config/constant.dart'; import 'package:mobdr/cubit/language/language_cubit.dart'; @@ -29,6 +32,8 @@ late ObjectBox objectbox; final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin(); +final EventBus eventBus = EventBus(); + Future main() async { // This is required so ObjectBox can get the application directory // to store the database in. @@ -47,6 +52,10 @@ Future main() async { WidgetsFlutterBinding.ensureInitialized(); Wakelock.enable(); + eventBus.on().listen((event) { + print('${DateTime.now()} Event: $event'); + }); + runApp(MyApp()); }); } @@ -68,6 +77,10 @@ class MyApp extends StatelessWidget { initDirectories(); initPlatformState(); + // url MP4 + SharedPrefs().urlMP4 = + 'https://mp4.ikksgroup.com/MobilePortal4/index.html#ajax/dashboard.html'; + // Initialize all bloc provider used on this entire application here return MultiBlocProvider( providers: [ diff --git a/lib/model/visite_model.dart b/lib/model/visite_model.dart index f32a88b..cc0a5de 100644 --- a/lib/model/visite_model.dart +++ b/lib/model/visite_model.dart @@ -32,7 +32,7 @@ class VisiteModel { id_distrib: visite.id_distrib_visite, id: visite.id, id_visite: visite.id_visite, - name: visite.title, + name: visite.id_etab.toString() + ' - ' + visite.title, photoCount: objectbox.getVisitPhotoCount(visite.id_visite), date: visite.date_visite.toString(), image: visite.url_photo_principale, diff --git a/lib/network/api_provider.dart b/lib/network/api_provider.dart index bb0785d..bb176c9 100644 --- a/lib/network/api_provider.dart +++ b/lib/network/api_provider.dart @@ -12,8 +12,6 @@ import 'package:crypto/crypto.dart'; class ApiProvider { Dio dio = Dio(); - late Response response; - late Response response2; String connErr = 'Please check your internet connection and try again'; Future getCrud(url, body) async { @@ -137,6 +135,7 @@ class ApiProvider { "fingerprint": "aa" // TODO: on peut mettre un fingerprint sur la version ou sur l'heure }; + Response response; try { response = await getCrud( @@ -204,6 +203,9 @@ class ApiProvider { /// Synchronize "stores & competing stores" Future SyncEtablissements() async { + Response response; + Response response2; + try { /// get "Etablissement" list response = await getCrud( @@ -230,7 +232,7 @@ class ApiProvider { if (response2.statusCode == STATUS_OK) { /// fill box "concurrence" - objectbox.addConcurrents(response2.data['concurrents']); + objectbox.addPhotoCompetitors(response2.data['concurrents']); } /// all ok @@ -247,6 +249,9 @@ class ApiProvider { /// Synchronize "visites" Future SyncVisites() async { + Response response; + Response response2; + try { var body = null; @@ -275,7 +280,7 @@ class ApiProvider { if (response2.statusCode == STATUS_OK) { // remove all objects - objectbox.visiteTagBox.removeAll(); + objectbox.visitTagBox.removeAll(); /// fill box "visiteTag" objectbox.addVisiteTags(response2.data['tags']); @@ -295,6 +300,8 @@ class ApiProvider { /// Synchronize "Photos" Future SyncPhotos() async { + Response response; + try { /// get "Photo typologies" response = await getCrud( @@ -306,7 +313,7 @@ class ApiProvider { if (response.statusCode == STATUS_OK) { // remove all objects - objectbox.photoTypologyBox.removeAll(); + objectbox.PhotoTypologyBox.removeAll(); /// fill box "Photo typologies" objectbox.addPhotoTypologies(response.data['typologies']); @@ -324,6 +331,8 @@ class ApiProvider { } Future getExample(apiToken) async { + Response response; + response = await getConnect(ApiConstants.baseUrl + '/example/getData', apiToken); print('res : ' + response.toString()); @@ -331,6 +340,8 @@ class ApiProvider { } Future postExample(String id, apiToken) async { + Response response; + var postData = {'id': id}; response = await postConnect( ApiConstants.baseUrl + '/example/postData', postData, apiToken); @@ -367,6 +378,8 @@ class ApiProvider { 'student_gender': studentGender, 'student_address': studentAddress, }; + Response response; + response = await postConnect( ApiConstants.baseUrl + '/student/addStudent', postData, apiToken); if (response.data['status'] == STATUS_OK) { @@ -395,6 +408,8 @@ class ApiProvider { 'student_gender': studentGender, 'student_address': studentAddress, }; + Response response; + response = await postConnect( ApiConstants.baseUrl + '/student/editStudent', postData, apiToken); if (response.data['status'] == STATUS_OK) { @@ -410,6 +425,7 @@ class ApiProvider { 'session_id': sessionId, 'student_id': studentId, }; + Response response; response = await postConnect( ApiConstants.baseUrl + '/student/deleteStudent', postData, apiToken); if (response.data['status'] == STATUS_OK) { diff --git a/lib/objectbox-model.json b/lib/objectbox-model.json index b98ec04..5495486 100644 --- a/lib/objectbox-model.json +++ b/lib/objectbox-model.json @@ -164,35 +164,6 @@ ], "relations": [] }, - { - "id": "6:1805690312272107423", - "lastPropertyId": "4:7447139022474751374", - "name": "Concurrent", - "properties": [ - { - "id": "1:2904282721431628480", - "name": "id", - "type": 6, - "flags": 1 - }, - { - "id": "2:6658127353491083480", - "name": "id_concurrence_lien", - "type": 6 - }, - { - "id": "3:2563846535684494722", - "name": "id_etab", - "type": 6 - }, - { - "id": "4:7447139022474751374", - "name": "nom", - "type": 9 - } - ], - "relations": [] - }, { "id": "7:8290500625256822711", "lastPropertyId": "14:5831680857919010234", @@ -291,65 +262,6 @@ ], "relations": [] }, - { - "id": "9:6788844671665652158", - "lastPropertyId": "17:7248999677905103482", - "name": "Photo", - "properties": [ - { - "id": "1:2982072387377736709", - "name": "id", - "type": 6, - "flags": 1 - }, - { - "id": "3:1374846727562410311", - "name": "id_visite", - "type": 6 - }, - { - "id": "4:374091471912277059", - "name": "id_photo_typologie", - "type": 6 - }, - { - "id": "6:234947897575384032", - "name": "date_photo", - "type": 10 - }, - { - "id": "7:3602779209059248697", - "name": "id_photo_mp4", - "type": 6 - }, - { - "id": "8:5116665990846416843", - "name": "photo_privee", - "type": 6 - }, - { - "id": "9:1716626028602523655", - "name": "photo_principale", - "type": 6 - }, - { - "id": "14:4568092734700892012", - "name": "uploaded", - "type": 6 - }, - { - "id": "16:539065583624712715", - "name": "image_name", - "type": 9 - }, - { - "id": "17:7248999677905103482", - "name": "tags", - "type": 9 - } - ], - "relations": [] - }, { "id": "10:2779194860339140505", "lastPropertyId": "4:5588276375011055284", @@ -378,16 +290,107 @@ } ], "relations": [] + }, + { + "id": "12:4500693035615595045", + "lastPropertyId": "4:5330383710454562585", + "name": "EtabCompetitor", + "properties": [ + { + "id": "1:7961815144802826808", + "name": "id", + "type": 6, + "flags": 1 + }, + { + "id": "2:5210870817793324298", + "name": "id_concurrence_lien", + "type": 6 + }, + { + "id": "3:7222947234243150693", + "name": "id_etab", + "type": 6 + }, + { + "id": "4:5330383710454562585", + "name": "nom", + "type": 9 + } + ], + "relations": [] + }, + { + "id": "13:6298506278273268036", + "lastPropertyId": "10:427077651567855068", + "name": "VisitPhoto", + "properties": [ + { + "id": "1:1717256666688760598", + "name": "id", + "type": 6, + "flags": 1 + }, + { + "id": "2:6583457577180129132", + "name": "id_visite", + "type": 6 + }, + { + "id": "3:614430257115472469", + "name": "id_photo_typologie", + "type": 6 + }, + { + "id": "4:4379833392180668916", + "name": "image_name", + "type": 9 + }, + { + "id": "5:5816417858904192200", + "name": "date_photo", + "type": 10 + }, + { + "id": "6:1774060819972417032", + "name": "id_photo_mp4", + "type": 6 + }, + { + "id": "7:1161534230522136468", + "name": "photo_privee", + "type": 6 + }, + { + "id": "8:8622794607160372440", + "name": "photo_principale", + "type": 6 + }, + { + "id": "9:2715965548965396457", + "name": "tags", + "type": 9 + }, + { + "id": "10:427077651567855068", + "name": "uploaded", + "type": 6 + } + ], + "relations": [] } ], - "lastEntityId": "10:2779194860339140505", + "lastEntityId": "13:6298506278273268036", "lastIndexId": "1:7907819717055295102", "lastRelationId": "0:0", "lastSequenceId": "0:0", "modelVersion": 5, "modelVersionParserMinimum": 5, "retiredEntityUids": [ - 7401686910042688313 + 7401686910042688313, + 1805690312272107423, + 6788844671665652158, + 2910300629980903548 ], "retiredIndexUids": [ 7907819717055295102 @@ -405,7 +408,25 @@ 2141346538986140281, 7877546811840884522, 3784190804330297742, - 1865824860595482227 + 1865824860595482227, + 2904282721431628480, + 6658127353491083480, + 2563846535684494722, + 7447139022474751374, + 2982072387377736709, + 1374846727562410311, + 374091471912277059, + 234947897575384032, + 3602779209059248697, + 5116665990846416843, + 1716626028602523655, + 4568092734700892012, + 539065583624712715, + 7248999677905103482, + 6313899520679425027, + 4752064214129719799, + 319372524127232986, + 783761731187897018 ], "retiredRelationUids": [], "version": 1 diff --git a/lib/objectbox.dart b/lib/objectbox.dart index 83db299..d73b695 100644 --- a/lib/objectbox.dart +++ b/lib/objectbox.dart @@ -1,9 +1,9 @@ import 'package:mobdr/db/box_user.dart'; import 'package:mobdr/db/box_log.dart'; import 'package:mobdr/db/box_etab.dart'; -import 'package:mobdr/db/box_concurrent.dart'; -import 'package:mobdr/db/box_visite.dart'; -import 'package:mobdr/db/box_visite_tag.dart'; +import 'package:mobdr/db/box_photo_competitor.dart'; +import 'package:mobdr/db/box_visit.dart'; +import 'package:mobdr/db/box_visit_tag.dart'; import 'package:mobdr/db/box_photo.dart'; import 'package:mobdr/db/box_photo_typology.dart'; @@ -20,26 +20,26 @@ class ObjectBox { /// A Box of notes. late final Box noteBox; - /// A Box of "user" + /// A Box of user late final Box userBox; - /// A Box of "Etablissement" + /// A Box of etablishment late final Box etabBox; - /// A Box of "Concurrent" - late final Box concurrentBox; + /// A Box of etablishment competitor + late final Box etabCompetitorBox; - /// A Box of "Visite" - late final Box visiteBox; + /// A Box of visit + late final Box visitBox; - /// A Box of "Visite tag" - late final Box visiteTagBox; + /// A Box for all visit tag by distributor / language + late final Box visitTagBox; - /// A Box of "Photo" - late final Box photoBox; + /// A Box of visit Photo + late final Box visitPhotoBox; - /// A Box of "Photo typology" - late final Box photoTypologyBox; + /// A Box of photo typology + late final Box PhotoTypologyBox; /// A Box of log. late final Box logBox; @@ -48,11 +48,11 @@ class ObjectBox { noteBox = Box(store); userBox = Box(store); etabBox = Box(store); - concurrentBox = Box(store); - visiteBox = Box(store); - visiteTagBox = Box(store); - photoBox = Box(store); - photoTypologyBox = Box(store); + etabCompetitorBox = Box(store); + visitBox = Box(store); + visitTagBox = Box(store); + PhotoTypologyBox = Box(store); + visitPhotoBox = Box(store); logBox = Box(store); // Add some demo data if the box is empty. @@ -61,13 +61,13 @@ class ObjectBox { } userBox.removeAll(); - etabBox.removeAll(); - concurrentBox.removeAll(); - //visiteBox.removeAll(); - //visiteTagBox.removeAll(); - //photoBox.removeAll(); - //photoTypologyBox.removeAll(); + //etabBox.removeAll(); + //etabCompetitorBox.removeAll(); + //visitBox.removeAll(); + //visitTagBox.removeAll(); + //visitPhotoBox.removeAll(); + //PhotoTypologyBox.removeAll(); // Add some demo data if the box is empty. if (userBox.isEmpty()) { @@ -200,39 +200,52 @@ class ObjectBox { return etabBox.count(); } - /// CONCURRENT --------------------------------------------------------------- + /// PHOTO COMPETITOR --------------------------------------------------------------- /// - // A function that converts a response body list into a List. - List parseConcurrents(List responseDataList) { + // A function that converts a response body list into a List. + List parsePhotoCompetitor(List responseDataList) { final parsed = responseDataList.cast>(); - return parsed.map((json) => Concurrent.fromJson(json)).toList(); + return parsed + .map((json) => EtabCompetitor.fromJson(json)) + .toList(); } - Future addConcurrents(List _listConcurrents) => - store.runInTransactionAsync(TxMode.write, _addConcurrentsInTx, - parseConcurrents(_listConcurrents)); + Future addPhotoCompetitors(List _listPhotoCompetitors) => + store.runInTransactionAsync(TxMode.write, _addPhotoCompetitorsInTx, + parsePhotoCompetitor(_listPhotoCompetitors)); - static void _addConcurrentsInTx(Store store, _Concurrents) { - store.box().putMany(_Concurrents); + static void _addPhotoCompetitorsInTx(Store store, _Competitors) { + store.box().putMany(_Competitors); } - Future addConcurrent(int _id_concurrence_lien, int _id_etab, _nom) => + Future addPhotoCompetitor( + int _id_concurrence_lien, int _id_etab, _nom) => store.runInTransactionAsync( TxMode.write, - _addConcurrentInTx, - Concurrent( + _addPhotoCompetitorInTx, + EtabCompetitor( id_concurrence_lien: _id_concurrence_lien, id_etab: _id_etab, nom: _nom, )); - static void _addConcurrentInTx(Store store, _Concurrent) { - store.box().put(_Concurrent); + static void _addPhotoCompetitorInTx(Store store, _Competitor) { + store.box().put(_Competitor); } - int getConcurrentCount() { - return concurrentBox.count(); + List getPhotoCompetitorList() { + final query = etabCompetitorBox + .query(EtabCompetitor_.id_etab.equals(1417)) + .order(EtabCompetitor_.nom) + .build(); + final photoCompetitors = query.find(); + + return photoCompetitors.toList(); + } + + int getPhotoCompetitorsCount() { + return etabCompetitorBox.count(); } /// VISITE ------------------------------------------------------------------ @@ -242,7 +255,7 @@ class ObjectBox { // Query for all visites, sorted by their date. // https://docs.objectbox.io/queries final builder = - visiteBox.query().order(Visite_.date_visite, flags: Order.descending); + visitBox.query().order(Visite_.date_visite, flags: Order.descending); // Build and watch the query, // set triggerImmediately to emit the query immediately on listen. return builder @@ -253,7 +266,7 @@ class ObjectBox { List getAllVisites() { // Query for all visites, sorted by their date. - final builder = visiteBox + final builder = visitBox .query() .order(Visite_.date_visite, flags: Order.descending) .build(); @@ -309,7 +322,7 @@ class ObjectBox { } int getVisiteCount() { - return visiteBox.count(); + return visitBox.count(); } //TODO changer en PHOTO TAG / mettre dans l'ordre CRUD @@ -352,7 +365,7 @@ class ObjectBox { } List getVisiteTagsLabels(int distribId, String langage) { - final query = visiteTagBox + final query = visitTagBox .query(VisiteTag_.id_distrib.equals(distribId) & VisiteTag_.langage.equals(langage)) //.order(VisiteTag_.libelle) @@ -364,15 +377,15 @@ class ObjectBox { } int getVisiteTagCount() { - return visiteTagBox.count(); + return visitTagBox.count(); } /// PHOTO -------------------------------------------------------------------- /// /// - Future> addPhotos(List photos) async { - final addedPhotos = await photoBox.putAndGetManyAsync(photos); + Future> addPhotos(List photos) async { + final addedPhotos = await visitPhotoBox.putAndGetManyAsync(photos); return addedPhotos; } @@ -381,7 +394,7 @@ class ObjectBox { store.runInTransactionAsync( TxMode.write, _addPhotoInTx, - Photo( + VisitPhoto( id_visite: id_visite, id_photo_typologie: id_photo_typologie, image_name: image_name)); @@ -389,17 +402,17 @@ class ObjectBox { static void _addPhotoInTx(Store store, _Photo) { // Perform ObjectBox operations that take longer than a few milliseconds // here. To keep it simple, this example just puts a single object. - store.box().put(_Photo); + store.box().put(_Photo); } - List getAllVisitTypologyPhotos( + List getAllVisitTypologyPhotos( int id_visite, int _id_photo_typologie) { // Query for all photos, sorted by their date. // https://docs.objectbox.io/queries - final query = photoBox - .query(Photo_.id_visite.equals(id_visite) & - Photo_.id_photo_typologie.equals(_id_photo_typologie)) - .order(Photo_.date_photo, flags: Order.descending) + final query = visitPhotoBox + .query(VisitPhoto_.id_visite.equals(id_visite) & + VisitPhoto_.id_photo_typologie.equals(_id_photo_typologie)) + .order(VisitPhoto_.date_photo, flags: Order.descending) .build(); return query.find(); } @@ -411,16 +424,17 @@ class ObjectBox { /// /// Returns: /// A Photo object, or null if no object is found. - Photo? getPhotoById(int id_photo) { - final photo = photoBox.get(id_photo); + VisitPhoto? getPhotoById(int id_photo) { + final photo = visitPhotoBox.get(id_photo); return photo; } - Stream> getPhotos() { + Stream> getPhotos() { // Query for all photos, sorted by their date. // https://docs.objectbox.io/queries - final builder = - photoBox.query().order(Photo_.date_photo, flags: Order.descending); + final builder = visitPhotoBox + .query() + .order(VisitPhoto_.date_photo, flags: Order.descending); // Build and watch the query, // set triggerImmediately to emit the query immediately on listen. return builder @@ -430,59 +444,61 @@ class ObjectBox { } void delPhoto(String _name) { - final query = photoBox.query(Photo_.image_name.equals(_name)).build(); + final query = + visitPhotoBox.query(VisitPhoto_.image_name.equals(_name)).build(); final results = query.find(); if (results.isNotEmpty) { final photoToDelete = results.first; - photoBox.removeAsync(photoToDelete.id); + visitPhotoBox.removeAsync(photoToDelete.id); } } int getVisitPhotoCount(int _id_visite) { - final builder = photoBox.query(Photo_.id_visite.equals(_id_visite)).build(); + final builder = + visitPhotoBox.query(VisitPhoto_.id_visite.equals(_id_visite)).build(); return builder.count(); } int getVisitTypologiePhotoCount(int _id_visite, int _id_photo_typologie) { - final builder = photoBox - .query(Photo_.id_visite.equals(_id_visite) & - Photo_.id_photo_typologie.equals(_id_photo_typologie)) + final builder = visitPhotoBox + .query(VisitPhoto_.id_visite.equals(_id_visite) & + VisitPhoto_.id_photo_typologie.equals(_id_photo_typologie)) .build(); return builder.count(); } Future putPhotoTypologie(int photoId, int typologieId) async { - final photo = photoBox.get(photoId); + final photo = visitPhotoBox.get(photoId); if (photo != null) { final updatedPhoto = photo.copyWith(id_photo_typologie: typologieId); - await photoBox.putAsync(updatedPhoto); + await visitPhotoBox.putAsync(updatedPhoto); } } Future putPhotoTags(int photoId, List tags) async { - final photo = photoBox.get(photoId); + final photo = visitPhotoBox.get(photoId); if (photo != null) { final updatedPhoto = photo.copyWith(tags: tags.join(",")); - await photoBox.putAsync(updatedPhoto); + await visitPhotoBox.putAsync(updatedPhoto); } } Future putPhotoVisibilities( int photoId, List visibilities) async { - final photo = photoBox.get(photoId); + final photo = visitPhotoBox.get(photoId); if (photo != null) { final updatedPhoto = photo.copyWith( photo_principale: visibilities.contains('principal') ? 1 : 0, photo_privee: visibilities.contains('private') ? 1 : 0); - await photoBox.putAsync(updatedPhoto); + await visitPhotoBox.putAsync(updatedPhoto); } } /* remettre les principal à zero - final queryBuilder = box.query(Photo_.visite_id.equals(idVisite) & Photo_.photo_principale.equals(1)); + final queryBuilder = box.query(VisitPhoto_.visite_id.equals(idVisite) & VisitPhoto_.photo_principale.equals(1)); final updatedPhotos = queryBuilder.build().find(); updatedPhotos.forEach((photo) { photo.photo_principale = 0; @@ -525,7 +541,7 @@ class ObjectBox { } List getPhotoTypologiesLabels() { - final query = photoTypologyBox.query().order(PhotoTypology_.ordre).build(); + final query = PhotoTypologyBox.query().order(PhotoTypology_.ordre).build(); final photoTypologies = query.find(); return photoTypologies .map((photoTypology) => photoTypology.libelle) @@ -533,7 +549,7 @@ class ObjectBox { } List getPhotoTypologiesList() { - final query = photoTypologyBox.query().order(PhotoTypology_.ordre).build(); + final query = PhotoTypologyBox.query().order(PhotoTypology_.ordre).build(); final photoTypologies = query.find(); return photoTypologies.toList(); @@ -542,7 +558,7 @@ class ObjectBox { Stream> getPhotoTypologies() { // Query for all Typologies, sorted by their order. // https://docs.objectbox.io/queries - final builder = photoTypologyBox.query().order(PhotoTypology_.ordre); + final builder = PhotoTypologyBox.query().order(PhotoTypology_.ordre); // Build and watch the query, // set triggerImmediately to emit the query immediately on listen. return builder diff --git a/lib/objectbox.g.dart b/lib/objectbox.g.dart index 2932a61..53ba97b 100644 --- a/lib/objectbox.g.dart +++ b/lib/objectbox.g.dart @@ -14,14 +14,14 @@ import 'package:objectbox/internal.dart'; // generated code can access "internal import 'package:objectbox/objectbox.dart'; import 'package:objectbox_flutter_libs/objectbox_flutter_libs.dart'; -import 'db/box_concurrent.dart'; import 'db/box_etab.dart'; import 'db/box_log.dart'; import 'db/box_photo.dart'; +import 'db/box_photo_competitor.dart'; import 'db/box_photo_typology.dart'; import 'db/box_user.dart'; -import 'db/box_visite.dart'; -import 'db/box_visite_tag.dart'; +import 'db/box_visit.dart'; +import 'db/box_visit_tag.dart'; import 'model.dart'; export 'package:objectbox/objectbox.dart'; // so that callers only have to import this file @@ -188,35 +188,6 @@ final _entities = [ ], relations: [], backlinks: []), - ModelEntity( - id: const IdUid(6, 1805690312272107423), - name: 'Concurrent', - lastPropertyId: const IdUid(4, 7447139022474751374), - flags: 0, - properties: [ - ModelProperty( - id: const IdUid(1, 2904282721431628480), - name: 'id', - type: 6, - flags: 1), - ModelProperty( - id: const IdUid(2, 6658127353491083480), - name: 'id_concurrence_lien', - type: 6, - flags: 0), - ModelProperty( - id: const IdUid(3, 2563846535684494722), - name: 'id_etab', - type: 6, - flags: 0), - ModelProperty( - id: const IdUid(4, 7447139022474751374), - name: 'nom', - type: 9, - flags: 0) - ], - relations: [], - backlinks: []), ModelEntity( id: const IdUid(7, 8290500625256822711), name: 'Visite', @@ -315,65 +286,6 @@ final _entities = [ ], relations: [], backlinks: []), - ModelEntity( - id: const IdUid(9, 6788844671665652158), - name: 'Photo', - lastPropertyId: const IdUid(17, 7248999677905103482), - flags: 0, - properties: [ - ModelProperty( - id: const IdUid(1, 2982072387377736709), - name: 'id', - type: 6, - flags: 1), - ModelProperty( - id: const IdUid(3, 1374846727562410311), - name: 'id_visite', - type: 6, - flags: 0), - ModelProperty( - id: const IdUid(4, 374091471912277059), - name: 'id_photo_typologie', - type: 6, - flags: 0), - ModelProperty( - id: const IdUid(6, 234947897575384032), - name: 'date_photo', - type: 10, - flags: 0), - ModelProperty( - id: const IdUid(7, 3602779209059248697), - name: 'id_photo_mp4', - type: 6, - flags: 0), - ModelProperty( - id: const IdUid(8, 5116665990846416843), - name: 'photo_privee', - type: 6, - flags: 0), - ModelProperty( - id: const IdUid(9, 1716626028602523655), - name: 'photo_principale', - type: 6, - flags: 0), - ModelProperty( - id: const IdUid(14, 4568092734700892012), - name: 'uploaded', - type: 6, - flags: 0), - ModelProperty( - id: const IdUid(16, 539065583624712715), - name: 'image_name', - type: 9, - flags: 0), - ModelProperty( - id: const IdUid(17, 7248999677905103482), - name: 'tags', - type: 9, - flags: 0) - ], - relations: [], - backlinks: []), ModelEntity( id: const IdUid(10, 2779194860339140505), name: 'PhotoTypology', @@ -402,6 +314,94 @@ final _entities = [ flags: 0) ], relations: [], + backlinks: []), + ModelEntity( + id: const IdUid(12, 4500693035615595045), + name: 'EtabCompetitor', + lastPropertyId: const IdUid(4, 5330383710454562585), + flags: 0, + properties: [ + ModelProperty( + id: const IdUid(1, 7961815144802826808), + name: 'id', + type: 6, + flags: 1), + ModelProperty( + id: const IdUid(2, 5210870817793324298), + name: 'id_concurrence_lien', + type: 6, + flags: 0), + ModelProperty( + id: const IdUid(3, 7222947234243150693), + name: 'id_etab', + type: 6, + flags: 0), + ModelProperty( + id: const IdUid(4, 5330383710454562585), + name: 'nom', + type: 9, + flags: 0) + ], + relations: [], + backlinks: []), + ModelEntity( + id: const IdUid(13, 6298506278273268036), + name: 'VisitPhoto', + lastPropertyId: const IdUid(10, 427077651567855068), + flags: 0, + properties: [ + ModelProperty( + id: const IdUid(1, 1717256666688760598), + name: 'id', + type: 6, + flags: 1), + ModelProperty( + id: const IdUid(2, 6583457577180129132), + name: 'id_visite', + type: 6, + flags: 0), + ModelProperty( + id: const IdUid(3, 614430257115472469), + name: 'id_photo_typologie', + type: 6, + flags: 0), + ModelProperty( + id: const IdUid(4, 4379833392180668916), + name: 'image_name', + type: 9, + flags: 0), + ModelProperty( + id: const IdUid(5, 5816417858904192200), + name: 'date_photo', + type: 10, + flags: 0), + ModelProperty( + id: const IdUid(6, 1774060819972417032), + name: 'id_photo_mp4', + type: 6, + flags: 0), + ModelProperty( + id: const IdUid(7, 1161534230522136468), + name: 'photo_privee', + type: 6, + flags: 0), + ModelProperty( + id: const IdUid(8, 8622794607160372440), + name: 'photo_principale', + type: 6, + flags: 0), + ModelProperty( + id: const IdUid(9, 2715965548965396457), + name: 'tags', + type: 9, + flags: 0), + ModelProperty( + id: const IdUid(10, 427077651567855068), + name: 'uploaded', + type: 6, + flags: 0) + ], + relations: [], backlinks: []) ]; @@ -425,11 +425,16 @@ Future openStore( ModelDefinition getObjectBoxModel() { final model = ModelInfo( entities: _entities, - lastEntityId: const IdUid(10, 2779194860339140505), + lastEntityId: const IdUid(13, 6298506278273268036), lastIndexId: const IdUid(1, 7907819717055295102), lastRelationId: const IdUid(0, 0), lastSequenceId: const IdUid(0, 0), - retiredEntityUids: const [7401686910042688313], + retiredEntityUids: const [ + 7401686910042688313, + 1805690312272107423, + 6788844671665652158, + 2910300629980903548 + ], retiredIndexUids: const [7907819717055295102], retiredPropertyUids: const [ 402019719780433349, @@ -444,7 +449,25 @@ ModelDefinition getObjectBoxModel() { 2141346538986140281, 7877546811840884522, 3784190804330297742, - 1865824860595482227 + 1865824860595482227, + 2904282721431628480, + 6658127353491083480, + 2563846535684494722, + 7447139022474751374, + 2982072387377736709, + 1374846727562410311, + 374091471912277059, + 234947897575384032, + 3602779209059248697, + 5116665990846416843, + 1716626028602523655, + 4568092734700892012, + 539065583624712715, + 7248999677905103482, + 6313899520679425027, + 4752064214129719799, + 319372524127232986, + 783761731187897018 ], retiredRelationUids: const [], modelVersion: 5, @@ -622,43 +645,10 @@ ModelDefinition getObjectBoxModel() { latitude: const fb.StringReader(asciiOptimization: true) .vTableGet(buffer, rootOffset, 18, '')); - return object; - }), - Concurrent: EntityDefinition( - model: _entities[4], - toOneRelations: (Concurrent object) => [], - toManyRelations: (Concurrent object) => {}, - getId: (Concurrent object) => object.id, - setId: (Concurrent object, int id) { - object.id = id; - }, - objectToFB: (Concurrent object, fb.Builder fbb) { - final nomOffset = fbb.writeString(object.nom); - fbb.startTable(5); - fbb.addInt64(0, object.id); - fbb.addInt64(1, object.id_concurrence_lien); - fbb.addInt64(2, object.id_etab); - fbb.addOffset(3, nomOffset); - fbb.finish(fbb.endTable()); - return object.id; - }, - objectFromFB: (Store store, ByteData fbData) { - final buffer = fb.BufferContext(fbData); - final rootOffset = buffer.derefObject(0); - - final object = Concurrent( - id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0), - id_concurrence_lien: - const fb.Int64Reader().vTableGet(buffer, rootOffset, 6, 0), - id_etab: - const fb.Int64Reader().vTableGet(buffer, rootOffset, 8, 0), - nom: const fb.StringReader(asciiOptimization: true) - .vTableGet(buffer, rootOffset, 10, '')); - return object; }), Visite: EntityDefinition( - model: _entities[5], + model: _entities[4], toOneRelations: (Visite object) => [], toManyRelations: (Visite object) => {}, getId: (Visite object) => object.id, @@ -716,7 +706,7 @@ ModelDefinition getObjectBoxModel() { return object; }), VisiteTag: EntityDefinition( - model: _entities[6], + model: _entities[5], toOneRelations: (VisiteTag object) => [], toManyRelations: (VisiteTag object) => {}, getId: (VisiteTag object) => object.id, @@ -750,62 +740,10 @@ ModelDefinition getObjectBoxModel() { langage: const fb.StringReader(asciiOptimization: true) .vTableGet(buffer, rootOffset, 12, '')); - return object; - }), - Photo: EntityDefinition( - model: _entities[7], - toOneRelations: (Photo object) => [], - toManyRelations: (Photo object) => {}, - getId: (Photo object) => object.id, - setId: (Photo object, int id) { - object.id = id; - }, - objectToFB: (Photo object, fb.Builder fbb) { - final image_nameOffset = fbb.writeString(object.image_name); - final tagsOffset = fbb.writeString(object.tags); - fbb.startTable(18); - fbb.addInt64(0, object.id); - fbb.addInt64(2, object.id_visite); - fbb.addInt64(3, object.id_photo_typologie); - fbb.addInt64(5, object.date_photo.millisecondsSinceEpoch); - fbb.addInt64(6, object.id_photo_mp4); - fbb.addInt64(7, object.photo_privee); - fbb.addInt64(8, object.photo_principale); - fbb.addInt64(13, object.uploaded); - fbb.addOffset(15, image_nameOffset); - fbb.addOffset(16, tagsOffset); - fbb.finish(fbb.endTable()); - return object.id; - }, - objectFromFB: (Store store, ByteData fbData) { - final buffer = fb.BufferContext(fbData); - final rootOffset = buffer.derefObject(0); - - final object = Photo( - id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0), - id_visite: - const fb.Int64Reader().vTableGet(buffer, rootOffset, 8, 0), - id_photo_typologie: - const fb.Int64Reader().vTableGet(buffer, rootOffset, 10, 0), - image_name: const fb.StringReader(asciiOptimization: true) - .vTableGet(buffer, rootOffset, 34, ''), - id_photo_mp4: - const fb.Int64Reader().vTableGet(buffer, rootOffset, 16, 0), - photo_privee: - const fb.Int64Reader().vTableGet(buffer, rootOffset, 18, 0), - photo_principale: - const fb.Int64Reader().vTableGet(buffer, rootOffset, 20, 0), - tags: const fb.StringReader(asciiOptimization: true) - .vTableGet(buffer, rootOffset, 36, ''), - date_photo: DateTime.fromMillisecondsSinceEpoch( - const fb.Int64Reader().vTableGet(buffer, rootOffset, 14, 0)), - uploaded: - const fb.Int64Reader().vTableGet(buffer, rootOffset, 30, 0)); - return object; }), PhotoTypology: EntityDefinition( - model: _entities[8], + model: _entities[6], toOneRelations: (PhotoTypology object) => [], toManyRelations: (PhotoTypology object) => {}, getId: (PhotoTypology object) => object.id, @@ -835,6 +773,91 @@ ModelDefinition getObjectBoxModel() { ordre: const fb.Int64Reader().vTableGet(buffer, rootOffset, 10, 0)); + return object; + }), + EtabCompetitor: EntityDefinition( + model: _entities[7], + toOneRelations: (EtabCompetitor object) => [], + toManyRelations: (EtabCompetitor object) => {}, + getId: (EtabCompetitor object) => object.id, + setId: (EtabCompetitor object, int id) { + object.id = id; + }, + objectToFB: (EtabCompetitor object, fb.Builder fbb) { + final nomOffset = fbb.writeString(object.nom); + fbb.startTable(5); + fbb.addInt64(0, object.id); + fbb.addInt64(1, object.id_concurrence_lien); + fbb.addInt64(2, object.id_etab); + fbb.addOffset(3, nomOffset); + fbb.finish(fbb.endTable()); + return object.id; + }, + objectFromFB: (Store store, ByteData fbData) { + final buffer = fb.BufferContext(fbData); + final rootOffset = buffer.derefObject(0); + + final object = EtabCompetitor( + id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0), + id_concurrence_lien: + const fb.Int64Reader().vTableGet(buffer, rootOffset, 6, 0), + id_etab: + const fb.Int64Reader().vTableGet(buffer, rootOffset, 8, 0), + nom: const fb.StringReader(asciiOptimization: true) + .vTableGet(buffer, rootOffset, 10, '')); + + return object; + }), + VisitPhoto: EntityDefinition( + model: _entities[8], + toOneRelations: (VisitPhoto object) => [], + toManyRelations: (VisitPhoto object) => {}, + getId: (VisitPhoto object) => object.id, + setId: (VisitPhoto object, int id) { + object.id = id; + }, + objectToFB: (VisitPhoto object, fb.Builder fbb) { + final image_nameOffset = fbb.writeString(object.image_name); + final tagsOffset = fbb.writeString(object.tags); + fbb.startTable(11); + fbb.addInt64(0, object.id); + fbb.addInt64(1, object.id_visite); + fbb.addInt64(2, object.id_photo_typologie); + fbb.addOffset(3, image_nameOffset); + fbb.addInt64(4, object.date_photo.millisecondsSinceEpoch); + fbb.addInt64(5, object.id_photo_mp4); + fbb.addInt64(6, object.photo_privee); + fbb.addInt64(7, object.photo_principale); + fbb.addOffset(8, tagsOffset); + fbb.addInt64(9, object.uploaded); + fbb.finish(fbb.endTable()); + return object.id; + }, + objectFromFB: (Store store, ByteData fbData) { + final buffer = fb.BufferContext(fbData); + final rootOffset = buffer.derefObject(0); + + final object = VisitPhoto( + id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0), + id_visite: + const fb.Int64Reader().vTableGet(buffer, rootOffset, 6, 0), + id_photo_typologie: + const fb.Int64Reader().vTableGet(buffer, rootOffset, 8, 0), + image_name: const fb.StringReader(asciiOptimization: true) + .vTableGet(buffer, rootOffset, 10, ''), + id_photo_mp4: + const fb.Int64Reader().vTableGet(buffer, rootOffset, 14, 0), + photo_privee: + const fb.Int64Reader().vTableGet(buffer, rootOffset, 16, 0), + photo_principale: + const fb.Int64Reader().vTableGet(buffer, rootOffset, 18, 0), + tags: const fb.StringReader(asciiOptimization: true) + .vTableGet(buffer, rootOffset, 20, ''), + date_photo: DateTime.fromMillisecondsSinceEpoch( + const fb.Int64Reader().vTableGet(buffer, rootOffset, 12, 0)), + uploaded: + const fb.Int64Reader().vTableGet(buffer, rootOffset, 22, 0)); + return object; }) }; @@ -932,148 +955,150 @@ class Etab_ { QueryStringProperty(_entities[3].properties[7]); } -/// [Concurrent] entity fields to define ObjectBox queries. -class Concurrent_ { - /// see [Concurrent.id] - static final id = - QueryIntegerProperty(_entities[4].properties[0]); - - /// see [Concurrent.id_concurrence_lien] - static final id_concurrence_lien = - QueryIntegerProperty(_entities[4].properties[1]); - - /// see [Concurrent.id_etab] - static final id_etab = - QueryIntegerProperty(_entities[4].properties[2]); - - /// see [Concurrent.nom] - static final nom = - QueryStringProperty(_entities[4].properties[3]); -} - /// [Visite] entity fields to define ObjectBox queries. class Visite_ { /// see [Visite.id] - static final id = QueryIntegerProperty(_entities[5].properties[0]); + static final id = QueryIntegerProperty(_entities[4].properties[0]); /// see [Visite.id_visite] static final id_visite = - QueryIntegerProperty(_entities[5].properties[1]); + QueryIntegerProperty(_entities[4].properties[1]); /// see [Visite.type_visite] static final type_visite = - QueryStringProperty(_entities[5].properties[2]); + QueryStringProperty(_entities[4].properties[2]); /// see [Visite.title] - static final title = QueryStringProperty(_entities[5].properties[3]); + static final title = QueryStringProperty(_entities[4].properties[3]); /// see [Visite.allDay] static final allDay = - QueryBooleanProperty(_entities[5].properties[4]); + QueryBooleanProperty(_entities[4].properties[4]); /// see [Visite.id_distrib_visite] static final id_distrib_visite = - QueryIntegerProperty(_entities[5].properties[5]); + QueryIntegerProperty(_entities[4].properties[5]); /// see [Visite.id_etab] static final id_etab = - QueryIntegerProperty(_entities[5].properties[6]); + QueryIntegerProperty(_entities[4].properties[6]); /// see [Visite.abandon] static final abandon = - QueryIntegerProperty(_entities[5].properties[7]); + QueryIntegerProperty(_entities[4].properties[7]); /// see [Visite.date_visite] static final date_visite = - QueryIntegerProperty(_entities[5].properties[8]); + QueryIntegerProperty(_entities[4].properties[8]); /// see [Visite.url_photo_principale] static final url_photo_principale = - QueryStringProperty(_entities[5].properties[9]); + QueryStringProperty(_entities[4].properties[9]); /// see [Visite.langage] static final langage = - QueryStringProperty(_entities[5].properties[10]); + QueryStringProperty(_entities[4].properties[10]); } /// [VisiteTag] entity fields to define ObjectBox queries. class VisiteTag_ { /// see [VisiteTag.id] - static final id = QueryIntegerProperty(_entities[6].properties[0]); + static final id = QueryIntegerProperty(_entities[5].properties[0]); /// see [VisiteTag.id_visite_tag] static final id_visite_tag = - QueryIntegerProperty(_entities[6].properties[1]); + QueryIntegerProperty(_entities[5].properties[1]); /// see [VisiteTag.id_distrib] static final id_distrib = - QueryIntegerProperty(_entities[6].properties[2]); + QueryIntegerProperty(_entities[5].properties[2]); /// see [VisiteTag.libelle] static final libelle = - QueryStringProperty(_entities[6].properties[3]); + QueryStringProperty(_entities[5].properties[3]); /// see [VisiteTag.langage] static final langage = - QueryStringProperty(_entities[6].properties[4]); -} - -/// [Photo] entity fields to define ObjectBox queries. -class Photo_ { - /// see [Photo.id] - static final id = QueryIntegerProperty(_entities[7].properties[0]); - - /// see [Photo.id_visite] - static final id_visite = - QueryIntegerProperty(_entities[7].properties[1]); - - /// see [Photo.id_photo_typologie] - static final id_photo_typologie = - QueryIntegerProperty(_entities[7].properties[2]); - - /// see [Photo.date_photo] - static final date_photo = - QueryIntegerProperty(_entities[7].properties[3]); - - /// see [Photo.id_photo_mp4] - static final id_photo_mp4 = - QueryIntegerProperty(_entities[7].properties[4]); - - /// see [Photo.photo_privee] - static final photo_privee = - QueryIntegerProperty(_entities[7].properties[5]); - - /// see [Photo.photo_principale] - static final photo_principale = - QueryIntegerProperty(_entities[7].properties[6]); - - /// see [Photo.uploaded] - static final uploaded = - QueryIntegerProperty(_entities[7].properties[7]); - - /// see [Photo.image_name] - static final image_name = - QueryStringProperty(_entities[7].properties[8]); - - /// see [Photo.tags] - static final tags = QueryStringProperty(_entities[7].properties[9]); + QueryStringProperty(_entities[5].properties[4]); } /// [PhotoTypology] entity fields to define ObjectBox queries. class PhotoTypology_ { /// see [PhotoTypology.id] static final id = - QueryIntegerProperty(_entities[8].properties[0]); + QueryIntegerProperty(_entities[6].properties[0]); /// see [PhotoTypology.id_photo_typologie] static final id_photo_typologie = - QueryIntegerProperty(_entities[8].properties[1]); + QueryIntegerProperty(_entities[6].properties[1]); /// see [PhotoTypology.libelle] static final libelle = - QueryStringProperty(_entities[8].properties[2]); + QueryStringProperty(_entities[6].properties[2]); /// see [PhotoTypology.ordre] static final ordre = - QueryIntegerProperty(_entities[8].properties[3]); + QueryIntegerProperty(_entities[6].properties[3]); +} + +/// [EtabCompetitor] entity fields to define ObjectBox queries. +class EtabCompetitor_ { + /// see [EtabCompetitor.id] + static final id = + QueryIntegerProperty(_entities[7].properties[0]); + + /// see [EtabCompetitor.id_concurrence_lien] + static final id_concurrence_lien = + QueryIntegerProperty(_entities[7].properties[1]); + + /// see [EtabCompetitor.id_etab] + static final id_etab = + QueryIntegerProperty(_entities[7].properties[2]); + + /// see [EtabCompetitor.nom] + static final nom = + QueryStringProperty(_entities[7].properties[3]); +} + +/// [VisitPhoto] entity fields to define ObjectBox queries. +class VisitPhoto_ { + /// see [VisitPhoto.id] + static final id = + QueryIntegerProperty(_entities[8].properties[0]); + + /// see [VisitPhoto.id_visite] + static final id_visite = + QueryIntegerProperty(_entities[8].properties[1]); + + /// see [VisitPhoto.id_photo_typologie] + static final id_photo_typologie = + QueryIntegerProperty(_entities[8].properties[2]); + + /// see [VisitPhoto.image_name] + static final image_name = + QueryStringProperty(_entities[8].properties[3]); + + /// see [VisitPhoto.date_photo] + static final date_photo = + QueryIntegerProperty(_entities[8].properties[4]); + + /// see [VisitPhoto.id_photo_mp4] + static final id_photo_mp4 = + QueryIntegerProperty(_entities[8].properties[5]); + + /// see [VisitPhoto.photo_privee] + static final photo_privee = + QueryIntegerProperty(_entities[8].properties[6]); + + /// see [VisitPhoto.photo_principale] + static final photo_principale = + QueryIntegerProperty(_entities[8].properties[7]); + + /// see [VisitPhoto.tags] + static final tags = + QueryStringProperty(_entities[8].properties[8]); + + /// see [VisitPhoto.uploaded] + static final uploaded = + QueryIntegerProperty(_entities[8].properties[9]); } diff --git a/lib/service/shared_prefs.dart b/lib/service/shared_prefs.dart index 1ccb2c6..0686898 100644 --- a/lib/service/shared_prefs.dart +++ b/lib/service/shared_prefs.dart @@ -123,4 +123,11 @@ class SharedPrefs { set photosDir(String value) { _sharedPrefs.setString('photosDir', value); } + + /// get/set url MP4 + String get urlMP4 => _sharedPrefs.getString('urlMP4') ?? ""; + + set urlMP4(String value) { + _sharedPrefs.setString('urlMP4', value); + } } diff --git a/lib/ui/home.dart b/lib/ui/home.dart index ce05424..26f218e 100644 --- a/lib/ui/home.dart +++ b/lib/ui/home.dart @@ -1,9 +1,14 @@ +import 'dart:async'; +import 'package:flutter/material.dart'; + +import 'package:mobdr/main.dart'; import 'package:mobdr/ui/account/tab_account.dart'; import 'package:mobdr/ui/home/tab_home.dart'; -import 'package:mobdr/ui/shopping_cart/tab_shopping_cart.dart'; +import 'package:mobdr/ui/mp4/tab_mp4.dart'; import 'package:mobdr/ui/sync/tab_sync.dart'; -import 'package:flutter/material.dart'; + import 'package:mobdr/config/constant.dart'; +import 'package:mobdr/events.dart'; class HomePage extends StatefulWidget { @override @@ -13,21 +18,34 @@ class HomePage extends StatefulWidget { class _HomePageState extends State with SingleTickerProviderStateMixin { late PageController _pageController; + late StreamSubscription sub; // déclaration de la variable sub + int _currentIndex = 0; - // Pages if you click bottom navigation - final List _contentPages = [ - TabHomePage(), - TabSyncPage(), - TabShoppingCartPage(), - TabAccountPage(), - ]; + List _contentPages = []; @override void initState() { + _contentPages = [ + TabHomePage(), + TabSyncPage(), + TabMP4Page(), + TabAccountPage(), + ]; + // set initial pages for navigation to home page _pageController = PageController(initialPage: 0); _pageController.addListener(_handleTabSelection); + + // Listen particular event + sub = eventBus.on().listen((e) { + setState(() { + _currentIndex = 2; + _pageController.jumpToPage(_currentIndex); + FocusScope.of(context).unfocus(); + }); + }); + super.initState(); } @@ -37,6 +55,7 @@ class _HomePageState extends State @override void dispose() { + sub.cancel(); _pageController.dispose(); super.dispose(); } @@ -80,8 +99,8 @@ class _HomePageState extends State icon: Icon(Icons.sync, color: _currentIndex == 1 ? ASSENT_COLOR : CHARCOAL)), BottomNavigationBarItem( - label: 'Cart', - icon: Icon(Icons.shopping_cart, + label: 'MP4', + icon: Icon(Icons.web, color: _currentIndex == 2 ? PRIMARY_COLOR : CHARCOAL)), BottomNavigationBarItem( label: 'Account', diff --git a/lib/ui/home/tab_home.dart b/lib/ui/home/tab_home.dart index 3340acb..28054ae 100644 --- a/lib/ui/home/tab_home.dart +++ b/lib/ui/home/tab_home.dart @@ -16,9 +16,7 @@ import 'package:mobdr/config/global_style.dart'; import 'package:mobdr/model/visite_model.dart'; import 'package:mobdr/ui/general/chat_us.dart'; import 'package:mobdr/ui/general/notification.dart'; -import 'package:mobdr/ui/home/visit_photo_typology.dart'; import 'package:mobdr/ui/reusable/reusable_widget.dart'; -import 'package:mobdr/ui/reusable/cache_image_network.dart'; class TabHomePage extends StatefulWidget { @override @@ -44,7 +42,8 @@ class _TabHomePageState extends State bool _isLoading = true; String _errorMessage = ''; - late List modelData = []; + late List todayVisitsData = []; + late List previousVisitsData = []; @override void initState() { @@ -88,179 +87,127 @@ class _TabHomePageState extends State Widget build(BuildContext context) { // if we used AutomaticKeepAliveClientMixin, we must call super.build(context); super.build(context); - final double boxImageSize = (MediaQuery.of(context).size.width / 4); + final double boxImageSize = (MediaQuery.of(context).size.width / 3); if (_isLoading) { return Center(child: CircularProgressIndicator()); - } else if (modelData.isEmpty) { - return Center( - child: Text('Aucune visite trouvée.'), - ); } return Scaffold( - appBar: AppBar( - automaticallyImplyLeading: false, - elevation: GlobalStyle.appBarElevation, - title: Text( - AppLocalizations.of(context)!.translate('i18n_hello')! + - ', ${SharedPrefs().prenom}', - style: GlobalStyle.appBarTitle, - ), - backgroundColor: GlobalStyle.appBarBackgroundColor, - systemOverlayStyle: GlobalStyle.appBarSystemOverlayStyle, - actions: [ - GestureDetector( - onTap: () { - Navigator.push(context, - MaterialPageRoute(builder: (context) => ChatUsPage())); - }, - child: Icon(Icons.email, color: BLACK_GREY)), - IconButton( - icon: _reusableWidget.customNotifIcon( - count: 8, notifColor: BLACK_GREY), - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => NotificationPage())); - }), - ], - ), - body: AnimatedList( - key: _listKey, - initialItemCount: modelData.length, - physics: AlwaysScrollableScrollPhysics(), - itemBuilder: (context, index, animation) { - return _buildVisitelistCard( - modelData[index], boxImageSize, animation, index); - }, - )); - } - - Widget _buildVisitelistCard( - VisiteModel visiteData, boxImageSize, animation, index) { - return SizeTransition( - sizeFactor: animation, - child: Container( - margin: EdgeInsets.fromLTRB(12, 6, 12, 0), - child: GestureDetector( - onTap: () { - Route route = MaterialPageRoute( - builder: (context) => VisitPhotoTypologyPage( - pp_id_distrib: visiteData.id_distrib, - pp_langage: visiteData.langage, - pp_id_visite: visiteData.id_visite, - pp_name: visiteData.name, - onRefreshVisit: (int photoCount) { - setState(() { - modelData[index].photoCount = photoCount; - }); - }, - )); - Navigator.push(context, route); - }, - child: Card( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), - ), - elevation: 2, - color: Colors.white, - child: Container( - margin: EdgeInsets.all(8), - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ClipRRect( - borderRadius: BorderRadius.all(Radius.circular(10)), - child: buildCacheNetworkImage( - width: boxImageSize, - height: boxImageSize, - url: visiteData.image, - ), - ), - SizedBox( - width: 10, - ), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container(height: 8), - Text( - visiteData.name, - style: GlobalStyle.productName.copyWith( - fontSize: 13, - ), - maxLines: 3, - overflow: TextOverflow.ellipsis, - ), - Container( - margin: EdgeInsets.only(top: 5), - child: Text( - visiteData.date, - style: GlobalStyle.productSale, - ), - ), - Container(height: 5), - Container( - margin: EdgeInsets.only(top: 5), - child: Text( - '${visiteData.photoCount} Photo(s)', - style: GlobalStyle.productPrice, - ), - ), - Container(height: 5), - Container( - margin: EdgeInsets.only(top: 5), - child: Row( - children: [ - Icon( - Icons.store, - color: SOFT_GREY, - size: 20, - ), - Text( - ' ' + visiteData.type_visite, - style: GlobalStyle.productName.copyWith( - fontSize: 13, - ), - maxLines: 1, - overflow: TextOverflow.ellipsis, - ) - ], - ), - ), - ], - ), - ) - ], - ), - ], - ), - ), - ), + appBar: AppBar( + automaticallyImplyLeading: false, + elevation: GlobalStyle.appBarElevation, + title: Text( + AppLocalizations.of(context)!.translate('i18n_hello')! + + ', ${SharedPrefs().prenom}', + style: GlobalStyle.appBarTitle, ), + backgroundColor: GlobalStyle.appBarBackgroundColor, + systemOverlayStyle: GlobalStyle.appBarSystemOverlayStyle, + actions: [ + GestureDetector( + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (context) => ChatUsPage())); + }, + child: Icon(Icons.email, color: BLACK_GREY)), + IconButton( + icon: _reusableWidget.customNotifIcon( + count: 8, notifColor: BLACK_GREY), + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => NotificationPage())); + }), + ], + ), + body: ListView( + physics: AlwaysScrollableScrollPhysics(), + children: [ + _buildTodayVisits(boxImageSize), + _builPreviousVisits(boxImageSize), + ], ), ); } - /// Called when a visit is refreshed with new photo count. - /// - /// [index]: The index of the visit being refreshed. - /// [newPhotoCount]: The new photo count for the visit. - void onRefreshVisit(int index, int newPhotoCount) { - setState(() { - modelData[index].photoCount = newPhotoCount; - }); + Widget _buildTodayVisits(boxImageSize) { + return Column( + children: [ + Container( + padding: EdgeInsets.fromLTRB(16, 16, 16, 0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text('Today Visits', style: GlobalStyle.horizontalTitle), + GestureDetector( + onTap: () { + //Navigator.push(context, MaterialPageRoute(builder: (context) => RestaurantListPage(title: 'Food Arround You'))); + }, + child: Text('View All', + style: GlobalStyle.viewAll, textAlign: TextAlign.end), + ) + ], + ), + ), + Container( + margin: EdgeInsets.only(top: 8), + height: boxImageSize * GlobalStyle.cardHeightMultiplication, + child: ListView.builder( + padding: EdgeInsets.symmetric(horizontal: 12), + scrollDirection: Axis.horizontal, + itemCount: todayVisitsData.length, + itemBuilder: (BuildContext context, int index) { + return _reusableWidget.buildHorizontalVisitListCard( + context, + todayVisitsData[index], + ); + }, + )), + ], + ); + } + + Widget _builPreviousVisits(boxImageSize) { + return Column( + children: [ + Container( + padding: EdgeInsets.fromLTRB(16, 16, 16, 0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text('Previous Visits', style: GlobalStyle.horizontalTitle), + GestureDetector( + onTap: () { + //Navigator.push(context, MaterialPageRoute(builder: (context) => RestaurantListPage(title: 'Food Arround You'))); + }, + child: Text('View All', + style: GlobalStyle.viewAll, textAlign: TextAlign.end), + ) + ], + ), + ), + Container( + margin: EdgeInsets.only(top: 8), + height: boxImageSize * GlobalStyle.cardHeightMultiplication, + child: ListView.builder( + padding: EdgeInsets.symmetric(horizontal: 12), + scrollDirection: Axis.horizontal, + itemCount: previousVisitsData.length, + itemBuilder: (BuildContext context, int index) { + return _reusableWidget.buildHorizontalVisitListCard( + context, previousVisitsData[index]); + }, + )), + ], + ); } /// Initializes data when the page loads. Future loadData() async { try { // visite model initialisation - modelData = await VisiteModel.getAllVisites(); + todayVisitsData = await VisiteModel.getAllVisites(); + previousVisitsData = await VisiteModel.getAllVisites(); } catch (e) { // set errorMessage for debug _errorMessage = 'Error loading visites : $e'; diff --git a/lib/ui/home/visit_photo_typology_list.dart b/lib/ui/home/visit_photo_typology_list.dart index 83bdb55..fcaf407 100644 --- a/lib/ui/home/visit_photo_typology_list.dart +++ b/lib/ui/home/visit_photo_typology_list.dart @@ -54,7 +54,7 @@ class _VisitPhotoTypologyListPageState // initialize photos files list final List _visitPhotoFiles = []; - List _visitPhotoData = []; + List _visitPhotoData = []; Color _color1 = Color(0xff777777); Color _color2 = Color(0xFF515151); @@ -212,7 +212,8 @@ class _VisitPhotoTypologyListPageState ])); } - Widget _buildPhotolistCard(Photo photoData, boxImageSize, animation, index) { + Widget _buildPhotolistCard( + VisitPhoto photoData, boxImageSize, animation, index) { return SizeTransition( sizeFactor: animation, child: Container( @@ -460,14 +461,14 @@ class _VisitPhotoTypologyListPageState /// void savePhotos() async { if (_visitPhotoFiles.length > 0) { - final List _listPhotos = []; + final List _listPhotos = []; for (var myTmpPhoto in _visitPhotoFiles) { /// move jpg file to photo directory final myPhoto = await moveFileFromTempToPhotosDir(myTmpPhoto); /// to insert into database - _listPhotos.add(Photo( + _listPhotos.add(VisitPhoto( id_visite: widget.pp_id_visite, id_photo_typologie: widget.pp_id_typologie, image_name: myPhoto.path.split('/').last)); diff --git a/lib/ui/home/visite_photo_typology_detail.dart b/lib/ui/home/visite_photo_typology_detail.dart index cb13d7e..7e4ac81 100644 --- a/lib/ui/home/visite_photo_typology_detail.dart +++ b/lib/ui/home/visite_photo_typology_detail.dart @@ -13,8 +13,7 @@ import 'package:mobdr/ui/home/visit_photo_tag.dart'; import 'package:mobdr/db/box_photo.dart'; import 'package:mobdr/db/box_photo_typology.dart'; - -//TODO : faire concurrents === +import 'package:mobdr/db/box_photo_competitor.dart'; class VisitPhotoTypologyDetailPage extends StatefulWidget { // variables corresponding to the data parameters @@ -45,13 +44,17 @@ class _VisitPhotoTypologyDetailPageState String _errorMessage = ''; // Typology list - late List _typologyList = []; + late List _typologiesList = []; int _typologyIndex = 0; List _visibilities = []; late List tagList = []; - late Photo _photo; + late VisitPhoto _photo; + + // competitors + List _competitorsList = []; + String _competitor = ''; @override void initState() { @@ -106,7 +109,7 @@ class _VisitPhotoTypologyDetailPageState // fred Map result = { 'change_typologie': _typologyIndex != - _typologyList.indexWhere((typology) => + _typologiesList.indexWhere((typology) => typology.id_photo_typologie == widget.pp_id_typologie), 'tags': tagList.join(","), 'photo_principale': _visibilities.contains('principal') ? 1 : 0, @@ -127,6 +130,7 @@ class _VisitPhotoTypologyDetailPageState _buildPhotoTypology(), _buildPhotoVisibility(), _buildPhotoTag(context), + _BuildPhotoCompetitor(), SizedBox(height: 16) ], ), @@ -213,8 +217,8 @@ class _VisitPhotoTypologyDetailPageState height: 16, ), Wrap( - children: List.generate(_typologyList.length, (index) { - return radioSize(_typologyList[index].libelle, index); + children: List.generate(_typologiesList.length, (index) { + return radioSize(_typologiesList[index].libelle, index); }), ), ], @@ -226,7 +230,7 @@ class _VisitPhotoTypologyDetailPageState onTap: () async { // save photo typology in the database objectbox.putPhotoTypologie( - widget.pp_id, _typologyList[index].id_photo_typologie); + widget.pp_id, _typologiesList[index].id_photo_typologie); setState(() { _typologyIndex = index; @@ -379,15 +383,138 @@ class _VisitPhotoTypologyDetailPageState ); } + Widget _BuildPhotoCompetitor() { + return Container( + margin: EdgeInsets.only(top: 12), + padding: EdgeInsets.all(16), + color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Competitor', + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold)), + SizedBox( + height: 16, + ), + GestureDetector( + behavior: HitTestBehavior.translucent, + onTap: () { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return _showCompetitionPopup(); + }, + ); + }, + child: Container( + alignment: Alignment.center, + padding: EdgeInsets.fromLTRB(12, 8, 12, 8), + margin: EdgeInsets.only(bottom: 16), + decoration: BoxDecoration( + color: Colors.white, + border: Border.all(width: 1, color: Colors.grey[300]!), + borderRadius: BorderRadius.all( + Radius.circular(10) // <--- border radius here + )), + child: _competitor == '' + ? Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Icon(Icons.thumb_down, color: SOFT_BLUE), + SizedBox(width: 12), + Text('Choose Competitor', + style: TextStyle( + color: CHARCOAL, + fontWeight: FontWeight.bold)), + ], + ), + Icon(Icons.chevron_right, size: 20, color: SOFT_GREY), + ], + ) + : Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(_competitor, + style: TextStyle( + color: CHARCOAL, + fontWeight: FontWeight.bold)), + ], + ), + Icon(Icons.chevron_right, size: 20, color: SOFT_GREY), + ], + ), + ), + ), + ], + )); + } + + Widget _showCompetitionPopup() { + return StatefulBuilder( + builder: (BuildContext context, StateSetter mystate) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Center( + child: Container( + margin: EdgeInsets.only(top: 12, bottom: 12), + width: 40, + height: 4, + decoration: BoxDecoration( + color: Colors.grey[500], + borderRadius: BorderRadius.circular(10)), + ), + ), + Container( + margin: EdgeInsets.fromLTRB(16, 8, 16, 8), + child: Text('Choose Competitor', style: GlobalStyle.chooseCourier), + ), + Flexible( + child: ListView.builder( + padding: EdgeInsets.all(16), + itemCount: _competitorsList.length, + itemBuilder: (BuildContext context, int index) { + EtabCompetitor competitor = _competitorsList[index]; + return GestureDetector( + behavior: HitTestBehavior.translucent, + onTap: () { + setState(() { + _competitor = competitor.nom; + }); + Navigator.pop(context); + }, + child: Container( + margin: EdgeInsets.only(top: 16), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text(competitor.nom, style: GlobalStyle.courierType), + ], + ), + ), + ); + }, + ), + ), + ], + ); + }); + } + /// Initializes data when the page loads. Future loadData(int photoId) async { String tags = ""; try { // photo typologies initialization - _typologyList = objectbox.getPhotoTypologiesList(); + _typologiesList = objectbox.getPhotoTypologiesList(); - _typologyIndex = _typologyList.indexWhere( + _typologyIndex = _typologiesList.indexWhere( (typology) => typology.id_photo_typologie == widget.pp_id_typologie); // get photo object @@ -400,6 +527,10 @@ class _VisitPhotoTypologyDetailPageState // photo tag initialization tags = _photo.tags; tagList = tags.isEmpty ? [] : _photo.tags.split(","); + + // competitor initialization + _competitorsList = objectbox.getPhotoCompetitorList(); + _competitor = ""; } catch (e) { // set errorMessage for debug _errorMessage = 'Error loading photo: $e'; diff --git a/lib/ui/mp4/tab_mp4.dart b/lib/ui/mp4/tab_mp4.dart new file mode 100644 index 0000000..925b609 --- /dev/null +++ b/lib/ui/mp4/tab_mp4.dart @@ -0,0 +1,83 @@ +import 'dart:async'; +import 'package:flutter/material.dart'; +import 'package:webview_flutter/webview_flutter.dart'; + +import 'package:mobdr/service/shared_prefs.dart'; +import 'package:mobdr/main.dart'; +import 'package:mobdr/events.dart'; + +class TabMP4Page extends StatefulWidget { + @override + _TabMP4PageState createState() => _TabMP4PageState(); +} + +class _TabMP4PageState extends State + with AutomaticKeepAliveClientMixin { + late final WebViewController controller; + late StreamSubscription sub; + + int loadingPercentage = 0; + String url = SharedPrefs().urlMP4; + + @override + void initState() { + super.initState(); + + controller = WebViewController() + ..setNavigationDelegate(NavigationDelegate( + onPageStarted: (url) { + setState(() { + loadingPercentage = 0; + }); + }, + onProgress: (progress) { + setState(() { + loadingPercentage = progress; + }); + }, + onPageFinished: (url) { + setState(() { + loadingPercentage = 100; + }); + }, + )) + ..loadRequest( + Uri.parse(url), + ); + + sub = eventBus.on().listen((e) { + setState(() { + controller.loadRequest( + Uri.parse(e.url), + ); + }); + }); + } + + @override + void dispose() { + sub.cancel(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + super.build(context); + return SafeArea( + child: Stack( + children: [ + WebViewWidget( + controller: controller, + ), + if (loadingPercentage < 100) + LinearProgressIndicator( + value: loadingPercentage / 100.0, + ), + ], + ), + ); + } + + @override + bool get wantKeepAlive => true; +} diff --git a/lib/ui/reusable/reusable_widget.dart b/lib/ui/reusable/reusable_widget.dart index 489566c..bd0c4a3 100644 --- a/lib/ui/reusable/reusable_widget.dart +++ b/lib/ui/reusable/reusable_widget.dart @@ -1,8 +1,15 @@ import 'dart:async'; - -import 'package:mobdr/config/constant.dart'; import 'package:flutter/material.dart'; +import 'package:mobdr/main.dart'; +import 'package:mobdr/events.dart'; +import 'package:mobdr/config/global_style.dart'; +import 'package:mobdr/config/constant.dart'; +import 'package:mobdr/service/shared_prefs.dart'; +import 'package:mobdr/ui/reusable/cache_image_network.dart'; + +//TODO Rechercher toutes les utilisations + class ReusableWidget { PreferredSizeWidget bottomAppBar() { return PreferredSize( @@ -224,4 +231,75 @@ class ReusableWidget { ), ); } + + Widget buildHorizontalVisitListCard(context, data) { + final double imageWidth = (MediaQuery.of(context).size.width / 2.3); + final double imageheight = (MediaQuery.of(context).size.width / 3.07); + return Container( + width: imageWidth, + child: Card( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(6), + ), + elevation: 2, + color: Colors.white, + child: GestureDetector( + behavior: HitTestBehavior.translucent, + onTap: () { + //Navigator.push(context, MaterialPageRoute(builder: (context) => DetailRestaurantPage())); + }, + child: Stack( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ClipRRect( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(10), + topRight: Radius.circular(6)), + child: buildCacheNetworkImage( + width: imageWidth, + height: imageheight, + url: data.image)), + Container( + margin: EdgeInsets.all(8), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + height: 36, + child: Text(data.name, + style: GlobalStyle.cardTitle, + maxLines: 2, + overflow: TextOverflow.ellipsis), + ), + ], + ), + ), + ], + ), + Positioned( + bottom: 4, //ajout de cette ligne pour placer l'icone en bas + right: 4, //ajout de cette ligne pour placer l'icone à droite + child: GestureDetector( + onTap: () { + // TODO si visite validée ce n'est pas la meme url (on il mettre date validation dans le json + SharedPrefs().urlMP4 = + '${ApiConstants.baseUrl}/MobilePortal4/index.html#ajax/visite_modification.html?visite=${data.id_visite}'; + eventBus.fire(UrlEvent(SharedPrefs().urlMP4)); + }, + child: Image.asset( + "assets/images/logo_mp4.png", + width: 24, + height: 24, + ), + ), + ), + ], + ), + ), + ), + ); + } } diff --git a/lib/ui/sync/tab_sync.dart b/lib/ui/sync/tab_sync.dart index 325ae86..90ff768 100644 --- a/lib/ui/sync/tab_sync.dart +++ b/lib/ui/sync/tab_sync.dart @@ -1,14 +1,12 @@ -/* -This is wishlist page -we used AutomaticKeepAliveClientMixin to keep the state when moving from 1 navbar to another navbar, so the page is not refresh overtime - */ +import 'package:flutter/material.dart'; +import 'package:timelines/timelines.dart'; +import 'dart:math'; import 'package:mobdr/config/global_style.dart'; import 'package:mobdr/ui/reusable/reusable_widget.dart'; import 'package:mobdr/network/api_provider.dart'; -import 'package:flutter/material.dart'; -import 'package:timelines/timelines.dart'; -import 'dart:math'; +import 'package:mobdr/main.dart'; +import 'package:mobdr/ui/home/tab_home.dart'; const completeColor = Color(0xff5e6172); const inProgressColor = Color(0xff5ec792); @@ -208,27 +206,37 @@ class _TabSyncPageState extends State floatingActionButton: FloatingActionButton( child: Icon(Icons.chevron_right), onPressed: () async { - ///FRED - var apiResponseEtabs = await _apiProvider.SyncEtablissements(); - var apiResponseVisites = await _apiProvider.SyncVisites(); - var apiResponsePhotos = await _apiProvider.SyncPhotos(); + var futures = [ + _apiProvider.SyncEtablissements(), + _apiProvider.SyncVisites(), + _apiProvider.SyncPhotos(), + ]; - if (apiResponseEtabs == 'OK') { + objectbox.etabBox.removeAll(); + objectbox.etabCompetitorBox.removeAll(); + objectbox.visitBox.removeAll(); + objectbox.visitTagBox.removeAll(); + objectbox.visitPhotoBox.removeAll(); + objectbox.PhotoTypologyBox.removeAll(); + + var results = await Future.wait(futures); + + if (results[0] == 'OK') { print("SyncEtablissements OK"); } else { - print("SyncEtablissements Error:" + apiResponseEtabs); + print("SyncEtablissements Error:" + results[0]); } - if (apiResponseVisites == 'OK') { + if (results[1] == 'OK') { print("SyncVisites OK"); } else { - print("SyncVisites Error:" + apiResponseVisites); + print("SyncVisites Error:" + results[1]); } - if (apiResponsePhotos == 'OK') { + if (results[0] == 'OK') { print("SyncPhotos OK"); } else { - print("SyncPhotos Error:" + apiResponsePhotos); + print("SyncPhotos Error:" + results[0]); } /// diff --git a/pubspec.lock b/pubspec.lock index ce8e0ea..b694e37 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -321,6 +321,22 @@ packages: url: "https://pub.dev" source: hosted version: "5.1.1" + equatable: + dependency: transitive + description: + name: equatable + sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2 + url: "https://pub.dev" + source: hosted + version: "2.0.5" + event_bus_plus: + dependency: "direct main" + description: + name: event_bus_plus + sha256: cbd27754d4c567f78fc88e7875e26c31d866d919f220523f34b29bf008f8fb1a + url: "https://pub.dev" + source: hosted + version: "0.6.1" fake_async: dependency: transitive description: @@ -573,6 +589,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.8.0" + logger: + dependency: transitive + description: + name: logger + sha256: db2ff852ed77090ba9f62d3611e4208a3d11dfa35991a81ae724c113fcb3e3f7 + url: "https://pub.dev" + source: hosted + version: "1.3.0" logging: dependency: transitive description: @@ -1186,6 +1210,38 @@ packages: url: "https://pub.dev" source: hosted version: "2.3.0" + webview_flutter: + dependency: "direct main" + description: + name: webview_flutter + sha256: "1a37bdbaaf5fbe09ad8579ab09ecfd473284ce482f900b5aea27cf834386a567" + url: "https://pub.dev" + source: hosted + version: "4.2.0" + webview_flutter_android: + dependency: transitive + description: + name: webview_flutter_android + sha256: d6cf18cd6c809c5a9294cd99707a21986aac4e08c87e1916ce2590315fb55d3a + url: "https://pub.dev" + source: hosted + version: "3.6.2" + webview_flutter_platform_interface: + dependency: transitive + description: + name: webview_flutter_platform_interface + sha256: "78715dc442b7849dbde74e92bb67de1cecf5addf95531c5fb474e72f5fe9a507" + url: "https://pub.dev" + source: hosted + version: "2.3.0" + webview_flutter_wkwebview: + dependency: transitive + description: + name: webview_flutter_wkwebview + sha256: c94d242d8cbe1012c06ba7ac790c46d6e6b68723b7d34f8c74ed19f68d166f49 + url: "https://pub.dev" + source: hosted + version: "3.4.0" win32: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 2f0dd83..c107850 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -78,9 +78,15 @@ dependencies: universal_io: 2.2.0 xml: ^6.2.2 - # https://pub.dev/packages/device_info_plus/install + # https://pub.dev/packages/device_info_plus/ device_info_plus: ^8.2.0 + # https://pub.dev/packages/webview_flutter/ + webview_flutter: ^4.2.0 + + # https://pub.dev/packages/event_bus_plus/ + event_bus_plus: ^0.6.1 + dev_dependencies: flutter_test: sdk: flutter @@ -147,6 +153,7 @@ flutter: - assets/images/mastercard.png - assets/images/logo.png - assets/images/logo_dark.png + - assets/images/logo_mp4.png - assets/images/logo_horizontal.png - assets/images/onboarding/search_product.gif - assets/images/process_timeline/status1.png