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/> <true/>
</dict> </dict>
<key>NSPhotoLibraryUsageDescription</key>
<string>Accessing your gallery allows you to save your memories</string>
</dict> </dict>
</plist> </plist>

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; 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/extensions/snackbar.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/welcome_screen.dart'; import 'package:quid_faciam_hodie/screens/welcome_screen.dart';
@ -27,6 +28,6 @@ class AuthState<T extends StatefulWidget> extends SupabaseAuthState<T> {
@override @override
void onErrorAuthenticating(String message) { 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(); await _signUp();
} catch (error) { } catch (error) {
if (mounted) { if (mounted) {
context.showLongErrorSnackBar( if (isMaterial(context))
message: localizations.loginScreenLoginFailed, context.showLongErrorSnackBar(
); message: localizations.loginScreenLoginFailed,
);
passwordController.clear(); passwordController.clear();
} }

View File

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

View File

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

View File

@ -85,97 +85,103 @@ class _SettingsScreenState extends AuthRequiredState<SettingsScreen>
], ],
), ),
) )
: SettingsList( : Padding(
sections: [ padding:
SettingsSection( EdgeInsets.only(top: isCupertino(context) ? LARGE_SPACE : 0),
title: Text(localizations.settingsScreenAccountSectionTitle), child: SettingsList(
tiles: <SettingsTile>[ sections: [
SettingsTile( SettingsSection(
leading: Icon(context.platformIcons.mail), title:
title: Text(user!.email!), Text(localizations.settingsScreenAccountSectionTitle),
), tiles: <SettingsTile>[
SettingsTile( SettingsTile(
leading: Icon(context.platformIcons.time), leading: Icon(context.platformIcons.mail),
title: Column( title: Text(user!.email!),
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,
),
)
],
), ),
), SettingsTile(
SettingsTile( leading: Icon(context.platformIcons.time),
leading: const Icon(Icons.logout_rounded), title: Column(
title: Text(localizations crossAxisAlignment: CrossAxisAlignment.start,
.settingsScreenAccountSectionLogoutLabel), children: [
onPressed: (_) async { Text(
await callWithLoading(supabase.auth.signOut); DateFormat('d. MMMM y, HH:mm:ss')
.format(DateTime.parse(user!.createdAt)),
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( const SizedBox(height: SMALL_SPACE),
child: Text( Text(
localizations localizations
.settingsScreenDeleteAccountConfirmLabel, .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); Navigator.pop(context);
context.showSuccessSnackBar( if (isMaterial(context))
message: localizations.memorySheetSavedToGallery); context.showSuccessSnackBar(
message: localizations.memorySheetSavedToGallery);
} catch (error) { } 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); Navigator.pop(context);
if (isNowPublic) { if (isNowPublic) {
context.showSuccessSnackBar( if (isMaterial(context))
message: localizations.memorySheetMemoryUpdatedToPublic); context.showSuccessSnackBar(
message: localizations.memorySheetMemoryUpdatedToPublic);
} else { } else {
context.showSuccessSnackBar( if (isMaterial(context))
message: localizations.memorySheetMemoryUpdatedToPrivate); context.showSuccessSnackBar(
message: localizations.memorySheetMemoryUpdatedToPrivate);
} }
} catch (error) { } 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, mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[ children: <Widget>[
PlatformCircularProgressIndicator(), PlatformCircularProgressIndicator(
cupertino: (_, __) => CupertinoProgressIndicatorData(
color: Colors.white,
),
),
const SizedBox(height: SMALL_SPACE), const SizedBox(height: SMALL_SPACE),
() { () {
switch (status) { switch (status) {