mnemo_cards/lib/widgets/header.dart

119 lines
3.3 KiB
Dart
Raw Normal View History

2024-05-22 20:48:44 +00:00
import 'dart:math';
import 'package:auto_route/auto_route.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class Header extends StatelessWidget {
final String? title;
final String? subtitle;
final bool hasPopButton;
final String? popText;
final Widget? trail;
2024-05-31 14:35:41 +00:00
final Color? color;
2024-05-22 20:48:44 +00:00
Header(
this.title, {
this.subtitle,
this.hasPopButton = false,
this.popText,
this.trail,
2024-05-31 14:35:41 +00:00
this.color,
2024-05-22 20:48:44 +00:00
});
@override
Widget build(BuildContext context) {
2024-05-31 14:35:41 +00:00
final topPadding = 74.h -
2024-05-22 20:48:44 +00:00
MediaQuery.of(context).padding.top -
2024-05-31 14:35:41 +00:00
(hasPopButton ? 30.0.h : 0.0);
2024-05-22 20:48:44 +00:00
return Container(
2024-05-31 14:35:41 +00:00
color: color,
2024-05-22 20:48:44 +00:00
alignment: Alignment.centerLeft,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: max(
topPadding / 2,
0,
),
),
if (hasPopButton)
Padding(
padding: EdgeInsets.only(left: 10.0.w),
child: TapRegion(
onTapInside: AutoRouter.of(context).maybePop,
behavior: HitTestBehavior.opaque,
child: SizedBox(
height: 30.h,
child: Row(
children: [
Image.asset(
'icons/back.png',
color: Colors.black,
width: 17,
height: 23.h,
),
if (popText != null)
Padding(
padding: const EdgeInsets.only(left: 4.0),
child: Text(
popText!,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
),
),
),
],
),
),
),
),
SizedBox(
height: max(
topPadding / 2,
0,
),
),
Container(
padding: EdgeInsets.only(left: 20.0.w, right: 24.w),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (title != null)
2024-05-31 14:35:41 +00:00
Text(
title!,
style: TextStyle(
fontSize: 36.sp,
fontWeight: FontWeight.w500,
height: 0.85,
),
textAlign: TextAlign.start,
2024-05-22 20:48:44 +00:00
),
if (trail != null) trail!,
],
),
),
if (subtitle != null)
Container(
2024-05-31 14:35:41 +00:00
padding: EdgeInsets.only(top: 4.0.h, left: 22.0.w, bottom: 4.0.h),
2024-05-22 20:48:44 +00:00
alignment: Alignment.centerLeft,
child: Text(
subtitle!,
style: TextStyle(
fontSize: 20.sp,
fontWeight: FontWeight.w300,
height: 0.85,
),
),
),
],
),
);
}
}