WallPaper_FSX_Flutter/lib/common/components/title_bar_widget.dart
2024-05-13 13:44:27 +08:00

70 lines
1.6 KiB
Dart

// Author: fengshengxiong
// Date: 2024/5/11
// Description: 标题栏
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:wallpaper/res/themes/app_sizes.dart';
class TitleBarWidget extends StatelessWidget {
const TitleBarWidget({
super.key,
required this.title,
this.showMenuBtn = false,
this.deleteOnTap,
});
final String title;
final bool? showMenuBtn;
final Function()? deleteOnTap;
@override
Widget build(BuildContext context) {
return Container(
height: kTextTabBarHeight,
alignment: Alignment.centerLeft,
child: Row(
children: [
SizedBox(width: 16.w),
Expanded(
child: Text(
title,
style: TextStyle(
color: Colors.white,
fontSize: 22.sp,
fontWeight: FontWeight.bold,
),
),
),
if (showMenuBtn!) ...[
IconButton(
onPressed: () {
_showPopMenu(context);
},
icon: const Icon(Icons.menu, color: Colors.white),
),
],
],
),
);
}
void _showPopMenu(context) {
showMenu(
context: context,
surfaceTintColor: Colors.white,
position: RelativeRect.fromLTRB(double.infinity, statusToolBarHeight, 0.0, 0.0),
items: [
PopupMenuItem<String>(
value: 'delete',
onTap: deleteOnTap,
child: const ListTile(
leading: Icon(Icons.delete),
title: Text('Delete All'),
),
),
],
);
}
}