Skip to content

Commit 4ed8342

Browse files
authored
Merge pull request #41 from Alwil17/devmain
Devmain
2 parents 4434baa + d464613 commit 4ed8342

30 files changed

+916
-252
lines changed

lib/l10n/app_en.arb

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,45 @@
7979
"descending": "Descending",
8080
"applyFilters": "Apply Filters",
8181
"explore": "Explore",
82-
"myReviews": "My Reviews"
82+
"myReviews": "My Reviews",
83+
"summary": "Summary",
84+
"perCategory": "Per Category",
85+
"perRating": "Per Rating",
86+
"myStats": "My Stats",
87+
"myActivity": "My Activity",
88+
"viewAll": "View All",
89+
"settings": "Settings",
90+
"account": "Account",
91+
"changePassword": "Change Password",
92+
"logout": "Logout",
93+
"appearance": "Appearance",
94+
"darkMode": "Dark Mode",
95+
"lightMode": "Light Mode",
96+
"systemMode": "System Mode",
97+
"language": "Language",
98+
"appVersion": "App Version",
99+
"privacyPolicy": "Privacy Policy",
100+
"contactSupport": "Contact Support",
101+
"end": "Finish",
102+
"selectThe": "Select the {selectOption}...",
103+
"@selectThe": {
104+
"description": "Label of the selection option.",
105+
"placeholders": {
106+
"selectOption": {
107+
"type": "String",
108+
"example": "Patient"
109+
}
110+
}
111+
},
112+
"french": "French",
113+
"english": "English",
114+
"languageValue": "{code, select, fr{French} en{English} other{Unknow}}",
115+
"@languageValue": {
116+
"description": "the label corresponding to language",
117+
"placeholders": {
118+
"code": {
119+
"type": "String"
120+
}
121+
}
122+
}
83123
}

lib/l10n/app_fr.arb

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,43 @@
7979
"descending": "Décroissant",
8080
"applyFilters": "Appliquer les filtres",
8181
"explore": "Explorer",
82-
"myReviews": "Mes avis"
82+
"myReviews": "Mes avis",
83+
"summary": "Résumé",
84+
"perCategory": "Par catégorie",
85+
"perRating": "Par note",
86+
"myStats": "Mes statistiques",
87+
"myActivity": "Mon activité",
88+
"viewAll": "Tout voir",
89+
"settings": "Paramètres",
90+
"account": "Compte",
91+
"changePassword": "Modifier le mot de passe",
92+
"logout": "Déconnexion",
93+
"appearance": "Apparence",
94+
"darkMode": "Mode sombre",
95+
"language": "Langue",
96+
"appVersion": "Version de l'app",
97+
"privacyPolicy": "Politique de confidentialité",
98+
"contactSupport": "Contacter le support",
99+
"end": "Terminer",
100+
"selectThe": "Sélectionnez la {selectOption}...",
101+
"@selectThe": {
102+
"description": "Label de l'option de sélection.",
103+
"placeholders": {
104+
"selectOption": {
105+
"type": "String",
106+
"example": "Patient"
107+
}
108+
}
109+
},
110+
"french": "Français",
111+
"english": "Anglais",
112+
"languageValue": "{code, select, fr{Français} en{Anglais} other{Inconnu}}",
113+
"@languageValue": {
114+
"description": "Le label correspondant à la langue",
115+
"placeholders": {
116+
"code": {
117+
"type": "String"
118+
}
119+
}
120+
}
83121
}

