style: New settings design
This commit is contained in:
parent
5940ad5054
commit
5d53a37e2e
10 changed files with 401 additions and 458 deletions
|
|
@ -22,16 +22,61 @@ class Settings extends StatefulWidget {
|
|||
}
|
||||
|
||||
class SettingsController extends State<Settings> {
|
||||
Future<dynamic>? profileFuture;
|
||||
Profile? profile;
|
||||
Future<Profile>? profileFuture;
|
||||
bool profileUpdated = false;
|
||||
|
||||
void updateProfile() => setState(() {
|
||||
profileUpdated = true;
|
||||
profile = profileFuture = null;
|
||||
profileFuture = null;
|
||||
});
|
||||
|
||||
void setDisplaynameAction() async {
|
||||
final profile = await profileFuture;
|
||||
final input = await showTextInputDialog(
|
||||
useRootNavigator: false,
|
||||
context: context,
|
||||
title: L10n.of(context)!.editDisplayname,
|
||||
okLabel: L10n.of(context)!.ok,
|
||||
cancelLabel: L10n.of(context)!.cancel,
|
||||
textFields: [
|
||||
DialogTextField(
|
||||
initialText: profile?.displayName ??
|
||||
Matrix.of(context).client.userID!.localpart,
|
||||
)
|
||||
],
|
||||
);
|
||||
if (input == null) return;
|
||||
final matrix = Matrix.of(context);
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () =>
|
||||
matrix.client.setDisplayName(matrix.client.userID!, input.single),
|
||||
);
|
||||
if (success.error == null) {
|
||||
updateProfile();
|
||||
}
|
||||
}
|
||||
|
||||
void logoutAction() async {
|
||||
if (await showOkCancelAlertDialog(
|
||||
useRootNavigator: false,
|
||||
context: context,
|
||||
title: L10n.of(context)!.areYouSureYouWantToLogout,
|
||||
okLabel: L10n.of(context)!.yes,
|
||||
cancelLabel: L10n.of(context)!.cancel,
|
||||
) ==
|
||||
OkCancelResult.cancel) {
|
||||
return;
|
||||
}
|
||||
final matrix = Matrix.of(context);
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => matrix.client.logout(),
|
||||
);
|
||||
}
|
||||
|
||||
void setAvatarAction() async {
|
||||
final profile = await profileFuture;
|
||||
final actions = [
|
||||
if (PlatformInfos.isMobile)
|
||||
SheetAction(
|
||||
|
|
@ -131,9 +176,9 @@ class SettingsController extends State<Settings> {
|
|||
}
|
||||
|
||||
bool? crossSigningCached;
|
||||
bool showChatBackupBanner = false;
|
||||
bool? showChatBackupBanner;
|
||||
|
||||
void firstRunBootstrapAction() async {
|
||||
void firstRunBootstrapAction([_]) async {
|
||||
await BootstrapDialog(
|
||||
client: Matrix.of(context).client,
|
||||
).show(context);
|
||||
|
|
@ -143,16 +188,11 @@ class SettingsController extends State<Settings> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final client = Matrix.of(context).client;
|
||||
profileFuture ??= client
|
||||
.getProfileFromUserId(
|
||||
profileFuture ??= client.getProfileFromUserId(
|
||||
client.userID!,
|
||||
cache: !profileUpdated,
|
||||
getFromRooms: !profileUpdated,
|
||||
)
|
||||
.then((p) {
|
||||
if (mounted) setState(() => profile = p);
|
||||
return p;
|
||||
});
|
||||
);
|
||||
return SettingsView(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue