Skip to content

Commit

Permalink
UI and orthography
Browse files Browse the repository at this point in the history
  • Loading branch information
FeloxleF committed Apr 16, 2024
1 parent d9772d6 commit a4c60cc
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 64 deletions.
5 changes: 3 additions & 2 deletions lib/Screens/Calendar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -155,7 +156,7 @@ class __CalendarState extends State<Calendar> {
if (index == 4) {
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) => const AppSettingPage()),
MaterialPageRoute(builder: (context) => const ProfilePage()),
);
return; // Return here to prevent further execution
}
Expand Down Expand Up @@ -194,7 +195,7 @@ class __CalendarState extends State<Calendar> {
Text(
'Activités du ${weekdays[DateFormat('EEEE').format(selectedDay)]}',
style: GoogleFonts.nunito(
fontSize: 27,
fontSize: 25,
fontWeight: FontWeight.w600,
),
),
Expand Down
7 changes: 4 additions & 3 deletions lib/Screens/HomeForm.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -50,7 +51,7 @@ class _HomeFormState extends State<HomeForm> {
if (index == 4) {
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) => const AppSettingPage()),
MaterialPageRoute(builder: (context) => const ProfilePage()),
);
return; // Return here to prevent further execution
}
Expand All @@ -77,7 +78,7 @@ class _HomeFormState extends State<HomeForm> {
currentPage = const LocationList();
break;
case 4:
currentPage = const AppSettingPage();
currentPage = const ProfilePage();
break;
default:
currentPage = const TaskList(); // Default to the first page
Expand All @@ -90,7 +91,7 @@ class _HomeFormState extends State<HomeForm> {
const SizedBox(height: 20),
Center(
child: Text(
"welcome to Activ'Mind",
"Bienvenue sur Activ'Mind",
style: GoogleFonts.nunito(
fontSize: 25,
fontWeight: FontWeight.w600,
Expand Down
36 changes: 22 additions & 14 deletions lib/Screens/appsettingpage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -38,7 +42,7 @@ class _AppSettingPageState extends State<AppSettingPage> {
);
return; // Return here to prevent further execution
}
if (index == 3) {
if (index == 3) {
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) => const LocationList()),
Expand All @@ -49,7 +53,7 @@ class _AppSettingPageState extends State<AppSettingPage> {
if (index == 4) {
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) => const AppSettingPage()),
MaterialPageRoute(builder: (context) => const ProfilePage()),
);
return; // Return here to prevent further execution
}
Expand All @@ -61,7 +65,8 @@ class _AppSettingPageState extends State<AppSettingPage> {

@override
Widget build(BuildContext context) {
final Widget currentPage;
var globalVariables = Provider.of<GlobalVariables>(context);
final Widget currentPage;
switch (_currentIndex) {
case 0:
currentPage = const TaskList();
Expand All @@ -82,31 +87,34 @@ class _AppSettingPageState extends State<AppSettingPage> {
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,
),
),
);
}
}
3 changes: 2 additions & 1 deletion lib/Screens/locationList.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -273,7 +274,7 @@ class _LocationListState extends State<LocationList> {
if (index == 4) {
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) => const AppSettingPage()),
MaterialPageRoute(builder: (context) => const ProfilePage()),
);
return;
}
Expand Down
64 changes: 38 additions & 26 deletions lib/Screens/profilepage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -31,43 +35,37 @@ class ProfilePage extends StatefulWidget {
}

class _ProfilePageState extends State<ProfilePage> {

Future<void> 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: <String, String>{
'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) {
Expand All @@ -92,7 +90,13 @@ class _ProfilePageState extends State<ProfilePage> {
);
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,
Expand All @@ -108,7 +112,8 @@ class _ProfilePageState extends State<ProfilePage> {

@override
Widget build(BuildContext context) {
final Widget currentPage;
var globalVariables = Provider.of<GlobalVariables>(context);
final Widget currentPage;
switch (_currentIndex) {
case 0:
currentPage = const TaskList();
Expand All @@ -120,34 +125,41 @@ class _ProfilePageState extends State<ProfilePage> {
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,
),
),
);
}
}
3 changes: 2 additions & 1 deletion lib/Screens/tasklist.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -189,7 +190,7 @@ Future<void> deleteTask(Map<String, dynamic>? 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
}
Expand Down
Loading

0 comments on commit a4c60cc

Please sign in to comment.