Skip to content

Commit

Permalink
fix: make entire settings tiles clickable
Browse files Browse the repository at this point in the history
SwitchListTile is far more appropriate, so the
user doesn't have to click only the small toggle
target at the end of the tile.
  • Loading branch information
Merrit committed Oct 14, 2024
1 parent c77929f commit 3b8dda9
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 114 deletions.
187 changes: 92 additions & 95 deletions lib/settings/widgets/behaviour_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,53 @@ class BehaviourSection extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
AppLocalizations.of(context)!.behaviourTitle,
),
Spacers.verticalXtraSmall,
ListTile(
final appsListCubit = context.read<AppsListCubit>();

final Widget autoRefreshTile = BlocBuilder<SettingsCubit, SettingsState>(
builder: (context, state) {
return SwitchListTile(
title: Text(
AppLocalizations.of(context)!.autoRefresh,
),
leading: const Icon(Icons.refresh),
secondary: const Icon(Icons.refresh),
subtitle: Text(
AppLocalizations.of(context)!.autoRefreshDescription,
),
trailing: BlocBuilder<SettingsCubit, SettingsState>(
builder: (context, state) {
return Switch(
value: state.autoRefresh,
onChanged: (value) async {
final appsListCubit = context.read<AppsListCubit>();
await settingsCubit.updateAutoRefresh(value);
appsListCubit.setAutoRefresh(
autoRefresh: value,
refreshInterval: state.refreshInterval,
);
},
);
},
value: state.autoRefresh,
onChanged: (value) async {
await settingsCubit.updateAutoRefresh(value);
appsListCubit.setAutoRefresh(
autoRefresh: value,
refreshInterval: state.refreshInterval,
);
},
);
},
);

final Widget minimizeAndRestoreTile = BlocBuilder<SettingsCubit, SettingsState>(
builder: (context, state) {
return SwitchListTile(
title: Text(
AppLocalizations.of(context)!.minimizeAndRestoreWindows,
),
secondary: const Icon(Icons.minimize),
value: state.minimizeWindows,
onChanged: (value) async {
await settingsCubit.updateMinimizeWindows(value);
},
);
},
);

return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
AppLocalizations.of(context)!.behaviourTitle,
),
Spacers.verticalXtraSmall,
autoRefreshTile,
BlocBuilder<SettingsCubit, SettingsState>(
builder: (context, state) {
return ListTile(
Expand All @@ -59,22 +75,7 @@ class BehaviourSection extends StatelessWidget {
);
},
),
ListTile(
title: Text(
AppLocalizations.of(context)!.minimizeAndRestoreWindows,
),
leading: const Icon(Icons.minimize),
trailing: BlocBuilder<SettingsCubit, SettingsState>(
builder: (context, state) {
return Switch(
value: state.minimizeWindows,
onChanged: (value) async {
await settingsCubit.updateMinimizeWindows(value);
},
);
},
),
),
minimizeAndRestoreTile,
const _PinSuspendedWindowsTile(),
const ShowHiddenTile(),
],
Expand Down Expand Up @@ -102,36 +103,34 @@ class _PinSuspendedWindowsTile extends StatelessWidget {

@override
Widget build(BuildContext context) {
return ListTile(
title: Text.rich(
TextSpan(
children: [
return BlocBuilder<SettingsCubit, SettingsState>(
builder: (context, state) {
return SwitchListTile(
title: Text.rich(
TextSpan(
text: '${AppLocalizations.of(context)!.pinSuspendedWindows} ',
),
WidgetSpan(
child: Tooltip(
message: AppLocalizations.of(context)!.pinSuspendedWindowsTooltip,
child: const Icon(
Icons.help_outline,
size: 18,
children: [
TextSpan(
text: '${AppLocalizations.of(context)!.pinSuspendedWindows} ',
),
),
WidgetSpan(
child: Tooltip(
message: AppLocalizations.of(context)!.pinSuspendedWindowsTooltip,
child: const Icon(
Icons.help_outline,
size: 18,
),
),
),
],
),
],
),
),
leading: const Icon(Icons.push_pin_outlined),
trailing: BlocBuilder<SettingsCubit, SettingsState>(
builder: (context, state) {
return Switch(
value: state.pinSuspendedWindows,
onChanged: (value) async {
await settingsCubit.updatePinSuspendedWindows(value);
},
);
},
),
),
secondary: const Icon(Icons.push_pin_outlined),
value: state.pinSuspendedWindows,
onChanged: (value) async {
await settingsCubit.updatePinSuspendedWindows(value);
},
);
},
);
}
}
Expand All @@ -141,38 +140,36 @@ class ShowHiddenTile extends StatelessWidget {

@override
Widget build(BuildContext context) {
return ListTile(
title: Text.rich(
TextSpan(
children: [
return BlocBuilder<SettingsCubit, SettingsState>(
builder: (context, state) {
return SwitchListTile(
title: Text.rich(
TextSpan(
text: '${AppLocalizations.of(context)!.showHiddenWindows} ',
),
WidgetSpan(
child: Tooltip(
message: AppLocalizations.of(context)!.showHiddenWindowsTooltip,
child: const Icon(
Icons.help_outline,
size: 18,
children: [
TextSpan(
text: '${AppLocalizations.of(context)!.showHiddenWindows} ',
),
),
WidgetSpan(
child: Tooltip(
message: AppLocalizations.of(context)!.showHiddenWindowsTooltip,
child: const Icon(
Icons.help_outline,
size: 18,
),
),
),
],
),
],
),
),
leading: const Icon(Icons.refresh),
trailing: BlocBuilder<SettingsCubit, SettingsState>(
builder: (context, state) {
return Switch(
value: state.showHiddenWindows,
onChanged: (value) async {
final appsListCubit = context.read<AppsListCubit>();
await settingsCubit.updateShowHiddenWindows(value);
await appsListCubit.manualRefresh();
},
);
},
),
),
secondary: const Icon(Icons.refresh),
value: state.showHiddenWindows,
onChanged: (value) async {
final appsListCubit = context.read<AppsListCubit>();
await settingsCubit.updateShowHiddenWindows(value);
await appsListCubit.manualRefresh();
},
);
},
);
}
}
36 changes: 17 additions & 19 deletions lib/settings/widgets/integration_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,23 @@ class _CloseToTrayTile extends StatelessWidget {

@override
Widget build(BuildContext context) {
return ListTile(
title: Text(
AppLocalizations.of(context)!.closeToTray,
),
leading: const Icon(Icons.bedtime),
trailing: BlocBuilder<SettingsCubit, SettingsState>(
builder: (context, state) {
return Switch(
value: state.closeToTray,
onChanged: (bool value) async {
await settingsCubit.updateCloseToTray(value);

if (state.startHiddenInTray && !value) {
await settingsCubit.updateStartHiddenInTray(false);
}
},
);
},
),
return BlocBuilder<SettingsCubit, SettingsState>(
builder: (context, state) {
return SwitchListTile(
title: Text(
AppLocalizations.of(context)!.closeToTray,
),
secondary: const Icon(Icons.bedtime),
value: state.closeToTray,
onChanged: (bool value) async {
await settingsCubit.updateCloseToTray(value);

if (state.startHiddenInTray && !value) {
await settingsCubit.updateStartHiddenInTray(false);
}
},
);
},
);
}
}
Expand Down

0 comments on commit 3b8dda9

Please sign in to comment.