This commit is contained in:
efrilm 2025-09-19 13:31:17 +07:00
parent fabb77d2b9
commit e1e702bd76
3 changed files with 770 additions and 1018 deletions

View File

@ -19,7 +19,7 @@ class SettingsLocalDatasource {
return TaxModel( return TaxModel(
name: 'Tax', name: 'Tax',
type: TaxType.pajak, type: TaxType.pajak,
value: 11, value: 0,
); );
} }
} }

View File

@ -44,7 +44,7 @@ class ReportBloc extends Bloc<ReportEvent, ReportState> {
category category
.getOrElse( .getOrElse(
() => CategoryAnalyticResponseModel(success: false, data: null)) () => CategoryAnalyticResponseModel(success: false, data: null))
.data!, .data,
profitLoss profitLoss
.getOrElse( .getOrElse(
() => ProfitLossResponseModel(success: false, data: null)) () => ProfitLossResponseModel(success: false, data: null))

View File

@ -28,116 +28,7 @@ class SuccessOrderPage extends StatefulWidget {
State<SuccessOrderPage> createState() => _SuccessOrderPageState(); State<SuccessOrderPage> createState() => _SuccessOrderPageState();
} }
class _SuccessOrderPageState extends State<SuccessOrderPage> class _SuccessOrderPageState extends State<SuccessOrderPage> {
with TickerProviderStateMixin {
late AnimationController _mainController;
late AnimationController _successController;
late AnimationController _cardController;
late AnimationController _floatingController;
late Animation<double> _fadeInAnimation;
late Animation<double> _scaleAnimation;
late Animation<double> _successIconAnimation;
late Animation<Offset> _slideUpAnimation;
late Animation<double> _floatingAnimation;
late Animation<double> _shimmerAnimation;
@override
void initState() {
super.initState();
_mainController = AnimationController(
duration: const Duration(milliseconds: 1000),
vsync: this,
);
_successController = AnimationController(
duration: const Duration(milliseconds: 1500),
vsync: this,
);
_cardController = AnimationController(
duration: const Duration(milliseconds: 800),
vsync: this,
);
_floatingController = AnimationController(
duration: const Duration(seconds: 3),
vsync: this,
)..repeat(reverse: true);
_fadeInAnimation = Tween<double>(
begin: 0.0,
end: 1.0,
).animate(CurvedAnimation(
parent: _mainController,
curve: const Interval(0.0, 0.6, curve: Curves.easeOut),
));
_scaleAnimation = Tween<double>(
begin: 0.8,
end: 1.0,
).animate(CurvedAnimation(
parent: _mainController,
curve: const Interval(0.2, 0.8, curve: Curves.elasticOut),
));
_successIconAnimation = Tween<double>(
begin: 0.0,
end: 1.0,
).animate(CurvedAnimation(
parent: _successController,
curve: Curves.elasticOut,
));
_slideUpAnimation = Tween<Offset>(
begin: const Offset(0.0, 0.3),
end: Offset.zero,
).animate(CurvedAnimation(
parent: _cardController,
curve: Curves.easeOutCubic,
));
_floatingAnimation = Tween<double>(
begin: -5.0,
end: 5.0,
).animate(CurvedAnimation(
parent: _floatingController,
curve: Curves.easeInOut,
));
_shimmerAnimation = Tween<double>(
begin: -1.0,
end: 2.0,
).animate(CurvedAnimation(
parent: _mainController,
curve: Curves.easeInOut,
));
// Start animations with staggered delays
_startAnimations();
}
void _startAnimations() async {
await Future.delayed(const Duration(milliseconds: 300));
_mainController.forward();
await Future.delayed(const Duration(milliseconds: 500));
_successController.forward();
await Future.delayed(const Duration(milliseconds: 700));
_cardController.forward();
}
@override
void dispose() {
_mainController.dispose();
_successController.dispose();
_cardController.dispose();
_floatingController.dispose();
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -155,10 +46,6 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
], ],
), ),
), ),
child: FadeTransition(
opacity: _fadeInAnimation,
child: ScaleTransition(
scale: _scaleAnimation,
child: Padding( child: Padding(
padding: const EdgeInsets.all(24.0), padding: const EdgeInsets.all(24.0),
child: Row( child: Row(
@ -181,15 +68,11 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
), ),
), ),
), ),
),
),
); );
} }
Widget _buildLeftPanel() { Widget _buildLeftPanel() {
return SlideTransition( return Container(
position: _slideUpAnimation,
child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.circular(24), borderRadius: BorderRadius.circular(24),
@ -226,15 +109,8 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
), ),
child: Column( child: Column(
children: [ children: [
// Animated Success Icon with Floating Effect // Success Icon
AnimatedBuilder( Container(
animation: _floatingAnimation,
builder: (context, child) {
return Transform.translate(
offset: Offset(0, _floatingAnimation.value),
child: ScaleTransition(
scale: _successIconAnimation,
child: Container(
padding: const EdgeInsets.all(20.0), padding: const EdgeInsets.all(20.0),
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: LinearGradient( gradient: LinearGradient(
@ -248,8 +124,7 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
shape: BoxShape.circle, shape: BoxShape.circle,
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: AppColors.primary color: AppColors.primary.withOpacity(0.3),
.withOpacity(0.3),
blurRadius: 20, blurRadius: 20,
offset: const Offset(0, 10), offset: const Offset(0, 10),
), ),
@ -261,49 +136,22 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
color: Colors.white, color: Colors.white,
), ),
), ),
),
);
},
),
const SizedBox(height: 24), const SizedBox(height: 24),
// Success Title with Shimmer Effect // Success Title
FadeTransition( const Text(
opacity: _fadeInAnimation,
child: ShaderMask(
shaderCallback: (bounds) {
return LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: const [
AppColors.primary,
Colors.amber,
AppColors.primary,
],
stops: [
_shimmerAnimation.value - 1,
_shimmerAnimation.value,
_shimmerAnimation.value + 1,
],
).createShader(bounds);
},
child: const Text(
'Pesanan Berhasil!', 'Pesanan Berhasil!',
style: TextStyle( style: TextStyle(
fontSize: 26, fontSize: 26,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: Colors.white, color: AppColors.primary,
),
),
), ),
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
FadeTransition( Container(
opacity: _fadeInAnimation,
child: Container(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 16, horizontal: 16,
vertical: 8, vertical: 8,
@ -322,7 +170,6 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
), ),
),
], ],
), ),
), ),
@ -339,8 +186,7 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
_buildInfoCard( _buildInfoCard(
icon: Icons.person_outline_rounded, icon: Icons.person_outline_rounded,
title: 'Nama Pelanggan', title: 'Nama Pelanggan',
value: value: widget.order.metadata?['customer_name'] ?? "-",
widget.order.metadata?['customer_name'] ?? "-",
gradient: [ gradient: [
Colors.blue.withOpacity(0.1), Colors.blue.withOpacity(0.1),
Colors.purple.withOpacity(0.1), Colors.purple.withOpacity(0.1),
@ -356,14 +202,12 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
icon: Icons.receipt_long_outlined, icon: Icons.receipt_long_outlined,
label: 'No. Pesanan', label: 'No. Pesanan',
value: widget.order.orderNumber ?? "-", value: widget.order.orderNumber ?? "-",
delay: 0.3,
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
_buildInfoRow( _buildInfoRow(
icon: Icons.wallet_outlined, icon: Icons.wallet_outlined,
label: 'Metode Pembayaran', label: 'Metode Pembayaran',
value: widget.paymentMethod ?? "-", value: widget.paymentMethod,
delay: 0.3,
), ),
if (widget.order.tableNumber != "") ...[ if (widget.order.tableNumber != "") ...[
const SizedBox(height: 12), const SizedBox(height: 12),
@ -371,17 +215,14 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
icon: Icons.table_restaurant_outlined, icon: Icons.table_restaurant_outlined,
label: 'No. Meja', label: 'No. Meja',
value: widget.order.tableNumber ?? "-", value: widget.order.tableNumber ?? "-",
delay: 0.4,
), ),
], ],
const SizedBox(height: 12), const SizedBox(height: 12),
_buildInfoRow( _buildInfoRow(
icon: Icons.access_time_rounded, icon: Icons.access_time_rounded,
label: 'Waktu', label: 'Waktu',
value: value: (widget.order.createdAt ?? DateTime.now())
(widget.order.createdAt ?? DateTime.now())
.toFormattedDate3(), .toFormattedDate3(),
delay: 0.5,
), ),
], ],
), ),
@ -397,14 +238,11 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
_buildBottomSection(), _buildBottomSection(),
], ],
), ),
),
); );
} }
Widget _buildRightPanel() { Widget _buildRightPanel() {
return SlideTransition( return Container(
position: _slideUpAnimation,
child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.circular(24), borderRadius: BorderRadius.circular(24),
@ -437,9 +275,7 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
), ),
child: Row( child: Row(
children: [ children: [
ScaleTransition( Container(
scale: _successIconAnimation,
child: Container(
padding: const EdgeInsets.all(12.0), padding: const EdgeInsets.all(12.0),
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: LinearGradient( gradient: LinearGradient(
@ -456,41 +292,32 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
size: 28, size: 28,
), ),
), ),
),
const SizedBox(width: 16), const SizedBox(width: 16),
Expanded( Expanded(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
FadeTransition( const Text(
opacity: _fadeInAnimation,
child: const Text(
'Detail Pesanan', 'Detail Pesanan',
style: TextStyle( style: TextStyle(
fontSize: 20, fontSize: 20,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
),
const SizedBox(height: 4), const SizedBox(height: 4),
FadeTransition( Text(
opacity: _fadeInAnimation,
child: Text(
'Ringkasan item yang dipesan', 'Ringkasan item yang dipesan',
style: TextStyle( style: TextStyle(
fontSize: 14, fontSize: 14,
color: Colors.grey.shade600, color: Colors.grey.shade600,
), ),
), ),
),
], ],
), ),
), ),
ScaleTransition( Container(
scale: _scaleAnimation, padding:
child: Container( const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
padding: const EdgeInsets.symmetric(
horizontal: 16, vertical: 10),
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: LinearGradient( gradient: LinearGradient(
colors: [ colors: [
@ -516,7 +343,6 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
), ),
), ),
), ),
),
], ],
), ),
), ),
@ -526,8 +352,7 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
child: ListView.separated( child: ListView.separated(
padding: const EdgeInsets.all(24.0), padding: const EdgeInsets.all(24.0),
itemCount: widget.productQuantity.length, itemCount: widget.productQuantity.length,
separatorBuilder: (context, index) => separatorBuilder: (context, index) => const SizedBox(height: 12),
const SizedBox(height: 12),
itemBuilder: (context, index) { itemBuilder: (context, index) {
return _buildProductCard(index); return _buildProductCard(index);
}, },
@ -538,7 +363,6 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
_buildSummaryFooter(), _buildSummaryFooter(),
], ],
), ),
),
); );
} }
@ -547,16 +371,7 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
final totalPrice = (item.product.price ?? 0) * item.quantity + final totalPrice = (item.product.price ?? 0) * item.quantity +
(item.variant?.priceModifier ?? 0); (item.variant?.priceModifier ?? 0);
return TweenAnimationBuilder<double>( return Container(
tween: Tween<double>(begin: 0.0, end: 1.0),
duration: Duration(milliseconds: 600 + (index * 100)),
curve: Curves.easeOutCubic,
builder: (context, animation, child) {
return Transform.translate(
offset: Offset(0, 20 * (1 - animation)),
child: Opacity(
opacity: animation,
child: Container(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: LinearGradient( gradient: LinearGradient(
@ -583,9 +398,7 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
child: Row( child: Row(
children: [ children: [
// Enhanced Product Image // Enhanced Product Image
Hero( Container(
tag: 'product_${index}',
child: Container(
width: 70, width: 70,
height: 70, height: 70,
decoration: BoxDecoration( decoration: BoxDecoration(
@ -612,7 +425,6 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
size: 28, size: 28,
), ),
), ),
),
const SizedBox(width: 16), const SizedBox(width: 16),
@ -663,8 +475,8 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
Container( Container(
padding: const EdgeInsets.symmetric( padding:
horizontal: 12, vertical: 8), const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: LinearGradient( gradient: LinearGradient(
colors: [ colors: [
@ -703,23 +515,16 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
), ),
], ],
), ),
),
),
);
},
); );
} }
Widget _buildSectionTitle(String title) { Widget _buildSectionTitle(String title) {
return FadeTransition( return Text(
opacity: _fadeInAnimation,
child: Text(
title, title,
style: const TextStyle( style: const TextStyle(
fontSize: 18, fontSize: 18,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
),
); );
} }
@ -729,9 +534,7 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
required String value, required String value,
required List<Color> gradient, required List<Color> gradient,
}) { }) {
return ScaleTransition( return Container(
scale: _scaleAnimation,
child: Container(
width: double.infinity, width: double.infinity,
padding: const EdgeInsets.all(20.0), padding: const EdgeInsets.all(20.0),
decoration: BoxDecoration( decoration: BoxDecoration(
@ -778,7 +581,6 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
), ),
], ],
), ),
),
); );
} }
@ -786,20 +588,10 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
required IconData icon, required IconData icon,
required String label, required String label,
required String value, required String value,
required double delay,
Color? valueColor, Color? valueColor,
bool showBadge = false, bool showBadge = false,
}) { }) {
return TweenAnimationBuilder<double>( return Row(
tween: Tween<double>(begin: 0.0, end: 1.0),
duration: Duration(milliseconds: (800 + delay * 1000).round()),
curve: Curves.easeOutCubic,
builder: (context, animation, child) {
return Transform.translate(
offset: Offset(0, 10 * (1 - animation)),
child: Opacity(
opacity: animation,
child: Row(
children: [ children: [
Icon( Icon(
icon, icon,
@ -856,10 +648,6 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
), ),
), ),
], ],
),
),
);
},
); );
} }
@ -883,9 +671,7 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
child: Column( child: Column(
children: [ children: [
// Total Amount with Enhanced Styling // Total Amount with Enhanced Styling
ScaleTransition( Container(
scale: _scaleAnimation,
child: Container(
padding: const EdgeInsets.all(20), padding: const EdgeInsets.all(20),
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: LinearGradient( gradient: LinearGradient(
@ -913,9 +699,7 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
), ),
), ),
Text( Text(
(widget.order.totalAmount ?? 0) (widget.order.totalAmount ?? 0).toString().currencyFormatRpV2,
.toString()
.currencyFormatRpV2,
style: const TextStyle( style: const TextStyle(
fontSize: 24, fontSize: 24,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -925,7 +709,6 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
], ],
), ),
), ),
),
const SizedBox(height: 24), const SizedBox(height: 24),
@ -933,13 +716,6 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
Row( Row(
children: [ children: [
Expanded( Expanded(
child: TweenAnimationBuilder<double>(
tween: Tween<double>(begin: 0.0, end: 1.0),
duration: const Duration(milliseconds: 800),
curve: Curves.easeOutCubic,
builder: (context, animation, child) {
return Transform.scale(
scale: animation,
child: Container( child: Container(
height: 50, height: 50,
decoration: BoxDecoration( decoration: BoxDecoration(
@ -970,19 +746,9 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
), ),
), ),
), ),
);
},
),
), ),
const SizedBox(width: 16), const SizedBox(width: 16),
Expanded( Expanded(
child: TweenAnimationBuilder<double>(
tween: Tween<double>(begin: 0.0, end: 1.0),
duration: const Duration(milliseconds: 1000),
curve: Curves.easeOutCubic,
builder: (context, animation, child) {
return Transform.scale(
scale: animation,
child: Container( child: Container(
height: 50, height: 50,
decoration: BoxDecoration( decoration: BoxDecoration(
@ -1048,9 +814,6 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
), ),
), ),
), ),
);
},
),
), ),
], ],
), ),
@ -1060,9 +823,7 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
} }
Widget _buildSummaryFooter() { Widget _buildSummaryFooter() {
return SlideTransition( return Container(
position: _slideUpAnimation,
child: Container(
width: double.infinity, width: double.infinity,
padding: const EdgeInsets.all(24.0), padding: const EdgeInsets.all(24.0),
decoration: BoxDecoration( decoration: BoxDecoration(
@ -1096,9 +857,7 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
), ),
// Subtotal Row // Subtotal Row
FadeTransition( Row(
opacity: _fadeInAnimation,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Row( Row(
@ -1120,9 +879,7 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
], ],
), ),
Text( Text(
(widget.order.totalAmount ?? 0) (widget.order.totalAmount ?? 0).toString().currencyFormatRpV2,
.toString()
.currencyFormatRpV2,
style: const TextStyle( style: const TextStyle(
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
@ -1130,14 +887,11 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
), ),
], ],
), ),
),
const SizedBox(height: 16), const SizedBox(height: 16),
// Total Payment Row with Enhanced Styling // Total Payment Row with Enhanced Styling
ScaleTransition( Container(
scale: _scaleAnimation,
child: Container(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: LinearGradient( gradient: LinearGradient(
@ -1216,10 +970,8 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
], ],
), ),
), ),
),
], ],
), ),
),
); );
} }
} }