revanced-manager/lib/ui/widgets/shared/custom_sliver_app_bar.dart
2022-09-19 16:24:31 +01:00

51 lines
1.3 KiB
Dart

import 'package:flutter/material.dart';
class CustomSliverAppBar extends StatelessWidget {
final Widget title;
final List<Widget>? actions;
final PreferredSizeWidget? bottom;
final bool isMainView;
const CustomSliverAppBar({
Key? key,
required this.title,
this.actions,
this.bottom,
this.isMainView = false,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return SliverAppBar(
pinned: true,
snap: false,
floating: false,
expandedHeight: 100.0,
automaticallyImplyLeading: !isMainView,
flexibleSpace: FlexibleSpaceBar(
titlePadding: EdgeInsets.only(
bottom: 14.0,
left: isMainView ? 20.0 : 55.0,
),
title: title,
),
leading: isMainView
? null
: IconButton(
icon: Icon(
Icons.arrow_back,
color: Theme.of(context).textTheme.headline6!.color,
),
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: MaterialStateColor.resolveWith(
(states) => states.contains(MaterialState.scrolledUnder)
? Theme.of(context).colorScheme.surface
: Theme.of(context).canvasColor,
),
actions: actions,
bottom: bottom,
);
}
}