2020-01-01 19:10:13 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2021-10-26 18:50:34 +02:00
|
|
|
|
2020-10-03 13:11:07 +02:00
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
2023-02-04 18:32:56 +01:00
|
|
|
import 'package:matrix/matrix.dart';
|
2023-01-26 09:47:30 +01:00
|
|
|
import 'package:url_launcher/url_launcher_string.dart';
|
2021-05-23 13:11:55 +02:00
|
|
|
import 'package:vrouter/vrouter.dart';
|
2020-01-01 19:10:13 +01:00
|
|
|
|
2021-10-26 18:50:34 +02:00
|
|
|
import 'package:fluffychat/config/app_config.dart';
|
2023-02-05 07:39:03 +01:00
|
|
|
import 'package:fluffychat/utils/fluffy_share.dart';
|
2021-10-26 18:50:34 +02:00
|
|
|
import 'package:fluffychat/utils/platform_infos.dart';
|
2023-02-04 18:32:56 +01:00
|
|
|
import 'package:fluffychat/widgets/avatar.dart';
|
|
|
|
import 'package:fluffychat/widgets/matrix.dart';
|
2021-11-09 21:32:16 +01:00
|
|
|
import 'settings.dart';
|
2020-01-01 19:10:13 +01:00
|
|
|
|
2021-05-22 09:13:47 +02:00
|
|
|
class SettingsView extends StatelessWidget {
|
2021-04-24 08:22:42 +02:00
|
|
|
final SettingsController controller;
|
2020-06-25 16:29:06 +02:00
|
|
|
|
2022-01-29 12:35:03 +01:00
|
|
|
const SettingsView(this.controller, {Key? key}) : super(key: key);
|
2021-01-18 08:38:19 +01:00
|
|
|
|
2020-01-01 19:10:13 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-02-13 11:55:22 +01:00
|
|
|
return Scaffold(
|
2023-02-04 18:32:56 +01:00
|
|
|
appBar: AppBar(
|
2023-02-04 21:59:53 +01:00
|
|
|
leading: CloseButton(
|
|
|
|
onPressed: VRouter.of(context).pop,
|
|
|
|
),
|
2023-02-04 18:32:56 +01:00
|
|
|
title: Text(L10n.of(context)!.settings),
|
|
|
|
actions: [
|
|
|
|
TextButton.icon(
|
|
|
|
onPressed: controller.logoutAction,
|
|
|
|
label: Text(L10n.of(context)!.logout),
|
|
|
|
icon: const Icon(Icons.logout_outlined),
|
2020-01-01 19:10:13 +01:00
|
|
|
),
|
2021-02-13 11:55:22 +01:00
|
|
|
],
|
2023-02-04 18:32:56 +01:00
|
|
|
),
|
|
|
|
body: ListTileTheme(
|
|
|
|
iconColor: Theme.of(context).colorScheme.onBackground,
|
|
|
|
child: ListView(
|
|
|
|
key: const Key('SettingsListViewContent'),
|
|
|
|
children: <Widget>[
|
|
|
|
FutureBuilder<Profile>(
|
|
|
|
future: controller.profileFuture,
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
final profile = snapshot.data;
|
|
|
|
final mxid = Matrix.of(context).client.userID ??
|
|
|
|
L10n.of(context)!.user;
|
|
|
|
final displayname =
|
|
|
|
profile?.displayName ?? mxid.localpart ?? mxid;
|
|
|
|
return Row(
|
|
|
|
children: [
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(32.0),
|
|
|
|
child: Stack(
|
|
|
|
children: [
|
|
|
|
Material(
|
|
|
|
elevation: Theme.of(context)
|
|
|
|
.appBarTheme
|
|
|
|
.scrolledUnderElevation ??
|
|
|
|
4,
|
|
|
|
shadowColor:
|
|
|
|
Theme.of(context).appBarTheme.shadowColor,
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
side: BorderSide(
|
|
|
|
color: Theme.of(context).dividerColor,
|
|
|
|
),
|
|
|
|
borderRadius: BorderRadius.circular(
|
|
|
|
Avatar.defaultSize * 2.5),
|
|
|
|
),
|
|
|
|
child: Hero(
|
|
|
|
tag: 'profilesettings',
|
|
|
|
child: Avatar(
|
|
|
|
mxContent: profile?.avatarUrl,
|
|
|
|
name: displayname,
|
|
|
|
size: Avatar.defaultSize * 2.5,
|
|
|
|
fontSize: 18 * 2.5,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (profile != null)
|
|
|
|
Positioned(
|
|
|
|
bottom: 0,
|
|
|
|
right: 0,
|
|
|
|
child: FloatingActionButton.small(
|
|
|
|
onPressed: controller.setAvatarAction,
|
|
|
|
heroTag: null,
|
|
|
|
child: const Icon(Icons.camera_alt_outlined),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: ListTile(
|
|
|
|
contentPadding: EdgeInsets.zero,
|
|
|
|
title: Align(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: TextButton.icon(
|
|
|
|
onPressed: controller.setDisplaynameAction,
|
|
|
|
icon: const Icon(
|
|
|
|
Icons.edit_outlined,
|
|
|
|
size: 18,
|
|
|
|
),
|
|
|
|
style: TextButton.styleFrom(
|
|
|
|
foregroundColor:
|
|
|
|
Theme.of(context).colorScheme.onBackground,
|
|
|
|
),
|
|
|
|
label: Text(
|
|
|
|
displayname,
|
|
|
|
maxLines: 1,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: const TextStyle(fontSize: 18),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
subtitle: Align(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: TextButton.icon(
|
2023-02-04 21:59:53 +01:00
|
|
|
onPressed: () => FluffyShare.share(mxid, context),
|
2023-02-04 18:32:56 +01:00
|
|
|
icon: const Icon(
|
|
|
|
Icons.copy_outlined,
|
|
|
|
size: 14,
|
|
|
|
),
|
|
|
|
style: TextButton.styleFrom(
|
|
|
|
foregroundColor:
|
|
|
|
Theme.of(context).colorScheme.secondary,
|
|
|
|
),
|
|
|
|
label: Text(
|
|
|
|
mxid,
|
|
|
|
maxLines: 1,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: const TextStyle(fontSize: 12),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
const Divider(thickness: 1),
|
|
|
|
SwitchListTile.adaptive(
|
|
|
|
controlAffinity: ListTileControlAffinity.trailing,
|
|
|
|
value: controller.showChatBackupBanner == false,
|
|
|
|
secondary: const Icon(Icons.backup_outlined),
|
|
|
|
title: Text(L10n.of(context)!.chatBackup),
|
2023-02-04 21:59:53 +01:00
|
|
|
onChanged: controller.firstRunBootstrapAction,
|
2023-02-04 18:32:56 +01:00
|
|
|
),
|
|
|
|
const Divider(thickness: 1),
|
|
|
|
ListTile(
|
|
|
|
leading: const Icon(Icons.format_paint_outlined),
|
|
|
|
title: Text(L10n.of(context)!.changeTheme),
|
|
|
|
onTap: () => VRouter.of(context).to('/settings/style'),
|
|
|
|
trailing: const Icon(Icons.chevron_right_outlined),
|
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
leading: const Icon(Icons.notifications_outlined),
|
|
|
|
title: Text(L10n.of(context)!.notifications),
|
|
|
|
onTap: () => VRouter.of(context).to('/settings/notifications'),
|
|
|
|
trailing: const Icon(Icons.chevron_right_outlined),
|
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
leading: const Icon(Icons.devices_outlined),
|
|
|
|
title: Text(L10n.of(context)!.devices),
|
|
|
|
onTap: () => VRouter.of(context).to('/settings/devices'),
|
|
|
|
trailing: const Icon(Icons.chevron_right_outlined),
|
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
leading: const Icon(Icons.chat_bubble_outline_outlined),
|
|
|
|
title: Text(L10n.of(context)!.chat),
|
|
|
|
onTap: () => VRouter.of(context).to('/settings/chat'),
|
|
|
|
trailing: const Icon(Icons.chevron_right_outlined),
|
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
leading: const Icon(Icons.shield_outlined),
|
|
|
|
title: Text(L10n.of(context)!.security),
|
|
|
|
onTap: () => VRouter.of(context).to('/settings/security'),
|
|
|
|
trailing: const Icon(Icons.chevron_right_outlined),
|
|
|
|
),
|
|
|
|
const Divider(thickness: 1),
|
|
|
|
ListTile(
|
|
|
|
leading: const Icon(Icons.help_outline_outlined),
|
|
|
|
title: Text(L10n.of(context)!.help),
|
|
|
|
onTap: () => launchUrlString(AppConfig.supportUrl),
|
|
|
|
trailing: const Icon(Icons.open_in_new_outlined),
|
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
leading: const Icon(Icons.shield_sharp),
|
|
|
|
title: Text(L10n.of(context)!.privacy),
|
|
|
|
onTap: () => launchUrlString(AppConfig.privacyUrl),
|
|
|
|
trailing: const Icon(Icons.open_in_new_outlined),
|
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
leading: const Icon(Icons.info_outline_rounded),
|
|
|
|
title: Text(L10n.of(context)!.about),
|
|
|
|
onTap: () => PlatformInfos.showDialog(context),
|
|
|
|
trailing: const Icon(Icons.chevron_right_outlined),
|
|
|
|
),
|
|
|
|
],
|
2021-02-03 15:47:51 +01:00
|
|
|
),
|
2021-02-13 11:55:22 +01:00
|
|
|
),
|
2020-01-01 19:10:13 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|