feat: lang
This commit is contained in:
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'dart:math' show cos, sin;
|
||||
|
||||
import '../../../../common/extension/extension.dart';
|
||||
import '../../../../common/theme/theme.dart';
|
||||
import '../../../../domain/order/order.dart';
|
||||
import '../../../components/appbar/appbar.dart';
|
||||
@@ -22,33 +23,33 @@ class OrderDetailPage extends StatelessWidget {
|
||||
expandedHeight: 120,
|
||||
pinned: true,
|
||||
backgroundColor: AppColor.primary,
|
||||
flexibleSpace: const CustomAppBar(title: "Detail Pesanan"),
|
||||
flexibleSpace: CustomAppBar(title: context.lang.order_details),
|
||||
elevation: 0,
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: Column(
|
||||
children: [
|
||||
// Order Status Card
|
||||
_buildOrderStatusCard(),
|
||||
_buildOrderStatusCard(context),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Table Visual Card (for dine-in)
|
||||
if (_isDineIn()) _buildTableVisualCard(),
|
||||
if (_isDineIn()) _buildTableVisualCard(context),
|
||||
|
||||
// Order Info Card
|
||||
_buildOrderInfoCard(),
|
||||
_buildOrderInfoCard(context),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Order Items Section
|
||||
_buildOrderItemsSection(),
|
||||
_buildOrderItemsSection(context),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Payment Summary Card
|
||||
_buildPaymentSummaryCard(),
|
||||
_buildPaymentSummaryCard(context),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Payment Methods Section
|
||||
_buildPaymentMethodsSection(),
|
||||
_buildPaymentMethodsSection(context),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
),
|
||||
@@ -58,7 +59,7 @@ class OrderDetailPage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildOrderStatusCard() {
|
||||
Widget _buildOrderStatusCard(BuildContext context) {
|
||||
Color statusColor = _getStatusColor(order.status);
|
||||
return Container(
|
||||
margin: const EdgeInsets.all(16),
|
||||
@@ -123,7 +124,7 @@ class OrderDetailPage extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Order Number',
|
||||
context.lang.order_number,
|
||||
style: AppStyle.sm.copyWith(
|
||||
color: AppColor.textSecondary,
|
||||
fontWeight: FontWeight.w500,
|
||||
@@ -157,7 +158,7 @@ class OrderDetailPage extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Status Pesanan',
|
||||
context.lang.order_status,
|
||||
style: AppStyle.sm.copyWith(
|
||||
color: AppColor.textSecondary,
|
||||
fontWeight: FontWeight.w500,
|
||||
@@ -197,7 +198,7 @@ class OrderDetailPage extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
'Total Amount',
|
||||
context.lang.total_amount,
|
||||
style: AppStyle.sm.copyWith(
|
||||
color: AppColor.textSecondary,
|
||||
fontWeight: FontWeight.w500,
|
||||
@@ -222,7 +223,7 @@ class OrderDetailPage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTableVisualCard() {
|
||||
Widget _buildTableVisualCard(BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.fromLTRB(16, 0, 16, 16),
|
||||
height: 220, // Increased height
|
||||
@@ -284,14 +285,14 @@ class OrderDetailPage extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Makan di Tempat',
|
||||
context.lang.dine_in,
|
||||
style: AppStyle.sm.copyWith(
|
||||
color: AppColor.white.withOpacity(0.9),
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Dine In Experience',
|
||||
context.lang.dine_in_experience,
|
||||
style: AppStyle.lg.copyWith(
|
||||
color: AppColor.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -347,7 +348,7 @@ class OrderDetailPage extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'MEJA',
|
||||
context.lang.table,
|
||||
style: AppStyle.xs.copyWith(
|
||||
color: AppColor.primary.withOpacity(
|
||||
0.7,
|
||||
@@ -417,7 +418,7 @@ class OrderDetailPage extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
'${order.orderItems.length} Items',
|
||||
'${order.orderItems.length} ${context.lang.items}',
|
||||
style: AppStyle.sm.copyWith(
|
||||
color: AppColor.white,
|
||||
fontWeight: FontWeight.w500,
|
||||
@@ -470,7 +471,7 @@ class OrderDetailPage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildOrderInfoCard() {
|
||||
Widget _buildOrderInfoCard(BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16),
|
||||
decoration: BoxDecoration(
|
||||
@@ -517,7 +518,7 @@ class OrderDetailPage extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Text(
|
||||
'Informasi Pesanan',
|
||||
context.lang.order_information,
|
||||
style: AppStyle.xl.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColor.primary,
|
||||
@@ -527,24 +528,28 @@ class OrderDetailPage extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
if (_shouldShowTableNumber())
|
||||
_buildInfoRow(Icons.table_restaurant, 'Meja', order.tableNumber),
|
||||
_buildInfoRow(
|
||||
Icons.table_restaurant,
|
||||
context.lang.table,
|
||||
order.tableNumber,
|
||||
),
|
||||
_buildInfoRow(
|
||||
Icons.delivery_dining,
|
||||
'Tipe Pesanan',
|
||||
context.lang.order_type,
|
||||
order.orderType,
|
||||
),
|
||||
_buildInfoRow(
|
||||
Icons.payment,
|
||||
'Status Pembayaran',
|
||||
context.lang.payment_status,
|
||||
order.paymentStatus,
|
||||
),
|
||||
_buildInfoRow(
|
||||
Icons.access_time,
|
||||
'Dibuat',
|
||||
context.lang.created,
|
||||
_formatDateTime(order.createdAt),
|
||||
),
|
||||
if (order.notes.isNotEmpty)
|
||||
_buildInfoRow(Icons.note, 'Catatan', order.notes),
|
||||
_buildInfoRow(Icons.note, context.lang.note, order.notes),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -590,7 +595,7 @@ class OrderDetailPage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildOrderItemsSection() {
|
||||
Widget _buildOrderItemsSection(BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16),
|
||||
decoration: BoxDecoration(
|
||||
@@ -612,7 +617,7 @@ class OrderDetailPage extends StatelessWidget {
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
'Item Pesanan',
|
||||
context.lang.order_item,
|
||||
style: AppStyle.lg.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColor.textPrimary,
|
||||
@@ -629,7 +634,7 @@ class OrderDetailPage extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
'${order.orderItems.length} Item',
|
||||
'${order.orderItems.length} ${context.lang.item}',
|
||||
style: AppStyle.sm.copyWith(
|
||||
color: AppColor.primary,
|
||||
fontWeight: FontWeight.w600,
|
||||
@@ -647,7 +652,7 @@ class OrderDetailPage extends StatelessWidget {
|
||||
separatorBuilder: (context, index) => const Divider(height: 24),
|
||||
itemBuilder: (context, index) {
|
||||
final item = order.orderItems[index];
|
||||
return _buildOrderItemCard(item);
|
||||
return _buildOrderItemCard(context, item);
|
||||
},
|
||||
),
|
||||
],
|
||||
@@ -655,9 +660,9 @@ class OrderDetailPage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildOrderItemCard(OrderItem item) {
|
||||
Widget _buildOrderItemCard(BuildContext context, OrderItem item) {
|
||||
// Assume we add status to OrderItem model or determine from order status
|
||||
String itemStatus = _getItemStatus(item);
|
||||
String itemStatus = _getItemStatus(context, item);
|
||||
Color itemStatusColor = _getItemStatusColor(itemStatus);
|
||||
|
||||
return Container(
|
||||
@@ -786,7 +791,7 @@ class OrderDetailPage extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Text(
|
||||
'Diskon: -Rp ${_formatCurrency(item.discountAmount)}',
|
||||
'${context.lang.discount}: -Rp ${_formatCurrency(item.discountAmount)}',
|
||||
style: AppStyle.xs.copyWith(
|
||||
color: AppColor.error,
|
||||
fontWeight: FontWeight.w600,
|
||||
@@ -811,7 +816,7 @@ class OrderDetailPage extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Total Item',
|
||||
context.lang.total_item,
|
||||
style: AppStyle.sm.copyWith(
|
||||
color: AppColor.textSecondary,
|
||||
fontWeight: FontWeight.w500,
|
||||
@@ -845,7 +850,7 @@ class OrderDetailPage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPaymentSummaryCard() {
|
||||
Widget _buildPaymentSummaryCard(BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16),
|
||||
decoration: BoxDecoration(
|
||||
@@ -866,26 +871,38 @@ class OrderDetailPage extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Ringkasan Pembayaran',
|
||||
context.lang.payment_summary,
|
||||
style: AppStyle.lg.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColor.primary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildSummaryRow('Subtotal', order.subtotal),
|
||||
_buildSummaryRow(context.lang.subtotal, order.subtotal),
|
||||
if (order.discountAmount > 0)
|
||||
_buildSummaryRow(
|
||||
'Diskon',
|
||||
context.lang.discount,
|
||||
-order.discountAmount,
|
||||
isDiscount: true,
|
||||
),
|
||||
_buildSummaryRow('Pajak', order.taxAmount),
|
||||
_buildSummaryRow(context.lang.tax, order.taxAmount),
|
||||
const Divider(height: 24),
|
||||
_buildSummaryRow('Total', order.totalAmount, isTotal: true),
|
||||
_buildSummaryRow('Dibayar', order.totalPaid, isSuccess: true),
|
||||
_buildSummaryRow(
|
||||
context.lang.total,
|
||||
order.totalAmount,
|
||||
isTotal: true,
|
||||
),
|
||||
_buildSummaryRow(
|
||||
context.lang.paid,
|
||||
order.totalPaid,
|
||||
isSuccess: true,
|
||||
),
|
||||
if (order.remainingAmount > 0)
|
||||
_buildSummaryRow('Sisa', order.remainingAmount, isError: true),
|
||||
_buildSummaryRow(
|
||||
context.lang.remaining,
|
||||
order.remainingAmount,
|
||||
isError: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -930,7 +947,7 @@ class OrderDetailPage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPaymentMethodsSection() {
|
||||
Widget _buildPaymentMethodsSection(BuildContext context) {
|
||||
if (order.payments.isEmpty) return const SizedBox();
|
||||
|
||||
return Container(
|
||||
@@ -952,7 +969,7 @@ class OrderDetailPage extends StatelessWidget {
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(20, 20, 20, 0),
|
||||
child: Text(
|
||||
'Metode Pembayaran',
|
||||
context.lang.payment_method,
|
||||
style: AppStyle.lg.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColor.textPrimary,
|
||||
@@ -1159,7 +1176,7 @@ class OrderDetailPage extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
String _getItemStatus(OrderItem item) {
|
||||
String _getItemStatus(BuildContext context, OrderItem item) {
|
||||
// Logic untuk menentukan status item berdasarkan:
|
||||
// 1. Status order secara keseluruhan
|
||||
// 2. Jika ada field status di OrderItem model
|
||||
@@ -1167,26 +1184,24 @@ class OrderDetailPage extends StatelessWidget {
|
||||
|
||||
switch (order.status.toLowerCase()) {
|
||||
case 'completed':
|
||||
return 'Selesai';
|
||||
return context.lang.completed;
|
||||
case 'pending':
|
||||
return 'Menunggu';
|
||||
return context.lang.pending;
|
||||
case 'cancelled':
|
||||
return 'Dibatalkan';
|
||||
return context.lang.void_text;
|
||||
default:
|
||||
return 'Menunggu';
|
||||
return context.lang.pending;
|
||||
}
|
||||
}
|
||||
|
||||
Color _getItemStatusColor(String status) {
|
||||
switch (status.toLowerCase()) {
|
||||
case 'selesai':
|
||||
case 'completed':
|
||||
return AppColor.success;
|
||||
case 'diproses':
|
||||
case 'pending':
|
||||
return AppColor.warning;
|
||||
case 'dibatalkan':
|
||||
case 'cancelled':
|
||||
return AppColor.error;
|
||||
case 'siap':
|
||||
return AppColor.info;
|
||||
default:
|
||||
return AppColor.primary;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user