Game Prize and Logout

This commit is contained in:
efrilm
2025-09-18 10:39:54 +07:00
parent 006486bc2a
commit 3c596461c6
31 changed files with 4189 additions and 677 deletions
+5 -1
View File
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../application/auth/auth_bloc.dart';
import '../application/auth/logout_form/logout_form_bloc.dart';
import '../common/theme/theme.dart';
import '../common/constant/app_constant.dart';
import '../injection.dart';
@@ -21,7 +22,10 @@ class _AppWidgetState extends State<AppWidget> {
@override
Widget build(BuildContext context) {
return MultiBlocProvider(
providers: [BlocProvider(create: (context) => getIt<AuthBloc>())],
providers: [
BlocProvider(create: (context) => getIt<AuthBloc>()),
BlocProvider(create: (context) => getIt<LogoutFormBloc>()),
],
child: MaterialApp.router(
debugShowCheckedModeBanner: false,
title: AppConstant.appName,
@@ -1,341 +1,368 @@
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../../../../application/auth/logout_form/logout_form_bloc.dart';
import '../../../../../common/theme/theme.dart';
import '../../../../../injection.dart';
import '../../../../components/toast/flushbar.dart';
import '../../../../router/app_router.gr.dart';
@RoutePage()
class ProfilePage extends StatelessWidget {
class ProfilePage extends StatelessWidget implements AutoRouteWrapper {
const ProfilePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColor.background,
appBar: AppBar(title: Text('Profil'), automaticallyImplyLeading: false),
body: SingleChildScrollView(
child: Column(
children: [
// Profile Header
Container(
width: double.infinity,
color: AppColor.white,
padding: const EdgeInsets.all(20),
child: Column(
children: [
// Profile Avatar & Info
GestureDetector(
onTap: () => context.router.push(AccountMyRoute()),
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: AppColor.primaryGradient,
begin: Alignment.topLeft,
end: Alignment.bottomRight,
return BlocListener<LogoutFormBloc, LogoutFormState>(
listener: (context, state) {
state.failureOrAuthOption.fold(
() => null,
(either) => either.fold(
(f) => AppFlushbar.showAuthFailureToast(context, f),
(_) => context.router.replaceAll([LoginRoute()]),
),
);
},
child: Scaffold(
backgroundColor: AppColor.background,
appBar: AppBar(title: Text('Profil'), automaticallyImplyLeading: false),
body: SingleChildScrollView(
child: Column(
children: [
// Profile Header
Container(
width: double.infinity,
color: AppColor.white,
padding: const EdgeInsets.all(20),
child: Column(
children: [
// Profile Avatar & Info
GestureDetector(
onTap: () => context.router.push(AccountMyRoute()),
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: AppColor.primaryGradient,
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.circular(16),
),
borderRadius: BorderRadius.circular(16),
),
child: Stack(
children: [
// Background Pattern
Positioned(
top: -20,
right: -20,
child: Container(
width: 80,
height: 80,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: AppColor.white.withOpacity(0.1),
),
),
),
Positioned(
top: 30,
right: 20,
child: Container(
width: 40,
height: 40,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: AppColor.white.withOpacity(0.08),
),
),
),
Positioned(
bottom: -10,
left: -10,
child: Container(
width: 60,
height: 60,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: AppColor.white.withOpacity(0.06),
),
),
),
// Decorative Lines
Positioned(
top: 10,
left: -5,
child: Transform.rotate(
angle: 0.5,
child: Stack(
children: [
// Background Pattern
Positioned(
top: -20,
right: -20,
child: Container(
width: 30,
height: 2,
width: 80,
height: 80,
decoration: BoxDecoration(
color: AppColor.white.withOpacity(0.15),
borderRadius: BorderRadius.circular(1),
shape: BoxShape.circle,
color: AppColor.white.withOpacity(0.1),
),
),
),
),
Positioned(
bottom: 15,
right: 10,
child: Transform.rotate(
angle: -0.5,
Positioned(
top: 30,
right: 20,
child: Container(
width: 25,
height: 2,
width: 40,
height: 40,
decoration: BoxDecoration(
color: AppColor.white.withOpacity(0.15),
borderRadius: BorderRadius.circular(1),
shape: BoxShape.circle,
color: AppColor.white.withOpacity(0.08),
),
),
),
),
// Main Content
Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
children: [
// Avatar
Container(
width: 60,
height: 60,
Positioned(
bottom: -10,
left: -10,
child: Container(
width: 60,
height: 60,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: AppColor.white.withOpacity(0.06),
),
),
),
// Decorative Lines
Positioned(
top: 10,
left: -5,
child: Transform.rotate(
angle: 0.5,
child: Container(
width: 30,
height: 2,
decoration: BoxDecoration(
color: AppColor.white,
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: AppColor.black.withOpacity(0.1),
blurRadius: 8,
offset: const Offset(0, 2),
),
],
),
child: Icon(
Icons.person,
size: 30,
color: AppColor.primary,
color: AppColor.white.withOpacity(0.15),
borderRadius: BorderRadius.circular(1),
),
),
const SizedBox(width: 16),
// User Info
Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'EFRIL',
style: AppStyle.lg.copyWith(
fontWeight: FontWeight.bold,
color: AppColor.white,
letterSpacing: 0.5,
),
),
Positioned(
bottom: 15,
right: 10,
child: Transform.rotate(
angle: -0.5,
child: Container(
width: 25,
height: 2,
decoration: BoxDecoration(
color: AppColor.white.withOpacity(0.15),
borderRadius: BorderRadius.circular(1),
),
),
),
),
// Main Content
Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
children: [
// Avatar
Container(
width: 60,
height: 60,
decoration: BoxDecoration(
color: AppColor.white,
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: AppColor.black.withOpacity(
0.1,
),
blurRadius: 8,
offset: const Offset(0, 2),
),
),
const SizedBox(height: 4),
Text(
'+6283873987851',
style: AppStyle.sm.copyWith(
color: AppColor.white.withOpacity(
0.9,
],
),
child: Icon(
Icons.person,
size: 30,
color: AppColor.primary,
),
),
const SizedBox(width: 16),
// User Info
Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'EFRIL',
style: AppStyle.lg.copyWith(
fontWeight: FontWeight.bold,
color: AppColor.white,
letterSpacing: 0.5,
),
),
),
],
const SizedBox(height: 4),
Text(
'+6283873987851',
style: AppStyle.sm.copyWith(
color: AppColor.white.withOpacity(
0.9,
),
),
),
],
),
),
// Arrow Icon
Icon(
Icons.arrow_forward_ios,
color: AppColor.white,
size: 14,
),
],
),
),
],
),
),
),
],
),
),
const SizedBox(height: 8),
// Menu Items
Container(
color: AppColor.white,
child: Column(
children: [
_buildMenuItem(
icon: Icons.location_on_outlined,
title: 'Alamat Tersimpan',
onTap: () => context.router.push(AddressRoute()),
),
_buildMenuItem(
icon: Icons.payment_outlined,
title: 'Pembayaran',
onTap: () => context.router.push(PaymentRoute()),
),
_buildMenuItem(
icon: Icons.help_outline,
title: 'Pusat Bantuan',
onTap: () {},
),
_buildMenuItem(
icon: Icons.settings_outlined,
title: 'Pengaturan',
onTap: () {},
showDivider: false,
),
],
),
),
const SizedBox(height: 8),
// Legal & Privacy Section
Container(
color: AppColor.white,
child: Column(
children: [
_buildMenuItem(
icon: Icons.description_outlined,
title: 'Syarat dan Ketentuan',
onTap: () {},
),
_buildMenuItem(
icon: Icons.privacy_tip_outlined,
title: 'Kebijakan Privasi',
onTap: () {},
showDivider: false,
),
],
),
),
const SizedBox(height: 8),
// Customer Service Section
Container(
color: AppColor.white,
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Butuh Bantuan?',
style: AppStyle.lg.copyWith(
fontWeight: FontWeight.w600,
color: AppColor.textPrimary,
),
),
const SizedBox(height: 8),
Text(
'Customer Service kami siap untuk membantu',
style: AppStyle.sm.copyWith(
color: AppColor.textSecondary,
),
),
const SizedBox(height: 16),
// WhatsApp Customer Service
Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: AppColor.backgroundLight,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: AppColor.borderLight),
),
child: Row(
children: [
Container(
width: 40,
height: 40,
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.circular(8),
),
child: Icon(
Icons.chat,
color: AppColor.white,
size: 20,
),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Enaklo Customer Service (chat only)',
style: AppStyle.sm.copyWith(
color: AppColor.textSecondary,
),
),
// Arrow Icon
Icon(
Icons.arrow_forward_ios,
color: AppColor.white,
size: 14,
Text(
'0812-1111-8456',
style: AppStyle.md.copyWith(
fontWeight: FontWeight.w600,
color: AppColor.success,
),
),
],
),
),
Icon(
Icons.arrow_forward_ios,
color: AppColor.textSecondary,
size: 14,
),
],
),
),
),
],
],
),
),
),
const SizedBox(height: 8),
const SizedBox(height: 20),
// Menu Items
Container(
color: AppColor.white,
child: Column(
children: [
_buildMenuItem(
icon: Icons.location_on_outlined,
title: 'Alamat Tersimpan',
onTap: () => context.router.push(AddressRoute()),
),
_buildMenuItem(
icon: Icons.payment_outlined,
title: 'Pembayaran',
onTap: () => context.router.push(PaymentRoute()),
),
_buildMenuItem(
icon: Icons.help_outline,
title: 'Pusat Bantuan',
onTap: () {},
),
_buildMenuItem(
icon: Icons.settings_outlined,
title: 'Pengaturan',
onTap: () {},
showDivider: false,
),
],
),
),
const SizedBox(height: 8),
// Legal & Privacy Section
Container(
color: AppColor.white,
child: Column(
children: [
_buildMenuItem(
icon: Icons.description_outlined,
title: 'Syarat dan Ketentuan',
onTap: () {},
),
_buildMenuItem(
icon: Icons.privacy_tip_outlined,
title: 'Kebijakan Privasi',
onTap: () {},
showDivider: false,
),
],
),
),
const SizedBox(height: 8),
// Customer Service Section
Container(
color: AppColor.white,
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Butuh Bantuan?',
style: AppStyle.lg.copyWith(
fontWeight: FontWeight.w600,
color: AppColor.textPrimary,
),
),
const SizedBox(height: 8),
Text(
'Customer Service kami siap untuk membantu',
style: AppStyle.sm.copyWith(color: AppColor.textSecondary),
),
const SizedBox(height: 16),
// WhatsApp Customer Service
Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: AppColor.backgroundLight,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: AppColor.borderLight),
),
child: Row(
children: [
Container(
width: 40,
height: 40,
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.circular(8),
),
child: Icon(
Icons.chat,
color: AppColor.white,
size: 20,
),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Enaklo Customer Service (chat only)',
style: AppStyle.sm.copyWith(
color: AppColor.textSecondary,
),
),
Text(
'0812-1111-8456',
style: AppStyle.md.copyWith(
fontWeight: FontWeight.w600,
color: AppColor.success,
),
),
],
),
),
Icon(
Icons.arrow_forward_ios,
color: AppColor.textSecondary,
size: 14,
),
],
),
),
],
),
),
const SizedBox(height: 20),
// Footer Section
Container(
color: AppColor.white,
padding: const EdgeInsets.all(20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Version 4.6.1',
style: AppStyle.sm.copyWith(color: AppColor.textSecondary),
),
GestureDetector(
onTap: () => _showLogoutDialog(context),
child: Text(
'Logout',
// Footer Section
Container(
color: AppColor.white,
padding: const EdgeInsets.all(20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Version 4.6.1',
style: AppStyle.sm.copyWith(
color: AppColor.primary,
fontWeight: FontWeight.w600,
color: AppColor.textSecondary,
),
),
),
],
GestureDetector(
onTap: () => _showLogoutDialog(
context,
onLogout: () => context.read<LogoutFormBloc>().add(
const LogoutFormEvent.submitted(),
),
),
child: Text(
'Logout',
style: AppStyle.sm.copyWith(
color: AppColor.primary,
fontWeight: FontWeight.w600,
),
),
),
],
),
),
),
const SizedBox(height: 100), // Bottom spacing
],
const SizedBox(height: 100), // Bottom spacing
],
),
),
),
);
@@ -372,7 +399,10 @@ class ProfilePage extends StatelessWidget {
);
}
void _showLogoutDialog(BuildContext context) {
void _showLogoutDialog(
BuildContext context, {
required VoidCallback onLogout,
}) {
showDialog(
context: context,
builder: (BuildContext context) {
@@ -395,6 +425,7 @@ class ProfilePage extends StatelessWidget {
onPressed: () => Navigator.of(context).pop(),
),
TextButton(
onPressed: onLogout,
child: Text(
'Logout',
style: AppStyle.md.copyWith(
@@ -402,15 +433,14 @@ class ProfilePage extends StatelessWidget {
fontWeight: FontWeight.w600,
),
),
onPressed: () {
Navigator.of(context).pop();
// Add logout logic here
// Example: context.router.pushAndClearStack('/login');
},
),
],
);
},
);
}
@override
Widget wrappedRoute(BuildContext context) =>
BlocProvider(create: (_) => getIt<LogoutFormBloc>(), child: this);
}
@@ -20,6 +20,7 @@ class PrizeHistory {
final int value;
final Color color;
final IconData icon;
final String? gamePrizeId; // Added for API integration
PrizeHistory({
required this.prize,
@@ -27,5 +28,73 @@ class PrizeHistory {
required this.value,
required this.color,
required this.icon,
this.gamePrizeId,
});
// CopyWith method for updating properties
PrizeHistory copyWith({
String? prize,
DateTime? dateTime,
int? value,
Color? color,
IconData? icon,
String? gamePrizeId,
}) {
return PrizeHistory(
prize: prize ?? this.prize,
dateTime: dateTime ?? this.dateTime,
value: value ?? this.value,
color: color ?? this.color,
icon: icon ?? this.icon,
gamePrizeId: gamePrizeId ?? this.gamePrizeId,
);
}
// Convert to Map for storage/API calls
Map<String, dynamic> toMap() {
return {
'prize': prize,
'dateTime': dateTime.toIso8601String(),
'value': value,
'gamePrizeId': gamePrizeId,
};
}
// Create from Map for loading from storage/API
factory PrizeHistory.fromMap(
Map<String, dynamic> map, {
required Color color,
required IconData icon,
}) {
return PrizeHistory(
prize: map['prize'] ?? '',
dateTime: DateTime.tryParse(map['dateTime'] ?? '') ?? DateTime.now(),
value: map['value'] ?? 0,
color: color,
icon: icon,
gamePrizeId: map['gamePrizeId'],
);
}
// Format date for display
String get formattedDate {
return '${dateTime.day.toString().padLeft(2, '0')}/${dateTime.month.toString().padLeft(2, '0')}/${dateTime.year} ${dateTime.hour.toString().padLeft(2, '0')}:${dateTime.minute.toString().padLeft(2, '0')}';
}
// Get prize category based on value
String get prizeCategory {
if (value >= 1000000) return 'Jackpot';
if (value >= 100000) return 'Big Prize';
if (value >= 10000) return 'Medium Prize';
if (value >= 1000) return 'Small Prize';
return 'Token/Spin';
}
// Get prize category color
Color get categoryColor {
if (value >= 1000000) return const Color(0xFFFFD700); // Gold
if (value >= 100000) return const Color(0xFFC0C0C0); // Silver
if (value >= 10000) return const Color(0xFFCD7F32); // Bronze
return color; // Default color
}
}
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -252,7 +252,7 @@ class FerrisWheelRoute extends _i33.PageRouteInfo<void> {
static _i33.PageInfo page = _i33.PageInfo(
name,
builder: (data) {
return const _i10.FerrisWheelPage();
return _i33.WrappedRoute(child: const _i10.FerrisWheelPage());
},
);
}