torrent list
This commit is contained in:
parent
d8ee8a3a24
commit
0d7aac068c
23 changed files with 1285 additions and 698 deletions
ui/lib/components
91
ui/lib/components/sliver_header.dart
Normal file
91
ui/lib/components/sliver_header.dart
Normal file
|
@ -0,0 +1,91 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class HideableHeaderSliver extends StatelessWidget {
|
||||
final Widget? leading;
|
||||
final Widget body;
|
||||
final double height;
|
||||
final List<Widget>? actions;
|
||||
|
||||
const HideableHeaderSliver({
|
||||
super.key,
|
||||
this.leading,
|
||||
required this.body,
|
||||
this.actions,
|
||||
this.height = 150,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SliverPersistentHeader(
|
||||
floating: true,
|
||||
pinned: false,
|
||||
delegate: _HideableHeaderSliverDelegate(
|
||||
leading: leading,
|
||||
body: body,
|
||||
actions: actions,
|
||||
height: height,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _HideableHeaderSliverDelegate extends SliverPersistentHeaderDelegate {
|
||||
final Widget? leading;
|
||||
final Widget body;
|
||||
final List<Widget>? actions;
|
||||
final double height;
|
||||
|
||||
const _HideableHeaderSliverDelegate({
|
||||
required this.leading,
|
||||
required this.body,
|
||||
required this.actions,
|
||||
required this.height,
|
||||
});
|
||||
|
||||
@override
|
||||
double get maxExtent => height;
|
||||
|
||||
@override
|
||||
double get minExtent => height;
|
||||
|
||||
@override
|
||||
bool shouldRebuild(covariant SliverPersistentHeaderDelegate oldDelegate) => true;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) {
|
||||
final content = <Widget>[
|
||||
if (leading != null) leading!,
|
||||
Expanded(child: body),
|
||||
if (actions != null && actions!.isNotEmpty) ButtonBar(children: actions!),
|
||||
];
|
||||
|
||||
final appBarTheme = AppBarTheme.of(context);
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
final onTop = (shrinkOffset == 0);
|
||||
|
||||
return Material(
|
||||
color:
|
||||
onTop ? appBarTheme.backgroundColor ?? colorScheme.surface : colorScheme.surfaceContainer,
|
||||
elevation: onTop ? 0 : appBarTheme.elevation ?? 3,
|
||||
surfaceTintColor: appBarTheme.surfaceTintColor ?? colorScheme.surfaceTint,
|
||||
child: ClipRect(
|
||||
child: SizedBox(
|
||||
height: maxExtent,
|
||||
child: Column(
|
||||
children: [
|
||||
const Spacer(),
|
||||
Row(
|
||||
children: content,
|
||||
),
|
||||
const Spacer(),
|
||||
const Divider(
|
||||
height: 1,
|
||||
thickness: 1,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue