Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start implementation of general settings #115

Merged
merged 6 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
212 changes: 212 additions & 0 deletions lib/pages/general_options/general_settings.dart
Original file line number Diff line number Diff line change
@@ -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<GeneralSettingsPage> createState() =>
_GeneralSettingsPageState();
}

class _GeneralSettingsPageState extends ConsumerState<GeneralSettingsPage> {
//default values
bool darkMode = false;
String selectedCurrency = "EUR";
dynamic selectedLanguage = "🇬🇧";

List<List<dynamic>> languages = [
["🇬🇧", "English"],
["🇮🇹", "Italiano"],
["🇫🇷", "Français"],
["🇩🇪", "Deutsch"]
];

List<List<String>> 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,
),
));
}),
)));
}
}
6 changes: 6 additions & 0 deletions lib/pages/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions lib/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -53,6 +54,8 @@ Route<dynamic> 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';
}
Expand Down
Loading