diff --git a/lib/logic/get_it/navigation.dart b/lib/logic/get_it/navigation.dart index 7a43bcd7..977b4a86 100644 --- a/lib/logic/get_it/navigation.dart +++ b/lib/logic/get_it/navigation.dart @@ -12,7 +12,7 @@ class NavigationService { if (context == null) { showSnackBar( - 'Could not show dialog. This should not happen, please report this.', + 'Could not show dialog. This should not happen, please report this.', ); return; } diff --git a/lib/ui/layouts/brand_hero_screen.dart b/lib/ui/layouts/brand_hero_screen.dart index 6782880a..37b1f3ea 100644 --- a/lib/ui/layouts/brand_hero_screen.dart +++ b/lib/ui/layouts/brand_hero_screen.dart @@ -1,6 +1,10 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; -import 'package:selfprivacy/ui/components/pre_styled_buttons/flash_fab.dart'; +import 'package:ionicons/ionicons.dart'; +import 'package:selfprivacy/logic/cubit/client_jobs/client_jobs_cubit.dart'; +import 'package:selfprivacy/ui/components/brand_bottom_sheet/brand_bottom_sheet.dart'; +import 'package:selfprivacy/ui/components/jobs_content/jobs_content.dart'; +import 'package:selfprivacy/ui/helpers/modals.dart'; import 'package:selfprivacy/ui/helpers/widget_size.dart'; import 'package:selfprivacy/utils/breakpoints.dart'; @@ -20,7 +24,6 @@ class BrandHeroScreen extends StatelessWidget { final List children; final bool hasBackButton; - @Deprecated('Flash button is now provided by root scaffold') final bool hasFlashButton; final IconData? heroIcon; final Widget? heroIconWidget; @@ -40,7 +43,6 @@ class BrandHeroScreen extends StatelessWidget { final bool hasHeroIcon = heroIcon != null || this.heroIconWidget != null; return Scaffold( - floatingActionButton: hasFlashButton ? const BrandFab() : null, body: CustomScrollView( slivers: [ HeroSliverAppBar( @@ -49,6 +51,7 @@ class BrandHeroScreen extends StatelessWidget { hasBackButton: hasBackButton, onBackButtonPressed: onBackButtonPressed, heroIconWidget: heroIconWidget, + hasFlashButton: hasFlashButton, ), if (heroSubtitle != null) SliverPadding( @@ -87,12 +90,14 @@ class HeroSliverAppBar extends StatefulWidget { required this.hasBackButton, required this.onBackButtonPressed, required this.heroIconWidget, + required this.hasFlashButton, super.key, }); final String heroTitle; final bool hasHeroIcon; final bool hasBackButton; + final bool hasFlashButton; final VoidCallback? onBackButtonPressed; final Widget heroIconWidget; @@ -105,6 +110,7 @@ class _HeroSliverAppBarState extends State { @override Widget build(final BuildContext context) { final isMobile = Breakpoints.small.isActive(context); + final isJobsListEmpty = context.watch().state is JobsStateEmpty; return SliverAppBar( expandedHeight: widget.hasHeroIcon ? 148.0 + _size.height : 72.0 + _size.height, @@ -115,6 +121,30 @@ class _HeroSliverAppBarState extends State { leading: (widget.hasBackButton && isMobile) ? const AutoLeadingButton() : const SizedBox.shrink(), + actions: [ + if (widget.hasFlashButton && isMobile) + AnimatedSwitcher( + duration: const Duration(milliseconds: 300), + child: IconButton( + onPressed: () { + showBrandBottomSheet( + context: context, + builder: (final BuildContext context) => + const BrandBottomSheet( + isExpended: true, + child: JobsContent(), + ), + ); + }, + icon: Icon( + isJobsListEmpty ? Ionicons.flash_outline : Ionicons.flash, + ), + color: isJobsListEmpty + ? Theme.of(context).colorScheme.onBackground + : Theme.of(context).colorScheme.primary, + ), + ), + ], flexibleSpace: FlexibleSpaceBar( title: LayoutBuilder( builder: (final context, final constraints) => SizedBox( diff --git a/lib/ui/pages/server_details/server_details_screen.dart b/lib/ui/pages/server_details/server_details_screen.dart index e1f8f713..aa843b6c 100644 --- a/lib/ui/pages/server_details/server_details_screen.dart +++ b/lib/ui/pages/server_details/server_details_screen.dart @@ -77,6 +77,7 @@ class _ServerDetailsScreenState extends State return BlocProvider( create: (final context) => context.read()..check(), child: BrandHeroScreen( + hasFlashButton: true, heroIcon: BrandIcons.server, heroTitle: 'server.card_title'.tr(), heroSubtitle: 'server.description'.tr(), diff --git a/lib/ui/pages/services/service_page.dart b/lib/ui/pages/services/service_page.dart index a015a51a..ff3b0e38 100644 --- a/lib/ui/pages/services/service_page.dart +++ b/lib/ui/pages/services/service_page.dart @@ -47,6 +47,7 @@ class _ServicePageState extends State { return BrandHeroScreen( hasBackButton: true, + hasFlashButton: true, heroIconWidget: SvgPicture.string( service.svgIcon, width: 48.0, diff --git a/lib/ui/pages/users/user_details.dart b/lib/ui/pages/users/user_details.dart index f20ff543..38743878 100644 --- a/lib/ui/pages/users/user_details.dart +++ b/lib/ui/pages/users/user_details.dart @@ -26,6 +26,7 @@ class UserDetailsPage extends StatelessWidget { if (user.type == UserType.root) { return BrandHeroScreen( hasBackButton: true, + hasFlashButton: true, heroTitle: 'ssh.root_title'.tr(), heroSubtitle: 'ssh.root_subtitle'.tr(), children: [ @@ -36,6 +37,7 @@ class UserDetailsPage extends StatelessWidget { return BrandHeroScreen( hasBackButton: true, + hasFlashButton: true, heroTitle: user.login, children: [ _UserLogins(user: user, domainName: domainName),