improvements & bugfixes

This commit is contained in:
Myzel394 2022-08-18 18:03:26 +02:00
parent 67d6435423
commit 71cceb0fdc
8 changed files with 127 additions and 102 deletions

View File

@ -70,6 +70,7 @@
<true/>
</dict>
<key>NSPhotoLibraryUsageDescription</key>
<string>Accessing your gallery allows you to save your memories</string>
</dict>
</plist>

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
import 'package:quid_faciam_hodie/extensions/snackbar.dart';
import 'package:quid_faciam_hodie/screens/main_screen.dart';
import 'package:quid_faciam_hodie/screens/welcome_screen.dart';
@ -27,6 +28,6 @@ class AuthState<T extends StatefulWidget> extends SupabaseAuthState<T> {
@override
void onErrorAuthenticating(String message) {
context.showErrorSnackBar(message: message);
if (isMaterial(context)) context.showErrorSnackBar(message: message);
}
}

View File

@ -69,9 +69,10 @@ class _LoginScreenState extends AuthState<LoginScreen> with Loadable {
await _signUp();
} catch (error) {
if (mounted) {
context.showLongErrorSnackBar(
message: localizations.loginScreenLoginFailed,
);
if (isMaterial(context))
context.showLongErrorSnackBar(
message: localizations.loginScreenLoginFailed,
);
passwordController.clear();
}

View File

@ -11,8 +11,11 @@ class SettingsButtonOverlay extends StatelessWidget {
return Positioned(
left: SMALL_SPACE,
top: SMALL_SPACE,
child: IconButton(
icon: Icon(context.platformIcons.settings),
child: PlatformTextButton(
child: Icon(
context.platformIcons.settings,
color: Colors.white,
),
onPressed: () {
Navigator.pushNamed(context, SettingsScreen.ID);
},

View File

@ -120,8 +120,12 @@ class _ServerLoadingScreenState extends State<ServerLoadingScreen> {
localizations.serverLoadingScreenDescription,
style: platformThemeData(
context,
material: (data) => data.textTheme.bodyText1,
cupertino: (data) => data.textTheme.textStyle,
material: (data) => data.textTheme.bodyText1!.copyWith(
color: Colors.white,
),
cupertino: (data) => data.textTheme.textStyle.copyWith(
color: Colors.white,
),
),
),
],

View File

@ -85,97 +85,103 @@ class _SettingsScreenState extends AuthRequiredState<SettingsScreen>
],
),
)
: SettingsList(
sections: [
SettingsSection(
title: Text(localizations.settingsScreenAccountSectionTitle),
tiles: <SettingsTile>[
SettingsTile(
leading: Icon(context.platformIcons.mail),
title: Text(user!.email!),
),
SettingsTile(
leading: Icon(context.platformIcons.time),
title: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
DateFormat('d. MMMM y, HH:mm:ss')
.format(DateTime.parse(user!.createdAt)),
),
const SizedBox(height: SMALL_SPACE),
Text(
localizations
.settingsScreenAccountSectionCreationDateLabel,
style: platformThemeData(
context,
material: (data) => data.textTheme.bodySmall,
cupertino: (data) => data.textTheme.textStyle,
),
)
],
: Padding(
padding:
EdgeInsets.only(top: isCupertino(context) ? LARGE_SPACE : 0),
child: SettingsList(
sections: [
SettingsSection(
title:
Text(localizations.settingsScreenAccountSectionTitle),
tiles: <SettingsTile>[
SettingsTile(
leading: Icon(context.platformIcons.mail),
title: Text(user!.email!),
),
),
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
.settingsScreenDangerSectionDeleteAccountLabel,
),
content: Text(
localizations
.settingsScreenDeleteAccountDescription,
style: getBodyTextTextStyle(platformContext),
),
actions: [
PlatformDialogAction(
child: Text(
localizations.generalCancelButtonLabel,
),
onPressed: () => Navigator.pop(context),
SettingsTile(
leading: Icon(context.platformIcons.time),
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
DateFormat('d. MMMM y, HH:mm:ss')
.format(DateTime.parse(user!.createdAt)),
),
PlatformDialogAction(
child: Text(
localizations
.settingsScreenDeleteAccountConfirmLabel,
const SizedBox(height: SMALL_SPACE),
Text(
localizations
.settingsScreenAccountSectionCreationDateLabel,
style: platformThemeData(
context,
material: (data) => data.textTheme.bodySmall,
cupertino: (data) =>
data.textTheme.tabLabelTextStyle,
),
onPressed: () => callWithLoading(deleteUser),
)
],
),
),
),
],
),
],
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
.settingsScreenDangerSectionDeleteAccountLabel,
),
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),
)
],
),
),
),
],
),
],
),
),
);
}

View File

@ -60,10 +60,12 @@ class _MemorySheetState extends State<MemorySheet> with Loadable {
Navigator.pop(context);
context.showSuccessSnackBar(
message: localizations.memorySheetSavedToGallery);
if (isMaterial(context))
context.showSuccessSnackBar(
message: localizations.memorySheetSavedToGallery);
} catch (error) {
context.showErrorSnackBar(message: localizations.generalError);
if (isMaterial(context))
context.showErrorSnackBar(message: localizations.generalError);
}
}
@ -86,14 +88,17 @@ class _MemorySheetState extends State<MemorySheet> with Loadable {
Navigator.pop(context);
if (isNowPublic) {
context.showSuccessSnackBar(
message: localizations.memorySheetMemoryUpdatedToPublic);
if (isMaterial(context))
context.showSuccessSnackBar(
message: localizations.memorySheetMemoryUpdatedToPublic);
} else {
context.showSuccessSnackBar(
message: localizations.memorySheetMemoryUpdatedToPrivate);
if (isMaterial(context))
context.showSuccessSnackBar(
message: localizations.memorySheetMemoryUpdatedToPrivate);
}
} catch (error) {
context.showErrorSnackBar(message: localizations.generalError);
if (isMaterial(context))
context.showErrorSnackBar(message: localizations.generalError);
}
}

View File

@ -132,7 +132,11 @@ class _MemoryViewState extends State<MemoryView> {
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
PlatformCircularProgressIndicator(),
PlatformCircularProgressIndicator(
cupertino: (_, __) => CupertinoProgressIndicatorData(
color: Colors.white,
),
),
const SizedBox(height: SMALL_SPACE),
() {
switch (status) {