Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(account): ability to update account email and password
- Loading branch information
1 parent
30fc640
commit 5ea6269
Showing
13 changed files
with
323 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export 'widgets/config_backup_tile.dart'; | ||
export 'widgets/config_delete_tile.dart'; | ||
export 'widgets/config_restore_tile.dart'; | ||
export 'widgets/delete_account_tile.dart'; |
59 changes: 59 additions & 0 deletions
59
lib/modules/settings/routes/account/widgets/change_email_tile.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:lunasea/core.dart'; | ||
import 'package:lunasea/modules/settings.dart'; | ||
|
||
class ChangeEmailTile extends StatefulWidget { | ||
const ChangeEmailTile({ | ||
Key? key, | ||
}) : super(key: key); | ||
|
||
@override | ||
State<StatefulWidget> createState() => _State(); | ||
} | ||
|
||
class _State extends State<ChangeEmailTile> { | ||
LunaLoadingState _loadingState = LunaLoadingState.INACTIVE; | ||
|
||
void updateState(LunaLoadingState state) { | ||
if (mounted) setState(() => _loadingState = state); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return LunaBlock( | ||
title: 'settings.UpdateEmail'.tr(), | ||
trailing: LunaIconButton( | ||
icon: LunaIcons.EMAIL, | ||
loadingState: _loadingState, | ||
), | ||
onTap: _update, | ||
); | ||
} | ||
|
||
Future<void> _update() async { | ||
if (_loadingState == LunaLoadingState.ACTIVE) return; | ||
updateState(LunaLoadingState.ACTIVE); | ||
|
||
Tuple3<bool, String, String> _result = | ||
await SettingsDialogs().updateAccountEmail(context); | ||
if (_result.item1) { | ||
await LunaFirebaseAuth() | ||
.updateEmail(_result.item2, _result.item3) | ||
.then((res) { | ||
if (res.state) { | ||
showLunaSuccessSnackBar( | ||
title: 'settings.EmailUpdated'.tr(), | ||
message: _result.item2, | ||
); | ||
} else { | ||
updateState(LunaLoadingState.INACTIVE); | ||
showLunaErrorSnackBar( | ||
title: 'settings.FailedToUpdateEmail'.tr(), | ||
message: res.error?.message ?? 'lunasea.UnknownError'.tr(), | ||
); | ||
} | ||
}); | ||
} | ||
updateState(LunaLoadingState.INACTIVE); | ||
} | ||
} |
Oops, something went wrong.