2022-02-16 07:01:05 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2022-05-30 13:49:42 +00:00
|
|
|
import 'package:selfprivacy/ui/components/pre_styled_buttons/flash_fab.dart';
|
2022-02-16 07:01:05 +00:00
|
|
|
|
|
|
|
class BrandHeroScreen extends StatelessWidget {
|
|
|
|
const BrandHeroScreen({
|
2022-06-05 19:36:32 +00:00
|
|
|
required this.children,
|
|
|
|
final super.key,
|
2022-02-16 07:01:05 +00:00
|
|
|
this.hasBackButton = true,
|
|
|
|
this.hasFlashButton = true,
|
|
|
|
this.heroIcon,
|
2022-10-04 10:34:56 +00:00
|
|
|
this.heroIconWidget,
|
|
|
|
this.heroTitle = '',
|
2022-02-16 07:01:05 +00:00
|
|
|
this.heroSubtitle,
|
2022-05-19 14:26:57 +00:00
|
|
|
this.onBackButtonPressed,
|
2022-06-05 19:36:32 +00:00
|
|
|
});
|
2022-02-16 07:01:05 +00:00
|
|
|
|
|
|
|
final List<Widget> children;
|
|
|
|
final bool hasBackButton;
|
|
|
|
final bool hasFlashButton;
|
|
|
|
final IconData? heroIcon;
|
2022-10-04 10:34:56 +00:00
|
|
|
final Widget? heroIconWidget;
|
|
|
|
final String heroTitle;
|
2022-02-16 07:01:05 +00:00
|
|
|
final String? heroSubtitle;
|
2022-05-19 14:26:57 +00:00
|
|
|
final VoidCallback? onBackButtonPressed;
|
2022-02-16 07:01:05 +00:00
|
|
|
|
|
|
|
@override
|
2022-10-04 10:34:56 +00:00
|
|
|
Widget build(final BuildContext context) {
|
|
|
|
final Widget heroIconWidget = this.heroIconWidget ??
|
|
|
|
Icon(
|
|
|
|
heroIcon ?? Icons.help,
|
|
|
|
size: 48.0,
|
|
|
|
color: Theme.of(context).colorScheme.onBackground,
|
|
|
|
);
|
|
|
|
final bool hasHeroIcon = heroIcon != null || this.heroIconWidget != null;
|
|
|
|
const EdgeInsetsGeometry heroTitlePadding = EdgeInsets.only(
|
|
|
|
bottom: 12.0,
|
|
|
|
top: 16.0,
|
|
|
|
);
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
floatingActionButton: hasFlashButton ? const BrandFab() : null,
|
|
|
|
body: CustomScrollView(
|
|
|
|
slivers: [
|
|
|
|
SliverAppBar(
|
|
|
|
expandedHeight: hasHeroIcon ? 160.0 : 96.0,
|
|
|
|
pinned: true,
|
|
|
|
stretch: true,
|
|
|
|
leading: hasBackButton
|
|
|
|
? IconButton(
|
|
|
|
icon: const Icon(Icons.arrow_back),
|
|
|
|
onPressed: onBackButtonPressed ??
|
|
|
|
() => Navigator.of(context).pop(),
|
|
|
|
)
|
|
|
|
: null,
|
|
|
|
flexibleSpace: FlexibleSpaceBar(
|
|
|
|
title: Text(
|
|
|
|
heroTitle,
|
|
|
|
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
|
|
|
color: Theme.of(context).colorScheme.onSurface,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
expandedTitleScale: 1.2,
|
|
|
|
centerTitle: true,
|
|
|
|
collapseMode: CollapseMode.pin,
|
|
|
|
titlePadding: heroTitlePadding,
|
|
|
|
background: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
if (hasHeroIcon) heroIconWidget,
|
|
|
|
],
|
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
2022-02-16 07:01:05 +00:00
|
|
|
),
|
2022-10-04 10:34:56 +00:00
|
|
|
if (heroSubtitle != null)
|
|
|
|
SliverPadding(
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
horizontal: 16.0,
|
|
|
|
vertical: 4.0,
|
|
|
|
),
|
|
|
|
sliver: SliverList(
|
|
|
|
delegate: SliverChildListDelegate([
|
|
|
|
Text(
|
|
|
|
heroSubtitle!,
|
|
|
|
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
|
|
|
color: Theme.of(context).colorScheme.onBackground,
|
|
|
|
),
|
|
|
|
textAlign: hasHeroIcon ? TextAlign.center : TextAlign.start,
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
2022-10-04 10:34:56 +00:00
|
|
|
]),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SliverPadding(
|
|
|
|
padding: const EdgeInsets.all(16.0),
|
|
|
|
sliver: SliverList(
|
|
|
|
delegate: SliverChildListDelegate(children),
|
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
2022-10-04 10:34:56 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2022-02-16 07:01:05 +00:00
|
|
|
}
|