This repository has been archived by the owner on Dec 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathaqua_scaffold.dart
105 lines (93 loc) · 3.1 KB
/
aqua_scaffold.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import "package:aqua/src/common_widgets/analytics.dart";
import "package:aqua/src/common_widgets/aqua_button.dart";
import "package:aqua/src/common_widgets/aqua_icons.dart";
import "package:aqua/src/common_widgets/aqua_theme.dart";
import "package:flutter/widgets.dart";
@immutable
class AquaScadffold extends StatelessWidget {
AquaScadffold({
Key? key,
this.scrollController,
this.title = "Title",
this.actions = const [],
this.slivers = const [],
}) : super(key: key);
final ScrollController? scrollController;
final String title;
final List<Widget> actions;
final List<Widget> slivers;
@override
Widget build(BuildContext context) {
final theme = AquaTheme.of(context);
final style = theme.scaffoldStyle;
final defaultActionButtonStyle =
theme.buttonStyleSet[style.defaultActionButtonvariant];
return Container(
color: style.backgroundColor,
child: CustomScrollView(
controller: scrollController,
slivers: [
SliverSafeArea(
sliver: SliverPadding(
padding: const EdgeInsets.fromLTRB(16, 32, 16, 16),
sliver: SliverToBoxAdapter(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
if (ModalRoute.of(context)?.canPop ?? false) ...[
AquaButton(
variant: AquaButtonVariant.secondary,
icon: AquaIcons.chevronLeft,
onTap: () {
Analytics.of(context).logEvent(
name: "Tap a Scaffold Back Button",
);
Navigator.of(context).pop();
},
),
SizedBox(width: 16),
],
Text(
title,
textAlign: TextAlign.start,
style: style.titleTextStyle,
),
],
),
DefaultAquaButtonStyle(
style: defaultActionButtonStyle,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: actions,
),
),
],
),
),
),
),
...slivers,
SliverSafeArea(
bottom: true,
sliver: SliverPadding(
padding: EdgeInsets.only(bottom: 64.0),
),
),
],
),
);
}
}
@immutable
class AquaScaffoldStyle {
const AquaScaffoldStyle({
required this.titleTextStyle,
this.defaultActionButtonvariant = AquaButtonVariant.secondary,
required this.backgroundColor,
});
final TextStyle titleTextStyle;
final AquaButtonVariant defaultActionButtonvariant;
final Color backgroundColor;
}