Houshan-Basa/lib/ui/widgets/sections/header/primary_appbar.dart

55 lines
1.7 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:hoshan/ui/screens/main/home_page.dart';
import 'package:hoshan/ui/theme/colors.dart';
import 'package:hoshan/ui/theme/responsive.dart';
import 'package:hoshan/ui/theme/text.dart';
class PrimaryAppbar extends StatelessWidget implements PreferredSizeWidget {
final BuildContext context;
final List<Widget>? actions;
final String? titleText;
final Function()? onBack;
const PrimaryAppbar(this.context,
{super.key, this.actions, this.titleText, this.onBack});
@override
Widget build(BuildContext context) {
return AppBar(
title: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
if (titleText != null)
Text(
titleText!,
style: AppTextStyles.body3
.copyWith(color: Theme.of(context).colorScheme.onSurface),
),
],
),
actions: actions,
automaticallyImplyLeading: false,
toolbarHeight: preferredSize.height,
leadingWidth: 100,
leading: GestureDetector(
onTap: () {
onBack?.call();
screenIndex.value = 0;
},
child: Container(
color: Theme.of(context).appBarTheme.backgroundColor,
alignment: Alignment.centerLeft,
padding: const EdgeInsets.symmetric(horizontal: 16),
child: const Icon(CupertinoIcons.back)),
),
shadowColor: AppColors.black.defaultShade.withValues(alpha: 0.15),
elevation: 4,
);
}
@override
Size get preferredSize => Size.fromHeight(
kToolbarHeight + (Responsive(context).isMobile() ? 12 : 32));
}