Skip to content

Commit

Permalink
feat(front/mobile): apply theme on Services page
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomi-Tom authored and RezaRahemtola committed Nov 3, 2023
1 parent 152aecf commit 7eb2d5c
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 124 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:area_mobile/colors.dart';
import 'package:area_mobile/components/editor/steps/action/select_action_event.dart';
import 'package:area_mobile/components/editor/steps/action/select_action_service.dart';
import 'package:area_mobile/components/editor/steps/select_area_params.dart';
Expand Down
9 changes: 6 additions & 3 deletions frontend/mobile/lib/components/services/service_card.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:area_mobile/colors.dart';
import 'package:area_mobile/types/services.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
Expand All @@ -15,16 +14,20 @@ class ServiceCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Card(
color: Theme.of(context).colorScheme.primary,
elevation: 8,
child: ListTile(
selected: selected,
selectedTileColor: secondaryColor,
selectedTileColor: Theme.of(context).colorScheme.secondary,
leading: SvgPicture.network(
service.imageUrl,
width: 32,
height: 32,
),
title: Text(service.id),
title: Text(service.id,
style: TextStyle(
color: Theme.of(context).colorScheme.onPrimary,
)),
onTap: onTap,
),
);
Expand Down
3 changes: 1 addition & 2 deletions frontend/mobile/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ ThemeData _buildDarkTheme() {
final ThemeData base = ThemeData.dark();
return base.copyWith(
colorScheme: base.colorScheme.copyWith(
primary: const Color(
0xFF516079), // Personnalisez les couleurs selon vos besoins
primary: const Color(0xFF516079),
secondary: const Color(0xFFF1895C),
onPrimary: const Color(0xFFC5C6C6),
onSecondary: const Color(0xFF2E3244)),
Expand Down
14 changes: 7 additions & 7 deletions frontend/mobile/lib/pages/landing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class _LandingPageState extends State<LandingPage> {
bool isLoggedIn = false;
int _selectedIndex = 2;
int libraryKey = 0;
String language = "en";
String locale = "en";
String theme = "light";

@override
Expand All @@ -33,14 +33,14 @@ class _LandingPageState extends State<LandingPage> {
}

void _checkSettings() async {
final storageLanguage = await storage.getLocale();
final storageLocale = await storage.getLocale();
final storageTheme = await storage.getTheme();

if (storageLanguage == null) {
storage.setLocale(language);
if (storageLocale == null) {
storage.setLocale(locale);
} else {
setState(() {
language = storageLanguage;
locale = storageLocale;
});
}

Expand All @@ -59,7 +59,7 @@ class _LandingPageState extends State<LandingPage> {
storage.setTheme(newTheme);

setState(() {
language = newLocale;
locale = newLocale;
theme = newTheme;
});
widget.updateTheme(newTheme);
Expand Down Expand Up @@ -89,7 +89,7 @@ class _LandingPageState extends State<LandingPage> {
Widget build(BuildContext context) {
return Localizations.override(
context: context,
locale: Locale(language),
locale: Locale(locale),
child: Builder(
builder: (context) {
if (!isLoggedIn) {
Expand Down
7 changes: 5 additions & 2 deletions frontend/mobile/lib/pages/services.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ class Services extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.primary,
title: Text(AppLocalizations.of(context)!.servicesTitle),
automaticallyImplyLeading: false),
body: Container(
constraints: const BoxConstraints(maxWidth: 450, maxHeight: 800),
color: const Color(0xFFC5C6C6),
color: Theme.of(context).colorScheme.onSecondary,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: FutureBuilder<ServiceReturn<List<Service>>>(
Expand Down Expand Up @@ -94,7 +95,9 @@ class _ServiceDetailsState extends State<ServiceDetails> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.service.id), automaticallyImplyLeading: false),
backgroundColor: Theme.of(context).colorScheme.primary,
title: Text(widget.service.id),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: SingleChildScrollView(
Expand Down
221 changes: 113 additions & 108 deletions frontend/mobile/lib/pages/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,120 +32,125 @@ class _UserHero extends State<User> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.primary,
actions: [
IconButton(
onPressed: () {
widget.onDisconnect();
},
icon: const Icon(Icons.logout),
),
],
title: Text(AppLocalizations.of(context)!.userTitle),
automaticallyImplyLeading: false),
body: Container(
color: Theme.of(context).colorScheme.onSecondary,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: FutureBuilder<ServiceReturn<UserMe>>(
future: future,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const CircularProgressIndicator();
} else {
final UserMe? user = snapshot.data?.data;
if (user != null) {
newLocale = user.settings.language;
newTheme = user.settings.theme;
newEmail = user.email;
}

if (user == null) {
return Column(
children: [
ElevatedButton(
onPressed: () {
widget.onDisconnect();
},
child: Text(AppLocalizations.of(context)!.logout),
),
],
);
}
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.primary,
actions: [
IconButton(
onPressed: () {
widget.onDisconnect();
},
icon: const Icon(Icons.logout),
),
],
title: Text(AppLocalizations.of(context)!.userTitle),
automaticallyImplyLeading: false),
body: Container(
color: Theme.of(context).colorScheme.onSecondary,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: FutureBuilder<ServiceReturn<UserMe>>(
future: future,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const CircularProgressIndicator();
} else {
final UserMe? user = snapshot.data?.data;
if (user != null) {
newLocale = user.settings.language;
newTheme = user.settings.theme;
newEmail = user.email;
}

return Column(
children: [
const UserTile(),
Form(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
TextFormField(
decoration: InputDecoration(
labelText: AppLocalizations.of(context)!.email),
initialValue: user.email,
onChanged: ((value) => newEmail = value),
),
const SizedBox(height: 16.0),
DropdownButtonFormField(
value: newLocale,
items: <InterfaceLanguage>[
InterfaceLanguage(id: "en", text: "🇺🇸 English"),
InterfaceLanguage(id: "fr", text: "🇫🇷 Francais"),
InterfaceLanguage(id: "is", text: "🇮🇸 Íslenskur"),
].map((InterfaceLanguage locale) {
return DropdownMenuItem<String>(
value: locale.id,
child: Text(locale.text),
);
}).toList(),
onChanged: (value) {
if (value == null) return;
newLocale = value;
},
decoration: InputDecoration(
labelText:
AppLocalizations.of(context)!.language),
),
DropdownButtonFormField(
value: newTheme,
items: [
'auto',
'dark',
'light',
].map((String theme) {
return DropdownMenuItem<String>(
value: theme,
child: Text(theme),
);
}).toList(),
onChanged: (value) {
if (value == null) return;
newTheme = value;
},
decoration: InputDecoration(
labelText: AppLocalizations.of(context)!.theme),
),
const SizedBox(height: 16.0),
if (user == null) {
return Column(
children: [
ElevatedButton(
onPressed: () {
widget.updateSettings(newLocale, newTheme);
services.user
.updateProfile(newEmail, newLocale, newTheme);
widget.onDisconnect();
},
child: Text(AppLocalizations.of(context)!.save),
child: Text(AppLocalizations.of(context)!.logout),
),
],
),
)
],
);
}
},
),
),
);
);
}

return Column(
children: [
const UserTile(),
Form(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
TextFormField(
decoration: InputDecoration(
labelText:
AppLocalizations.of(context)!.email),
initialValue: user.email,
onChanged: ((value) => newEmail = value),
),
const SizedBox(height: 16.0),
DropdownButtonFormField(
value: newLocale,
items: <InterfaceLanguage>[
InterfaceLanguage(
id: "en", text: "🇺🇸 English"),
InterfaceLanguage(
id: "fr", text: "🇫🇷 Francais"),
InterfaceLanguage(
id: "is", text: "🇮🇸 Íslenskur"),
].map((InterfaceLanguage locale) {
return DropdownMenuItem<String>(
value: locale.id,
child: Text(locale.text),
);
}).toList(),
onChanged: (value) {
if (value == null) return;
newLocale = value;
},
decoration: InputDecoration(
labelText:
AppLocalizations.of(context)!.language),
),
DropdownButtonFormField(
value: newTheme,
items: [
'auto',
'dark',
'light',
].map((String theme) {
return DropdownMenuItem<String>(
value: theme,
child: Text(theme),
);
}).toList(),
onChanged: (value) {
if (value == null) return;
newTheme = value;
},
decoration: InputDecoration(
labelText:
AppLocalizations.of(context)!.theme),
),
const SizedBox(height: 16.0),
ElevatedButton(
onPressed: () {
widget.updateSettings(newLocale, newTheme);
services.user.updateProfile(
newEmail, newLocale, newTheme);
},
child: Text(AppLocalizations.of(context)!.save),
),
],
),
)
],
);
}
},
),
),
));
}
}

Expand Down
1 change: 0 additions & 1 deletion frontend/mobile/lib/storage/index.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:flutter/material.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';

class Storage {
Expand Down

0 comments on commit 7eb2d5c

Please sign in to comment.