mirror of
https://github.com/Myzel394/quid_faciam_hodie.git
synced 2025-06-19 15:45:26 +02:00
added settings page
This commit is contained in:
parent
99f64b85e6
commit
72c3e356ae
@ -2,6 +2,7 @@
|
|||||||
"appTitleQuestion": "Quid faciam hodie?",
|
"appTitleQuestion": "Quid faciam hodie?",
|
||||||
|
|
||||||
"generalError": "There was an error",
|
"generalError": "There was an error",
|
||||||
|
"generalCancelButtonLabel": "Cancel",
|
||||||
|
|
||||||
"welcomeScreenDescription": "Find out what you did all the days and unlock moments you completely forgot!",
|
"welcomeScreenDescription": "Find out what you did all the days and unlock moments you completely forgot!",
|
||||||
"welcomeScreenSubtitle": "What did I do today?",
|
"welcomeScreenSubtitle": "What did I do today?",
|
||||||
@ -68,5 +69,17 @@
|
|||||||
"emptyScreenTitle": "Houston, we have a problem",
|
"emptyScreenTitle": "Houston, we have a problem",
|
||||||
"emptyScreenSubtitle": "The user hasn't created any memories yet!",
|
"emptyScreenSubtitle": "The user hasn't created any memories yet!",
|
||||||
"emptyScreenDescription": "To view your timeline you need to create some memories first! :)",
|
"emptyScreenDescription": "To view your timeline you need to create some memories first! :)",
|
||||||
"emptyScreenCreateMemory": "Create a Memory"
|
"emptyScreenCreateMemory": "Create a Memory",
|
||||||
|
|
||||||
|
|
||||||
|
"settingsScreenLoading": "Loading Settings...",
|
||||||
|
"settingsScreenTitle": "Settings",
|
||||||
|
"settingsScreenAccountSectionTitle": "Your Account",
|
||||||
|
"settingsScreenAccountSectionCreationDateLabel": "Created at",
|
||||||
|
"settingsScreenAccountSectionLogoutLabel": "Log out",
|
||||||
|
"settingsScreenDangerSectionTitle": "Danger Zone",
|
||||||
|
"settingsScreenDangerSectionDeleteAccountLabel": "Delete Account",
|
||||||
|
"settingsScreenDeleteAccountTitle": "Delete Account",
|
||||||
|
"settingsScreenDeleteAccountDescription": "Are you sure you want to delete your account? This action cannot be undone! All your memories will be deleted as well.",
|
||||||
|
"settingsScreenDeleteAccountConfirmLabel": "Delete Account now"
|
||||||
}
|
}
|
@ -10,6 +10,7 @@ import 'package:quid_faciam_hodie/screens/grant_permission_screen.dart';
|
|||||||
import 'package:quid_faciam_hodie/screens/login_screen.dart';
|
import 'package:quid_faciam_hodie/screens/login_screen.dart';
|
||||||
import 'package:quid_faciam_hodie/screens/main_screen.dart';
|
import 'package:quid_faciam_hodie/screens/main_screen.dart';
|
||||||
import 'package:quid_faciam_hodie/screens/server_loading_screen.dart';
|
import 'package:quid_faciam_hodie/screens/server_loading_screen.dart';
|
||||||
|
import 'package:quid_faciam_hodie/screens/settings_screen.dart';
|
||||||
import 'package:quid_faciam_hodie/screens/timeline_screen.dart';
|
import 'package:quid_faciam_hodie/screens/timeline_screen.dart';
|
||||||
import 'package:quid_faciam_hodie/screens/welcome_screen.dart';
|
import 'package:quid_faciam_hodie/screens/welcome_screen.dart';
|
||||||
|
|
||||||
@ -64,6 +65,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
CalendarScreen.ID: (context) => const CalendarScreen(),
|
CalendarScreen.ID: (context) => const CalendarScreen(),
|
||||||
ServerLoadingScreen.ID: (context) => const ServerLoadingScreen(),
|
ServerLoadingScreen.ID: (context) => const ServerLoadingScreen(),
|
||||||
EmptyScreen.ID: (context) => const EmptyScreen(),
|
EmptyScreen.ID: (context) => const EmptyScreen(),
|
||||||
|
SettingsScreen.ID: (context) => const SettingsScreen(),
|
||||||
},
|
},
|
||||||
initialRoute: ServerLoadingScreen.ID,
|
initialRoute: ServerLoadingScreen.ID,
|
||||||
),
|
),
|
||||||
|
@ -12,6 +12,7 @@ import 'package:quid_faciam_hodie/constants/values.dart';
|
|||||||
import 'package:quid_faciam_hodie/extensions/snackbar.dart';
|
import 'package:quid_faciam_hodie/extensions/snackbar.dart';
|
||||||
import 'package:quid_faciam_hodie/managers/file_manager.dart';
|
import 'package:quid_faciam_hodie/managers/file_manager.dart';
|
||||||
import 'package:quid_faciam_hodie/managers/global_values_manager.dart';
|
import 'package:quid_faciam_hodie/managers/global_values_manager.dart';
|
||||||
|
import 'package:quid_faciam_hodie/screens/main_screen/settings_button_overlay.dart';
|
||||||
import 'package:quid_faciam_hodie/utils/auth_required.dart';
|
import 'package:quid_faciam_hodie/utils/auth_required.dart';
|
||||||
import 'package:quid_faciam_hodie/utils/loadable.dart';
|
import 'package:quid_faciam_hodie/utils/loadable.dart';
|
||||||
import 'package:quid_faciam_hodie/widgets/animate_in_builder.dart';
|
import 'package:quid_faciam_hodie/widgets/animate_in_builder.dart';
|
||||||
@ -317,11 +318,13 @@ class _MainScreenState extends AuthRequiredState<MainScreen> with Loadable {
|
|||||||
child: AspectRatio(
|
child: AspectRatio(
|
||||||
aspectRatio: 1 / controller!.value.aspectRatio,
|
aspectRatio: 1 / controller!.value.aspectRatio,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
|
alignment: Alignment.center,
|
||||||
fit: StackFit.expand,
|
fit: StackFit.expand,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
controller!.buildPreview(),
|
controller!.buildPreview(),
|
||||||
if (isRecording)
|
if (isRecording)
|
||||||
RecordingOverlay(controller: controller!),
|
RecordingOverlay(controller: controller!),
|
||||||
|
if (!isRecording) SettingsButtonOverlay(),
|
||||||
if (uploadingPhotoAnimation != null)
|
if (uploadingPhotoAnimation != null)
|
||||||
UploadingPhoto(
|
UploadingPhoto(
|
||||||
data: uploadingPhotoAnimation!,
|
data: uploadingPhotoAnimation!,
|
||||||
|
22
lib/screens/main_screen/settings_button_overlay.dart
Normal file
22
lib/screens/main_screen/settings_button_overlay.dart
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
|
||||||
|
import 'package:quid_faciam_hodie/constants/spacing.dart';
|
||||||
|
import 'package:quid_faciam_hodie/screens/settings_screen.dart';
|
||||||
|
|
||||||
|
class SettingsButtonOverlay extends StatelessWidget {
|
||||||
|
const SettingsButtonOverlay({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Positioned(
|
||||||
|
left: SMALL_SPACE,
|
||||||
|
top: SMALL_SPACE,
|
||||||
|
child: IconButton(
|
||||||
|
icon: Icon(context.platformIcons.settings),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pushNamed(context, SettingsScreen.ID);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
164
lib/screens/settings_screen.dart
Normal file
164
lib/screens/settings_screen.dart
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
|
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:quid_faciam_hodie/constants/spacing.dart';
|
||||||
|
import 'package:quid_faciam_hodie/extensions/snackbar.dart';
|
||||||
|
import 'package:quid_faciam_hodie/screens/welcome_screen.dart';
|
||||||
|
import 'package:quid_faciam_hodie/utils/auth_required.dart';
|
||||||
|
import 'package:quid_faciam_hodie/utils/loadable.dart';
|
||||||
|
import 'package:quid_faciam_hodie/utils/theme.dart';
|
||||||
|
import 'package:settings_ui/settings_ui.dart';
|
||||||
|
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||||
|
|
||||||
|
final supabase = Supabase.instance.client;
|
||||||
|
|
||||||
|
class SettingsScreen extends StatefulWidget {
|
||||||
|
static const ID = '/settings';
|
||||||
|
|
||||||
|
const SettingsScreen({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SettingsScreen> createState() => _SettingsScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SettingsScreenState extends AuthRequiredState<SettingsScreen>
|
||||||
|
with Loadable {
|
||||||
|
User? user;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onAuthenticated(Session session) {
|
||||||
|
if (session.user != null) {
|
||||||
|
setState(() {
|
||||||
|
user = session.user;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteUser() async {
|
||||||
|
return;
|
||||||
|
|
||||||
|
final localizations = AppLocalizations.of(context)!;
|
||||||
|
|
||||||
|
final response = await supabase
|
||||||
|
.from('auth.users')
|
||||||
|
.delete()
|
||||||
|
.match({'id': user!.id}).execute();
|
||||||
|
|
||||||
|
if (response.error != null) {
|
||||||
|
context.showLongErrorSnackBar(message: localizations.generalError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mounted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Navigator.pop(context);
|
||||||
|
Navigator.pushNamedAndRemoveUntil(
|
||||||
|
context,
|
||||||
|
WelcomeScreen.ID,
|
||||||
|
(route) => false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final localizations = AppLocalizations.of(context)!;
|
||||||
|
|
||||||
|
return PlatformScaffold(
|
||||||
|
appBar: PlatformAppBar(
|
||||||
|
title: Text(localizations.settingsScreenTitle),
|
||||||
|
),
|
||||||
|
body: (user == null || isLoading)
|
||||||
|
? Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
PlatformCircularProgressIndicator(),
|
||||||
|
const SizedBox(height: MEDIUM_SPACE),
|
||||||
|
Text(localizations.settingsScreenLoading),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: SettingsList(
|
||||||
|
sections: [
|
||||||
|
SettingsSection(
|
||||||
|
title: Text(localizations.settingsScreenAccountSectionTitle),
|
||||||
|
tiles: <SettingsTile>[
|
||||||
|
SettingsTile(
|
||||||
|
leading: Icon(context.platformIcons.mail),
|
||||||
|
title: Text(user!.email!),
|
||||||
|
),
|
||||||
|
SettingsTile(
|
||||||
|
leading: Text(localizations
|
||||||
|
.settingsScreenAccountSectionCreationDateLabel),
|
||||||
|
title: Text(
|
||||||
|
DateFormat('d. MMMM y, HH:mm:ss')
|
||||||
|
.format(DateTime.parse(user!.createdAt)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SettingsTile(
|
||||||
|
leading: const Icon(Icons.logout_rounded),
|
||||||
|
title: Text(localizations
|
||||||
|
.settingsScreenAccountSectionLogoutLabel),
|
||||||
|
onPressed: (_) async {
|
||||||
|
await callWithLoading(supabase.auth.signOut);
|
||||||
|
|
||||||
|
if (!mounted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Navigator.pushNamedAndRemoveUntil(
|
||||||
|
context,
|
||||||
|
WelcomeScreen.ID,
|
||||||
|
(route) => false,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SettingsSection(
|
||||||
|
title: Text(localizations.settingsScreenDangerSectionTitle),
|
||||||
|
tiles: <SettingsTile>[
|
||||||
|
SettingsTile(
|
||||||
|
leading: Icon(context.platformIcons.delete),
|
||||||
|
title: Text(localizations
|
||||||
|
.settingsScreenDangerSectionDeleteAccountLabel),
|
||||||
|
onPressed: (_) => showPlatformDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (platformContext) => PlatformAlertDialog(
|
||||||
|
title: Text(
|
||||||
|
localizations.settingsScreenDeleteAccountTitle,
|
||||||
|
),
|
||||||
|
content: Text(
|
||||||
|
localizations
|
||||||
|
.settingsScreenDeleteAccountDescription,
|
||||||
|
style: getBodyTextTextStyle(platformContext),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
PlatformDialogAction(
|
||||||
|
child: Text(
|
||||||
|
localizations.generalCancelButtonLabel,
|
||||||
|
),
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
),
|
||||||
|
PlatformDialogAction(
|
||||||
|
child: Text(
|
||||||
|
localizations
|
||||||
|
.settingsScreenDeleteAccountConfirmLabel,
|
||||||
|
),
|
||||||
|
onPressed: () => callWithLoading(deleteUser),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:quid_faciam_hodie/foreign_types/memory.dart';
|
import 'package:quid_faciam_hodie/foreign_types/memory.dart';
|
||||||
import 'package:quid_faciam_hodie/models/timeline.dart';
|
import 'package:quid_faciam_hodie/models/timeline.dart';
|
||||||
@ -67,10 +68,12 @@ class _TimelinePageState extends State<TimelinePage> {
|
|||||||
onDoubleTap: () async {
|
onDoubleTap: () async {
|
||||||
timeline.pause();
|
timeline.pause();
|
||||||
|
|
||||||
await showModalBottomSheet(
|
await showPlatformModalSheet(
|
||||||
context: context,
|
context: context,
|
||||||
backgroundColor: Colors.transparent,
|
material: MaterialModalSheetData(
|
||||||
isScrollControlled: true,
|
backgroundColor: Colors.transparent,
|
||||||
|
isScrollControlled: true,
|
||||||
|
),
|
||||||
builder: (sheetContext) => MemorySheet(
|
builder: (sheetContext) => MemorySheet(
|
||||||
memory: timeline.currentMemory,
|
memory: timeline.currentMemory,
|
||||||
sheetContext: sheetContext,
|
sheetContext: sheetContext,
|
||||||
|
@ -546,6 +546,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.1.15"
|
version: "0.1.15"
|
||||||
|
settings_ui:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: settings_ui
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.2"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
|
@ -55,6 +55,7 @@ dependencies:
|
|||||||
flutter_calendar_widget: ^0.0.2
|
flutter_calendar_widget: ^0.0.2
|
||||||
flutter_platform_widgets: ^2.0.0
|
flutter_platform_widgets: ^2.0.0
|
||||||
lottie: ^1.4.1
|
lottie: ^1.4.1
|
||||||
|
settings_ui: ^2.0.2
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user