From bc1f5601e2e87597bdbf95f5a7e29aef85d124a7 Mon Sep 17 00:00:00 2001 From: felix Date: Mon, 15 Apr 2024 21:49:12 -0400 Subject: [PATCH 1/9] weekday on task manager --- lib/Screens/Calendar.dart | 22 +++++++++++++++++++++- lib/Screens/createtask.dart | 2 +- lib/main.dart | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/Screens/Calendar.dart b/lib/Screens/Calendar.dart index 70d41f2..efb5915 100644 --- a/lib/Screens/Calendar.dart +++ b/lib/Screens/Calendar.dart @@ -121,6 +121,16 @@ class __CalendarState extends State { } } + Map weekdays = { + 'Monday': 'Lundi', + 'Tuesday': 'Mardi', + 'Wednesday': 'Mercredi', + 'Thursday': 'Jeudi', + 'Friday': 'Vendredi', + 'Saturday': 'Samedi', + 'Sunday': 'Dimanche', + }; + int _currentIndex = 1; void _onItemTapped(int index) { @@ -185,6 +195,7 @@ class __CalendarState extends State { default: currentPage = const TaskList(); // Default to the first page } + return Scaffold( appBar: const MyAppBar(), @@ -193,7 +204,16 @@ class __CalendarState extends State { children: [ const SizedBox(height: 15), Text( - 'Emploi du temps du $selectedDayFormatted2', + 'Emploie du temps du ${weekdays[DateFormat('EEEE').format(selectedDay)]}', + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20, + fontFamily: 'Nunito', + ), + ), + const SizedBox(height: 3), + Text( + selectedDayFormatted2, style: const TextStyle( fontWeight: FontWeight.bold, fontSize: 20, diff --git a/lib/Screens/createtask.dart b/lib/Screens/createtask.dart index 0b7c2a6..d40edbb 100644 --- a/lib/Screens/createtask.dart +++ b/lib/Screens/createtask.dart @@ -167,7 +167,7 @@ class _createTaskState extends State { if (form!.validate()) { SharedPreferences prefs = await SharedPreferences.getInstance(); final token = prefs.getString('token'); - final String apiUrl = 'http://10.0.2.2:8000/tasks/${taskData?["id"]}/'; + final String apiUrl = 'http://10.0.2.2:8000/tasks/${taskData["id"]}/'; print(apiUrl); final response = await http.put( Uri.parse(apiUrl), diff --git a/lib/main.dart b/lib/main.dart index 43bb119..5e7fd73 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,6 @@ //import 'package:activmind_app/Screens/inscrire.dart'; import 'dart:convert'; +import 'package:intl/date_symbol_data_file.dart'; import 'package:logger/logger.dart'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; From 492e59d6ce49391f15a1d171b07a74438974e89b Mon Sep 17 00:00:00 2001 From: felix Date: Mon, 15 Apr 2024 21:50:03 -0400 Subject: [PATCH 2/9] weekday on task manager --- lib/Screens/Calendar.dart | 107 +++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 53 deletions(-) diff --git a/lib/Screens/Calendar.dart b/lib/Screens/Calendar.dart index efb5915..65091b5 100644 --- a/lib/Screens/Calendar.dart +++ b/lib/Screens/Calendar.dart @@ -15,9 +15,7 @@ import 'package:intl/intl.dart'; import 'package:logger/logger.dart'; import 'createtask.dart'; -var logger = Logger( - level: Level.all -); +var logger = Logger(level: Level.all); extension TimeOfDayExtension on TimeOfDay { String formatHHmm24() { @@ -26,23 +24,19 @@ extension TimeOfDayExtension on TimeOfDay { } class Calendar extends StatefulWidget { - final DateTime? selectedDay; + const Calendar({super.key, this.selectedDay}); @override State createState() => __CalendarState(); } - - - - class __CalendarState extends State { - DateTime selectedDay = DateTime.now(); String selectedDayFormatted = DateFormat('yyyy-MM-dd').format(DateTime.now()); - String selectedDayFormatted2 = DateFormat('MM-dd-yyyy').format(DateTime.now()); + String selectedDayFormatted2 = + DateFormat('MM-dd-yyyy').format(DateTime.now()); void _selectDay(DateTime day) { setState(() { @@ -73,20 +67,17 @@ class __CalendarState extends State { } } - Future fetchTasks(String date) async { - SharedPreferences prefs = await SharedPreferences.getInstance(); final token = prefs.getString('token'); final csrfToken = await fetchCSRFToken(); final response = await http.get( - Uri.parse('http://10.0.2.2:8000/tasks/?date=$date'), - headers: { - 'Content-Type': 'application/json; charset=UTF-8', - 'Authorization': 'Token $token', - 'X-CSRFToken': csrfToken, - } - ); + Uri.parse('http://10.0.2.2:8000/tasks/?date=$date'), + headers: { + 'Content-Type': 'application/json; charset=UTF-8', + 'Authorization': 'Token $token', + 'X-CSRFToken': csrfToken, + }); if (response.statusCode == 200) { final jsonBody = jsonDecode(response.body); @@ -107,13 +98,12 @@ class __CalendarState extends State { final token = prefs.getString('token'); final csrfToken = await fetchCSRFToken(); final response = await http.delete( - Uri.parse('http://10.0.2.2:8000/tasks/$id/'), - headers: { - 'Content-Type': 'application/json; charset=UTF-8', - 'Authorization': 'Token $token', - 'X-CSRFToken': csrfToken, - } - ); + Uri.parse('http://10.0.2.2:8000/tasks/$id/'), + headers: { + 'Content-Type': 'application/json; charset=UTF-8', + 'Authorization': 'Token $token', + 'X-CSRFToken': csrfToken, + }); if (response.statusCode == 204) { fetchTasks(selectedDayFormatted); } else { @@ -174,9 +164,7 @@ class __CalendarState extends State { }); } - - -@override + @override Widget build(BuildContext context) { Widget currentPage; switch (_currentIndex) { @@ -223,27 +211,29 @@ class __CalendarState extends State { Row( children: [ Padding( - padding: const EdgeInsets.only(top: 15.0, left: 8, bottom: 8), + padding: + const EdgeInsets.only(top: 15.0, left: 8, bottom: 8), child: ElevatedButton( onPressed: () { - _selectDay(DateTime(selectedDay.year, selectedDay.month, selectedDay.day - 1)); + _selectDay(DateTime(selectedDay.year, selectedDay.month, + selectedDay.day - 1)); }, child: const Text( - '<', + '<', style: TextStyle( fontSize: 25, color: Colors.black, ), ), - ) - - ), + )), const Spacer(), Padding( - padding: const EdgeInsets.only(top: 15.0, right: 8, bottom: 8), + padding: + const EdgeInsets.only(top: 15.0, right: 8, bottom: 8), child: ElevatedButton( onPressed: () { - _selectDay(DateTime(selectedDay.year, selectedDay.month, selectedDay.day + 1)); + _selectDay(DateTime(selectedDay.year, selectedDay.month, + selectedDay.day + 1)); }, child: const Text( '>', @@ -252,9 +242,7 @@ class __CalendarState extends State { color: Colors.black, ), ), - ) - - ), + )), ], ), const SizedBox(height: 15), @@ -265,12 +253,15 @@ class __CalendarState extends State { itemBuilder: (context, index) { return Card( elevation: 5, - margin: const EdgeInsets.only(left: 15, right: 15, bottom: 15), + margin: + const EdgeInsets.only(left: 15, right: 15, bottom: 15), child: ListTile( leading: Text(items[index].startTime.formatHHmm24()), title: Text(items[index].title), subtitle: Text(items[index].discription), - trailing: items[index].endTime == null ? null : Text(items[index].endTime!.formatHHmm24()), + trailing: items[index].endTime == null + ? null + : Text(items[index].endTime!.formatHHmm24()), onTap: () => showDialog( context: context, builder: (context) => AlertDialog( @@ -280,12 +271,19 @@ class __CalendarState extends State { mainAxisSize: MainAxisSize.min, children: [ Text("Description: ${items[index].discription}"), - Text("Date: ${DateFormat('yyyy-MM-dd').format(items[index].doDate)}"), - Text("Start Time: ${items[index].startTime.formatHHmm24()}"), - Text("End Time: ${items[index].endTime?.formatHHmm24()}"), - Text("Alarm: ${items[index].alarm ? 'Yes' : 'No'}",), - Text("repetation: ${items[index].repetation ? 'Yes' : 'No'}"), - Text("termine: ${items[index].done ? 'Yes' : 'No'}"), + Text( + "Date: ${DateFormat('yyyy-MM-dd').format(items[index].doDate)}"), + Text( + "Start Time: ${items[index].startTime.formatHHmm24()}"), + Text( + "End Time: ${items[index].endTime?.formatHHmm24()}"), + Text( + "Alarm: ${items[index].alarm ? 'Yes' : 'No'}", + ), + Text( + "repetation: ${items[index].repetation ? 'Yes' : 'No'}"), + Text( + "termine: ${items[index].done ? 'Yes' : 'No'}"), ], ), actions: [ @@ -306,7 +304,10 @@ class __CalendarState extends State { Navigator.push( context, MaterialPageRoute( - builder: (_) => createTask(taskData: items[index].toJson(), operation: 'edit',), // Pass the task data + builder: (_) => createTask( + taskData: items[index].toJson(), + operation: 'edit', + ), // Pass the task data ), ); }, @@ -325,16 +326,17 @@ class __CalendarState extends State { Navigator.pushAndRemoveUntil( context, MaterialPageRoute( - builder: (_) => createTask(taskData: {"do_date": selectedDayFormatted},operation: 'creat'), + builder: (_) => createTask( + taskData: {"do_date": selectedDayFormatted}, + operation: 'creat'), ), - (Route route) => false, + (Route route) => false, ); }, child: const Icon(Icons.add), ), ), - // ), ], ), @@ -375,5 +377,4 @@ class __CalendarState extends State { // ), ); } - } From 3aaa7246c7a4cf3e726d683104b7c31f8d3f0ba9 Mon Sep 17 00:00:00 2001 From: felix Date: Tue, 16 Apr 2024 00:35:03 -0400 Subject: [PATCH 3/9] empty message task manager --- lib/Screens/Calendar.dart | 159 +++++++++++++++++++++----------------- 1 file changed, 88 insertions(+), 71 deletions(-) diff --git a/lib/Screens/Calendar.dart b/lib/Screens/Calendar.dart index 65091b5..2facf2e 100644 --- a/lib/Screens/Calendar.dart +++ b/lib/Screens/Calendar.dart @@ -186,13 +186,13 @@ class __CalendarState extends State { return Scaffold( appBar: const MyAppBar(), - - body: SingleChildScrollView( + body: Padding( + padding: const EdgeInsets.all(0), child: Column( children: [ const SizedBox(height: 15), Text( - 'Emploie du temps du ${weekdays[DateFormat('EEEE').format(selectedDay)]}', + 'Activités du ${weekdays[DateFormat('EEEE').format(selectedDay)]}', style: const TextStyle( fontWeight: FontWeight.bold, fontSize: 20, @@ -246,81 +246,98 @@ class __CalendarState extends State { ], ), const SizedBox(height: 15), - ListView.builder( - shrinkWrap: true, - physics: const AlwaysScrollableScrollPhysics(), - itemCount: items.length, - itemBuilder: (context, index) { - return Card( - elevation: 5, - margin: - const EdgeInsets.only(left: 15, right: 15, bottom: 15), - child: ListTile( - leading: Text(items[index].startTime.formatHHmm24()), - title: Text(items[index].title), - subtitle: Text(items[index].discription), - trailing: items[index].endTime == null - ? null - : Text(items[index].endTime!.formatHHmm24()), - onTap: () => showDialog( - context: context, - builder: (context) => AlertDialog( - title: Text(items[index].title), - content: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text("Description: ${items[index].discription}"), - Text( - "Date: ${DateFormat('yyyy-MM-dd').format(items[index].doDate)}"), - Text( - "Start Time: ${items[index].startTime.formatHHmm24()}"), - Text( - "End Time: ${items[index].endTime?.formatHHmm24()}"), - Text( - "Alarm: ${items[index].alarm ? 'Yes' : 'No'}", + if (items.isEmpty) + const Padding( + padding: EdgeInsets.all(16.0), // Ajustez la valeur selon vos besoins + child: Center( + child: Text( + "Vous n'avez pas encore d'activitées prévues à cette date", + style: TextStyle( + fontSize: 20, + fontFamily: 'Nunito', + ), + textAlign: TextAlign.center, + ), + ), + ) + else + Expanded( + child: ListView.builder( + shrinkWrap: true, + physics: const AlwaysScrollableScrollPhysics(), + itemCount: items.length, + itemBuilder: (context, index) { + return Card( + elevation: 5, + margin: + const EdgeInsets.only(left: 15, right: 15, bottom: 15), + child: ListTile( + leading: Text(items[index].startTime.formatHHmm24()), + title: Text(items[index].title), + subtitle: Text(items[index].discription), + trailing: items[index].endTime == null + ? null + : Text(items[index].endTime!.formatHHmm24()), + onTap: () => showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text(items[index].title), + content: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text("Description: ${items[index].discription}"), + Text( + "Date: ${DateFormat('yyyy-MM-dd').format(items[index].doDate)}"), + Text( + "Start Time: ${items[index].startTime.formatHHmm24()}"), + Text( + "End Time: ${items[index].endTime?.formatHHmm24()}"), + Text( + "Alarm: ${items[index].alarm ? 'Yes' : 'No'}", + ), + Text( + "repetation: ${items[index].repetation ? 'Yes' : 'No'}"), + Text( + "termine: ${items[index].done ? 'Yes' : 'No'}"), + ], + ), + actions: [ + TextButton( + child: const Text('ّFermer'), + onPressed: () => Navigator.of(context).pop(), + ), + TextButton( + child: const Text('Supprimer'), + onPressed: () { + deleteTask(items[index].id!); + Navigator.of(context).pop(); + }, + ), + TextButton( + child: const Text('Modify'), + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (_) => createTask( + taskData: items[index].toJson(), + operation: 'edit', + ), // Pass the task data + ), + ); + }, ), - Text( - "repetation: ${items[index].repetation ? 'Yes' : 'No'}"), - Text( - "termine: ${items[index].done ? 'Yes' : 'No'}"), ], ), - actions: [ - TextButton( - child: const Text('ّFermer'), - onPressed: () => Navigator.of(context).pop(), - ), - TextButton( - child: const Text('Supprimer'), - onPressed: () { - deleteTask(items[index].id!); - Navigator.of(context).pop(); - }, - ), - TextButton( - child: const Text('Modify'), - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (_) => createTask( - taskData: items[index].toJson(), - operation: 'edit', - ), // Pass the task data - ), - ); - }, - ), - ], ), ), - ), - ); - }, + ); + }, + ), ), Padding( - padding: const EdgeInsets.only(top: 8), + padding: const EdgeInsets.only(top: 8, bottom: 8), child: FloatingActionButton( onPressed: () { Navigator.pushAndRemoveUntil( From 7ceaa8b099335ef1ee9e645c153a3c76a55c4fc2 Mon Sep 17 00:00:00 2001 From: felix Date: Tue, 16 Apr 2024 00:36:48 -0400 Subject: [PATCH 4/9] empty message task manager --- lib/Screens/Calendar.dart | 1 - lib/Screens/createtask.dart | 1 - lib/main.dart | 2 -- 3 files changed, 4 deletions(-) diff --git a/lib/Screens/Calendar.dart b/lib/Screens/Calendar.dart index 2facf2e..c2f2176 100644 --- a/lib/Screens/Calendar.dart +++ b/lib/Screens/Calendar.dart @@ -47,7 +47,6 @@ class __CalendarState extends State { fetchTasks(selectedDayFormatted); } - final _formKey = GlobalKey(); List items = []; // on charge les tâches de la date du jour lors de l'initialisation du calendrier diff --git a/lib/Screens/createtask.dart b/lib/Screens/createtask.dart index d40edbb..adbcd2d 100644 --- a/lib/Screens/createtask.dart +++ b/lib/Screens/createtask.dart @@ -1,5 +1,4 @@ import 'dart:convert'; -import 'dart:ffi'; import 'package:activmind_app/Screens/Calendar.dart'; import 'package:activmind_app/common/gen_text_form_field.dart'; import 'package:http/http.dart' as http; diff --git a/lib/main.dart b/lib/main.dart index 5e7fd73..a19793b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,7 +1,5 @@ //import 'package:activmind_app/Screens/inscrire.dart'; import 'dart:convert'; -import 'package:intl/date_symbol_data_file.dart'; -import 'package:logger/logger.dart'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; import 'package:provider/provider.dart'; From 91e14bc6edaef6db3cde7f55532f370462795ea8 Mon Sep 17 00:00:00 2001 From: felix Date: Tue, 16 Apr 2024 01:16:47 -0400 Subject: [PATCH 5/9] add google font package --- lib/Screens/Calendar.dart | 30 +++++++++++++++++------------- lib/main.dart | 8 ++++++-- pubspec.lock | 10 +++++++++- pubspec.yaml | 1 + 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/lib/Screens/Calendar.dart b/lib/Screens/Calendar.dart index c2f2176..932ace8 100644 --- a/lib/Screens/Calendar.dart +++ b/lib/Screens/Calendar.dart @@ -14,6 +14,7 @@ import '../common/task_class.dart'; import 'package:intl/intl.dart'; import 'package:logger/logger.dart'; import 'createtask.dart'; +import 'package:google_fonts/google_fonts.dart'; var logger = Logger(level: Level.all); @@ -192,19 +193,17 @@ class __CalendarState extends State { const SizedBox(height: 15), Text( 'Activités du ${weekdays[DateFormat('EEEE').format(selectedDay)]}', - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20, - fontFamily: 'Nunito', + style: GoogleFonts.nunito( + fontSize: 30, + fontWeight: FontWeight.w600, ), ), const SizedBox(height: 3), Text( selectedDayFormatted2, - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20, - fontFamily: 'Arial', + style: GoogleFonts.nunito( + fontSize: 25, + fontWeight: FontWeight.w600, ), ), Row( @@ -246,14 +245,14 @@ class __CalendarState extends State { ), const SizedBox(height: 15), if (items.isEmpty) - const Padding( - padding: EdgeInsets.all(16.0), // Ajustez la valeur selon vos besoins + Padding( + padding: const EdgeInsets.all(16.0), // Ajustez la valeur selon vos besoins child: Center( child: Text( "Vous n'avez pas encore d'activitées prévues à cette date", - style: TextStyle( + style: GoogleFonts.nunito( fontSize: 20, - fontFamily: 'Nunito', + fontWeight: FontWeight.normal, ), textAlign: TextAlign.center, ), @@ -280,7 +279,12 @@ class __CalendarState extends State { onTap: () => showDialog( context: context, builder: (context) => AlertDialog( - title: Text(items[index].title), + title: Text(items[index].title, + style: GoogleFonts.nunito( + fontSize: 25, + fontWeight: FontWeight.w600, + ), + ), content: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, diff --git a/lib/main.dart b/lib/main.dart index a19793b..f26d355 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,7 @@ //import 'package:activmind_app/Screens/inscrire.dart'; import 'dart:convert'; import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; import 'package:http/http.dart' as http; import 'package:provider/provider.dart'; import 'Screens/homeform.dart'; @@ -79,9 +80,12 @@ class MyApp extends StatelessWidget { ); } else { // Token is invalid or not present, navigate to login page - return const MaterialApp( + return MaterialApp( debugShowCheckedModeBanner: false, - home: LoginForm(), + theme: ThemeData( + textTheme: GoogleFonts.nunitoTextTheme(), // Ajoutez cette ligne + ), + home: const LoginForm(), ); } } diff --git a/pubspec.lock b/pubspec.lock index 4b1f030..cf4c8ec 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -160,6 +160,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.2.3" + google_fonts: + dependency: "direct main" + description: + name: google_fonts + sha256: b1ac0fe2832c9cc95e5e88b57d627c5e68c223b9657f4b96e1487aa9098c7b82 + url: "https://pub.dev" + source: hosted + version: "6.2.1" http: dependency: "direct main" description: @@ -631,4 +639,4 @@ packages: version: "1.0.4" sdks: dart: ">=3.3.0 <4.0.0" - flutter: ">=3.19.0" + flutter: ">=3.19.2" diff --git a/pubspec.yaml b/pubspec.yaml index ce94cbb..9d75a00 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -46,6 +46,7 @@ dependencies: table_calendar: ^3.1.1 logger: ^2.2.0 intl: ^0.19.0 + google_fonts: ^6.2.1 # fluttertoast: ^8.2.4 From d9772d6e05472d37d6395641bf2ff40e7d4c2267 Mon Sep 17 00:00:00 2001 From: felix Date: Tue, 16 Apr 2024 02:11:03 -0400 Subject: [PATCH 6/9] UI and orthography --- lib/Screens/Calendar.dart | 113 ++++++++++++++++++++++++++++------ lib/Screens/HomeForm.dart | 18 +++++- lib/Screens/createtask.dart | 50 ++++++++++----- lib/Screens/locationList.dart | 17 ++--- 4 files changed, 151 insertions(+), 47 deletions(-) diff --git a/lib/Screens/Calendar.dart b/lib/Screens/Calendar.dart index 932ace8..d4fc0ef 100644 --- a/lib/Screens/Calendar.dart +++ b/lib/Screens/Calendar.dart @@ -190,11 +190,11 @@ class __CalendarState extends State { padding: const EdgeInsets.all(0), child: Column( children: [ - const SizedBox(height: 15), + const SizedBox(height: 20), Text( 'Activités du ${weekdays[DateFormat('EEEE').format(selectedDay)]}', style: GoogleFonts.nunito( - fontSize: 30, + fontSize: 27, fontWeight: FontWeight.w600, ), ), @@ -202,7 +202,7 @@ class __CalendarState extends State { Text( selectedDayFormatted2, style: GoogleFonts.nunito( - fontSize: 25, + fontSize: 22, fontWeight: FontWeight.w600, ), ), @@ -270,12 +270,34 @@ class __CalendarState extends State { margin: const EdgeInsets.only(left: 15, right: 15, bottom: 15), child: ListTile( - leading: Text(items[index].startTime.formatHHmm24()), - title: Text(items[index].title), - subtitle: Text(items[index].discription), + leading: Text(items[index].startTime.formatHHmm24(), + style: GoogleFonts.nunito( + fontSize: 15, + fontWeight: FontWeight.bold, + ), + ), + title: Text(items[index].title, + textAlign: TextAlign.center, + style: GoogleFonts.nunito( + fontSize: 20, + fontWeight: FontWeight.w600, + ), + ), + subtitle: Text(items[index].discription, + textAlign: TextAlign.center, + style: GoogleFonts.nunito( + fontSize: 15, + fontWeight: FontWeight.w500, + ), + ), trailing: items[index].endTime == null ? null - : Text(items[index].endTime!.formatHHmm24()), + : Text(items[index].endTime!.formatHHmm24(), + style: GoogleFonts.nunito( + fontSize: 15, + fontWeight: FontWeight.bold, + ), + ), onTap: () => showDialog( context: context, builder: (context) => AlertDialog( @@ -289,36 +311,77 @@ class __CalendarState extends State { crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - Text("Description: ${items[index].discription}"), + Text("Description : ${items[index].discription}", + style: GoogleFonts.nunito( + fontSize: 20, + fontWeight: FontWeight.w400, + ), + ), Text( - "Date: ${DateFormat('yyyy-MM-dd').format(items[index].doDate)}"), + "Date : ${DateFormat('MM-dd-yyyy').format(items[index].doDate)}", + style: GoogleFonts.nunito( + fontSize: 20, + fontWeight: FontWeight.w400, + ), + ), Text( - "Start Time: ${items[index].startTime.formatHHmm24()}"), + "Heure de début : ${items[index].startTime.formatHHmm24()}", + style: GoogleFonts.nunito( + fontSize: 20, + fontWeight: FontWeight.w400, + ), + ), Text( - "End Time: ${items[index].endTime?.formatHHmm24()}"), + "Heure de fin : ${items[index].endTime?.formatHHmm24()}", + style: GoogleFonts.nunito( + fontSize: 20, + fontWeight: FontWeight.w400, + ), + ), Text( - "Alarm: ${items[index].alarm ? 'Yes' : 'No'}", + "Alarme : ${items[index].alarm ? 'Oui' : 'Non'}", + style: GoogleFonts.nunito( + fontSize: 20, + fontWeight: FontWeight.w400, + ), ), Text( - "repetation: ${items[index].repetation ? 'Yes' : 'No'}"), + "repetition: ${items[index].repetation ? 'Oui' : 'Non'}", + style: GoogleFonts.nunito( + fontSize: 20, + fontWeight: FontWeight.w400, + ), + ), + Text( - "termine: ${items[index].done ? 'Yes' : 'No'}"), + "terminée: ${items[index].done ? 'Oui' : 'Non'}", + style: GoogleFonts.nunito( + fontSize: 20, + fontWeight: FontWeight.w400, + ), + ), ], ), actions: [ TextButton( - child: const Text('ّFermer'), - onPressed: () => Navigator.of(context).pop(), - ), - TextButton( - child: const Text('Supprimer'), + child: Text('Supprimer', + style: GoogleFonts.nunito( + fontSize: 15, + fontWeight: FontWeight.bold, + ), + ), onPressed: () { deleteTask(items[index].id!); Navigator.of(context).pop(); }, ), TextButton( - child: const Text('Modify'), + child: Text('Modifier', + style: GoogleFonts.nunito( + fontSize: 15, + fontWeight: FontWeight.bold, + ), + ), onPressed: () { Navigator.push( context, @@ -331,6 +394,16 @@ class __CalendarState extends State { ); }, ), + TextButton( + child: Text('ّFermer', + style: GoogleFonts.nunito( + fontSize: 15, + fontWeight: FontWeight.bold, + ),), + onPressed: () => Navigator.of(context).pop(), + ), + + ], ), ), diff --git a/lib/Screens/HomeForm.dart b/lib/Screens/HomeForm.dart index 7920431..efad92f 100644 --- a/lib/Screens/HomeForm.dart +++ b/lib/Screens/HomeForm.dart @@ -4,6 +4,7 @@ import 'package:activmind_app/Screens/locationList.dart'; import 'package:activmind_app/Screens/tasklist.dart'; import 'package:activmind_app/common/appandfooterbar.dart'; import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; class HomeForm extends StatefulWidget { const HomeForm({Key? key}) : super(key: key); @@ -61,7 +62,7 @@ class _HomeFormState extends State { @override Widget build(BuildContext context) { - final Widget currentPage; + final Widget currentPage; switch (_currentIndex) { case 0: currentPage = const TaskList(); @@ -83,7 +84,20 @@ class _HomeFormState extends State { } return Scaffold( appBar: const MyAppBar(), // Use MyAppBar for header - body: const Text('welcom to ActivMind'), + body: Padding( + padding: const EdgeInsets.all(20), + child: Column(children: [ + const SizedBox(height: 20), + Center( + child: Text( + "welcome to Activ'Mind", + style: GoogleFonts.nunito( + fontSize: 25, + fontWeight: FontWeight.w600, + ), + )), + ]), + ), bottomNavigationBar: BottomNavBar( currentIndex: _currentIndex, onTap: _onItemTapped, diff --git a/lib/Screens/createtask.dart b/lib/Screens/createtask.dart index adbcd2d..9e24f38 100644 --- a/lib/Screens/createtask.dart +++ b/lib/Screens/createtask.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'package:activmind_app/Screens/Calendar.dart'; import 'package:activmind_app/common/gen_text_form_field.dart'; +import 'package:google_fonts/google_fonts.dart'; import 'package:http/http.dart' as http; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; @@ -219,25 +220,26 @@ class _createTaskState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ const SizedBox(height: 10.0), - const Text( - "Ajouter une tâche", - style: TextStyle( - fontWeight: FontWeight.bold, - color: Colors.white, - fontSize: 25.0), + Text( + "Ajouter une activité", + style: GoogleFonts.nunito( + fontSize: 25, + fontWeight: FontWeight.bold, + color: Colors.white, + ), ), const SizedBox(height: 20.0), GetTextFormField( controller: _titleController, icon: Icons.title, - hintName: 'titre*', + hintName: 'Titre*', inputtype: TextInputType.text, ), const SizedBox(height: 10.0), GetTextFormField( controller: _descriptionController, icon: Icons.description, - hintName: 'description *', + hintName: 'Description *', ), const SizedBox(height: 20.0), Padding( @@ -253,7 +255,7 @@ class _createTaskState extends State { builder: (BuildContext context, Widget? child) { return Theme( data: ThemeData.light().copyWith( - colorScheme: ColorScheme.light( + colorScheme: const ColorScheme.light( primary: Color.fromARGB(255, 107, 109, 174), ), @@ -353,7 +355,7 @@ class _createTaskState extends State { ), const SizedBox(height: 5.0), Container( - padding: const EdgeInsets.all(8), + padding: const EdgeInsets.symmetric(horizontal: 8), child: Row( children: [ Checkbox( @@ -365,12 +367,17 @@ class _createTaskState extends State { }); }, ), - const Text("Alarm"), + Text("Alarm", + style: GoogleFonts.nunito( + fontSize: 15, + fontWeight: FontWeight.w600, + ), + ), ], ), ), Container( - padding: const EdgeInsets.all(8), + padding: const EdgeInsets.symmetric(horizontal: 8), child: Row( children: [ Checkbox( @@ -382,12 +389,17 @@ class _createTaskState extends State { }); }, ), - const Text("Repetation"), + Text("Repetition", + style: GoogleFonts.nunito( + fontSize: 15, + fontWeight: FontWeight.w600, + ), + ), ], ), ), Container( - padding: const EdgeInsets.all(8), + padding: const EdgeInsets.symmetric(horizontal: 8), child: Row( children: [ Checkbox( @@ -399,7 +411,11 @@ class _createTaskState extends State { }); }, ), - const Text("Done"), + Text("Terminée", + style: GoogleFonts.nunito( + fontSize: 15, + fontWeight: FontWeight.w600, + ),), ], ), ), @@ -415,7 +431,7 @@ class _createTaskState extends State { ), onPressed: () => selectOperation(operation, taskData), - child: const Text('soumettre'), + child: const Text('Enregistrer'), ), SizedBox(width: 20), ElevatedButton( @@ -434,7 +450,7 @@ class _createTaskState extends State { ), (Route route) => false); }, - child: const Text('Annoler'), + child: const Text('Annuler'), ), ], ), diff --git a/lib/Screens/locationList.dart b/lib/Screens/locationList.dart index 6712c1b..ac466e5 100644 --- a/lib/Screens/locationList.dart +++ b/lib/Screens/locationList.dart @@ -9,6 +9,7 @@ import 'package:activmind_app/common/taskform.dart'; import 'package:flutter/material.dart'; import 'package:activmind_app/common/appandfooterbar.dart'; import 'package:activmind_app/common/csrf.dart'; +import 'package:google_fonts/google_fonts.dart'; import 'package:http/http.dart' as http; import 'package:shared_preferences/shared_preferences.dart'; import 'package:geolocator/geolocator.dart'; @@ -339,12 +340,12 @@ class _LocationListState extends State { return SingleChildScrollView( child: Column( children: [ - const Text( - 'list de location', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20, - fontFamily: 'Arial', + const SizedBox(height: 20), + Text( + 'Liste des localisations', + style: GoogleFonts.nunito( + fontSize: 25, + fontWeight: FontWeight.w600, ), ), ListView.builder( @@ -400,11 +401,11 @@ class _LocationListState extends State { ), Padding( - padding: const EdgeInsets.only(top: 8), + padding: const EdgeInsets.all(20), child: TextField( controller: _locationNameController, decoration: const InputDecoration( - hintText: 'Entrez le nom de cette location', + hintText: 'Nom de la localisation', ), ), ), From a4c60cc48fcfedb9db38eceb458fb3578a0b1c0b Mon Sep 17 00:00:00 2001 From: felix Date: Tue, 16 Apr 2024 02:55:37 -0400 Subject: [PATCH 7/9] UI and orthography --- lib/Screens/Calendar.dart | 5 +-- lib/Screens/HomeForm.dart | 7 ++-- lib/Screens/appsettingpage.dart | 36 +++++++++++-------- lib/Screens/locationList.dart | 3 +- lib/Screens/profilepage.dart | 64 +++++++++++++++++++-------------- lib/Screens/tasklist.dart | 3 +- lib/common/appandfooterbar.dart | 29 +++++++-------- 7 files changed, 83 insertions(+), 64 deletions(-) diff --git a/lib/Screens/Calendar.dart b/lib/Screens/Calendar.dart index d4fc0ef..53fe7d5 100644 --- a/lib/Screens/Calendar.dart +++ b/lib/Screens/Calendar.dart @@ -4,6 +4,7 @@ import 'dart:core'; import 'package:activmind_app/Screens/HomeForm.dart'; import 'package:activmind_app/Screens/appsettingpage.dart'; import 'package:activmind_app/Screens/locationList.dart'; +import 'package:activmind_app/Screens/profilepage.dart'; import 'package:activmind_app/Screens/tasklist.dart'; import 'package:activmind_app/common/appandfooterbar.dart'; import 'package:flutter/material.dart'; @@ -155,7 +156,7 @@ class __CalendarState extends State { if (index == 4) { Navigator.pushReplacement( context, - MaterialPageRoute(builder: (context) => const AppSettingPage()), + MaterialPageRoute(builder: (context) => const ProfilePage()), ); return; // Return here to prevent further execution } @@ -194,7 +195,7 @@ class __CalendarState extends State { Text( 'Activités du ${weekdays[DateFormat('EEEE').format(selectedDay)]}', style: GoogleFonts.nunito( - fontSize: 27, + fontSize: 25, fontWeight: FontWeight.w600, ), ), diff --git a/lib/Screens/HomeForm.dart b/lib/Screens/HomeForm.dart index efad92f..d4e31e5 100644 --- a/lib/Screens/HomeForm.dart +++ b/lib/Screens/HomeForm.dart @@ -1,6 +1,7 @@ import 'package:activmind_app/Screens/Calendar.dart'; import 'package:activmind_app/Screens/appsettingpage.dart'; import 'package:activmind_app/Screens/locationList.dart'; +import 'package:activmind_app/Screens/profilepage.dart'; import 'package:activmind_app/Screens/tasklist.dart'; import 'package:activmind_app/common/appandfooterbar.dart'; import 'package:flutter/material.dart'; @@ -50,7 +51,7 @@ class _HomeFormState extends State { if (index == 4) { Navigator.pushReplacement( context, - MaterialPageRoute(builder: (context) => const AppSettingPage()), + MaterialPageRoute(builder: (context) => const ProfilePage()), ); return; // Return here to prevent further execution } @@ -77,7 +78,7 @@ class _HomeFormState extends State { currentPage = const LocationList(); break; case 4: - currentPage = const AppSettingPage(); + currentPage = const ProfilePage(); break; default: currentPage = const TaskList(); // Default to the first page @@ -90,7 +91,7 @@ class _HomeFormState extends State { const SizedBox(height: 20), Center( child: Text( - "welcome to Activ'Mind", + "Bienvenue sur Activ'Mind", style: GoogleFonts.nunito( fontSize: 25, fontWeight: FontWeight.w600, diff --git a/lib/Screens/appsettingpage.dart b/lib/Screens/appsettingpage.dart index b161586..7a40526 100644 --- a/lib/Screens/appsettingpage.dart +++ b/lib/Screens/appsettingpage.dart @@ -5,6 +5,10 @@ import 'package:activmind_app/Screens/profilepage.dart'; import 'package:activmind_app/Screens/tasklist.dart'; import 'package:activmind_app/common/appandfooterbar.dart'; import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'package:provider/provider.dart'; + +import '../common/globalvariable.dart'; class AppSettingPage extends StatefulWidget { const AppSettingPage({Key? key}) : super(key: key); @@ -38,7 +42,7 @@ class _AppSettingPageState extends State { ); return; // Return here to prevent further execution } - if (index == 3) { + if (index == 3) { Navigator.pushReplacement( context, MaterialPageRoute(builder: (context) => const LocationList()), @@ -49,7 +53,7 @@ class _AppSettingPageState extends State { if (index == 4) { Navigator.pushReplacement( context, - MaterialPageRoute(builder: (context) => const AppSettingPage()), + MaterialPageRoute(builder: (context) => const ProfilePage()), ); return; // Return here to prevent further execution } @@ -61,7 +65,8 @@ class _AppSettingPageState extends State { @override Widget build(BuildContext context) { - final Widget currentPage; + var globalVariables = Provider.of(context); + final Widget currentPage; switch (_currentIndex) { case 0: currentPage = const TaskList(); @@ -82,31 +87,34 @@ class _AppSettingPageState extends State { currentPage = const TaskList(); // Default to the first page } return Scaffold( - appBar: const MyAppBar(), - + appBar: const MyAppBar(), body: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Center( child: ElevatedButton( onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (_) => const ProfilePage())); - }, + Navigator.push(context, + MaterialPageRoute(builder: (_) => const ProfilePage())); + }, child: const Text('Open Profile Page'), ), ), - const SizedBox(height: 20), // Add some space between button and footer - const Text('Welcome to ActivMind'), + const SizedBox(height: 20), + // Add some space between button and footer + Text('Vous êtes sur le profil de ${globalVariables.user ?? ''}', + textAlign: TextAlign.center, + style: GoogleFonts.nunito( + fontSize: 22, + fontWeight: FontWeight.w400, + ), + ), ], ), - bottomNavigationBar: BottomNavBar( currentIndex: _currentIndex, onTap: _onItemTapped, - ), + ), ); } } diff --git a/lib/Screens/locationList.dart b/lib/Screens/locationList.dart index ac466e5..8a7935c 100644 --- a/lib/Screens/locationList.dart +++ b/lib/Screens/locationList.dart @@ -2,6 +2,7 @@ import 'dart:convert'; // import 'package:fluttertoast/fluttertoast.dart'; import 'package:activmind_app/Screens/Calendar.dart'; import 'package:activmind_app/Screens/HomeForm.dart'; +import 'package:activmind_app/Screens/profilepage.dart'; import 'package:activmind_app/Screens/tasklist.dart'; import 'package:activmind_app/Screens/appsettingpage.dart'; import 'package:activmind_app/common/defftappages.dart'; @@ -273,7 +274,7 @@ class _LocationListState extends State { if (index == 4) { Navigator.pushReplacement( context, - MaterialPageRoute(builder: (context) => const AppSettingPage()), + MaterialPageRoute(builder: (context) => const ProfilePage()), ); return; } diff --git a/lib/Screens/profilepage.dart b/lib/Screens/profilepage.dart index a3c93d9..b079241 100644 --- a/lib/Screens/profilepage.dart +++ b/lib/Screens/profilepage.dart @@ -13,15 +13,19 @@ // return Container(); // } // } +import 'package:activmind_app/Screens/locationList.dart'; import 'package:activmind_app/main.dart'; +import 'package:google_fonts/google_fonts.dart'; import 'package:http/http.dart' as http; import 'package:activmind_app/Screens/Calendar.dart'; import 'package:activmind_app/Screens/HomeForm.dart'; import 'package:activmind_app/Screens/tasklist.dart'; import 'package:activmind_app/common/appandfooterbar.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import '../common/globalvariable.dart'; class ProfilePage extends StatefulWidget { const ProfilePage({Key? key}) : super(key: key); @@ -31,43 +35,37 @@ class ProfilePage extends StatefulWidget { } class _ProfilePageState extends State { - Future signOut() async { - SharedPreferences prefs = await SharedPreferences.getInstance(); + SharedPreferences prefs = await SharedPreferences.getInstance(); final token = prefs.getString('token'); - const String apiUrl = 'http://10.0.2.2:8000/auth/logout/'; + const String apiUrl = 'http://10.0.2.2:8000/auth/logout/'; final response = await http.post( Uri.parse(apiUrl), headers: { 'Content-Type': 'application/json; charset=UTF-8', 'Authorization': 'Token $token', - }, - ); if (response.statusCode == 200) { // Task updated successfully print('user loged out successfully'); SharedPreferences.getInstance().then((prefs) { - prefs.remove('token'); - Navigator.pushReplacement( - context, - MaterialPageRoute(builder: (context) => const MyApp()), - ); - }); + prefs.remove('token'); + Navigator.pushReplacement( + context, + MaterialPageRoute(builder: (context) => const MyApp()), + ); + }); } else { // Task update failed print('Failed to logedout. Status code: ${response.statusCode}'); } - - // Example: Navigate back to the login screen (replace 'LoginScreen()' with your actual login screen) - } - + int _currentIndex = 4; void _onItemTapped(int index) { @@ -92,7 +90,13 @@ class _ProfilePageState extends State { ); return; // Return here to prevent further execution } - + if (index == 3) { + Navigator.pushReplacement( + context, + MaterialPageRoute(builder: (context) => const LocationList()), + ); + return; // Return here to prevent further execution + } if (index == 4) { Navigator.pushReplacement( context, @@ -108,7 +112,8 @@ class _ProfilePageState extends State { @override Widget build(BuildContext context) { - final Widget currentPage; + var globalVariables = Provider.of(context); + final Widget currentPage; switch (_currentIndex) { case 0: currentPage = const TaskList(); @@ -120,34 +125,41 @@ class _ProfilePageState extends State { currentPage = const HomeForm(); break; case 4: - currentPage = const ProfilePage(); + currentPage = const LocationList(); break; default: currentPage = const TaskList(); // Default to the first page } return Scaffold( - appBar: const MyAppBar(), - + appBar: const MyAppBar(), body: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ + Text( + 'Vous êtes sur le profil de : ${globalVariables.user ?? ''}', + textAlign: TextAlign.center, + style: GoogleFonts.nunito( + fontSize: 22, + fontWeight: FontWeight.w400, + ), + ), + const SizedBox(height: 20), Center( child: ElevatedButton( onPressed: () { - signOut(); // Call signOut function when the button is pressed - }, + signOut(); // Call signOut function when the button is pressed + }, child: const Text('Se déconnecter'), ), ), - const SizedBox(height: 20), // Add some space between button and footer - const Text('Welcome to ActivMind'), + + // Add some space between button and footer ], ), - bottomNavigationBar: BottomNavBar( currentIndex: _currentIndex, onTap: _onItemTapped, - ), + ), ); } } diff --git a/lib/Screens/tasklist.dart b/lib/Screens/tasklist.dart index fc1dda5..e176d8d 100644 --- a/lib/Screens/tasklist.dart +++ b/lib/Screens/tasklist.dart @@ -5,6 +5,7 @@ import 'package:activmind_app/Screens/HomeForm.dart'; import 'package:activmind_app/Screens/appsettingpage.dart'; import 'package:activmind_app/Screens/createtask.dart'; import 'package:activmind_app/Screens/locationList.dart'; +import 'package:activmind_app/Screens/profilepage.dart'; import 'package:activmind_app/common/defftappages.dart'; import 'package:activmind_app/common/taskform.dart'; import 'package:flutter/material.dart'; @@ -189,7 +190,7 @@ Future deleteTask(Map? taskData) async { if (index == 4) { Navigator.pushReplacement( context, - MaterialPageRoute(builder: (context) => const AppSettingPage()), + MaterialPageRoute(builder: (context) => const ProfilePage()), ); return; // Return here to prevent further execution } diff --git a/lib/common/appandfooterbar.dart b/lib/common/appandfooterbar.dart index b907aed..f8ab14c 100644 --- a/lib/common/appandfooterbar.dart +++ b/lib/common/appandfooterbar.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import 'package:activmind_app/common/globalvariable.dart'; @@ -7,18 +8,16 @@ class MyAppBar extends StatelessWidget implements PreferredSizeWidget { @override Widget build(BuildContext context) { - var globalVariables = Provider.of(context); return AppBar( - title: const Center( + title: Center( child: Text( 'Activ\'Mind', - style: TextStyle( + style: GoogleFonts.passeroOne( + fontSize: 25, fontWeight: FontWeight.bold, color: Colors.indigoAccent, - fontSize: 24, - fontFamily: 'Arial', ), ), ), @@ -26,13 +25,11 @@ class MyAppBar extends StatelessWidget implements PreferredSizeWidget { icon: const Icon(Icons.alarm), onPressed: () {}, ), - actions: [ - // IconButton( - // icon: Icon(Icons.notifications_none), - // onPressed: () {}, - // ), - - Text(globalVariables.user ?? ''), + actions: const [ + Padding( + padding: EdgeInsets.only(right: 18.0), + child: Text('V 1.0'), + ) ], ); } @@ -41,13 +38,12 @@ class MyAppBar extends StatelessWidget implements PreferredSizeWidget { Size get preferredSize => const Size.fromHeight(kToolbarHeight); } - - class BottomNavBar extends StatelessWidget { final int currentIndex; final Function(int) onTap; - const BottomNavBar({super.key, required this.currentIndex, required this.onTap}); + const BottomNavBar( + {super.key, required this.currentIndex, required this.onTap}); @override Widget build(BuildContext context) { @@ -56,8 +52,7 @@ class BottomNavBar extends StatelessWidget { backgroundColor: Colors.white, currentIndex: currentIndex, onTap: onTap, - items: - const [ + items: const [ BottomNavigationBarItem( icon: Icon(Icons.list_alt), label: 'List', From d83b20a1c5c540fcc3a9970b2c4142bb483c3d4d Mon Sep 17 00:00:00 2001 From: felix Date: Tue, 16 Apr 2024 02:57:02 -0400 Subject: [PATCH 8/9] UI and orthography --- lib/Screens/Calendar.dart | 1 - lib/Screens/HomeForm.dart | 1 - lib/Screens/locationList.dart | 1 - lib/Screens/tasklist.dart | 2 -- lib/common/appandfooterbar.dart | 3 --- 5 files changed, 8 deletions(-) diff --git a/lib/Screens/Calendar.dart b/lib/Screens/Calendar.dart index 53fe7d5..af6008b 100644 --- a/lib/Screens/Calendar.dart +++ b/lib/Screens/Calendar.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'dart:convert'; import 'dart:core'; import 'package:activmind_app/Screens/HomeForm.dart'; -import 'package:activmind_app/Screens/appsettingpage.dart'; import 'package:activmind_app/Screens/locationList.dart'; import 'package:activmind_app/Screens/profilepage.dart'; import 'package:activmind_app/Screens/tasklist.dart'; diff --git a/lib/Screens/HomeForm.dart b/lib/Screens/HomeForm.dart index d4e31e5..a1c9913 100644 --- a/lib/Screens/HomeForm.dart +++ b/lib/Screens/HomeForm.dart @@ -1,5 +1,4 @@ import 'package:activmind_app/Screens/Calendar.dart'; -import 'package:activmind_app/Screens/appsettingpage.dart'; import 'package:activmind_app/Screens/locationList.dart'; import 'package:activmind_app/Screens/profilepage.dart'; import 'package:activmind_app/Screens/tasklist.dart'; diff --git a/lib/Screens/locationList.dart b/lib/Screens/locationList.dart index 8a7935c..8d589fe 100644 --- a/lib/Screens/locationList.dart +++ b/lib/Screens/locationList.dart @@ -4,7 +4,6 @@ import 'package:activmind_app/Screens/Calendar.dart'; import 'package:activmind_app/Screens/HomeForm.dart'; import 'package:activmind_app/Screens/profilepage.dart'; import 'package:activmind_app/Screens/tasklist.dart'; -import 'package:activmind_app/Screens/appsettingpage.dart'; import 'package:activmind_app/common/defftappages.dart'; import 'package:activmind_app/common/taskform.dart'; import 'package:flutter/material.dart'; diff --git a/lib/Screens/tasklist.dart b/lib/Screens/tasklist.dart index e176d8d..ce8e79b 100644 --- a/lib/Screens/tasklist.dart +++ b/lib/Screens/tasklist.dart @@ -1,8 +1,6 @@ import 'dart:convert'; -// import 'package:fluttertoast/fluttertoast.dart'; import 'package:activmind_app/Screens/Calendar.dart'; import 'package:activmind_app/Screens/HomeForm.dart'; -import 'package:activmind_app/Screens/appsettingpage.dart'; import 'package:activmind_app/Screens/createtask.dart'; import 'package:activmind_app/Screens/locationList.dart'; import 'package:activmind_app/Screens/profilepage.dart'; diff --git a/lib/common/appandfooterbar.dart b/lib/common/appandfooterbar.dart index f8ab14c..cd8b022 100644 --- a/lib/common/appandfooterbar.dart +++ b/lib/common/appandfooterbar.dart @@ -1,14 +1,11 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:provider/provider.dart'; -import 'package:activmind_app/common/globalvariable.dart'; class MyAppBar extends StatelessWidget implements PreferredSizeWidget { const MyAppBar({Key? key}) : super(key: key); @override Widget build(BuildContext context) { - var globalVariables = Provider.of(context); return AppBar( title: Center( From 17530ed1d477181072667c415bd73c3bfbd87d2a Mon Sep 17 00:00:00 2001 From: felix Date: Tue, 16 Apr 2024 03:31:55 -0400 Subject: [PATCH 9/9] UI and orthography --- lib/Screens/forgot_password.dart | 54 +++++++----- lib/Screens/inscrire.dart | 2 +- lib/Screens/login_form.dart | 100 ++++++++++++++-------- lib/Screens/signup_form.dart | 142 +++++++++++++++---------------- 4 files changed, 169 insertions(+), 129 deletions(-) diff --git a/lib/Screens/forgot_password.dart b/lib/Screens/forgot_password.dart index 4b33a14..04bcbab 100644 --- a/lib/Screens/forgot_password.dart +++ b/lib/Screens/forgot_password.dart @@ -48,11 +48,11 @@ class _ForgotPasswordFormState extends State { ), ); return true; - } - else { + } else { ScaffoldMessenger.of(context).showSnackBar( SnackBar( - content: Text('Erreur lors de la réinitialisation du mot de passe: ${response.statusCode}'), + content: Text( + 'Erreur lors de la réinitialisation du mot de passe: ${response.statusCode}'), backgroundColor: Colors.red, ), ); @@ -61,7 +61,8 @@ class _ForgotPasswordFormState extends State { } catch (e) { ScaffoldMessenger.of(context).showSnackBar( const SnackBar( - content: Text('Une erreur s\'est produite. Veuillez réessayer plus tard.'), + content: + Text('Une erreur s\'est produite. Veuillez réessayer plus tard.'), backgroundColor: Colors.red, ), ); @@ -113,30 +114,21 @@ class _ForgotPasswordFormState extends State { icon: Icons.person, hintName: 'Email', inputtype: TextInputType.text), - const SizedBox(height: 5.0), + const SizedBox(height: 10.0), GetTextFormField( controller: _conpassword, icon: Icons.lock, hintName: 'mot de passe', isObscureText: true, ), - const SizedBox(height: 5.0), + const SizedBox(height: 10.0), GetTextFormField( controller: _conconfpassword, icon: Icons.lock, hintName: 'confirmer mot de passe', isObscureText: true, ), - const SizedBox(height: 20.0), - TextButton( - onPressed: () { - Navigator.push( - context, - MaterialPageRoute(builder: (context) => const LoginForm()), - ); - }, - child: const Text('Retourner à la page de connexion'), - ), + const SizedBox(height: 15.0), Container( margin: const EdgeInsets.all(30.0), width: double.infinity, @@ -146,17 +138,39 @@ class _ForgotPasswordFormState extends State { child: TextButton( onPressed: () async { if (await resetPassword()) { - await Future.delayed(const Duration(seconds: 1)); // Attendez 1 seconde - onResetPasswordSuccess(context); // Redirigez vers LoginForm uniquement si la réinitialisation du mot de passe a réussi + await Future.delayed( + const Duration(seconds: 1)); // Attendez 1 seconde + onResetPasswordSuccess( + context); // Redirigez vers LoginForm uniquement si la réinitialisation du mot de passe a réussi } }, child: const Text( 'Reinitialiser le mot de passe', - style: TextStyle( - color: Color.fromARGB(255, 197, 198, 243)), + style: + TextStyle(color: Color.fromARGB(255, 197, 198, 243), + fontSize: 18.0, + ), ), ), ), + const SizedBox(height: 80.0), + TextButton( + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const LoginForm()), + ); + }, + child: const Text( + 'Retour à la page de connexion', + style: TextStyle( + fontSize: 20.0, + color: Colors.white70, + ), + ), + ), + ], ), ), diff --git a/lib/Screens/inscrire.dart b/lib/Screens/inscrire.dart index 0a295b0..83171c5 100644 --- a/lib/Screens/inscrire.dart +++ b/lib/Screens/inscrire.dart @@ -29,7 +29,7 @@ class _InscrireFormState extends State { width: 100.0, ), const Text( - "s'inscrire", + "Inscrivez-vous", style: TextStyle( fontWeight: FontWeight.bold, color: Colors.white, diff --git a/lib/Screens/login_form.dart b/lib/Screens/login_form.dart index dce2aaf..dba3571 100644 --- a/lib/Screens/login_form.dart +++ b/lib/Screens/login_form.dart @@ -1,6 +1,7 @@ // ignore_for_file: avoid_print import 'package:activmind_app/Screens/HomeForm.dart'; + // import 'package:activmind_app/Screens/home.dart'; import 'package:activmind_app/Screens/signup_form.dart'; import 'package:activmind_app/Screens/Calendar.dart'; @@ -39,17 +40,18 @@ class _LoginFormState extends State { final BuildContext currentContext = context; if (response.statusCode == 200) { // Save token to local storage - final token = jsonDecode(response.body)['token']; - await saveToken(token); + final token = jsonDecode(response.body)['token']; + await saveToken(token); + + // Extract username from response + final Map userData = jsonDecode(response.body); + final String username = userData['username']; - // Extract username from response - final Map userData = jsonDecode(response.body); - final String username = userData['username']; + // Update global variable with the username + var globalVariables = + Provider.of(context, listen: false); + globalVariables.user = username; - // Update global variable with the username - var globalVariables = Provider.of(context, listen: false); - globalVariables.user = username; - // ignore: use_build_context_synchronously Navigator.pushReplacement( currentContext, MaterialPageRoute(builder: (_) => const HomeForm())); @@ -70,11 +72,10 @@ class _LoginFormState extends State { // } } - Future saveToken(String token) async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - await prefs.setString('token', token); -} + SharedPreferences prefs = await SharedPreferences.getInstance(); + await prefs.setString('token', token); + } @override Widget build(BuildContext context) { @@ -100,6 +101,7 @@ class _LoginFormState extends State { height: 100.0, width: 100.0, ), + const SizedBox(height: 20.0), const Text( 'se connecter', style: TextStyle( @@ -107,26 +109,35 @@ class _LoginFormState extends State { color: Colors.white, fontSize: 25.0), ), + const SizedBox(height: 10.0), GetTextFormField( controller: _conemail, icon: Icons.person, hintName: 'Email', inputtype: TextInputType.text), - const SizedBox(height: 5.0), + const SizedBox(height: 10.0), GetTextFormField( controller: _conpassword, icon: Icons.lock, hintName: 'mot de passe', isObscureText: true, ), + const SizedBox(height: 15.0), TextButton( onPressed: () { Navigator.push( context, - MaterialPageRoute(builder: (context) => const ForgotPasswordForm()), + MaterialPageRoute( + builder: (context) => const ForgotPasswordForm()), ); }, - child: Text('Mot de passe oublié ?'), + child: const Text( + 'Mot de passe oublié ?', + style: TextStyle( + color: Colors.white, + fontSize: 18.0, + fontWeight: FontWeight.bold), + ), ), Container( margin: const EdgeInsets.all(30.0), @@ -135,28 +146,45 @@ class _LoginFormState extends State { color: const Color.fromARGB(255, 76, 77, 166), borderRadius: BorderRadius.circular(30.0)), child: TextButton( - onPressed: login, + onPressed: login, + child: const Text( + 'connexion', + style: TextStyle( + color: Colors.white70, + fontSize: 20.0, + ), + ), + ), + ), + Column( + mainAxisAlignment: MainAxisAlignment.center, + // Centre les éléments verticalement + children: [ + const SizedBox(height: 100.0), + const Text( + "Vous n'avez pas encore de compte ?", + style: TextStyle( + fontWeight: FontWeight.bold, + color: Color.fromARGB(255, 76, 77, 166), + fontSize: 18.0), + ), + TextButton( + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (_) => const SignupForm())); + }, child: const Text( - 'connexion', + "Inscrivez-vous", style: TextStyle( - color: Color.fromARGB(255, 197, 198, 243)), - )), - ), - Center( - child: Container( - child: TextButton( - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (_) => const SignupForm())); - }, - child: const Text( - 'Inscrivez-vous', - style: TextStyle( - color: Color.fromARGB(255, 197, 198, 243)), - ))), - ), + color: Colors.white70, + fontSize: 18.0, + ), + ), + ), + ], + ) ], ), ), diff --git a/lib/Screens/signup_form.dart b/lib/Screens/signup_form.dart index 5f2a540..ed99379 100644 --- a/lib/Screens/signup_form.dart +++ b/lib/Screens/signup_form.dart @@ -2,6 +2,7 @@ import 'package:activmind_app/Screens/login_form.dart'; import 'package:activmind_app/common/comhelper.dart'; import 'package:flutter/material.dart'; import 'package:activmind_app/common/gen_text_form_field.dart'; + // ignore: depend_on_referenced_packages import 'package:http/http.dart' as http; import 'dart:convert'; @@ -24,60 +25,52 @@ class _SignupFormState extends State { final _conbirthdate = TextEditingController(); final _formKey = GlobalKey(); - List dropdownItems = ['Patient', 'Support', 'Assistent']; String? selectedDropdownItem; Future signUp() async { final form = _formKey.currentState; String email = _conemail.text; - String password1= _conpassword.text; + String password1 = _conpassword.text; String password2 = _conconfpassword.text; String firstName = _confirstname.text; String lastName = _conlastname.text; String birthDate = _conbirthdate.text; - - ToastContext toastContext = ToastContext(); - if (form!.validate()){ - if (password1 != password2){ - alterdialog(context, 'non concordance des mots de passe'); - } - else{ + if (form!.validate()) { + if (password1 != password2) { + alterdialog(context, 'non concordance des mots de passe'); + } else { final response = await http.post( - Uri.parse('http://10.0.2.2:8000/register/'), - headers: { - 'Content-Type': 'application/json; charset=UTF-8', - }, - body: jsonEncode({ - 'email': _conemail.text, - 'password': _conpassword.text, - 'dropdownValue': selectedDropdownItem ?? '', - 'first_name' : _confirstname.text, - 'last_name' : _conlastname.text, - "date_of_birth" : _conbirthdate.text - }), - ); - - - if (response.statusCode == 200 || response.statusCode == 201) { - // ignore: use_build_context_synchronously - Navigator.pushAndRemoveUntil( - context, - MaterialPageRoute( - builder: (_) => const LoginForm(), - ), - (Route route) => false); - } else { - - - // ignore: use_build_context_synchronously - alterdialog(context, "La définition de l'utilisateur a rencontré une erreur"); - } + Uri.parse('http://10.0.2.2:8000/register/'), + headers: { + 'Content-Type': 'application/json; charset=UTF-8', + }, + body: jsonEncode({ + 'email': _conemail.text, + 'password': _conpassword.text, + 'dropdownValue': selectedDropdownItem ?? '', + 'first_name': _confirstname.text, + 'last_name': _conlastname.text, + "date_of_birth": _conbirthdate.text + }), + ); + + if (response.statusCode == 200 || response.statusCode == 201) { + // ignore: use_build_context_synchronously + Navigator.pushAndRemoveUntil( + context, + MaterialPageRoute( + builder: (_) => const LoginForm(), + ), + (Route route) => false); + } else { + // ignore: use_build_context_synchronously + alterdialog(context, "Erreur dans l'inscription, veuillez réessayer"); + } } } - } @override @@ -103,8 +96,9 @@ class _SignupFormState extends State { height: 100.0, width: 100.0, ), + const SizedBox(height: 20.0), const Text( - "s'inscrire", + "Inscription", style: TextStyle( fontWeight: FontWeight.bold, color: Colors.white, @@ -132,7 +126,6 @@ class _SignupFormState extends State { isObscureText: true, ), const SizedBox(height: 5.0), - GetTextFormField( controller: _confirstname, icon: Icons.person, @@ -153,18 +146,15 @@ class _SignupFormState extends State { hintName: 'Date de naissance *', inputtype: TextInputType.text, ), - - const SizedBox(height: 5.0), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ const Text( - "type d'utilisateur:", + "type d'utilisateur * :", style: TextStyle( color: Color.fromARGB(255, 6, 6, 6), fontSize: 16.0, - ), ), const SizedBox(width: 10.0), @@ -177,9 +167,11 @@ class _SignupFormState extends State { child: Text( value, style: TextStyle( - color: value == selectedDropdownItem ? Colors.white : Colors.black, - ), + color: value == selectedDropdownItem + ? Colors.white + : Colors.black, ), + ), ); }).toList(), onChanged: (String? newValue) { @@ -193,33 +185,39 @@ class _SignupFormState extends State { const SizedBox(height: 20.0), ElevatedButton( style: ElevatedButton.styleFrom( - foregroundColor: Colors.white, backgroundColor: const Color.fromARGB(255, 76, 77, 166), + foregroundColor: Colors.white, + backgroundColor: const Color.fromARGB(255, 76, 77, 166), ), - onPressed: signUp, - child: const Text('soumettre'), + onPressed: signUp, + child: const Text('Enregistrer'), ), const SizedBox(height: 20.0), - Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Text('vous avez une compte?'), - TextButton( - onPressed: () { - Navigator.pushAndRemoveUntil( - context, - MaterialPageRoute( - builder: (_) => const LoginForm(), - ), - (Route route) => false); - }, - child: const Text( - 'connectez-vous', - style: TextStyle( - color: Color.fromARGB(255, 197, 198, 243)), - )) - ], - ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + 'vous avez une compte?', + style: TextStyle( + fontSize: 18.0, fontWeight: FontWeight.w400), + ), + TextButton( + onPressed: () { + Navigator.pushAndRemoveUntil( + context, + MaterialPageRoute( + builder: (_) => const LoginForm(), + ), + (Route route) => false); + }, + child: const Text( + 'connectez-vous', + style: TextStyle( + color: Color.fromARGB(255, 197, 198, 243), + fontSize: 18.0, + ), + ), + ), + ], ), ], ), @@ -229,4 +227,4 @@ class _SignupFormState extends State { ), ); } -} \ No newline at end of file +}