91 lines
2.4 KiB
Dart
91 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:trans_lark/generated/assets.dart';
|
|
|
|
class TBaseAppbarWidget extends StatelessWidget implements PreferredSizeWidget {
|
|
const TBaseAppbarWidget({
|
|
super.key,
|
|
this.backgroundColor,
|
|
this.backColor,
|
|
this.title,
|
|
this.titleWidget,
|
|
this.actionWidget,
|
|
this.onBackTap,
|
|
});
|
|
|
|
final Color? backgroundColor;
|
|
final Color? backColor;
|
|
final String? title;
|
|
final Widget? titleWidget;
|
|
final Widget? actionWidget;
|
|
final Function()? onBackTap;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AppBar(
|
|
backgroundColor: backgroundColor ?? Colors.white,
|
|
surfaceTintColor: Colors.transparent,
|
|
automaticallyImplyLeading: false,
|
|
centerTitle: false,
|
|
title: _buildTitle(context),
|
|
titleSpacing: 0.0,
|
|
leadingWidth: 0.0,
|
|
);
|
|
}
|
|
|
|
Widget _buildTitle(BuildContext context) {
|
|
return SizedBox(
|
|
height: preferredSize.height,
|
|
child: Row(
|
|
children: [
|
|
SizedBox(
|
|
width: 60,
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 4),
|
|
child: FittedBox(
|
|
fit: BoxFit.none,
|
|
child: ClipOval(
|
|
child: Material(
|
|
color: Colors.transparent,
|
|
child: InkWell(
|
|
onTap: onBackTap ?? Get.back,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(10.0),
|
|
child: Image.asset(
|
|
Assets.imagesAppbarBack,
|
|
width: 24,
|
|
height: 24,
|
|
color: backColor,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: titleWidget ??
|
|
Text(
|
|
title ?? '',
|
|
overflow: TextOverflow.ellipsis,
|
|
style: const TextStyle(
|
|
color: Colors.black,
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: 60,
|
|
child: actionWidget,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
|
|
}
|