2020-10-19 19:28:45 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2021-09-01 12:38:32 +00:00
|
|
|
import 'package:flutter/services.dart';
|
2020-10-19 19:28:45 +00:00
|
|
|
import 'package:freezer/settings.dart';
|
|
|
|
|
|
|
|
class LeadingIcon extends StatelessWidget {
|
|
|
|
final IconData icon;
|
2021-09-01 12:38:32 +00:00
|
|
|
final Color? color;
|
2020-10-19 19:28:45 +00:00
|
|
|
LeadingIcon(this.icon, {this.color});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Container(
|
|
|
|
width: 42.0,
|
|
|
|
height: 42.0,
|
|
|
|
decoration: BoxDecoration(
|
2021-09-01 12:38:32 +00:00
|
|
|
color: (color ?? Theme.of(context).primaryColor).withOpacity(1.0),
|
|
|
|
shape: BoxShape.circle),
|
2020-10-19 19:28:45 +00:00
|
|
|
child: Icon(
|
|
|
|
icon,
|
|
|
|
color: Colors.white,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Container with set size to match LeadingIcon
|
|
|
|
class EmptyLeading extends StatelessWidget {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Container(width: 42.0, height: 42.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class FreezerAppBar extends StatelessWidget implements PreferredSizeWidget {
|
2021-09-01 12:38:32 +00:00
|
|
|
final String? title;
|
2020-10-19 19:28:45 +00:00
|
|
|
final List<Widget> actions;
|
2021-09-01 12:38:32 +00:00
|
|
|
final Widget? bottom;
|
2020-10-19 19:28:45 +00:00
|
|
|
//Should be specified if bottom is specified
|
|
|
|
final double height;
|
2021-09-02 20:45:14 +00:00
|
|
|
final SystemUiOverlayStyle? systemUiOverlayStyle;
|
2020-10-19 19:28:45 +00:00
|
|
|
|
2021-09-02 20:45:14 +00:00
|
|
|
const FreezerAppBar(this.title,
|
|
|
|
{this.actions = const [],
|
|
|
|
this.bottom,
|
|
|
|
this.height = 56.0,
|
|
|
|
this.systemUiOverlayStyle});
|
2021-09-01 12:38:32 +00:00
|
|
|
|
2020-10-19 19:28:45 +00:00
|
|
|
Size get preferredSize => Size.fromHeight(this.height);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Theme(
|
2021-09-01 12:38:32 +00:00
|
|
|
data: ThemeData(
|
|
|
|
primaryColor: (Theme.of(context).brightness == Brightness.light)
|
|
|
|
? Colors.white
|
|
|
|
: Colors.black),
|
2020-10-19 19:28:45 +00:00
|
|
|
child: AppBar(
|
2021-09-02 20:45:14 +00:00
|
|
|
systemOverlayStyle: systemUiOverlayStyle,
|
2020-10-19 19:28:45 +00:00
|
|
|
elevation: 0.0,
|
|
|
|
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
|
|
|
title: Text(
|
2021-09-01 12:38:32 +00:00
|
|
|
title!,
|
2020-10-19 19:28:45 +00:00
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.w900,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
actions: actions,
|
2021-09-01 12:38:32 +00:00
|
|
|
bottom: bottom as PreferredSizeWidget?,
|
2020-10-19 19:28:45 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class FreezerDivider extends StatelessWidget {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Divider(
|
|
|
|
thickness: 1.5,
|
|
|
|
indent: 16.0,
|
|
|
|
endIndent: 16.0,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle popupMenuTextStyle() {
|
2021-09-01 12:38:32 +00:00
|
|
|
return TextStyle(color: settings.isDark ? Colors.white : Colors.black);
|
|
|
|
}
|