61 lines
1.8 KiB
Dart
61 lines
1.8 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:hoshan/core/routes/route_generator.dart';
|
|
import 'package:hoshan/ui/theme/colors.dart';
|
|
import 'package:hoshan/ui/theme/responsive.dart';
|
|
import 'package:hoshan/ui/theme/text.dart';
|
|
|
|
class ReversibleAppbar extends StatelessWidget implements PreferredSizeWidget {
|
|
final Widget? title;
|
|
final String? titleText;
|
|
final BuildContext context;
|
|
|
|
const ReversibleAppbar(this.context, {super.key, this.title, this.titleText});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AppBar(
|
|
title: Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
title ??
|
|
Text(
|
|
titleText ?? '',
|
|
style: Responsive(context).isMobile()
|
|
? AppTextStyles.body3
|
|
: AppTextStyles.body1,
|
|
),
|
|
],
|
|
),
|
|
toolbarHeight: preferredSize.height,
|
|
automaticallyImplyLeading: false,
|
|
leadingWidth: 100,
|
|
leading: GestureDetector(
|
|
onTap: () {
|
|
try {
|
|
context.pop();
|
|
} catch (e) {
|
|
context.go(Routes.main);
|
|
}
|
|
},
|
|
child: Container(
|
|
color: Theme.of(context).appBarTheme.backgroundColor,
|
|
alignment: Alignment.centerLeft,
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
child: Icon(
|
|
CupertinoIcons.back,
|
|
size: Responsive(context).isMobile() ? null : 32,
|
|
),
|
|
),
|
|
),
|
|
shadowColor: AppColors.black.defaultShade.withValues(alpha: 0.15),
|
|
elevation: 4,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Size get preferredSize => Size.fromHeight(
|
|
kToolbarHeight + (Responsive(context).isMobile() ? 0 : 32));
|
|
}
|