2024-04-01 08:41:52 +08:00
|
|
|
import 'package:flutter/material.dart';
|
2024-04-01 14:59:20 +08:00
|
|
|
import 'package:sk_base_mobile/util/util.dart';
|
2024-04-01 08:41:52 +08:00
|
|
|
|
|
|
|
class SkAppbar extends StatelessWidget implements PreferredSizeWidget {
|
|
|
|
final String title;
|
2024-04-01 14:27:44 +08:00
|
|
|
final List<Widget>? action;
|
2024-04-03 13:45:34 +08:00
|
|
|
final bool hideLeading;
|
2024-04-08 13:50:23 +08:00
|
|
|
final PreferredSizeWidget? bottom;
|
|
|
|
final Color? backgroundColor;
|
|
|
|
final Color? iconAndTextColor;
|
2024-04-15 10:59:12 +08:00
|
|
|
final Function()? onPop;
|
2024-04-03 13:45:34 +08:00
|
|
|
const SkAppbar(
|
2024-04-08 13:50:23 +08:00
|
|
|
{super.key,
|
|
|
|
required this.title,
|
|
|
|
this.action,
|
|
|
|
this.hideLeading = false,
|
|
|
|
this.backgroundColor,
|
|
|
|
this.iconAndTextColor,
|
2024-04-15 10:59:12 +08:00
|
|
|
this.onPop,
|
2024-04-08 13:50:23 +08:00
|
|
|
this.bottom});
|
2024-04-01 08:41:52 +08:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-04-01 14:27:44 +08:00
|
|
|
return AppBar(
|
2024-04-08 13:50:23 +08:00
|
|
|
titleTextStyle: TextStyle(
|
|
|
|
color: iconAndTextColor,
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
letterSpacing: ScreenAdaper.width(2)),
|
|
|
|
backgroundColor: backgroundColor,
|
|
|
|
bottom: bottom,
|
2024-04-03 13:45:34 +08:00
|
|
|
leading: hideLeading
|
|
|
|
? const SizedBox()
|
|
|
|
: IconButton(
|
|
|
|
icon: Icon(
|
|
|
|
Icons.arrow_back_ios,
|
|
|
|
size: ScreenAdaper.height(40),
|
2024-04-08 13:50:23 +08:00
|
|
|
color: iconAndTextColor,
|
2024-04-03 13:45:34 +08:00
|
|
|
),
|
2024-04-15 10:59:12 +08:00
|
|
|
onPressed: () async {
|
|
|
|
if (onPop != null) {
|
|
|
|
onPop!();
|
|
|
|
} else {
|
|
|
|
Navigator.pop(context);
|
|
|
|
}
|
2024-04-03 13:45:34 +08:00
|
|
|
},
|
|
|
|
),
|
2024-04-01 14:59:20 +08:00
|
|
|
title: Text(
|
|
|
|
title,
|
2024-04-01 17:35:34 +08:00
|
|
|
style: TextStyle(fontSize: ScreenAdaper.height(30)),
|
2024-04-01 14:59:20 +08:00
|
|
|
),
|
2024-04-01 14:27:44 +08:00
|
|
|
actions: action,
|
|
|
|
);
|
2024-04-01 08:41:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Size get preferredSize => Size.fromHeight(kToolbarHeight);
|
|
|
|
}
|