refactor: Fix callbacks returning sets

pull/440/head
Inex Code 2024-01-31 15:14:37 +04:00
parent 02870c3149
commit 725c592086
5 changed files with 62 additions and 77 deletions

View File

@ -335,13 +335,12 @@ class BackupDetailsPage extends StatelessWidget {
'backup.forget_snapshot_alert'.tr(), 'backup.forget_snapshot_alert'.tr(),
actionButtonTitle: actionButtonTitle:
'backup.forget_snapshot'.tr(), 'backup.forget_snapshot'.tr(),
actionButtonOnPressed: () => { actionButtonOnPressed: () =>
context.read<BackupsBloc>().add( context.read<BackupsBloc>().add(
ForgetSnapshot( ForgetSnapshot(
backup.id, backup.id,
),
), ),
),
},
); );
}, },
title: Text( title: Text(
@ -416,11 +415,9 @@ class BackupDetailsPage extends StatelessWidget {
), ),
onTap: preventActions onTap: preventActions
? null ? null
: () => { : () => context
context .read<BackupsBloc>()
.read<BackupsBloc>() .add(const ForceSnapshotListUpdate()),
.add(const ForceSnapshotListUpdate()),
},
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
const Divider(), const Divider(),
@ -444,7 +441,7 @@ class BackupDetailsPage extends StatelessWidget {
), ),
// onTap: preventActions // onTap: preventActions
// ? null // ? null
// : () => {context.read<BackupsCubit>().reuploadKey()}, // : () => context.read<BackupsCubit>().reuploadKey(),
), ),
], ],
), ),

View File

@ -75,11 +75,9 @@ class BackupsListPage extends StatelessWidget {
alertTitle: 'backup.forget_snapshot'.tr(), alertTitle: 'backup.forget_snapshot'.tr(),
description: 'backup.forget_snapshot_alert'.tr(), description: 'backup.forget_snapshot_alert'.tr(),
actionButtonTitle: 'backup.forget_snapshot'.tr(), actionButtonTitle: 'backup.forget_snapshot'.tr(),
actionButtonOnPressed: () => { actionButtonOnPressed: () => context
context .read<BackupsBloc>()
.read<BackupsBloc>() .add(ForgetSnapshot(backup.id)),
.add(ForgetSnapshot(backup.id)),
},
); );
}, },
title: Text( title: Text(

View File

@ -80,9 +80,8 @@ class _ServicePageState extends State<ServicePage> {
const SizedBox(height: 8), const SizedBox(height: 8),
ListTile( ListTile(
iconColor: Theme.of(context).colorScheme.onBackground, iconColor: Theme.of(context).colorScheme.onBackground,
onTap: () => { onTap: () =>
context.read<ServicesBloc>().add(ServiceRestart(service)), context.read<ServicesBloc>().add(ServiceRestart(service)),
},
leading: const Icon(Icons.restart_alt_outlined), leading: const Icon(Icons.restart_alt_outlined),
title: Text( title: Text(
'service_page.restart'.tr(), 'service_page.restart'.tr(),
@ -92,14 +91,12 @@ class _ServicePageState extends State<ServicePage> {
), ),
ListTile( ListTile(
iconColor: Theme.of(context).colorScheme.onBackground, iconColor: Theme.of(context).colorScheme.onBackground,
onTap: () => { onTap: () => context.read<JobsCubit>().addJob(
context.read<JobsCubit>().addJob( ServiceToggleJob(
ServiceToggleJob( service: service,
service: service, needToTurnOn: serviceDisabled,
needToTurnOn: serviceDisabled,
),
), ),
}, ),
leading: const Icon(Icons.power_settings_new), leading: const Icon(Icons.power_settings_new),
title: Text( title: Text(
serviceDisabled serviceDisabled

View File

@ -51,10 +51,7 @@ class _ServicesPageState extends State<ServicesPage> {
iconData: BrandIcons.box, iconData: BrandIcons.box,
) )
: RefreshIndicator( : RefreshIndicator(
onRefresh: () async { onRefresh: context.read<ServicesBloc>().awaitReload,
// Create a ServicesRelaod event and wait for the state to change.
await context.read<ServicesBloc>().awaitReload();
},
child: ListView( child: ListView(
padding: paddingH15V0, padding: paddingH15V0,
children: [ children: [

View File

@ -46,17 +46,15 @@ class UserDetailsPage extends StatelessWidget {
const SizedBox(height: 8), const SizedBox(height: 8),
ListTile( ListTile(
iconColor: Theme.of(context).colorScheme.onBackground, iconColor: Theme.of(context).colorScheme.onBackground,
onTap: () => { onTap: () => showModalBottomSheet(
showModalBottomSheet( context: context,
context: context, isScrollControlled: true,
isScrollControlled: true, useRootNavigator: true,
useRootNavigator: true, builder: (final BuildContext context) => Padding(
builder: (final BuildContext context) => Padding( padding: MediaQuery.of(context).viewInsets,
padding: MediaQuery.of(context).viewInsets, child: ResetPassword(user: user),
child: ResetPassword(user: user),
),
), ),
}, ),
leading: const Icon(Icons.lock_reset_outlined), leading: const Icon(Icons.lock_reset_outlined),
title: Text( title: Text(
'users.reset_password'.tr(), 'users.reset_password'.tr(),
@ -87,45 +85,43 @@ class _DeleteUserTile extends StatelessWidget {
Widget build(final BuildContext context) => ListTile( Widget build(final BuildContext context) => ListTile(
iconColor: Theme.of(context).colorScheme.error, iconColor: Theme.of(context).colorScheme.error,
textColor: Theme.of(context).colorScheme.error, textColor: Theme.of(context).colorScheme.error,
onTap: () => { onTap: () => showDialog(
showDialog( context: context,
context: context, // useRootNavigator: false,
// useRootNavigator: false, builder: (final BuildContext context) => AlertDialog(
builder: (final BuildContext context) => AlertDialog( title: Text('basis.confirmation'.tr()),
title: Text('basis.confirmation'.tr()), content: SingleChildScrollView(
content: SingleChildScrollView( child: ListBody(
child: ListBody( children: <Widget>[
children: <Widget>[ Text(
Text( 'users.delete_confirm_question'.tr(),
'users.delete_confirm_question'.tr(),
),
],
),
),
actions: <Widget>[
TextButton(
child: Text('basis.cancel'.tr()),
onPressed: () {
context.router.pop();
},
),
TextButton(
child: Text(
'basis.delete'.tr(),
style: TextStyle(
color: Theme.of(context).colorScheme.error,
),
), ),
onPressed: () { ],
context.read<JobsCubit>().addJob(DeleteUserJob(user: user)); ),
context.router.childControllers.first.pop();
context.router.pop();
},
),
],
), ),
actions: <Widget>[
TextButton(
child: Text('basis.cancel'.tr()),
onPressed: () {
context.router.pop();
},
),
TextButton(
child: Text(
'basis.delete'.tr(),
style: TextStyle(
color: Theme.of(context).colorScheme.error,
),
),
onPressed: () {
context.read<JobsCubit>().addJob(DeleteUserJob(user: user));
context.router.childControllers.first.pop();
context.router.pop();
},
),
],
), ),
}, ),
leading: const Icon(Icons.person_remove_outlined), leading: const Icon(Icons.person_remove_outlined),
title: Text( title: Text(
'users.delete_user'.tr(), 'users.delete_user'.tr(),