From 9ae4da5c874d1532ffcf5ba7a9d91dd133b835ca Mon Sep 17 00:00:00 2001 From: Tom JUMEL Date: Fri, 9 Dec 2022 21:27:53 +0100 Subject: [PATCH 01/10] Semesters to statistics --- lib/src/ui/screen/stats.dart | 203 +++++++++++++++++++++++++---------- 1 file changed, 149 insertions(+), 54 deletions(-) diff --git a/lib/src/ui/screen/stats.dart b/lib/src/ui/screen/stats.dart index db22ae9..96bde2a 100644 --- a/lib/src/ui/screen/stats.dart +++ b/lib/src/ui/screen/stats.dart @@ -5,6 +5,7 @@ import 'package:flutter/services.dart'; import 'package:fl_chart/fl_chart.dart'; import 'package:intl/intl.dart'; +import 'package:payutc/src/api/assos_utc.dart'; import 'package:payutc/src/models/payutc_history.dart'; import 'package:payutc/src/services/app.dart'; import 'package:payutc/src/services/utils.dart'; @@ -24,10 +25,22 @@ class _StatPageState extends State { int select = 0; List history = AppService.instance.historyService.history?.historique ?? []; + late Semester selectedSemester; + List semesters = []; @override void initState() { super.initState(); + semesters = AppService.instance.semesters.toList(); + semesters.removeWhere((element) { + //remove future semesters + if (DateTime.now().isBefore(element.beginAt)) return true; + //remove semesters without history + if (history.isNotEmpty && + !(history.any((e) => isInSemester(e.date, element)))) return true; + return false; + }); + selectedSemester = _findCurrentSemester(semesters); } @override @@ -40,7 +53,7 @@ class _StatPageState extends State { centerTitle: true, ), body: DefaultTabController( - length: 5, + length: 5 + (semesters.isNotEmpty ? 1 : 0), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ @@ -51,20 +64,24 @@ class _StatPageState extends State { color: Colors.black12, borderRadius: BorderRadius.circular(15), ), - tabs: const [ - Tab( + tabs: [ + const Tab( child: Text("Semaine"), ), - Tab( + const Tab( child: Text("Mois"), ), - Tab( + if (semesters.isNotEmpty) + const Tab( + child: Text("Semestre"), + ), + const Tab( child: Text("Année"), ), - Tab( + const Tab( child: Text("Depuis le jour 1"), ), - Tab( + const Tab( child: Text("SY02"), ), ], @@ -88,6 +105,7 @@ class _StatPageState extends State { DateTime(DateTime.now().year, DateTime.now().month), DateTime.now(), "le mois actuel"), + if (semesters.isNotEmpty) _buildSemesterPage(), _buildPage(history, DateTime(DateTime.now().year), DateTime.now(), "l'année actuelle"), _buildPage(history, null, null, "la totale"), @@ -102,6 +120,64 @@ class _StatPageState extends State { ); } + Widget _buildSemesterPage() { + return ListView( + padding: const EdgeInsets.all(20), + children: [ + const Text( + "Semestre", + style: TextStyle(fontSize: 20, color: Colors.white), + ), + const SizedBox( + height: 10, + ), + DropdownButtonFormField( + value: selectedSemester, + iconSize: 24, + elevation: 16, + decoration: const InputDecoration( + border: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10)), + borderSide: BorderSide(color: AppColors.scaffold), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10)), + borderSide: BorderSide(color: AppColors.scaffold), + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10)), + borderSide: BorderSide(color: AppColors.scaffold), + ), + fillColor: AppColors.scaffold, + filled: true, + hintText: 'Choisissez un semestre', + contentPadding: EdgeInsets.symmetric(horizontal: 15), + ), + onChanged: (Semester? newValue) { + setState(() { + selectedSemester = newValue!; + }); + }, + items: semesters.map>((Semester value) { + return DropdownMenuItem( + value: value, + child: Text(value.name), + ); + }).toList(), + ), + const SizedBox( + height: 20, + ), + ...buildContentPage( + splitForPeriod( + history, selectedSemester.beginAt, selectedSemester.endAt), + selectedSemester.beginAt, + selectedSemester.endAt, + selectedSemester.name) + ], + ); + } + List splitForPeriod( List items, DateTime start, DateTime end) { List res = []; @@ -128,53 +204,7 @@ class _StatPageState extends State { return ListView( padding: const EdgeInsets.all(20), children: [ - Text("Infos ($s)", - style: const TextStyle(fontSize: 20, color: Colors.white)), - Text( - "Période du ${DateFormat("dd/MM/yyyy").format(start ?? items.last.date)} au ${DateFormat("dd/MM/yyyy").format(end ?? DateTime.now())}", - style: const TextStyle(fontSize: 11, color: Colors.white54), - ), - const SizedBox(height: 20), - _buildInfo( - "Achats", - items.where((element) => element.isPurchase).fold( - 0, - (previousValue, element) => - previousValue + (element.amount!.abs().toInt()))), - const SizedBox(height: 10), - _buildInfo( - "Virements envoyé", - items - .where((element) => element.isVirement && element.isOutAmount) - .fold( - 0, - (previousValue, element) => - previousValue + (element.amount!.abs().toInt()))), - const SizedBox(height: 10), - _buildInfo( - "Virements reçu", - items - .where((element) => element.isVirement && element.isInAmount) - .fold( - 0, - (previousValue, element) => - previousValue + (element.amount!.abs().toInt()))), - const SizedBox(height: 10), - _buildInfo( - "Recharges", - items.where((element) => element.isReload).fold( - 0, - (previousValue, element) => - previousValue + (element.amount!.abs().toInt()))), - const SizedBox(height: 20), - const Text("Top des achats", - style: TextStyle(fontSize: 20, color: Colors.white)), - const Text( - "Trié par achats", - style: TextStyle(fontSize: 11, color: Colors.white54), - ), - const SizedBox(height: 20), - _buildTop(items.toList(), start, end), + ...buildContentPage(items, start, end, s), ], ); } @@ -542,6 +572,71 @@ class _StatPageState extends State { list.sort((a, b) => b.amount!.compareTo(a.amount!)); return list.length > 4 ? list.sublist(0, 4) : list; } + + Semester _findCurrentSemester(List semesters) { + final now = DateTime.now(); + for (final semester in semesters) { + if (semester.beginAt.isBefore(now) && semester.endAt.isAfter(now)) { + return semester; + } + } + return semesters.first; + } + + List buildContentPage( + List items, DateTime? start, DateTime? end, String s) => + [ + Text("Infos ($s)", + style: const TextStyle(fontSize: 20, color: Colors.white)), + Text( + "Période du ${DateFormat("dd/MM/yyyy").format(start ?? items.last.date)} au ${DateFormat("dd/MM/yyyy").format(end ?? DateTime.now())}", + style: const TextStyle(fontSize: 11, color: Colors.white54), + ), + const SizedBox(height: 20), + _buildInfo( + "Achats", + items.where((element) => element.isPurchase).fold( + 0, + (previousValue, element) => + previousValue + (element.amount!.abs().toInt()))), + const SizedBox(height: 10), + _buildInfo( + "Virements envoyé", + items + .where((element) => element.isVirement && element.isOutAmount) + .fold( + 0, + (previousValue, element) => + previousValue + (element.amount!.abs().toInt()))), + const SizedBox(height: 10), + _buildInfo( + "Virements reçu", + items + .where((element) => element.isVirement && element.isInAmount) + .fold( + 0, + (previousValue, element) => + previousValue + (element.amount!.abs().toInt()))), + const SizedBox(height: 10), + _buildInfo( + "Recharges", + items.where((element) => element.isReload).fold( + 0, + (previousValue, element) => + previousValue + (element.amount!.abs().toInt()))), + const SizedBox(height: 20), + const Text("Top des achats", + style: TextStyle(fontSize: 20, color: Colors.white)), + const Text( + "Trié par achats", + style: TextStyle(fontSize: 11, color: Colors.white54), + ), + const SizedBox(height: 20), + _buildTop(items.toList(), start, end), + ]; + + isInSemester(DateTime date, Semester element) => + date.isAfter(element.beginAt) && date.isBefore(element.endAt); } class PieItems { From a8642e11bc243a6d3136aab0964833447f031e1e Mon Sep 17 00:00:00 2001 From: Tom JUMEL Date: Fri, 9 Dec 2022 21:28:11 +0100 Subject: [PATCH 02/10] PayUTC rename --- lib/src/ui/screen/splash.dart | 2 +- lib/src/ui/screen/transfert_select_amount.dart | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/src/ui/screen/splash.dart b/lib/src/ui/screen/splash.dart index 7323819..9c9c92d 100644 --- a/lib/src/ui/screen/splash.dart +++ b/lib/src/ui/screen/splash.dart @@ -54,7 +54,7 @@ class _SplashPageState extends State { height: 30, ), const Text( - "Pay'ut", + "Pay'UTC", style: TextStyle(color: Colors.white, fontSize: 30), ), const SizedBox( diff --git a/lib/src/ui/screen/transfert_select_amount.dart b/lib/src/ui/screen/transfert_select_amount.dart index d5cde67..d69ace1 100644 --- a/lib/src/ui/screen/transfert_select_amount.dart +++ b/lib/src/ui/screen/transfert_select_amount.dart @@ -4,9 +4,13 @@ import 'dart:math'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; + import 'package:local_auth/local_auth.dart'; import 'package:local_auth_android/local_auth_android.dart'; import 'package:local_auth_ios/local_auth_ios.dart'; +import 'package:sentry_flutter/sentry_flutter.dart'; +import 'package:sleek_circular_slider/sleek_circular_slider.dart'; + import 'package:payutc/compil.dart'; import 'package:payutc/generated/l10n.dart'; import 'package:payutc/src/models/transfert.dart'; @@ -15,9 +19,6 @@ import 'package:payutc/src/services/app.dart'; import 'package:payutc/src/services/random_sentence.dart'; import 'package:payutc/src/services/search_user_manager.dart'; import 'package:payutc/src/ui/screen/select_amount.dart'; -import 'package:sentry_flutter/sentry_flutter.dart'; -import 'package:sleek_circular_slider/sleek_circular_slider.dart'; - import '../style/color.dart'; class SelectTransfertAmountScreen extends StatefulWidget { From 4fb9286c94a7e90387ed94b8d796caf3fab8378b Mon Sep 17 00:00:00 2001 From: Tom JUMEL Date: Fri, 9 Dec 2022 21:29:16 +0100 Subject: [PATCH 03/10] Add "open in external browser" payment link to have card autocomplete. (demande utilisateur) --- lib/src/ui/screen/reload.dart | 89 +++++++++++++++++++++++++++++++---- 1 file changed, 81 insertions(+), 8 deletions(-) diff --git a/lib/src/ui/screen/reload.dart b/lib/src/ui/screen/reload.dart index e24aa22..a1e143f 100644 --- a/lib/src/ui/screen/reload.dart +++ b/lib/src/ui/screen/reload.dart @@ -4,12 +4,14 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:url_launcher/url_launcher_string.dart'; import 'package:webview_flutter/webview_flutter.dart'; import 'package:payutc/generated/l10n.dart'; import 'package:payutc/src/env.dart'; import 'package:payutc/src/services/app.dart'; import 'package:payutc/src/ui/screen/select_amount.dart'; +import 'package:payutc/src/ui/style/color.dart'; class PaymentFlowPage extends StatefulWidget { final double amount; @@ -50,6 +52,27 @@ class PaymentFlowPage extends StatefulWidget { } class _PaymentFlowPageState extends State { + String? _url, _error; + + @override + void initState() { + AppService.instance.nemoPayApi + .requestTransfertUrl(widget.amount) + .then((value) => setState(() { + _url = value; + if (mounted) { + setState(() {}); + } + })) + .catchError((e) { + _error = "Une erreur est survenue"; + if (mounted) { + setState(() {}); + } + }); + super.initState(); + } + @override Widget build(BuildContext context) { return WillPopScope( @@ -82,11 +105,50 @@ class _PaymentFlowPageState extends State { elevation: 0, iconTheme: const IconThemeData(color: Colors.white), systemOverlayStyle: SystemUiOverlayStyle.light, + actions: [ + if (_url != null) + IconButton( + icon: const Icon(Icons.open_in_new), + onPressed: () => showDialog( + context: context, + builder: (_) { + return AlertDialog( + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(15)), + title: const Text("Ouvrir dans le navigateur"), + content: const Text( + "Tu n'arrive pas à accéder à la page ou au " + "paiement ? Tu peux essayer d'ouvrir la page dans " + "un navigateur. (Il faudra ensuite revenir sur l'application)", + style: TextStyle(fontSize: 12), + ), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context, false), + child: const Text("Annuler"), + ), + TextButton( + style: TextButton.styleFrom( + foregroundColor: Colors.black54), + onPressed: () { + Navigator.pop(context, true); + Navigator.pop(context, true); + launchUrlString(_url!, + mode: LaunchMode.externalApplication); + }, + child: const Text("Passer par le navigateur"), + ), + ], + ); + }, + ), + ), + ], ), backgroundColor: Colors.black, - body: FutureBuilder( - future: AppService.instance.nemoPayApi - .requestTransfertUrl(widget.amount), + body: FutureBuilder( + future: Future.value(_url), builder: (context, snapshot) { if (snapshot.data != null) { return ClipRRect( @@ -108,13 +170,24 @@ class _PaymentFlowPageState extends State { )), ); } - if (!snapshot.hasData && - snapshot.connectionState == ConnectionState.waiting) { - return const Center( - child: CircularProgressIndicator(), + if (_error != null) { + return Center( + child: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(15), + ), + padding: const EdgeInsets.all(16), + child: Text( + "$_error", + style: const TextStyle(color: AppColors.red), + ), + ), ); } - return const SizedBox(); + return const Center( + child: CircularProgressIndicator(), + ); }), ), ); From e65969774fad961bfbb705b894a19fbfedbe170c Mon Sep 17 00:00:00 2001 From: Tom JUMEL Date: Fri, 9 Dec 2022 21:29:33 +0100 Subject: [PATCH 04/10] Ui overflow fix --- lib/src/ui/component/payutc_item.dart | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/src/ui/component/payutc_item.dart b/lib/src/ui/component/payutc_item.dart index 519627f..491ffa3 100644 --- a/lib/src/ui/component/payutc_item.dart +++ b/lib/src/ui/component/payutc_item.dart @@ -102,9 +102,19 @@ class PayUtcItemWidget extends StatelessWidget { s, style: const TextStyle(color: Colors.white), ), - Text( - t, - style: const TextStyle(color: Colors.white), + const SizedBox( + width: 10, + ), + Expanded( + child: Align( + alignment: Alignment.centerRight, + child: Text( + t, + style: const TextStyle(color: Colors.white), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + ), ), ], ); @@ -132,16 +142,18 @@ class PayUtcItemWidget extends StatelessWidget { ), _row("Montant", item.amountParse.toStringAsFixed(2)), _row("Dénomination", item.nameExtracted(context)), - _row("Service", item.service(context)), + if (!item.isVirement) + _row("Service", item.service(context)), _row("Date", DateFormat("dd/MM/yyyy").format(item.date)), _row("Heure", DateFormat("HH:mm").format(item.date)), const SizedBox( height: 10, ), if (item.isVirement) ...[ - const Text( - "Message", - style: TextStyle(color: Colors.white, fontSize: 18), + Text( + "${item.userVirName} a écrit :", + style: + const TextStyle(color: Colors.white, fontSize: 18), ), const SizedBox( height: 5, From c495196e8284aef8edf5d83d65e04b89fba23620 Mon Sep 17 00:00:00 2001 From: Tom JUMEL Date: Fri, 9 Dec 2022 21:31:10 +0100 Subject: [PATCH 05/10] GEt semester from assos.utc.fr --- lib/src/api/assos_utc.dart | 48 ++++++++++++++++++++++++++++++++++++++ lib/src/services/app.dart | 4 ++++ 2 files changed, 52 insertions(+) create mode 100644 lib/src/api/assos_utc.dart diff --git a/lib/src/api/assos_utc.dart b/lib/src/api/assos_utc.dart new file mode 100644 index 0000000..ddca038 --- /dev/null +++ b/lib/src/api/assos_utc.dart @@ -0,0 +1,48 @@ +import 'package:dio/dio.dart'; + +class AssosUTC { + //dio get https://assos.utc.fr/api/v1/semesters + static Future> getSemesters() async { + final response = await Dio().get('https://assos.utc.fr/api/v1/semesters'); + if (response.statusCode == 200) { + return (response.data as List) + .map((e) => Semester.fromJson(e)) + .toList(); + } else { + throw Exception('Failed to load semesters'); + } + } +} + +//{ +// "id": "052f21d0-6c88-11ec-9f69-2306293b178e", +// "name": "A22", +// "is_spring": false, +// "begin_at": "2022-09-01 00:00:00", +// "end_at": "2023-01-31 23:59:59" +// } +class Semester { + final String id; + final String name; + final bool isSpring; + final DateTime beginAt; + final DateTime endAt; + + Semester({ + required this.id, + required this.name, + required this.isSpring, + required this.beginAt, + required this.endAt, + }); + + factory Semester.fromJson(Map json) { + return Semester( + id: json['id'], + name: json['name'], + isSpring: json['is_spring'], + beginAt: DateTime.parse(json['begin_at']), + endAt: DateTime.parse(json['end_at']), + ); + } +} diff --git a/lib/src/services/app.dart b/lib/src/services/app.dart index 14299b6..a6e719e 100644 --- a/lib/src/services/app.dart +++ b/lib/src/services/app.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:dio/dio.dart'; +import 'package:payutc/src/api/assos_utc.dart'; import 'package:payutc/src/api/cas.dart'; import 'package:payutc/src/api/ginger.dart'; import 'package:payutc/src/api/nemopay.dart'; @@ -60,6 +61,8 @@ class AppService extends ChangeNotifier { Owner get user => userWallet!.user; + List semesters = []; + Future initApp() async { await storageService.init(); if (await isFirstConnect) return false; @@ -68,6 +71,7 @@ class AppService extends ChangeNotifier { appProperties = await nemoPayApi.getAppProperties(); await walletService.forceLoad(); await historyService.forceLoadHistory(); + semesters = await AssosUTC.getSemesters(); return true; } From 87463e2fd2681b9302f5a97e63ba94e1395ae60f Mon Sep 17 00:00:00 2001 From: Tom JUMEL Date: Fri, 9 Dec 2022 21:31:31 +0100 Subject: [PATCH 06/10] fixes --- lib/src/ui/screen/account_screen.dart | 4 +++- lib/src/ui/screen/home.dart | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/src/ui/screen/account_screen.dart b/lib/src/ui/screen/account_screen.dart index 13f43db..3f4ebd3 100644 --- a/lib/src/ui/screen/account_screen.dart +++ b/lib/src/ui/screen/account_screen.dart @@ -120,7 +120,9 @@ class _AccountPageState extends State { Translate.of(context).nousContacter, () { launchUrlString( - "mailto:payutc@assos.utc.fr?subject=[App]&body=Bonjour,\n"); + "mailto:payutc@assos.utc.fr?subject=[App]&body=Bonjour,\n", + mode: LaunchMode.externalApplication, + ); }, ), if (showLogConsole) diff --git a/lib/src/ui/screen/home.dart b/lib/src/ui/screen/home.dart index 5614bfc..52d8139 100644 --- a/lib/src/ui/screen/home.dart +++ b/lib/src/ui/screen/home.dart @@ -1,6 +1,9 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; + +import 'package:skeletons/skeletons.dart'; + import 'package:payutc/generated/l10n.dart'; import 'package:payutc/src/services/app.dart'; import 'package:payutc/src/services/history.dart'; @@ -12,8 +15,6 @@ import 'package:payutc/src/ui/screen/stats.dart'; import 'package:payutc/src/ui/screen/transfert_select_amount.dart'; import 'package:payutc/src/ui/style/color.dart'; import 'package:payutc/src/ui/style/theme.dart'; -import 'package:skeletons/skeletons.dart'; - import '../component/rounded_icon.dart'; import 'account_screen.dart'; import 'receive.dart'; @@ -146,7 +147,7 @@ class _HomePageState extends State children: [ Text( AppService.instance.translateMoney( - (AppService.instance.userWallet?.credit ?? + (historyController.history?.credit ?? 00) / 100), style: const TextStyle( From 71a62b70b4310eb63ddb0f3b74897b601c8866e5 Mon Sep 17 00:00:00 2001 From: Tom JUMEL Date: Fri, 9 Dec 2022 22:06:39 +0100 Subject: [PATCH 07/10] IOS First connect fix --- lib/src/services/app.dart | 9 ++++----- lib/src/services/storage.dart | 4 +--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/src/services/app.dart b/lib/src/services/app.dart index a6e719e..5b6d42b 100644 --- a/lib/src/services/app.dart +++ b/lib/src/services/app.dart @@ -1,9 +1,7 @@ import 'dart:convert'; -import 'package:flutter/material.dart'; - import 'package:dio/dio.dart'; - +import 'package:flutter/material.dart'; import 'package:payutc/src/api/assos_utc.dart'; import 'package:payutc/src/api/cas.dart'; import 'package:payutc/src/api/ginger.dart'; @@ -16,6 +14,7 @@ import 'package:payutc/src/models/wallet.dart'; import 'package:payutc/src/services/history.dart'; import 'package:payutc/src/services/storage.dart'; import 'package:payutc/src/services/wallet.dart'; + import '../env.dart'; class AppService extends ChangeNotifier { @@ -65,8 +64,8 @@ class AppService extends ChangeNotifier { Future initApp() async { await storageService.init(); - if (await isFirstConnect) return false; - UserData d = (await storageService.userData)!; + UserData? d = (await storageService.userData); + if (await isFirstConnect || d == null) return false; userName = await (d.isCas ? _casConnect() : _classicConnect()); appProperties = await nemoPayApi.getAppProperties(); await walletService.forceLoad(); diff --git a/lib/src/services/storage.dart b/lib/src/services/storage.dart index 246a992..d603921 100644 --- a/lib/src/services/storage.dart +++ b/lib/src/services/storage.dart @@ -1,9 +1,7 @@ import 'package:flutter/material.dart'; - import 'package:flutter_secure_storage/flutter_secure_storage.dart'; -import 'package:shared_preferences/shared_preferences.dart'; - import 'package:payutc/src/models/user_data.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class StorageService { StorageService(); From d4fb0e0d92725a466daf55acdf235f6bf3b37a73 Mon Sep 17 00:00:00 2001 From: Tom JUMEL Date: Fri, 9 Dec 2022 22:15:37 +0100 Subject: [PATCH 08/10] CrazyStats first --- lib/src/ui/screen/stats.dart | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/src/ui/screen/stats.dart b/lib/src/ui/screen/stats.dart index 96bde2a..229a5db 100644 --- a/lib/src/ui/screen/stats.dart +++ b/lib/src/ui/screen/stats.dart @@ -1,10 +1,8 @@ +import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; - -import 'package:fl_chart/fl_chart.dart'; import 'package:intl/intl.dart'; - import 'package:payutc/src/api/assos_utc.dart'; import 'package:payutc/src/models/payutc_history.dart'; import 'package:payutc/src/services/app.dart'; @@ -65,6 +63,9 @@ class _StatPageState extends State { borderRadius: BorderRadius.circular(15), ), tabs: [ + const Tab( + child: Text("SY02"), + ), const Tab( child: Text("Semaine"), ), @@ -81,9 +82,6 @@ class _StatPageState extends State { const Tab( child: Text("Depuis le jour 1"), ), - const Tab( - child: Text("SY02"), - ), ], ), Expanded( @@ -95,6 +93,7 @@ class _StatPageState extends State { color: Colors.black), child: TabBarView( children: [ + _buildCrazyStats(history), _buildPage( history, DateTime.now().subtract(const Duration(days: 7)), @@ -109,7 +108,6 @@ class _StatPageState extends State { _buildPage(history, DateTime(DateTime.now().year), DateTime.now(), "l'année actuelle"), _buildPage(history, null, null, "la totale"), - _buildCrazyStats(history), ], ), ), @@ -400,10 +398,12 @@ class _StatPageState extends State { } _extractTopDays(List history) { + history = history.toList(); + history.removeWhere((element) => (element.amount ?? 0) > 1500); Map map = {}; //group history by date day/month/year for (PayUtcItem item in history) { - if (item.isOutAmount && item.isProduct && item.amount! < 1500) { + if (item.isOutAmount && item.isProduct) { DateTime date = DateTime(item.date.year, item.date.month, item.date.day); if (map.containsKey(date)) { From 3e3aa1964edca7a24b3f68a307bf9916ebd70a60 Mon Sep 17 00:00:00 2001 From: Tom JUMEL Date: Sat, 10 Dec 2022 09:21:34 +0100 Subject: [PATCH 09/10] int qtt --- lib/src/ui/screen/stats.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/ui/screen/stats.dart b/lib/src/ui/screen/stats.dart index 229a5db..6dabe57 100644 --- a/lib/src/ui/screen/stats.dart +++ b/lib/src/ui/screen/stats.dart @@ -260,7 +260,7 @@ class _StatPageState extends State { style: const TextStyle(color: Colors.white), ), subtitle: Text( - "${item.quantity} achats", + "${item.quantity.toInt()} achats", style: const TextStyle(color: Colors.white), ), trailing: Text( From 0da17c1b2553c1a97e0eb27e3a2276f570f89b8c Mon Sep 17 00:00:00 2001 From: Tom JUMEL Date: Sat, 10 Dec 2022 17:44:52 +0100 Subject: [PATCH 10/10] CGUs --- assets/therms/cgu.html | 1301 +++++++++++++++++ lib/src/services/app.dart | 5 +- lib/src/services/storage.dart | 4 +- lib/src/ui/screen/splash.dart | 25 + lib/src/ui/screen/stats.dart | 4 +- .../account_settings_screen.dart | 10 + 6 files changed, 1345 insertions(+), 4 deletions(-) create mode 100644 assets/therms/cgu.html diff --git a/assets/therms/cgu.html b/assets/therms/cgu.html new file mode 100644 index 0000000..202b87b --- /dev/null +++ b/assets/therms/cgu.html @@ -0,0 +1,1301 @@ + + + + + + + + + + + + + Conditions générales d’utilisation + + + + + + + + + + + + + + + + + +

Conditions générales d’utilisation

+

Pay’UTC est une application émise et propulsée par le SIMDE.
+ Adresse : Centre Universitaire B.Franklin, BP 501, Rue Roger Coutollenc 60200 Compiegne.

+

Cette est une application conçue pour consulter et effectuer certaines opérations sur son porte feuille cashless + Pay’UTC, lui même concu et géré par la société Weezevent.
+ En aucun cas cette application ne sera considérée comme officiellement liée au service cashless Pay’UTC propulsé + par Weezevent et ne sera considérée que comme une initiative locale de facilitation d’accès et d’utilisation de + ce service.

+

Stockage des données

+

Pour vous améliorer l’experience de la connexion au service Pay’UTC (connexion necessaire pour le fonctionnement + des fonctionnalités fournies par l’API du système cashless Pay’UTC, lors de la première connexion l’application + sauvegarde de manière sécurisé sur votre téléphone votre nom d’utilisateur/mot de passe. Sécurisé via flutter_secure_storage +

+

Autrement, aucune donnée n’est stockée directement sur l’application.

+

L’application utilise les services du systeme cashless Pay’UTC, accessible ici payutc.nemopay.net.

+

Traitement des + données

+

Les données telles que le nom d’utilisateur et le mot de passe CAS-UTC, ou l’adresse et + mail et le mot de passe associé à un compte valide sur le système cashless Pay’UTC, sont émise au service + d’authentification centralisé (CAS) de l’Université de Technologie de Compiègne (UTC), ou le mail et mot de + passe associé transmis au système d’authentification du système cashless Pay’UTC, afin de pour pouvoir vous + connecter.
+ Elles constituent les seules données stockées et retransmises par l’application.

+

Les données d’historiques d’achat de l’utilisateur via le système cashless Pay’UTC sont utilisées pour les + statistiques de consommation personnelles de l’utilisateur. Ce traitement est local sur l’application.

+

Sous traitance

+

Pour le bon fonctionement de l’application, nous utilisons des sous traitants

+ +
+ + + diff --git a/lib/src/services/app.dart b/lib/src/services/app.dart index 5b6d42b..99ea383 100644 --- a/lib/src/services/app.dart +++ b/lib/src/services/app.dart @@ -1,7 +1,9 @@ import 'dart:convert'; -import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; + +import 'package:dio/dio.dart'; + import 'package:payutc/src/api/assos_utc.dart'; import 'package:payutc/src/api/cas.dart'; import 'package:payutc/src/api/ginger.dart'; @@ -14,7 +16,6 @@ import 'package:payutc/src/models/wallet.dart'; import 'package:payutc/src/services/history.dart'; import 'package:payutc/src/services/storage.dart'; import 'package:payutc/src/services/wallet.dart'; - import '../env.dart'; class AppService extends ChangeNotifier { diff --git a/lib/src/services/storage.dart b/lib/src/services/storage.dart index d603921..246a992 100644 --- a/lib/src/services/storage.dart +++ b/lib/src/services/storage.dart @@ -1,8 +1,10 @@ import 'package:flutter/material.dart'; + import 'package:flutter_secure_storage/flutter_secure_storage.dart'; -import 'package:payutc/src/models/user_data.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:payutc/src/models/user_data.dart'; + class StorageService { StorageService(); diff --git a/lib/src/ui/screen/splash.dart b/lib/src/ui/screen/splash.dart index 9c9c92d..50cd293 100644 --- a/lib/src/ui/screen/splash.dart +++ b/lib/src/ui/screen/splash.dart @@ -1,6 +1,7 @@ import 'dart:io'; import 'package:flutter/cupertino.dart'; +import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -11,6 +12,7 @@ import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:payutc/compil.dart'; import 'package:payutc/generated/l10n.dart'; import 'package:payutc/src/services/app.dart'; +import 'package:payutc/src/ui/component/ui_utils.dart'; import 'package:payutc/src/ui/screen/home.dart'; import 'package:payutc/src/ui/style/color.dart'; @@ -287,6 +289,21 @@ class _LoginPageState extends State { const SizedBox( height: 5, ), + Text.rich( + TextSpan( + text: Translate.of(context).connect_mention_legs, + children: [ + TextSpan( + text: + " ${Translate.of(context).mentionsLgales}", + style: const TextStyle( + color: AppColors.orange, + ), + recognizer: TapGestureRecognizer() + ..onTap = _mentionsLeg) + ], + ), + ), ], ), ), @@ -299,6 +316,14 @@ class _LoginPageState extends State { ); } + void _mentionsLeg() { + showWebView( + context, + "assets/therms/cgu.html", + Translate.of(context).mentionsLgales, + ); + } + void _connect(BuildContext context) async { if (!Form.of(context)!.validate()) return; setState(() { diff --git a/lib/src/ui/screen/stats.dart b/lib/src/ui/screen/stats.dart index 6dabe57..a10013a 100644 --- a/lib/src/ui/screen/stats.dart +++ b/lib/src/ui/screen/stats.dart @@ -1,8 +1,10 @@ -import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; + +import 'package:fl_chart/fl_chart.dart'; import 'package:intl/intl.dart'; + import 'package:payutc/src/api/assos_utc.dart'; import 'package:payutc/src/models/payutc_history.dart'; import 'package:payutc/src/services/app.dart'; diff --git a/lib/src/ui/screen/sub_account_screen/account_settings_screen.dart b/lib/src/ui/screen/sub_account_screen/account_settings_screen.dart index 04b83a0..dc44a48 100644 --- a/lib/src/ui/screen/sub_account_screen/account_settings_screen.dart +++ b/lib/src/ui/screen/sub_account_screen/account_settings_screen.dart @@ -193,6 +193,16 @@ class APropos extends StatelessWidget { ); }, ), + btnAccount( + Translate.of(context).mentionsLgales, + () { + showWebView( + context, + "assets/therms/cgu.html", + Translate.of(context).mentionsLgales, + ); + }, + ), btnAccount( Translate.of(context).licensesPayutc, () {