212 lines
7.9 KiB
Dart
212 lines
7.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:intl/intl.dart';
|
|
import '../models/booking.dart';
|
|
import 'home_page.dart';
|
|
|
|
class TicketPage extends StatelessWidget {
|
|
final Booking booking;
|
|
|
|
const TicketPage({super.key, required this.booking});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final bookingDate = DateTime.parse(booking.date);
|
|
|
|
return Scaffold(
|
|
body: Center(
|
|
child: SingleChildScrollView(
|
|
padding: const EdgeInsets.all(24),
|
|
child: Container(
|
|
constraints: const BoxConstraints(maxWidth: 500),
|
|
padding: const EdgeInsets.all(32),
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFF1F2937),
|
|
borderRadius: BorderRadius.circular(16),
|
|
border: Border.all(color: const Color(0xFF374151)),
|
|
),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Container(
|
|
width: 64,
|
|
height: 64,
|
|
decoration: BoxDecoration(
|
|
color: Colors.green,
|
|
borderRadius: BorderRadius.circular(32),
|
|
),
|
|
child: const Icon(Icons.check, color: Colors.white, size: 40),
|
|
),
|
|
const SizedBox(height: 16),
|
|
const Text(
|
|
'Pemesanan Berhasil!',
|
|
style: TextStyle(fontSize: 28, fontWeight: FontWeight.bold),
|
|
),
|
|
const SizedBox(height: 8),
|
|
const Text(
|
|
'E-Ticket Anda',
|
|
style: TextStyle(color: Colors.grey),
|
|
),
|
|
const SizedBox(height: 24),
|
|
Container(
|
|
padding: const EdgeInsets.all(24),
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFF111827),
|
|
borderRadius: BorderRadius.circular(12),
|
|
border: Border.all(color: const Color(0xFF374151)),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
const Icon(
|
|
Icons.confirmation_number,
|
|
size: 48,
|
|
color: Color(0xFFFBBF24),
|
|
),
|
|
const SizedBox(height: 24),
|
|
_buildTicketRow(
|
|
'Kode Booking',
|
|
booking.code,
|
|
isHighlight: true,
|
|
),
|
|
const Divider(color: Color(0xFF374151), height: 32),
|
|
_buildTicketRow('Film', booking.film),
|
|
const Divider(color: Color(0xFF374151), height: 32),
|
|
_buildTicketRow('Bioskop', booking.cinema),
|
|
const Divider(color: Color(0xFF374151), height: 32),
|
|
_buildTicketRow(
|
|
'Tanggal',
|
|
DateFormat('EEE, dd MMM yyyy').format(bookingDate),
|
|
),
|
|
const Divider(color: Color(0xFF374151), height: 32),
|
|
_buildTicketRow('Jam Tayang', booking.schedule),
|
|
const Divider(color: Color(0xFF374151), height: 32),
|
|
_buildTicketRow('Kursi', booking.seats.join(', ')),
|
|
const Divider(color: Color(0xFF374151), height: 32),
|
|
_buildTicketRow('Pembayaran', booking.paymentMethod),
|
|
const Divider(color: Color(0xFF374151), height: 32),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
const Text(
|
|
'Total Pembayaran',
|
|
style: TextStyle(color: Colors.grey),
|
|
),
|
|
Text(
|
|
'Rp ${_formatPrice(booking.price)}',
|
|
style: const TextStyle(
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.bold,
|
|
color: Color(0xFFFBBF24),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(height: 24),
|
|
Container(
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
color: Colors.blue.shade900.withOpacity(0.3),
|
|
borderRadius: BorderRadius.circular(8),
|
|
border: Border.all(color: Colors.blue.shade700),
|
|
),
|
|
child: const Row(
|
|
children: [
|
|
Icon(Icons.info_outline, color: Colors.blue, size: 20),
|
|
SizedBox(width: 12),
|
|
Expanded(
|
|
child: Text(
|
|
'Tunjukkan e-ticket ini di loket bioskop',
|
|
style: TextStyle(fontSize: 12, color: Colors.blue),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(height: 24),
|
|
SizedBox(
|
|
width: double.infinity,
|
|
child: ElevatedButton(
|
|
onPressed: () {
|
|
Navigator.pushAndRemoveUntil(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (_) =>
|
|
HomePage(username: booking.user, isGuest: false),
|
|
),
|
|
(route) => false,
|
|
);
|
|
},
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: const Color(0xFFFBBF24),
|
|
foregroundColor: Colors.black,
|
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
|
),
|
|
child: const Text(
|
|
'Kembali ke Beranda',
|
|
style: TextStyle(fontWeight: FontWeight.bold),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 12),
|
|
SizedBox(
|
|
width: double.infinity,
|
|
child: OutlinedButton(
|
|
onPressed: () {
|
|
Navigator.pushAndRemoveUntil(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (_) =>
|
|
HomePage(username: booking.user, isGuest: false),
|
|
),
|
|
(route) => false,
|
|
);
|
|
},
|
|
style: OutlinedButton.styleFrom(
|
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
|
side: const BorderSide(color: Color(0xFF374151)),
|
|
),
|
|
child: const Text('Pesan Tiket Lagi'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildTicketRow(
|
|
String label,
|
|
String value, {
|
|
bool isHighlight = false,
|
|
}) {
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(label, style: const TextStyle(color: Colors.grey, fontSize: 14)),
|
|
Flexible(
|
|
child: Text(
|
|
value,
|
|
style: TextStyle(
|
|
color: isHighlight ? const Color(0xFFFBBF24) : Colors.white,
|
|
fontWeight: isHighlight ? FontWeight.bold : FontWeight.w600,
|
|
fontSize: isHighlight ? 18 : 14,
|
|
),
|
|
textAlign: TextAlign.right,
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
String _formatPrice(int price) {
|
|
return price.toString().replaceAllMapped(
|
|
RegExp(r'(\d{1,3})(?=(\d{3})+(?!\d))'),
|
|
(m) => '${m[1]}.',
|
|
);
|
|
}
|
|
}
|