2020-11-14 10:08:13 +01:00
|
|
|
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
2021-05-23 13:11:55 +02:00
|
|
|
|
2021-05-22 08:53:52 +02:00
|
|
|
import 'package:fluffychat/widgets/sentry_switch_list_tile.dart';
|
|
|
|
import 'package:fluffychat/widgets/settings_switch_list_tile.dart';
|
2021-04-03 13:09:20 +02:00
|
|
|
|
2020-01-01 19:10:13 +01:00
|
|
|
import 'package:famedlysdk/famedlysdk.dart';
|
2020-12-19 13:06:31 +01:00
|
|
|
import 'package:fluffychat/utils/beautify_string_extension.dart';
|
2020-10-04 17:01:54 +02:00
|
|
|
|
2021-04-09 16:29:48 +02:00
|
|
|
import 'package:fluffychat/config/app_config.dart';
|
2020-10-04 17:01:54 +02:00
|
|
|
import 'package:fluffychat/utils/platform_infos.dart';
|
2020-01-01 19:10:13 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2020-10-03 13:11:07 +02:00
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
2020-01-04 09:40:38 +01:00
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
2021-05-23 13:11:55 +02:00
|
|
|
import 'package:vrouter/vrouter.dart';
|
2020-01-01 19:10:13 +01:00
|
|
|
|
2021-05-22 08:53:52 +02:00
|
|
|
import '../../widgets/content_banner.dart';
|
|
|
|
import '../../widgets/matrix.dart';
|
2021-04-15 13:03:14 +02:00
|
|
|
import '../../config/app_config.dart';
|
|
|
|
import '../../config/setting_keys.dart';
|
2021-04-24 08:22:42 +02: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
|
|
|
|
2021-05-22 09:13:47 +02: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) {
|
2020-05-13 15:58:59 +02:00
|
|
|
final client = Matrix.of(context).client;
|
2021-02-13 11:55:22 +01:00
|
|
|
return Scaffold(
|
|
|
|
body: NestedScrollView(
|
|
|
|
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) =>
|
|
|
|
<Widget>[
|
|
|
|
SliverAppBar(
|
|
|
|
expandedHeight: 300.0,
|
|
|
|
floating: true,
|
|
|
|
pinned: true,
|
2021-05-16 11:29:18 +02:00
|
|
|
title: Text(L10n.of(context).settings),
|
2021-02-27 09:10:08 +01:00
|
|
|
actions: [
|
|
|
|
FutureBuilder(
|
2021-04-24 08:22:42 +02:00
|
|
|
future: controller.crossSigningCachedFuture,
|
2021-02-27 09:10:08 +01:00
|
|
|
builder: (context, snapshot) {
|
|
|
|
final needsBootstrap = Matrix.of(context)
|
|
|
|
.client
|
|
|
|
.encryption
|
2021-04-09 20:16:56 +02:00
|
|
|
?.crossSigning
|
|
|
|
?.enabled ==
|
2021-02-27 09:10:08 +01:00
|
|
|
false ||
|
|
|
|
snapshot.data == false;
|
|
|
|
final isUnknownSession =
|
|
|
|
Matrix.of(context).client.isUnknownSession;
|
|
|
|
final displayHeader = needsBootstrap || isUnknownSession;
|
|
|
|
if (!displayHeader) return Container();
|
|
|
|
return TextButton.icon(
|
|
|
|
icon: Icon(Icons.cloud, color: Colors.red),
|
|
|
|
label: Text(
|
|
|
|
L10n.of(context).chatBackup,
|
|
|
|
style: TextStyle(color: Colors.red),
|
|
|
|
),
|
2021-04-24 08:22:42 +02:00
|
|
|
onPressed: controller.firstRunBootstrapAction,
|
2021-02-27 09:10:08 +01:00
|
|
|
);
|
|
|
|
}),
|
|
|
|
],
|
2021-02-13 11:55:22 +01:00
|
|
|
backgroundColor: Theme.of(context).appBarTheme.color,
|
|
|
|
flexibleSpace: FlexibleSpaceBar(
|
2021-04-24 08:22:42 +02:00
|
|
|
background: ContentBanner(controller.profile?.avatarUrl,
|
|
|
|
onEdit: controller.setAvatarAction),
|
2020-01-01 19:10:13 +01:00
|
|
|
),
|
|
|
|
),
|
2021-02-13 11:55:22 +01:00
|
|
|
],
|
|
|
|
body: ListView(
|
|
|
|
children: <Widget>[
|
|
|
|
ListTile(
|
|
|
|
title: Text(
|
|
|
|
L10n.of(context).notifications,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Theme.of(context).accentColor,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
),
|
2020-02-16 10:42:59 +01:00
|
|
|
),
|
2021-02-13 11:55:22 +01:00
|
|
|
ListTile(
|
|
|
|
trailing: Icon(Icons.notifications_outlined),
|
|
|
|
title: Text(L10n.of(context).notifications),
|
2021-05-23 13:11:55 +02:00
|
|
|
onTap: () => VRouter.of(context).push('/settings/notifications'),
|
2020-09-21 17:50:01 +02:00
|
|
|
),
|
2021-02-13 11:55:22 +01:00
|
|
|
Divider(thickness: 1),
|
|
|
|
ListTile(
|
|
|
|
title: Text(
|
|
|
|
L10n.of(context).chat,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Theme.of(context).accentColor,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
2020-02-16 09:56:17 +01:00
|
|
|
),
|
|
|
|
),
|
2020-02-16 10:42:59 +01:00
|
|
|
ListTile(
|
2021-02-13 11:55:22 +01:00
|
|
|
title: Text(L10n.of(context).changeTheme),
|
2021-05-23 13:11:55 +02:00
|
|
|
onTap: () => VRouter.of(context).push('/settings/style'),
|
2021-02-13 11:55:22 +01:00
|
|
|
trailing: Icon(Icons.style_outlined),
|
2020-10-03 11:11:28 +02:00
|
|
|
),
|
2021-02-13 11:55:22 +01:00
|
|
|
SettingsSwitchListTile(
|
|
|
|
title: L10n.of(context).renderRichContent,
|
|
|
|
onChanged: (b) => AppConfig.renderHtml = b,
|
|
|
|
storeKey: SettingKeys.renderHtml,
|
|
|
|
defaultValue: AppConfig.renderHtml,
|
2020-02-16 10:42:59 +01:00
|
|
|
),
|
2021-02-13 11:55:22 +01:00
|
|
|
SettingsSwitchListTile(
|
|
|
|
title: L10n.of(context).hideRedactedEvents,
|
|
|
|
onChanged: (b) => AppConfig.hideRedactedEvents = b,
|
|
|
|
storeKey: SettingKeys.hideRedactedEvents,
|
|
|
|
defaultValue: AppConfig.hideRedactedEvents,
|
2021-01-17 15:43:38 +01:00
|
|
|
),
|
2021-02-13 11:55:22 +01:00
|
|
|
SettingsSwitchListTile(
|
|
|
|
title: L10n.of(context).hideUnknownEvents,
|
|
|
|
onChanged: (b) => AppConfig.hideUnknownEvents = b,
|
|
|
|
storeKey: SettingKeys.hideUnknownEvents,
|
|
|
|
defaultValue: AppConfig.hideUnknownEvents,
|
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
title: Text(L10n.of(context).emoteSettings),
|
2021-05-23 13:11:55 +02:00
|
|
|
onTap: () => VRouter.of(context).push('/settings/emotes'),
|
2021-02-13 11:55:22 +01:00
|
|
|
trailing: Icon(Icons.insert_emoticon_outlined),
|
|
|
|
),
|
|
|
|
Divider(thickness: 1),
|
|
|
|
ListTile(
|
|
|
|
title: Text(
|
|
|
|
L10n.of(context).account,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Theme.of(context).accentColor,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
trailing: Icon(Icons.edit_outlined),
|
|
|
|
title: Text(L10n.of(context).editDisplayname),
|
2021-04-24 08:22:42 +02:00
|
|
|
subtitle: Text(
|
|
|
|
controller.profile?.displayname ?? client.userID.localpart),
|
|
|
|
onTap: controller.setDisplaynameAction,
|
2021-02-13 11:55:22 +01:00
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
trailing: Icon(Icons.phone_outlined),
|
|
|
|
title: Text(L10n.of(context).editJitsiInstance),
|
|
|
|
subtitle: Text(AppConfig.jitsiInstance),
|
2021-04-24 08:22:42 +02:00
|
|
|
onTap: controller.setJitsiInstanceAction,
|
2021-02-13 11:55:22 +01:00
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
trailing: Icon(Icons.devices_other_outlined),
|
|
|
|
title: Text(L10n.of(context).devices),
|
2021-05-23 13:11:55 +02:00
|
|
|
onTap: () => VRouter.of(context).push('/settings/devices'),
|
2021-02-13 11:55:22 +01:00
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
trailing: Icon(Icons.block_outlined),
|
|
|
|
title: Text(L10n.of(context).ignoredUsers),
|
2021-05-23 13:11:55 +02:00
|
|
|
onTap: () => VRouter.of(context).push('/settings/ignorelist'),
|
2021-02-13 11:55:22 +01:00
|
|
|
),
|
|
|
|
SentrySwitchListTile(),
|
|
|
|
Divider(thickness: 1),
|
|
|
|
ListTile(
|
|
|
|
trailing: Icon(Icons.security_outlined),
|
|
|
|
title: Text(
|
|
|
|
L10n.of(context).changePassword,
|
|
|
|
),
|
2021-04-24 08:22:42 +02:00
|
|
|
onTap: controller.changePasswordAccountAction,
|
2021-02-13 11:55:22 +01:00
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
trailing: Icon(Icons.email_outlined),
|
|
|
|
title: Text(L10n.of(context).passwordRecovery),
|
2021-05-23 13:11:55 +02:00
|
|
|
onTap: () => VRouter.of(context).push('/settings/3pid'),
|
2021-02-13 11:55:22 +01:00
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
trailing: Icon(Icons.exit_to_app_outlined),
|
|
|
|
title: Text(L10n.of(context).logout),
|
2021-04-24 08:22:42 +02:00
|
|
|
onTap: controller.logoutAction,
|
2021-02-13 11:55:22 +01:00
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
trailing: Icon(Icons.delete_forever_outlined),
|
|
|
|
title: Text(
|
|
|
|
L10n.of(context).deleteAccount,
|
|
|
|
style: TextStyle(color: Colors.red),
|
|
|
|
),
|
2021-04-24 08:22:42 +02:00
|
|
|
onTap: controller.deleteAccountAction,
|
2021-02-13 11:55:22 +01:00
|
|
|
),
|
|
|
|
if (client.encryption != null) ...{
|
|
|
|
Divider(thickness: 1),
|
|
|
|
ListTile(
|
|
|
|
title: Text(
|
|
|
|
L10n.of(context).security,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Theme.of(context).accentColor,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (PlatformInfos.isMobile)
|
|
|
|
ListTile(
|
|
|
|
trailing: Icon(Icons.lock_outlined),
|
|
|
|
title: Text(L10n.of(context).appLock),
|
2021-04-24 08:22:42 +02:00
|
|
|
onTap: controller.setAppLockAction,
|
2021-02-13 11:55:22 +01:00
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
title: Text(L10n.of(context).yourPublicKey),
|
|
|
|
onTap: () => showOkAlertDialog(
|
2021-05-23 15:02:36 +02:00
|
|
|
useRootNavigator: false,
|
2021-02-13 11:55:22 +01:00
|
|
|
context: context,
|
|
|
|
title: L10n.of(context).yourPublicKey,
|
|
|
|
message: client.fingerprintKey.beautified,
|
2021-02-24 12:17:23 +01:00
|
|
|
okLabel: L10n.of(context).ok,
|
2021-02-13 11:55:22 +01:00
|
|
|
),
|
|
|
|
trailing: Icon(Icons.vpn_key_outlined),
|
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
title: Text(L10n.of(context).cachedKeys),
|
|
|
|
trailing: Icon(Icons.wb_cloudy_outlined),
|
|
|
|
subtitle: Text(
|
|
|
|
'${client.encryption.keyManager.enabled ? L10n.of(context).onlineKeyBackupEnabled : L10n.of(context).onlineKeyBackupDisabled}\n${client.encryption.crossSigning.enabled ? L10n.of(context).crossSigningEnabled : L10n.of(context).crossSigningDisabled}'),
|
2021-04-24 08:22:42 +02:00
|
|
|
onTap: controller.bootstrapSettingsAction,
|
2021-02-13 11:55:22 +01:00
|
|
|
),
|
|
|
|
},
|
|
|
|
Divider(thickness: 1),
|
|
|
|
ListTile(
|
|
|
|
title: Text(
|
|
|
|
L10n.of(context).about,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Theme.of(context).accentColor,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
),
|
2021-05-23 13:11:55 +02:00
|
|
|
onTap: () => VRouter.of(context).push('/logs'),
|
2021-02-13 11:55:22 +01:00
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
trailing: Icon(Icons.help_outlined),
|
|
|
|
title: Text(L10n.of(context).help),
|
|
|
|
onTap: () => launch(AppConfig.supportUrl),
|
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
trailing: Icon(Icons.privacy_tip_outlined),
|
|
|
|
title: Text(L10n.of(context).privacy),
|
|
|
|
onTap: () => launch(AppConfig.privacyUrl),
|
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
trailing: Icon(Icons.link_outlined),
|
|
|
|
title: Text(L10n.of(context).about),
|
|
|
|
onTap: () => PlatformInfos.showDialog(context),
|
|
|
|
),
|
|
|
|
],
|
2021-02-03 15:47:51 +01:00
|
|
|
),
|
2021-02-13 11:55:22 +01:00
|
|
|
),
|
2020-01-01 19:10:13 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|