Skip to content

Commit

Permalink
Merge branch 'main' into dev-test
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaantonelli authored Dec 18, 2023
2 parents 44d85b2 + d2a2ace commit 1cc0a2a
Show file tree
Hide file tree
Showing 7 changed files with 319 additions and 86 deletions.
167 changes: 167 additions & 0 deletions lib/pages/notifications/notifications_settings.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../../../constants/functions.dart';
import '../../constants/style.dart';
import '../../providers/settings_provider.dart';

class NotificationsSettings extends ConsumerStatefulWidget {
const NotificationsSettings({Key? key}) : super(key: key);

@override
ConsumerState<NotificationsSettings> createState() => _NotificationsSettingsState();
}

class _NotificationsSettingsState extends ConsumerState<NotificationsSettings> with Functions {

@override
Widget build(BuildContext context) {
// Is used to init the state of the switches
ref.read(settingsProvider);
return Scaffold(
backgroundColor: Theme.of(context).colorScheme.background,
appBar: AppBar(
leading: IconButton(
icon: Icon(
Icons.arrow_back_ios_new,
color: Theme.of(context).colorScheme.secondary,
),
onPressed: () => Navigator.pop(context),
),
),
body: SingleChildScrollView(
physics: const BouncingScrollPhysics(),
child: Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(vertical: 24.0, horizontal: 16.0),
child: Row(
children: [
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Theme.of(context).colorScheme.primary,
),
padding: const EdgeInsets.all(8.0),
child: Icon(
Icons.notifications_active,
size: 24.0,
color: Theme.of(context).colorScheme.background,
),
),
const SizedBox(width: 12.0),
Text(
"Notifications",
style: Theme.of(context)
.textTheme
.headlineLarge!
.copyWith(color: Theme.of(context).colorScheme.primary),
),
],
),
),
Container(
width: double.infinity,
margin: const EdgeInsets.symmetric(horizontal: 16),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(4),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text(
"Add transactions reminder",
style: Theme.of(context).textTheme.bodyMedium,
),
),
CupertinoSwitch(
value: ref.watch(transactionReminderSwitchProvider),
onChanged: (value) {
ref.read(transactionReminderSwitchProvider.notifier).state = value;
ref.read(settingsProvider.notifier).updateNotifications();
},
),
],
),
),
Container(
alignment: Alignment.centerLeft,
padding: const EdgeInsets.only(left: 28, top: 24, bottom: 8),
child: Text(
"RECURRING TRANSACTIONS",
style: Theme.of(context).textTheme.labelLarge!.copyWith(color: grey1),
),
),
Container(
width: double.infinity,
margin: const EdgeInsets.symmetric(horizontal: 16),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(4),
),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text(
"Recurring transaction added",
style: Theme.of(context).textTheme.bodyMedium,
),
),
CupertinoSwitch(
value: ref.watch(transactionRecAddedSwitchProvider),
onChanged: (value) {
ref.read(transactionRecAddedSwitchProvider.notifier).state = value;
ref.read(settingsProvider.notifier).updateNotifications();
},
),
],
),
const SizedBox(height: 12),
Divider(
height: 1,
color: Theme.of(context).colorScheme.primary.withOpacity(0.4),
),
const SizedBox(height: 12),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text(
"Recurring transaction reminder",
style: Theme.of(context).textTheme.bodyMedium,
),
),
CupertinoSwitch(
value: ref.watch(transactionRecReminderSwitchProvider),
onChanged: (value) {
ref.read(transactionRecReminderSwitchProvider.notifier).state = value;
ref.read(settingsProvider.notifier).updateNotifications();
},
),
],
),
],
),
),
Container(
alignment: Alignment.centerLeft,
padding: const EdgeInsets.only(left: 28, top: 6),
child: Text(
"Remind me before a recurring transaction is added",
style: Theme.of(context).textTheme.labelMedium!.copyWith(color: grey1),
),
),
],
),
),
);
}
}
182 changes: 101 additions & 81 deletions lib/pages/settings_page.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Settings page.

