add account, checkout page
This commit is contained in:
@@ -0,0 +1,124 @@
|
||||
/// Checkout Submit Button Widget
|
||||
///
|
||||
/// Place order or send negotiation request button.
|
||||
library;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:worker/core/constants/ui_constants.dart';
|
||||
import 'package:worker/core/theme/colors.dart';
|
||||
|
||||
/// Checkout Submit Button
|
||||
///
|
||||
/// Button that changes based on negotiation checkbox state.
|
||||
class CheckoutSubmitButton extends StatelessWidget {
|
||||
final GlobalKey<FormState> formKey;
|
||||
final bool needsNegotiation;
|
||||
final bool needsInvoice;
|
||||
final String name;
|
||||
final String phone;
|
||||
final String address;
|
||||
final String? province;
|
||||
final String? ward;
|
||||
final String paymentMethod;
|
||||
final String companyName;
|
||||
final String taxId;
|
||||
final double total;
|
||||
|
||||
const CheckoutSubmitButton({
|
||||
super.key,
|
||||
required this.formKey,
|
||||
required this.needsNegotiation,
|
||||
required this.needsInvoice,
|
||||
required this.name,
|
||||
required this.phone,
|
||||
required this.address,
|
||||
required this.province,
|
||||
required this.ward,
|
||||
required this.paymentMethod,
|
||||
required this.companyName,
|
||||
required this.taxId,
|
||||
required this.total,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.md),
|
||||
child: Column(
|
||||
children: [
|
||||
// Terms Agreement Text
|
||||
const Text(
|
||||
'Bằng việc đặt hàng, bạn đồng ý với các điều khoản và điều kiện của chúng tôi',
|
||||
style: TextStyle(fontSize: 12, color: AppColors.grey500),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
|
||||
const SizedBox(height: AppSpacing.md),
|
||||
|
||||
// Place Order / Send Negotiation Button
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
if (formKey.currentState?.validate() ?? false) {
|
||||
_handlePlaceOrder(context);
|
||||
}
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: needsNegotiation
|
||||
? AppColors.warning
|
||||
: AppColors.primaryBlue,
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(AppRadius.button),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
needsNegotiation ? 'Gửi yêu cầu đàm phán' : 'Đặt hàng',
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Handle place order
|
||||
void _handlePlaceOrder(BuildContext context) {
|
||||
// TODO: Implement actual order placement with backend
|
||||
|
||||
if (needsNegotiation) {
|
||||
// Show negotiation request sent message
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Yêu cầu đàm phán giá đã được gửi!'),
|
||||
backgroundColor: AppColors.success,
|
||||
duration: Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
// Show order success message
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Đặt hàng thành công!'),
|
||||
backgroundColor: AppColors.success,
|
||||
duration: Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Navigate back after a short delay
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
if (context.mounted) {
|
||||
context.pop();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user