From a4c60cc48fcfedb9db38eceb458fb3578a0b1c0b Mon Sep 17 00:00:00 2001 From: felix Date: Tue, 16 Apr 2024 02:55:37 -0400 Subject: [PATCH] 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',