diff --git a/lib/pages/general_options/general_settings.dart b/lib/pages/general_options/general_settings.dart new file mode 100644 index 0000000..fcf93fa --- /dev/null +++ b/lib/pages/general_options/general_settings.dart @@ -0,0 +1,212 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:intl/intl.dart'; + +import '../../constants/style.dart'; + +class GeneralSettingsPage extends ConsumerStatefulWidget { + const GeneralSettingsPage({super.key}); + + @override + ConsumerState createState() => + _GeneralSettingsPageState(); +} + +class _GeneralSettingsPageState extends ConsumerState { + //default values + bool darkMode = false; + String selectedCurrency = "EUR"; + dynamic selectedLanguage = "🇬🇧"; + + List> languages = [ + ["🇬🇧", "English"], + ["🇮🇹", "Italiano"], + ["🇫🇷", "Français"], + ["🇩🇪", "Deutsch"] + ]; + + List> currencies = [ + ["£", "British Pound"], + ["€", "Euro"], + ["\$", "US Dollar"], + ["CHF", "Swiss Franc"], + ["¥", "Yuan"], + ]; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: Theme.of(context).colorScheme.background, + elevation: 0, + centerTitle: true, + leading: IconButton( + icon: const Icon( + Icons.arrow_back_ios_new, + color: Color(0XFF7DA1C4), + ), + onPressed: () { + Navigator.pop(context); + // Return to previous page + }, + ), + title: Text( + 'General Settings', + style: Theme.of(context) + .textTheme + .headlineLarge! + .copyWith(color: Theme.of(context).colorScheme.primary), + ), + ), + body: SingleChildScrollView( + padding: const EdgeInsets.only(left: 20, right: 20, top: 25), + physics: const BouncingScrollPhysics(), + child: Column( + children: [ + Row( + children: [ + Text("Appearance", + style: Theme.of(context).textTheme.titleLarge!.copyWith( + color: Theme.of(context).colorScheme.primary)), + const Spacer(), + CircleAvatar( + radius: 30.0, + backgroundColor: blue5, + child: IconButton( + color: blue5, + onPressed: () { + setState(() { + darkMode = !darkMode; + }); + }, + icon: Icon( + darkMode ? Icons.dark_mode : Icons.light_mode, + size: 25.0, + color: Theme.of(context).colorScheme.background, + ), + )), + ], + ), + const SizedBox(height: 20), + Row( + children: [ + Text("Currency", + style: Theme.of(context).textTheme.titleLarge!.copyWith( + color: Theme.of(context).colorScheme.primary)), + const Spacer(), + GestureDetector( + onTap: () { + sellectCurrency(); + }, + child: CircleAvatar( + radius: 30.0, + backgroundColor: blue5, + child: Center( + child: Text( + NumberFormat().simpleCurrencySymbol(selectedCurrency), + style: const TextStyle(color: white, fontSize: 25), + )))), + ], + ), + const SizedBox(height: 20), + /* + Row( + children: [ + Text("Language", + style: Theme.of(context).textTheme.titleLarge!.copyWith( + color: Theme.of(context).colorScheme.primary)), + const Spacer(), + GestureDetector( + onTap: () { + selectLanguage(); + }, + child: CircleAvatar( + radius: 30.0, + backgroundColor: blue5, + child: Center(child: Text(selectedLanguage, style: const TextStyle(fontSize: 30))), + )), + ], + ),*/ + ], + ), + ), + ); + } + + selectLanguage() { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text('Select a language', + style: Theme.of(context) + .textTheme + .titleLarge! + .copyWith(color: Theme.of(context).colorScheme.primary)), + content: SizedBox( + height: 220, + width: 220, + child: ListView.builder( + itemCount: languages.length, + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemBuilder: (BuildContext context, int index) { + return GestureDetector( + onTap: () { + setState(() { + selectedLanguage = languages.elementAt(index)[0]; + }); + Navigator.pop(context); + }, + child: ListTile( + leading: Text(languages.elementAt(index)[0], + style: const TextStyle(fontSize: 30)), + title: Text( + languages.elementAt(index)[1], + textAlign: TextAlign.center, + ), + )); + }), + ))); + } + + sellectCurrency() { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text('Select a currency', + style: Theme.of(context) + .textTheme + .titleLarge! + .copyWith(color: Theme.of(context).colorScheme.primary)), + content: SizedBox( + height: 220, + width: 220, + child: ListView.builder( + itemCount: currencies.length, + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemBuilder: (BuildContext context, int index) { + return GestureDetector( + onTap: () { + setState(() { + selectedCurrency = currencies.elementAt(index)[0]; + }); + Navigator.pop(context); + }, + child: ListTile( + leading: CircleAvatar( + radius: 22, + backgroundColor: blue5, + child: Text(currencies.elementAt(index)[0], + style: const TextStyle( + color: Colors.white, fontSize: 20)), + ), + title: Text( + currencies.elementAt(index)[1], + textAlign: TextAlign.center, + ), + )); + }), + ))); + } +} diff --git a/lib/pages/settings_page.dart b/lib/pages/settings_page.dart index 5bb72e0..7328ca3 100644 --- a/lib/pages/settings_page.dart +++ b/lib/pages/settings_page.dart @@ -20,6 +20,12 @@ class SettingsPage extends ConsumerStatefulWidget { } var settingsOptions = const [ + [ + Icons.settings, + "General Settings", + "Edit general settings", + "/general-settings", + ], [ Icons.account_balance_wallet, "Accounts", diff --git a/lib/routes.dart b/lib/routes.dart index 49414f2..bf1c16c 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'pages/categories/category_list.dart'; +import 'pages/general_options/general_settings.dart'; import 'pages/more_info_page/collaborators_page.dart'; import 'pages/more_info_page/more_info.dart'; import 'pages/more_info_page/privacy_policy.dart'; @@ -53,6 +54,8 @@ Route makeRoute(RouteSettings settings) { return _materialPageRoute(settings.name, const StatsPage()); case '/settings': return _noTransitionPageRoute(settings.name, const SettingsPage()); + case '/general-settings': + return _noTransitionPageRoute(settings.name, const GeneralSettingsPage()); default: throw 'Route is not defined'; }