feat: update home ui
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../common/extension/extension.dart';
|
||||
import '../../../../common/theme/theme.dart';
|
||||
import '../../../../domain/user/user.dart';
|
||||
import '../../../components/assets/assets.gen.dart';
|
||||
import '../../../components/spacer/spacer.dart';
|
||||
|
||||
class HeaderTopBar extends StatelessWidget {
|
||||
final User user;
|
||||
const HeaderTopBar({super.key, required this.user});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
// Logo + Greeting
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Assets.images.logo.image(width: 64),
|
||||
Text(
|
||||
'${_greeting(context)}, ${user.name}',
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.white.withOpacity(0.9),
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Notification
|
||||
GestureDetector(
|
||||
onTap: () {},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.white.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.notifications_none_rounded,
|
||||
color: AppColor.white,
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SpaceWidth(8),
|
||||
|
||||
// Avatar
|
||||
Container(
|
||||
width: 36,
|
||||
height: 36,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
_getInitials(user.name),
|
||||
style: AppStyle.sm.copyWith(
|
||||
color: AppColor.primary,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
String _greeting(BuildContext context) {
|
||||
final hour = DateTime.now().hour;
|
||||
if (hour >= 4 && hour < 10) return context.lang.good_morning;
|
||||
if (hour >= 10 && hour < 15) return context.lang.good_afternoon;
|
||||
if (hour >= 15 && hour < 18) return context.lang.good_evening;
|
||||
return context.lang.good_night;
|
||||
}
|
||||
|
||||
String _getInitials(String name) {
|
||||
final parts = name.trim().split(' ');
|
||||
if (parts.length >= 2) {
|
||||
return '${parts[0][0]}${parts[1][0]}'.toUpperCase();
|
||||
}
|
||||
return parts[0].isNotEmpty ? parts[0][0].toUpperCase() : '';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user