feat: current user
This commit is contained in:
parent
5387d7b7a6
commit
e7525238fe
@ -1,9 +1,13 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
|
import '../../../../application/auth/auth_bloc.dart';
|
||||||
|
import '../../../../common/constant/app_constant.dart';
|
||||||
import '../../../../common/extension/extension.dart';
|
import '../../../../common/extension/extension.dart';
|
||||||
import '../../../../common/painter/wave_painter.dart';
|
import '../../../../common/painter/wave_painter.dart';
|
||||||
import '../../../../common/theme/theme.dart';
|
import '../../../../common/theme/theme.dart';
|
||||||
|
import '../../../../domain/auth/auth.dart';
|
||||||
import '../../../components/spacer/spacer.dart';
|
import '../../../components/spacer/spacer.dart';
|
||||||
|
|
||||||
class HomeHeader extends StatefulWidget {
|
class HomeHeader extends StatefulWidget {
|
||||||
@ -102,6 +106,8 @@ class _HomeHeaderState extends State<HomeHeader> with TickerProviderStateMixin {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
return BlocBuilder<AuthBloc, AuthState>(
|
||||||
|
builder: (context, state) {
|
||||||
return AnimatedBuilder(
|
return AnimatedBuilder(
|
||||||
animation: Listenable.merge([
|
animation: Listenable.merge([
|
||||||
_particleController,
|
_particleController,
|
||||||
@ -136,12 +142,14 @@ class _HomeHeaderState extends State<HomeHeader> with TickerProviderStateMixin {
|
|||||||
_buildAnimatedBackground(),
|
_buildAnimatedBackground(),
|
||||||
|
|
||||||
// Main content
|
// Main content
|
||||||
SafeArea(child: _buildContent(context)),
|
SafeArea(child: _buildContent(context, state.user)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildAnimatedBackground() {
|
Widget _buildAnimatedBackground() {
|
||||||
@ -255,7 +263,7 @@ class _HomeHeaderState extends State<HomeHeader> with TickerProviderStateMixin {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildContent(BuildContext context) {
|
Widget _buildContent(BuildContext context, User user) {
|
||||||
String greeting(BuildContext context) {
|
String greeting(BuildContext context) {
|
||||||
final hour = DateTime.now().hour;
|
final hour = DateTime.now().hour;
|
||||||
|
|
||||||
@ -291,7 +299,7 @@ class _HomeHeaderState extends State<HomeHeader> with TickerProviderStateMixin {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'AppSkel POS Owner',
|
AppConstant.appName,
|
||||||
style: AppStyle.lg.copyWith(
|
style: AppStyle.lg.copyWith(
|
||||||
color: AppColor.white.withOpacity(0.9),
|
color: AppColor.white.withOpacity(0.9),
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
@ -307,7 +315,7 @@ class _HomeHeaderState extends State<HomeHeader> with TickerProviderStateMixin {
|
|||||||
),
|
),
|
||||||
const SpaceHeight(2),
|
const SpaceHeight(2),
|
||||||
Text(
|
Text(
|
||||||
'Manager',
|
user.role.toTitleCase,
|
||||||
style: AppStyle.sm.copyWith(
|
style: AppStyle.sm.copyWith(
|
||||||
color: AppColor.white.withOpacity(0.7),
|
color: AppColor.white.withOpacity(0.7),
|
||||||
fontSize: 11,
|
fontSize: 11,
|
||||||
@ -383,7 +391,7 @@ class _HomeHeaderState extends State<HomeHeader> with TickerProviderStateMixin {
|
|||||||
),
|
),
|
||||||
const SpaceHeight(2),
|
const SpaceHeight(2),
|
||||||
Text(
|
Text(
|
||||||
'Vira Vania! 👋',
|
'${user.name}! 👋',
|
||||||
style: AppStyle.h4.copyWith(
|
style: AppStyle.h4.copyWith(
|
||||||
color: AppColor.white,
|
color: AppColor.white,
|
||||||
fontWeight: FontWeight.w800,
|
fontWeight: FontWeight.w800,
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:line_icons/line_icons.dart';
|
import 'package:line_icons/line_icons.dart';
|
||||||
import 'package:loader_overlay/loader_overlay.dart';
|
import 'package:loader_overlay/loader_overlay.dart';
|
||||||
|
|
||||||
|
import '../../../application/auth/auth_bloc.dart';
|
||||||
import '../../../application/auth/logout_form/logout_form_bloc.dart';
|
import '../../../application/auth/logout_form/logout_form_bloc.dart';
|
||||||
import '../../../common/theme/theme.dart';
|
import '../../../common/theme/theme.dart';
|
||||||
import '../../../injection.dart';
|
import '../../../injection.dart';
|
||||||
@ -49,7 +50,9 @@ class ProfilePage extends StatelessWidget implements AutoRouteWrapper {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
child: Scaffold(
|
child: BlocBuilder<AuthBloc, AuthState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
return Scaffold(
|
||||||
backgroundColor: AppColor.background,
|
backgroundColor: AppColor.background,
|
||||||
body: CustomScrollView(
|
body: CustomScrollView(
|
||||||
slivers: [
|
slivers: [
|
||||||
@ -59,11 +62,13 @@ class ProfilePage extends StatelessWidget implements AutoRouteWrapper {
|
|||||||
pinned: true,
|
pinned: true,
|
||||||
expandedHeight: 264.0,
|
expandedHeight: 264.0,
|
||||||
flexibleSpace: LayoutBuilder(
|
flexibleSpace: LayoutBuilder(
|
||||||
builder: (BuildContext context, BoxConstraints constraints) {
|
builder:
|
||||||
|
(BuildContext context, BoxConstraints constraints) {
|
||||||
// Calculate the collapse ratio
|
// Calculate the collapse ratio
|
||||||
final double top = constraints.biggest.height;
|
final double top = constraints.biggest.height;
|
||||||
final double collapsedHeight =
|
final double collapsedHeight =
|
||||||
MediaQuery.of(context).padding.top + kToolbarHeight;
|
MediaQuery.of(context).padding.top +
|
||||||
|
kToolbarHeight;
|
||||||
final double expandedHeight = 264.0;
|
final double expandedHeight = 264.0;
|
||||||
final double shrinkRatio =
|
final double shrinkRatio =
|
||||||
((expandedHeight - top) /
|
((expandedHeight - top) /
|
||||||
@ -71,7 +76,7 @@ class ProfilePage extends StatelessWidget implements AutoRouteWrapper {
|
|||||||
.clamp(0.0, 1.0);
|
.clamp(0.0, 1.0);
|
||||||
|
|
||||||
return FlexibleSpaceBar(
|
return FlexibleSpaceBar(
|
||||||
background: ProfileHeader(),
|
background: ProfileHeader(user: state.user),
|
||||||
titlePadding: const EdgeInsets.only(
|
titlePadding: const EdgeInsets.only(
|
||||||
left: 20,
|
left: 20,
|
||||||
right: 12,
|
right: 12,
|
||||||
@ -80,7 +85,8 @@ class ProfilePage extends StatelessWidget implements AutoRouteWrapper {
|
|||||||
title: Opacity(
|
title: Opacity(
|
||||||
opacity: shrinkRatio,
|
opacity: shrinkRatio,
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'Profile',
|
'Profile',
|
||||||
@ -106,7 +112,7 @@ class ProfilePage extends StatelessWidget implements AutoRouteWrapper {
|
|||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
const SpaceHeight(20),
|
const SpaceHeight(20),
|
||||||
ProfileAccountInfo(),
|
ProfileAccountInfo(user: state.user),
|
||||||
const SpaceHeight(12),
|
const SpaceHeight(12),
|
||||||
ProfileBusinessSetting(),
|
ProfileBusinessSetting(),
|
||||||
const SpaceHeight(12),
|
const SpaceHeight(12),
|
||||||
@ -121,6 +127,8 @@ class ProfilePage extends StatelessWidget implements AutoRouteWrapper {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,15 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:line_icons/line_icons.dart';
|
||||||
|
|
||||||
|
import '../../../../common/extension/extension.dart';
|
||||||
import '../../../../common/theme/theme.dart';
|
import '../../../../common/theme/theme.dart';
|
||||||
|
import '../../../../domain/auth/auth.dart';
|
||||||
import 'divider.dart';
|
import 'divider.dart';
|
||||||
import 'profile_tile.dart';
|
import 'profile_tile.dart';
|
||||||
|
|
||||||
class ProfileAccountInfo extends StatelessWidget {
|
class ProfileAccountInfo extends StatelessWidget {
|
||||||
const ProfileAccountInfo({super.key});
|
final User user;
|
||||||
|
const ProfileAccountInfo({super.key, required this.user});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -38,9 +42,9 @@ class ProfileAccountInfo extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
|
|
||||||
ProfileTile(
|
ProfileTile(
|
||||||
icon: Icons.email_outlined,
|
icon: LineIcons.envelope,
|
||||||
title: 'Email',
|
title: 'Email',
|
||||||
subtitle: 'john.doe@business.com',
|
subtitle: user.email,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// Edit email
|
// Edit email
|
||||||
},
|
},
|
||||||
@ -49,31 +53,9 @@ class ProfileAccountInfo extends StatelessWidget {
|
|||||||
ProfileDivider(),
|
ProfileDivider(),
|
||||||
|
|
||||||
ProfileTile(
|
ProfileTile(
|
||||||
icon: Icons.phone_outlined,
|
icon: LineIcons.calendarAlt,
|
||||||
title: 'Phone Number',
|
|
||||||
subtitle: '+62 812 3456 7890',
|
|
||||||
onTap: () {
|
|
||||||
// Edit phone
|
|
||||||
},
|
|
||||||
),
|
|
||||||
|
|
||||||
ProfileDivider(),
|
|
||||||
|
|
||||||
ProfileTile(
|
|
||||||
icon: Icons.location_on_outlined,
|
|
||||||
title: 'Address',
|
|
||||||
subtitle: 'Jl. Merdeka No. 123, Jakarta',
|
|
||||||
onTap: () {
|
|
||||||
// Edit address
|
|
||||||
},
|
|
||||||
),
|
|
||||||
|
|
||||||
ProfileDivider(),
|
|
||||||
|
|
||||||
ProfileTile(
|
|
||||||
icon: Icons.calendar_today_outlined,
|
|
||||||
title: 'Member Since',
|
title: 'Member Since',
|
||||||
subtitle: 'January 15, 2024',
|
subtitle: user.createdAt.toDate,
|
||||||
showArrow: false,
|
showArrow: false,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -1,12 +1,15 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
|
import '../../../../common/extension/extension.dart';
|
||||||
import '../../../../common/painter/wave_painter.dart';
|
import '../../../../common/painter/wave_painter.dart';
|
||||||
import '../../../../common/theme/theme.dart';
|
import '../../../../common/theme/theme.dart';
|
||||||
|
import '../../../../domain/auth/auth.dart';
|
||||||
import '../../../components/spacer/spacer.dart';
|
import '../../../components/spacer/spacer.dart';
|
||||||
|
|
||||||
class ProfileHeader extends StatefulWidget {
|
class ProfileHeader extends StatefulWidget {
|
||||||
const ProfileHeader({super.key});
|
final User user;
|
||||||
|
const ProfileHeader({super.key, required this.user});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ProfileHeader> createState() => _ProfileHeaderState();
|
State<ProfileHeader> createState() => _ProfileHeaderState();
|
||||||
@ -347,7 +350,7 @@ class _ProfileHeaderState extends State<ProfileHeader>
|
|||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'John Doe',
|
widget.user.name,
|
||||||
style: AppStyle.h5.copyWith(
|
style: AppStyle.h5.copyWith(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: AppColor.textWhite,
|
color: AppColor.textWhite,
|
||||||
@ -408,7 +411,7 @@ class _ProfileHeaderState extends State<ProfileHeader>
|
|||||||
),
|
),
|
||||||
const SpaceHeight(6),
|
const SpaceHeight(6),
|
||||||
Text(
|
Text(
|
||||||
'Business Owner',
|
widget.user.role.toTitleCase,
|
||||||
style: AppStyle.md.copyWith(
|
style: AppStyle.md.copyWith(
|
||||||
color: AppColor.textWhite,
|
color: AppColor.textWhite,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user