diff --git a/lib/ui/components/pre_styled_buttons/flash_fab.dart b/lib/ui/components/pre_styled_buttons/flash_fab.dart index 5378838e..6c4810b6 100644 --- a/lib/ui/components/pre_styled_buttons/flash_fab.dart +++ b/lib/ui/components/pre_styled_buttons/flash_fab.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:ionicons/ionicons.dart'; import 'package:selfprivacy/logic/cubit/client_jobs/client_jobs_cubit.dart'; -import 'package:selfprivacy/ui/components/jobs_content/jobs_content.dart'; +import 'package:selfprivacy/utils/show_jobs_modal.dart'; class BrandFab extends StatefulWidget { const BrandFab({ @@ -60,19 +60,7 @@ class _BrandFabState extends State child: FloatingActionButton( onPressed: () { // TODO: Make a hero animation to the screen - showModalBottomSheet( - context: context, - useRootNavigator: true, - isScrollControlled: true, - builder: (final BuildContext context) => DraggableScrollableSheet( - expand: false, - maxChildSize: 0.9, - minChildSize: 0.4, - initialChildSize: 0.6, - builder: (final context, final scrollController) => - JobsContent(controller: scrollController), - ), - ); + showModalJobsSheet(context: context); }, isExtended: widget.extended, tooltip: 'jobs.title'.tr(), diff --git a/lib/ui/layouts/brand_hero_screen.dart b/lib/ui/layouts/brand_hero_screen.dart index a82ed720..638ec2be 100644 --- a/lib/ui/layouts/brand_hero_screen.dart +++ b/lib/ui/layouts/brand_hero_screen.dart @@ -4,9 +4,9 @@ import 'package:flutter/material.dart'; import 'package:ionicons/ionicons.dart'; import 'package:selfprivacy/logic/cubit/client_jobs/client_jobs_cubit.dart'; import 'package:selfprivacy/ui/components/drawers/support_drawer.dart'; -import 'package:selfprivacy/ui/components/jobs_content/jobs_content.dart'; import 'package:selfprivacy/ui/helpers/widget_size.dart'; import 'package:selfprivacy/utils/breakpoints.dart'; +import 'package:selfprivacy/utils/show_jobs_modal.dart'; class BrandHeroScreen extends StatelessWidget { const BrandHeroScreen({ @@ -146,20 +146,7 @@ class _HeroSliverAppBarState extends State { duration: const Duration(milliseconds: 300), child: IconButton( onPressed: () { - showModalBottomSheet( - context: context, - useRootNavigator: true, - isScrollControlled: true, - builder: (final BuildContext context) => - DraggableScrollableSheet( - expand: false, - maxChildSize: 0.9, - minChildSize: 0.4, - initialChildSize: 0.6, - builder: (final context, final scrollController) => - JobsContent(controller: scrollController), - ), - ); + showModalJobsSheet(context: context); }, icon: Icon( isJobsListEmpty ? Ionicons.flash_outline : Ionicons.flash, diff --git a/lib/ui/pages/server_storage/binds_migration/services_migration.dart b/lib/ui/pages/server_storage/binds_migration/services_migration.dart index 0fc2c7d2..c62a9d4f 100644 --- a/lib/ui/pages/server_storage/binds_migration/services_migration.dart +++ b/lib/ui/pages/server_storage/binds_migration/services_migration.dart @@ -9,9 +9,9 @@ import 'package:selfprivacy/logic/models/service.dart'; import 'package:selfprivacy/ui/components/brand_header/brand_header.dart'; import 'package:selfprivacy/ui/components/buttons/brand_button.dart'; import 'package:selfprivacy/ui/components/info_box/info_box.dart'; -import 'package:selfprivacy/ui/components/jobs_content/jobs_content.dart'; import 'package:selfprivacy/ui/components/storage_list_items/server_storage_list_item.dart'; import 'package:selfprivacy/ui/components/storage_list_items/service_migration_list_item.dart'; +import 'package:selfprivacy/utils/show_jobs_modal.dart'; @RoutePage() class ServicesMigrationPage extends StatefulWidget { @@ -191,20 +191,7 @@ class _ServicesMigrationPageState extends State { } } context.router.popUntilRoot(); - showModalBottomSheet( - context: context, - useRootNavigator: true, - isScrollControlled: true, - builder: (final BuildContext context) => - DraggableScrollableSheet( - expand: false, - maxChildSize: 0.9, - minChildSize: 0.4, - initialChildSize: 0.6, - builder: (final context, final scrollController) => - JobsContent(controller: scrollController), - ), - ); + showModalJobsSheet(context: context); }, ), const SizedBox(height: 32), diff --git a/lib/ui/pages/server_storage/server_storage.dart b/lib/ui/pages/server_storage/server_storage.dart index 2f7932a8..d8bd5972 100644 --- a/lib/ui/pages/server_storage/server_storage.dart +++ b/lib/ui/pages/server_storage/server_storage.dart @@ -12,6 +12,7 @@ import 'package:selfprivacy/ui/components/buttons/outlined_button.dart'; import 'package:selfprivacy/ui/components/storage_list_items/server_storage_list_item.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; import 'package:selfprivacy/ui/router/router.dart'; +import 'package:selfprivacy/utils/show_jobs_modal.dart'; @RoutePage() class ServerStoragePage extends StatefulWidget { @@ -73,7 +74,10 @@ class _ServerStoragePageState extends State { padding: const EdgeInsets.symmetric(horizontal: 16.0), child: BrandOutlinedButton( title: 'jobs.collect_nix_garbage'.tr(), - onPressed: context.read().collectNixGarbage, + onPressed: () { + context.read().collectNixGarbage(); + showModalJobsSheet(context: context); + }, ), ), ], diff --git a/lib/utils/show_jobs_modal.dart b/lib/utils/show_jobs_modal.dart new file mode 100644 index 00000000..81e7d92f --- /dev/null +++ b/lib/utils/show_jobs_modal.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; +import 'package:selfprivacy/ui/components/jobs_content/jobs_content.dart'; + +Future showModalJobsSheet({ + required final BuildContext context, +}) => + showModalBottomSheet( + context: context, + useRootNavigator: true, + isScrollControlled: true, + builder: (final BuildContext context) => DraggableScrollableSheet( + expand: false, + maxChildSize: 0.9, + minChildSize: 0.4, + initialChildSize: 0.6, + builder: (final context, final scrollController) => + JobsContent(controller: scrollController), + ), + );