2025-10-25 00:19:51 +07:00
|
|
|
part of 'dialog.dart';
|
|
|
|
|
|
|
|
|
|
class VariantDialog extends StatelessWidget {
|
|
|
|
|
final Product product;
|
|
|
|
|
const VariantDialog({super.key, required this.product});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return CustomModalDialog(
|
|
|
|
|
title: 'Pilih Varian',
|
|
|
|
|
subtitle: 'Silahkan pilih varian yang sesuai',
|
|
|
|
|
minWidth: context.deviceWidth * 0.4,
|
2026-03-01 20:02:12 +07:00
|
|
|
contentPadding: const EdgeInsets.all(16),
|
2025-10-25 00:19:51 +07:00
|
|
|
child: Wrap(
|
|
|
|
|
spacing: 12,
|
|
|
|
|
runSpacing: 12,
|
|
|
|
|
crossAxisAlignment: WrapCrossAlignment.start,
|
|
|
|
|
runAlignment: WrapAlignment.start,
|
|
|
|
|
alignment: WrapAlignment.start,
|
|
|
|
|
children: product.variants.map((variant) {
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
onTap: () {
|
|
|
|
|
// Aksi saat varian dipilih
|
2026-09-06 23:03:31 +07:00
|
|
|
final bloc = context.read<CheckoutFormBloc>();
|
|
|
|
|
// Context dialog ini mati begitu di-pop, jadi dialog lanjutan
|
|
|
|
|
// dibuka lewat context milik Navigator.
|
|
|
|
|
final navigator = Navigator.of(context, rootNavigator: true);
|
|
|
|
|
navigator.pop();
|
|
|
|
|
|
|
|
|
|
// Produk timbangan lanjut ke papan angka; varian hanya mengubah
|
|
|
|
|
// harga per satuannya.
|
|
|
|
|
if (product.isSoldByWeight) {
|
|
|
|
|
showDialog(
|
|
|
|
|
context: navigator.context,
|
|
|
|
|
builder: (context) => WeightInputDialog(
|
|
|
|
|
product: product,
|
|
|
|
|
variant: variant,
|
|
|
|
|
onSubmit: (weight) => bloc.add(
|
|
|
|
|
CheckoutFormEvent.addWeightedItem(
|
|
|
|
|
product,
|
|
|
|
|
variant,
|
|
|
|
|
weight,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bloc.add(CheckoutFormEvent.addItem(product, variant));
|
2025-10-25 00:19:51 +07:00
|
|
|
},
|
|
|
|
|
child: Container(
|
|
|
|
|
width: (context.deviceWidth * 0.4 - 12 - 32) / 2 - 6, // 2 per row
|
|
|
|
|
padding: const EdgeInsets.all(12),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
border: Border.all(color: Colors.grey.shade300),
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
variant.name,
|
|
|
|
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
|
Text(
|
|
|
|
|
variant.priceModifier.currencyFormatRpV2,
|
2026-03-01 20:02:12 +07:00
|
|
|
style: const TextStyle(color: AppColor.black),
|
2025-10-25 00:19:51 +07:00
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}).toList(),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|