diff --git a/lib/settings/widgets/behaviour_section.dart b/lib/settings/widgets/behaviour_section.dart index 9b0fc9d..2953562 100644 --- a/lib/settings/widgets/behaviour_section.dart +++ b/lib/settings/widgets/behaviour_section.dart @@ -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(); + + final Widget autoRefreshTile = BlocBuilder( + 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( - builder: (context, state) { - return Switch( - value: state.autoRefresh, - onChanged: (value) async { - final appsListCubit = context.read(); - 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( + 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( builder: (context, state) { return ListTile( @@ -59,22 +75,7 @@ class BehaviourSection extends StatelessWidget { ); }, ), - ListTile( - title: Text( - AppLocalizations.of(context)!.minimizeAndRestoreWindows, - ), - leading: const Icon(Icons.minimize), - trailing: BlocBuilder( - builder: (context, state) { - return Switch( - value: state.minimizeWindows, - onChanged: (value) async { - await settingsCubit.updateMinimizeWindows(value); - }, - ); - }, - ), - ), + minimizeAndRestoreTile, const _PinSuspendedWindowsTile(), const ShowHiddenTile(), ], @@ -102,36 +103,34 @@ class _PinSuspendedWindowsTile extends StatelessWidget { @override Widget build(BuildContext context) { - return ListTile( - title: Text.rich( - TextSpan( - children: [ + return BlocBuilder( + 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( - 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); + }, + ); + }, ); } } @@ -141,38 +140,36 @@ class ShowHiddenTile extends StatelessWidget { @override Widget build(BuildContext context) { - return ListTile( - title: Text.rich( - TextSpan( - children: [ + return BlocBuilder( + 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( - builder: (context, state) { - return Switch( - value: state.showHiddenWindows, - onChanged: (value) async { - final appsListCubit = context.read(); - await settingsCubit.updateShowHiddenWindows(value); - await appsListCubit.manualRefresh(); - }, - ); - }, - ), + ), + secondary: const Icon(Icons.refresh), + value: state.showHiddenWindows, + onChanged: (value) async { + final appsListCubit = context.read(); + await settingsCubit.updateShowHiddenWindows(value); + await appsListCubit.manualRefresh(); + }, + ); + }, ); } } diff --git a/lib/settings/widgets/integration_section.dart b/lib/settings/widgets/integration_section.dart index 039a2e8..0b6a7ec 100644 --- a/lib/settings/widgets/integration_section.dart +++ b/lib/settings/widgets/integration_section.dart @@ -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( - 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( + 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); + } + }, + ); + }, ); } }