2022-09-02 15:35:25 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
class CustomSliverAppBar extends StatelessWidget {
|
|
|
|
const CustomSliverAppBar({
|
2023-11-11 13:07:32 +01:00
|
|
|
super.key,
|
2022-09-02 15:35:25 +02:00
|
|
|
required this.title,
|
2022-09-06 15:40:49 +02:00
|
|
|
this.actions,
|
2022-09-02 15:35:25 +02:00
|
|
|
this.bottom,
|
2022-09-19 17:24:31 +02:00
|
|
|
this.isMainView = false,
|
2022-09-19 18:40:06 +02:00
|
|
|
this.onBackButtonPressed,
|
2023-11-11 13:07:32 +01:00
|
|
|
});
|
2023-01-30 13:35:06 +01:00
|
|
|
final Widget title;
|
|
|
|
final List<Widget>? actions;
|
|
|
|
final PreferredSizeWidget? bottom;
|
|
|
|
final bool isMainView;
|
|
|
|
final Function()? onBackButtonPressed;
|
2022-09-02 15:35:25 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return SliverAppBar(
|
|
|
|
pinned: true,
|
|
|
|
expandedHeight: 100.0,
|
2022-09-19 17:24:31 +02:00
|
|
|
automaticallyImplyLeading: !isMainView,
|
|
|
|
flexibleSpace: FlexibleSpaceBar(
|
|
|
|
titlePadding: EdgeInsets.only(
|
2022-09-19 18:40:06 +02:00
|
|
|
bottom: bottom != null ? 16.0 : 14.0,
|
2022-09-19 17:24:31 +02:00
|
|
|
left: isMainView ? 20.0 : 55.0,
|
|
|
|
),
|
|
|
|
title: title,
|
|
|
|
),
|
|
|
|
leading: isMainView
|
|
|
|
? null
|
|
|
|
: IconButton(
|
|
|
|
icon: Icon(
|
|
|
|
Icons.arrow_back,
|
2023-02-19 04:16:49 +01:00
|
|
|
color: Theme.of(context).textTheme.titleLarge!.color,
|
2022-09-19 17:24:31 +02:00
|
|
|
),
|
2022-09-19 18:40:06 +02:00
|
|
|
onPressed:
|
|
|
|
onBackButtonPressed ?? () => Navigator.of(context).pop(),
|
2022-09-19 17:24:31 +02:00
|
|
|
),
|
2022-09-02 15:35:25 +02:00
|
|
|
backgroundColor: MaterialStateColor.resolveWith(
|
|
|
|
(states) => states.contains(MaterialState.scrolledUnder)
|
2022-09-05 04:32:36 +02:00
|
|
|
? Theme.of(context).colorScheme.surface
|
|
|
|
: Theme.of(context).canvasColor,
|
2022-09-02 15:35:25 +02:00
|
|
|
),
|
2022-09-06 15:40:49 +02:00
|
|
|
actions: actions,
|
2022-09-02 15:35:25 +02:00
|
|
|
bottom: bottom,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|