feat: New settings design
This commit is contained in:
parent
a5c88479af
commit
e961596bc9
12 changed files with 125 additions and 98 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
|
|
@ -36,24 +37,30 @@ class SettingsController extends State<Settings> {
|
|||
});
|
||||
|
||||
void setAvatarAction() async {
|
||||
final action = profile?.avatarUrl == null
|
||||
? AvatarAction.change
|
||||
: await showConfirmationDialog<AvatarAction>(
|
||||
context: context,
|
||||
title: L10n.of(context).pleaseChoose,
|
||||
actions: [
|
||||
AlertDialogAction(
|
||||
key: AvatarAction.change,
|
||||
label: L10n.of(context).changeYourAvatar,
|
||||
isDefaultAction: true,
|
||||
),
|
||||
AlertDialogAction(
|
||||
key: AvatarAction.remove,
|
||||
label: L10n.of(context).removeYourAvatar,
|
||||
isDestructiveAction: true,
|
||||
),
|
||||
],
|
||||
);
|
||||
final action = await showModalActionSheet<AvatarAction>(
|
||||
context: context,
|
||||
title: L10n.of(context).changeYourAvatar,
|
||||
actions: [
|
||||
SheetAction(
|
||||
key: AvatarAction.camera,
|
||||
label: L10n.of(context).openCamera,
|
||||
isDefaultAction: true,
|
||||
icon: CupertinoIcons.camera,
|
||||
),
|
||||
SheetAction(
|
||||
key: AvatarAction.file,
|
||||
label: L10n.of(context).openGallery,
|
||||
icon: CupertinoIcons.photo,
|
||||
),
|
||||
if (profile?.avatarUrl != null)
|
||||
SheetAction(
|
||||
key: AvatarAction.remove,
|
||||
label: L10n.of(context).removeYourAvatar,
|
||||
isDestructiveAction: true,
|
||||
icon: CupertinoIcons.delete,
|
||||
),
|
||||
],
|
||||
);
|
||||
if (action == null) return;
|
||||
final matrix = Matrix.of(context);
|
||||
if (action == AvatarAction.remove) {
|
||||
|
|
@ -69,7 +76,9 @@ class SettingsController extends State<Settings> {
|
|||
MatrixFile file;
|
||||
if (PlatformInfos.isMobile) {
|
||||
final result = await ImagePicker().pickImage(
|
||||
source: ImageSource.gallery,
|
||||
source: action == AvatarAction.camera
|
||||
? ImageSource.camera
|
||||
: ImageSource.gallery,
|
||||
imageQuality: 50,
|
||||
maxWidth: 1600,
|
||||
maxHeight: 1600);
|
||||
|
|
@ -183,4 +192,4 @@ class SettingsController extends State<Settings> {
|
|||
}
|
||||
}
|
||||
|
||||
enum AvatarAction { change, remove }
|
||||
enum AvatarAction { camera, file, remove }
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
|
@ -31,7 +32,7 @@ class SettingsView extends StatelessWidget {
|
|||
background: ContentBanner(
|
||||
controller.profile?.avatarUrl,
|
||||
onEdit: controller.setAvatarAction,
|
||||
defaultIcon: Icons.account_circle_outlined,
|
||||
defaultIcon: CupertinoIcons.person_circle,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
@ -41,41 +42,46 @@ class SettingsView extends StatelessWidget {
|
|||
ListTile(
|
||||
title: Text(L10n.of(context).changeTheme),
|
||||
onTap: () => VRouter.of(context).to('/settings/style'),
|
||||
leading: const Icon(Icons.format_paint_outlined),
|
||||
leading: const Icon(CupertinoIcons.paintbrush),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.notifications_outlined),
|
||||
leading: const Icon(CupertinoIcons.bell),
|
||||
title: Text(L10n.of(context).notifications),
|
||||
onTap: () => VRouter.of(context).to('/settings/notifications'),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.chat_bubble_outline),
|
||||
leading: const Icon(CupertinoIcons.device_phone_portrait),
|
||||
title: Text(L10n.of(context).devices),
|
||||
onTap: () => VRouter.of(context).to('/settings/devices'),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(CupertinoIcons.chat_bubble_2),
|
||||
title: Text(L10n.of(context).chat),
|
||||
onTap: () => VRouter.of(context).to('/settings/chat'),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.account_box_outlined),
|
||||
leading: const Icon(CupertinoIcons.person),
|
||||
title: Text(L10n.of(context).account),
|
||||
onTap: () => VRouter.of(context).to('/settings/account'),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.security_outlined),
|
||||
leading: const Icon(CupertinoIcons.shield),
|
||||
title: Text(L10n.of(context).security),
|
||||
onTap: () => VRouter.of(context).to('/settings/security'),
|
||||
),
|
||||
const Divider(thickness: 1),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.help_outlined),
|
||||
leading: const Icon(CupertinoIcons.question_circle),
|
||||
title: Text(L10n.of(context).help),
|
||||
onTap: () => launch(AppConfig.supportUrl),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.privacy_tip_outlined),
|
||||
leading: const Icon(CupertinoIcons.checkmark_shield),
|
||||
title: Text(L10n.of(context).privacy),
|
||||
onTap: () => launch(AppConfig.privacyUrl),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.link_outlined),
|
||||
leading: const Icon(CupertinoIcons.info_circle),
|
||||
title: Text(L10n.of(context).about),
|
||||
onTap: () => PlatformInfos.showDialog(context),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue