// 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( value: 'delete', onTap: deleteOnTap, child: const ListTile( leading: Icon(Icons.delete), title: Text('Delete All'), ), ), ], ); } }