Merge branch 'krille/adaptive-switches' into 'main'

design: Adaptive switches

See merge request famedly/fluffychat!587
This commit is contained in:
Krille Fear 2021-11-27 09:34:26 +00:00
commit 16c7a89666
8 changed files with 17 additions and 19 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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(

View File

@ -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) =>

View File

@ -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,

View File

@ -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<SentrySwitchListTile> {
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) =>

View File

@ -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<SettingsSwitchListTile> {
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 {