// ignore_for_file: unused_result

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../custom_widgets/default_container.dart';
Expand Down Expand Up @@ -54,7 +56,7 @@ var settingsOptions = const [
Icons.notifications_active,
"Notifications",
"Manage your notifications settings",
null,
"/notifications-settings",
],
[
Icons.info,
Expand All @@ -68,34 +70,49 @@ class _SettingsPageState extends ConsumerState<SettingsPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Theme.of(context).colorScheme.background,
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.background,
elevation: 0,
centerTitle: true,
leading: IconButton(
icon: const Icon(
icon: Icon(
Icons.arrow_back_ios_new,
color: Color(0XFF7DA1C4),
color: Theme.of(context).colorScheme.secondary,
),
onPressed: () {
Navigator.pop(context);
// Return to previous page
},
),
title: Text(
'Settings',
style: Theme.of(context)
.textTheme
.headlineLarge!
.copyWith(color: Theme.of(context).colorScheme.primary),
),
),
body: SingleChildScrollView(
physics: const BouncingScrollPhysics(),
child: Column(
children: [
const Padding(
padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 16.0),
Padding(
padding: const EdgeInsets.symmetric(vertical: 24.0, horizontal: 16.0),
child: Row(
children: [
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Theme.of(context).colorScheme.primary,
),
padding: const EdgeInsets.all(5.0),
child: Icon(
Icons.settings,
size: 28.0,
color: Theme.of(context).colorScheme.background,
),
),
const SizedBox(width: 12.0),
Text(
"Settings",
style: Theme.of(context)
.textTheme
.headlineLarge!
.copyWith(color: Theme.of(context).colorScheme.primary),
),
],
),
),
ListView.separated(
itemCount: settingsOptions.length,
Expand Down Expand Up @@ -125,27 +142,29 @@ class _SettingsPageState extends ConsumerState<SettingsPage> {
),
),
const SizedBox(width: 12.0),
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
setting[1].toString(),
style: Theme.of(context)
.textTheme
.titleLarge!
.copyWith(color: Theme.of(context).colorScheme.primary),
textAlign: TextAlign.left,
),
Text(
setting[2].toString(),
style: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(color: Theme.of(context).colorScheme.primary),
textAlign: TextAlign.left,
),
],
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
setting[1].toString(),
style: Theme.of(context)
.textTheme
.titleLarge!
.copyWith(color: Theme.of(context).colorScheme.primary),
),
Text(
setting[2].toString(),
style: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(color: Theme.of(context).colorScheme.primary),
overflow: TextOverflow.ellipsis,
maxLines: 2,
),
],
),
),
],
),
Expand All @@ -156,52 +175,53 @@ class _SettingsPageState extends ConsumerState<SettingsPage> {
),
),
bottomSheet: Container(
color: Colors.deepOrangeAccent,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
const Text(
'[DEV ONLY]\nDANGEROUS\nZONE',
style: TextStyle(
fontSize: 11,
color: Colors.yellowAccent,
shadows: <Shadow>[
Shadow(
offset: Offset(1.0, 1.0),
blurRadius: 3.0,
color: Color.fromARGB(255, 0, 0, 0),
),
],
),
textAlign: TextAlign.center,
),
ElevatedButton(
child: const Text('CLEAR DB'),
onPressed: () async {
await SossoldiDatabase.instance.clearDatabase().then((v) {
ref.refresh(accountsProvider);
ref.refresh(categoriesProvider);
ref.refresh(transactionsProvider);
ref.refresh(budgetsProvider);
showSuccessDialog(context, "DB Cleared");
});
},
),
ElevatedButton(
child: const Text('CLEAR AND FILL DEMO DATA'),
onPressed: () async {
await SossoldiDatabase.instance.clearDatabase();
await SossoldiDatabase.instance.fillDemoData().then((value) {
ref.refresh(accountsProvider);
ref.refresh(categoriesProvider);
ref.refresh(transactionsProvider);
ref.refresh(budgetsProvider);
showSuccessDialog(context, "DB Cleared, and DEMO data added");
});
},
color: Colors.deepOrangeAccent,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
const Text(
'[DEV ONLY]\nDANGEROUS\nZONE',
style: TextStyle(
fontSize: 11,
color: Colors.yellowAccent,
shadows: <Shadow>[
Shadow(
offset: Offset(1.0, 1.0),
blurRadius: 3.0,
color: Color.fromARGB(255, 0, 0, 0),
),
],
),
],
)),
textAlign: TextAlign.center,
),
ElevatedButton(
child: const Text('CLEAR DB'),
onPressed: () async {
await SossoldiDatabase.instance.clearDatabase().then((v) {
ref.refresh(accountsProvider);
ref.refresh(categoriesProvider);
ref.refresh(transactionsProvider);
ref.refresh(budgetsProvider);
showSuccessDialog(context, "DB Cleared");
});
},
),
ElevatedButton(
child: const Text('CLEAR AND FILL DEMO DATA'),
onPressed: () async {
await SossoldiDatabase.instance.clearDatabase();
await SossoldiDatabase.instance.fillDemoData().then((value) {
ref.refresh(accountsProvider);
ref.refresh(categoriesProvider);
ref.refresh(transactionsProvider);
ref.refresh(budgetsProvider);
showSuccessDialog(context, "DB Cleared, and DEMO data added");
});
},
),
],
),
),
);
}
}
Loading

0 comments on commit 1cc0a2a

Please sign in to comment.