lib/main.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ class MyApp extends StatelessWidget {
104104
builder: (context, appStateProvider, child) {
105105
return MaterialApp.router(
106106
title: 'RateMaster',
107-
theme: appTheme,
107+
theme: lightTheme,
108+
darkTheme: darkTheme,
109+
themeMode: appStateProvider.isDarkMode ? ThemeMode.dark : ThemeMode.light,
108110
localizationsDelegates: [
109111
AppLocalizations.delegate, // Add this line
110112
GlobalMaterialLocalizations.delegate,

lib/providers/app_state_provider.dart

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
import 'package:flutter/material.dart';
2+
import 'package:package_info_plus/package_info_plus.dart';
23
import 'package:shared_preferences/shared_preferences.dart';
34

45
class AppStateProvider with ChangeNotifier {
56
late SharedPreferences sharedPreferences;
67

78
String _locale = "fr";
9+
String _appVersion = "1.0.0";
10+
bool _isDarkMode = false;
811

912
// Getters
1013
String get locale => _locale;
14+
String get appVersion => _appVersion;
15+
bool get isDarkMode => _isDarkMode;
1116

1217

1318
// Initialize SharedPreferences
@@ -18,11 +23,20 @@ class AppStateProvider with ChangeNotifier {
1823
await sharedPreferences.setString(key, value);
1924
notifyListeners();
2025
}
26+
Future<void> _setBool(String key, bool value) async {
27+
await sharedPreferences.setBool(key, value);
28+
notifyListeners();
29+
}
2130

2231
// Load preferences from SharedPreferences at startup
2332
Future<void> loadPreferences() async {
2433
// Use jsonDecode for user data stored in SharedPreferences
2534
_locale = sharedPreferences.getString(_kLocale) ?? "fr";
35+
_isDarkMode = sharedPreferences.getBool(_kTheme) ?? false;
36+
37+
// Get app version
38+
PackageInfo info = await PackageInfo.fromPlatform();
39+
_appVersion = info.version;
2640

2741
notifyListeners();
2842
}
@@ -39,6 +53,13 @@ class AppStateProvider with ChangeNotifier {
3953
_setString(_kLocale, state);
4054
_locale = state;
4155
}
56+
57+
set isDarkMode(bool state) {
58+
_setBool(_kTheme, state);
59+
_isDarkMode = state;
60+
}
61+
4262
}
4363

44-
const String _kLocale = "locale";
64+
const String _kLocale = "locale";
65+
const String _kTheme = "is_dark_mode";

lib/routes/app_router.dart

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import 'package:rate_master/routes/routes.dart';
88
import 'package:rate_master/screens/items/item_detail_screen.dart';
99
import 'package:rate_master/screens/profile/profile_screen.dart';
1010
import 'package:rate_master/screens/search/search_screen.dart';
11-
import 'package:rate_master/screens/stats/my_reviews_screen.dart';
12-
import 'package:rate_master/screens/stats/my_stats_screen.dart';
11+
import 'package:rate_master/screens/settings/settings_screen.dart';
12+
import 'package:rate_master/screens/stats/my_activity_screen.dart';
1313
import 'package:rate_master/shared/error_screen.dart';
1414

1515
class AppRouter {
@@ -68,21 +68,13 @@ class AppRouter {
6868
GoRoute(
6969
path: APP_PAGES.stats.toPath,
7070
name: APP_PAGES.stats.toName,
71-
builder: (context, state) => MyStatsScreen(),
71+
builder: (context, state) => MyActivityScreen(),
7272
),
73-
/*
7473
GoRoute(
75-
path: APP_PAGES.login.toPath,
76-
name: APP_PAGES.login.toName,
77-
builder: (context, state) => LoginScreen(),
78-
routes: [
79-
GoRoute(
80-
path: APP_PAGES.forgetPassword.toPath,
81-
name: APP_PAGES.forgetPassword.toName,
82-
builder: (context, state) => ForgetPasswordScreen(),
83-
),
84-
]
85-
),*/
74+
path: APP_PAGES.settings.toPath,
75+
name: APP_PAGES.settings.toName,
76+
builder: (context, state) => SettingsScreen(),
77+
),
8678
],
8779
debugLogDiagnostics: true,
8880
errorBuilder: (context, state) => ErrorScreen(error: state.error),

lib/routes/routes.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ abstract class Routes {
88
static const String profile = "/profile";
99
static const String search = "/search";
1010
static const String stats = "/stats";
11+
static const String settings = "/settings";
1112
}
1213

1314
enum APP_PAGES {
@@ -20,6 +21,7 @@ enum APP_PAGES {
2021
profile,
2122
search,
2223
stats,
24+
settings,
2325
}
2426

2527
extension AppPageExtension on APP_PAGES {
@@ -43,6 +45,8 @@ extension AppPageExtension on APP_PAGES {
4345
return Routes.search;
4446
case APP_PAGES.stats:
4547
return Routes.stats;
48+
case APP_PAGES.settings:
49+
return Routes.settings;
4650
}
4751
}
4852

lib/screens/home/home_screen.dart

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import 'package:rate_master/screens/home/widgets/recommanded_list.dart';
1010
import 'package:rate_master/shared/constants/constants.dart';
1111
import 'package:rate_master/shared/theme/theme.dart';
1212
import 'package:rate_master/shared/widgets/expanding_bottom_nav.dart';
13-
import 'package:rate_master/shared/widgets/global_app_bar.dart';
1413
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
1514

15+
import 'widgets/home_app_bar.dart';
16+
1617
class HomeScreen extends StatefulWidget {
1718
const HomeScreen({super.key});
1819

@@ -41,11 +42,7 @@ class _HomeScreenState extends State<HomeScreen> {
4142

4243
return Scaffold(
4344
key: _scaffoldKey,
44-
backgroundColor: Colors.white,
45-
appBar: globalAppBar(context, () {
46-
// Manual Pull-to-refresh
47-
itemProvider.fetchItems();
48-
}),
45+
appBar: homeAppBar(context, null),
4946
bottomNavigationBar: ExpandingBottomNav(items: Constants.navItems),
5047
body: SingleChildScrollView(
5148
padding: EdgeInsets.all(16),
@@ -62,14 +59,11 @@ class _HomeScreenState extends State<HomeScreen> {
6259
children: [
6360
TextSpan(
6461
text: "${locale.welcome} ",
65-
style: TextStyle(
66-
fontSize: 16,
67-
),
62+
style: Theme.of(context).textTheme.bodyMedium,
6863
),
6964
TextSpan(
7065
text: "${authProvider.user!.name},",
71-
style: TextStyle(
72-
fontSize: 18,
66+
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
7367
fontWeight: FontWeight.bold,
7468
),
7569
),
@@ -83,7 +77,6 @@ class _HomeScreenState extends State<HomeScreen> {
8377
child: Container(
8478
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 12),
8579
decoration: BoxDecoration(
86-
color: Colors.white,
8780
borderRadius: BorderRadius.circular(30),
8881
border: Border.all(color: AppColors.accent),
8982
),
@@ -100,17 +93,20 @@ class _HomeScreenState extends State<HomeScreen> {
10093
),
10194
),
10295

103-
10496
const SizedBox(height: 16),
97+
10598
/// Recommanded section
10699
// Title
107100
_buildSectionTitle(context, locale.recommandedForYou),
108101
// Content
109102
SizedBox(height: 200, child: buildRecommandedList(context)),
110103
const SizedBox(height: 16),
104+
111105
/// To rate section
112106
// Title
113-
_buildSectionTitle(context, locale.recentlyRated),
107+
_buildSectionTitle(context, locale.recentlyRated,
108+
onViewAllPressed: () =>
109+
context.pushNamed(APP_PAGES.stats.toName)),
114110
// Content
115111
// Par exemple :
116112
SizedBox(
@@ -127,7 +123,7 @@ class _HomeScreenState extends State<HomeScreen> {
127123
Widget _buildSectionTitle(BuildContext context, String title,
128124
{VoidCallback? onViewAllPressed}) {
129125
return Padding(
130-
padding: EdgeInsets.only(left: 5, top: 5, right: 5, bottom: 0),
126+
padding: EdgeInsets.only(left: 5, top: 5, right: 5, bottom: 5),
131127
child: Row(
132128
mainAxisAlignment: MainAxisAlignment.spaceBetween,
133129
children: [
@@ -138,15 +134,26 @@ class _HomeScreenState extends State<HomeScreen> {
138134
fontSize: 18,
139135
fontWeight: FontWeight.bold),
140136
),
141-
TextButton(
142-
onPressed: onViewAllPressed,
143-
child: Row(children: [PhosphorIcon(PhosphorIconsRegular.caretLeft),PhosphorIcon(PhosphorIconsRegular.caretRight)],),
144-
),
137+
onViewAllPressed != null
138+
? TextButton(
139+
onPressed: onViewAllPressed,
140+
child: Row(
141+
children: [
142+
Text(
143+
AppLocalizations.of(context)!.viewAll,
144+
style: TextStyle(color: Colors.blue),
145+
),
146+
PhosphorIcon(
147+
PhosphorIconsRegular.arrowRight,
148+
size: 12,
149+
color: Colors.blue,
150+
)
151+
],
152+
),
153+
)
154+
: const SizedBox.shrink(),
145155
],
146156
),
147157
);
148158
}
149-
150-
151-
152159
}

lib/shared/widgets/global_app_bar.dart renamed to lib/screens/home/widgets/home_app_bar.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,22 @@ import 'package:phosphor_flutter/phosphor_flutter.dart';
44
import 'package:rate_master/routes/routes.dart';
55
import 'package:rate_master/shared/theme/theme.dart';
66

7-
PreferredSizeWidget globalAppBar(
7+
PreferredSizeWidget homeAppBar(
88
BuildContext context, VoidCallback? onRefresh) {
99
return AppBar(
10-
backgroundColor: Colors.white,
11-
elevation: 0,
1210
leading: InkWell(
1311
onTap: () => context.pushNamed(APP_PAGES.profile.toName),
1412
child: Padding(
1513
padding: const EdgeInsets.only(left: 12.0),
1614
child: CircleAvatar(
17-
backgroundColor: Colors.white,
15+
backgroundColor: Colors.white70,
1816
child: Image.asset("assets/images/avatar.png"),
1917
),
2018
),
2119
),
2220
actions: [
23-
IconButton(
21+
// TODO: Add a notification icon
22+
/*IconButton(
2423
style: ButtonStyle(
2524
backgroundColor: WidgetStatePropertyAll(AppColors.accent),
2625
shape: WidgetStatePropertyAll(
@@ -32,7 +31,7 @@ PreferredSizeWidget globalAppBar(
3231
icon: PhosphorIcon(PhosphorIconsRegular.arrowClockwise,
3332
color: Colors.white),
3433
onPressed: onRefresh,
35-
),
34+
),*/
3635
IconButton(
3736
style: ButtonStyle(
3837
backgroundColor: WidgetStatePropertyAll(AppColors.accent),

lib/screens/home/widgets/recently_rated.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ Widget buildRecentlyRated(BuildContext context) {
4040
// Affiche la liste horizontale
4141
return ListView.separated(
4242
shrinkWrap: true,
43-
physics: const NeverScrollableScrollPhysics(),
4443
separatorBuilder: (_, __) => const SizedBox(height: 12),
4544
itemCount: ratingProvider.userReviews
4645
.where((r) => itemProvider.items.any((i) => i.id == r.itemId))

lib/screens/items/dialogs/show_rate_now_sheet.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ Future<bool> showRateNowSheet(BuildContext context, {
2525
shape: const RoundedRectangleBorder(
2626
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
2727
),
28-
backgroundColor: Colors.white,
2928
builder: (ctx) => Padding(
3029
padding: EdgeInsets.only(
3130
bottom: MediaQuery.of(ctx).viewInsets.bottom,

0 commit comments

Comments
 (0)