Wallpaper-Genie/lib/common/components/navigation_bar/custom_appbar.dart
2024-07-22 19:13:11 +08:00

73 lines
2.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:wallpaperx/generated/assets.dart';
import 'package:wallpaperx/res/themes/app_colors.dart';
class CustomAppbar extends StatelessWidget implements PreferredSizeWidget {
const CustomAppbar(
this.title, {
super.key,
this.backgroundColor,
this.backWidget,
this.titleStyle,
this.onBackTap,
});
final Color? backgroundColor;
final Widget? backWidget;
final String title;
final TextStyle? titleStyle;
final Function()? onBackTap;
@override
Widget build(BuildContext context) {
return Container(
height: preferredSize.height,
padding: EdgeInsets.fromLTRB(10, ScreenUtil().statusBarHeight, 20, 0).w,
color: backgroundColor ?? seedColor,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
backWidget ??
ClipOval(
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: onBackTap ?? () => Get.back(),
child: Padding(
padding: const EdgeInsets.all(10).w,
child: Image.asset(
Assets.iconBack,
width: 32.w,
height: 32.w,
color: Colors.white,
),
),
),
),
),
Flexible(
child: Text(
title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: titleStyle ??
TextStyle(
color: Colors.black,
fontSize: 20.sp,
fontWeight: FontWeight.w500,
),
),
),
Container(width: 13.w),
],
),
);
}
@override
Size get preferredSize =>
Size.fromHeight(ScreenUtil().statusBarHeight + kToolbarHeight);
}