From 84baec19a157daaf6e7fc60eed84f0d081827144 Mon Sep 17 00:00:00 2001 From: Krille Fear Date: Sat, 27 Nov 2021 10:10:29 +0100 Subject: [PATCH] design: Adaptive switches --- lib/pages/new_group/new_group_view.dart | 2 +- lib/pages/new_space/new_space_view.dart | 2 +- lib/pages/settings_chat/settings_chat_view.dart | 10 +++++----- lib/pages/settings_emotes/settings_emotes_view.dart | 8 +++----- .../settings_notifications_view.dart | 4 ++-- lib/utils/platform_infos.dart | 2 +- lib/widgets/sentry_switch_list_tile.dart | 4 ++-- lib/widgets/settings_switch_list_tile.dart | 4 ++-- 8 files changed, 17 insertions(+), 19 deletions(-) diff --git a/lib/pages/new_group/new_group_view.dart b/lib/pages/new_group/new_group_view.dart index f68210d0..581a2610 100644 --- a/lib/pages/new_group/new_group_view.dart +++ b/lib/pages/new_group/new_group_view.dart @@ -34,7 +34,7 @@ class NewGroupView extends StatelessWidget { hintText: L10n.of(context).enterAGroupName), ), ), - SwitchListTile( + SwitchListTile.adaptive( title: Text(L10n.of(context).groupIsPublic), value: controller.publicGroup, onChanged: controller.setPublicGroup, diff --git a/lib/pages/new_space/new_space_view.dart b/lib/pages/new_space/new_space_view.dart index 099b5f64..17608869 100644 --- a/lib/pages/new_space/new_space_view.dart +++ b/lib/pages/new_space/new_space_view.dart @@ -34,7 +34,7 @@ class NewSpaceView extends StatelessWidget { hintText: L10n.of(context).enterASpacepName), ), ), - SwitchListTile( + SwitchListTile.adaptive( title: Text(L10n.of(context).spaceIsPublic), value: controller.publicGroup, onChanged: controller.setPublicGroup, diff --git a/lib/pages/settings_chat/settings_chat_view.dart b/lib/pages/settings_chat/settings_chat_view.dart index 023362dc..073f6b50 100644 --- a/lib/pages/settings_chat/settings_chat_view.dart +++ b/lib/pages/settings_chat/settings_chat_view.dart @@ -24,32 +24,32 @@ class SettingsChatView extends StatelessWidget { withScrolling: true, child: Column( children: [ - SettingsSwitchListTile( + SettingsSwitchListTile.adaptive( title: L10n.of(context).renderRichContent, onChanged: (b) => AppConfig.renderHtml = b, storeKey: SettingKeys.renderHtml, defaultValue: AppConfig.renderHtml, ), - SettingsSwitchListTile( + SettingsSwitchListTile.adaptive( title: L10n.of(context).hideRedactedEvents, onChanged: (b) => AppConfig.hideRedactedEvents = b, storeKey: SettingKeys.hideRedactedEvents, defaultValue: AppConfig.hideRedactedEvents, ), - SettingsSwitchListTile( + SettingsSwitchListTile.adaptive( title: L10n.of(context).hideUnknownEvents, onChanged: (b) => AppConfig.hideUnknownEvents = b, storeKey: SettingKeys.hideUnknownEvents, defaultValue: AppConfig.hideUnknownEvents, ), - SettingsSwitchListTile( + SettingsSwitchListTile.adaptive( title: L10n.of(context).autoplayImages, onChanged: (b) => AppConfig.autoplayImages = b, storeKey: SettingKeys.autoplayImages, defaultValue: AppConfig.autoplayImages, ), if (PlatformInfos.isMobile) - SettingsSwitchListTile( + SettingsSwitchListTile.adaptive( title: L10n.of(context).sendOnEnter, onChanged: (b) => AppConfig.sendOnEnter = b, storeKey: SettingKeys.sendOnEnter, diff --git a/lib/pages/settings_emotes/settings_emotes_view.dart b/lib/pages/settings_emotes/settings_emotes_view.dart index d3c2859d..fc167d58 100644 --- a/lib/pages/settings_emotes/settings_emotes_view.dart +++ b/lib/pages/settings_emotes/settings_emotes_view.dart @@ -83,12 +83,10 @@ class EmotesSettingsView extends StatelessWidget { ), ), if (controller.room != null) - ListTile( + SwitchListTile.adaptive( title: Text(L10n.of(context).enableEmotesGlobally), - trailing: Switch( - value: controller.isGloballyActive(client), - onChanged: controller.setIsGloballyActive, - ), + value: controller.isGloballyActive(client), + onChanged: controller.setIsGloballyActive, ), if (!controller.readonly || controller.room != null) Divider( diff --git a/lib/pages/settings_notifications/settings_notifications_view.dart b/lib/pages/settings_notifications/settings_notifications_view.dart index a6fe7263..44180f73 100644 --- a/lib/pages/settings_notifications/settings_notifications_view.dart +++ b/lib/pages/settings_notifications/settings_notifications_view.dart @@ -35,7 +35,7 @@ class SettingsNotificationsView extends StatelessWidget { builder: (BuildContext context, _) { return Column( children: [ - SwitchListTile( + SwitchListTile.adaptive( value: !Matrix.of(context).client.allPushNotificationsMuted, title: Text( L10n.of(context).notificationsEnabledForThisAccount), @@ -72,7 +72,7 @@ class SettingsNotificationsView extends StatelessWidget { ), ), for (var item in NotificationSettingsItem.items) - SwitchListTile( + SwitchListTile.adaptive( value: controller.getNotificationSetting(item) ?? true, title: Text(item.title(context)), onChanged: (bool enabled) => diff --git a/lib/utils/platform_infos.dart b/lib/utils/platform_infos.dart index 9c16faf0..9eec8ed1 100644 --- a/lib/utils/platform_infos.dart +++ b/lib/utils/platform_infos.dart @@ -60,7 +60,7 @@ abstract class PlatformInfos { onPressed: () => VRouter.of(context).to('logs'), child: const Text('Logs'), ), - SentrySwitchListTile(label: L10n.of(context).sendBugReports), + SentrySwitchListTile.adaptive(label: L10n.of(context).sendBugReports), ], applicationIcon: Image.asset('assets/logo.png', width: 64, height: 64), applicationName: AppConfig.applicationName, diff --git a/lib/widgets/sentry_switch_list_tile.dart b/lib/widgets/sentry_switch_list_tile.dart index 5f9ac4d8..ac1c9451 100644 --- a/lib/widgets/sentry_switch_list_tile.dart +++ b/lib/widgets/sentry_switch_list_tile.dart @@ -7,7 +7,7 @@ import 'package:fluffychat/utils/sentry_controller.dart'; class SentrySwitchListTile extends StatefulWidget { final String label; - const SentrySwitchListTile({Key key, this.label}) : super(key: key); + const SentrySwitchListTile.adaptive({Key key, this.label}) : super(key: key); @override _SentrySwitchListTileState createState() => _SentrySwitchListTileState(); @@ -22,7 +22,7 @@ class _SentrySwitchListTileState extends State { future: SentryController.getSentryStatus(), builder: (context, snapshot) { _enabled = snapshot.data ?? false; - return SwitchListTile( + return SwitchListTile.adaptive( title: Text(widget.label ?? L10n.of(context).sendBugReports), value: _enabled, onChanged: (b) => diff --git a/lib/widgets/settings_switch_list_tile.dart b/lib/widgets/settings_switch_list_tile.dart index a09d40b4..0df7d675 100644 --- a/lib/widgets/settings_switch_list_tile.dart +++ b/lib/widgets/settings_switch_list_tile.dart @@ -8,7 +8,7 @@ class SettingsSwitchListTile extends StatefulWidget { final String title; final Function(bool) onChanged; - const SettingsSwitchListTile({ + const SettingsSwitchListTile.adaptive({ Key key, this.defaultValue = false, @required this.storeKey, @@ -27,7 +27,7 @@ class _SettingsSwitchListTileState extends State { future: Matrix.of(context) .store .getItemBool(widget.storeKey, widget.defaultValue), - builder: (context, snapshot) => SwitchListTile( + builder: (context, snapshot) => SwitchListTile.adaptive( value: snapshot.data ?? widget.defaultValue, title: Text(widget.title), onChanged: (bool newValue) async {