feat: slicing home page
This commit is contained in:
@@ -15,6 +15,166 @@ class OrderMenu extends StatelessWidget {
|
||||
final ProductQuantity data;
|
||||
const OrderMenu({super.key, required this.data});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
margin: EdgeInsets.only(bottom: 8.0),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.primary.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
data.product.name ?? "_",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 2,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 12.0),
|
||||
_buildIconButton(
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => ItemNotesDialog(item: data),
|
||||
);
|
||||
},
|
||||
icon: Icons.edit_note,
|
||||
),
|
||||
SizedBox(width: 8.0),
|
||||
_buildIconButton(
|
||||
onTap: () {},
|
||||
icon: Icons.delete_outline,
|
||||
iconColor: AppColors.red,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SpaceHeight(12.0),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
(data.product.price!.toIntegerFromText * data.quantity)
|
||||
.currencyFormatRp,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 2,
|
||||
style: const TextStyle(
|
||||
color: AppColors.primary,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
SpaceWidth(16),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.white,
|
||||
borderRadius: BorderRadius.circular(50.0),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
_buildIconButton(
|
||||
onTap: () {
|
||||
context
|
||||
.read<CheckoutBloc>()
|
||||
.add(CheckoutEvent.removeItem(data.product));
|
||||
},
|
||||
icon: Icons.remove,
|
||||
iconColor: AppColors.primary,
|
||||
bgColor: Colors.grey.shade300,
|
||||
),
|
||||
SizedBox(
|
||||
width: 30.0,
|
||||
child: Center(
|
||||
child: Text(
|
||||
data.quantity.toString(),
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildIconButton(
|
||||
onTap: () {
|
||||
context
|
||||
.read<CheckoutBloc>()
|
||||
.add(CheckoutEvent.addItem(data.product));
|
||||
},
|
||||
icon: Icons.add,
|
||||
iconColor: AppColors.white,
|
||||
bgColor: AppColors.primary,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (data.notes.isNotEmpty) ...[
|
||||
SpaceHeight(8.0),
|
||||
Divider(),
|
||||
SpaceHeight(8.0),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8.0,
|
||||
vertical: 4.0,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.white,
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
child: Text(
|
||||
'Notes: ${data.notes}',
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColors.black,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
GestureDetector _buildIconButton({
|
||||
required Function()? onTap,
|
||||
Color iconColor = AppColors.black,
|
||||
Color bgColor = AppColors.white,
|
||||
required IconData icon,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
decoration: BoxDecoration(
|
||||
color: bgColor,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(
|
||||
icon,
|
||||
size: 20,
|
||||
color: iconColor,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class OrderMenuOld extends StatelessWidget {
|
||||
final ProductQuantity data;
|
||||
const OrderMenuOld({super.key, required this.data});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
@@ -39,6 +199,8 @@ class OrderMenu extends StatelessWidget {
|
||||
width: 50.0,
|
||||
height: 50.0,
|
||||
fit: BoxFit.cover,
|
||||
errorWidget: (context, url, error) =>
|
||||
const Icon(Icons.error),
|
||||
),
|
||||
),
|
||||
title: Row(
|
||||
@@ -70,7 +232,8 @@ class OrderMenu extends StatelessWidget {
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(data.product.price!.toIntegerFromText.currencyFormatRp),
|
||||
Text(
|
||||
data.product.price!.toIntegerFromText.currencyFormatRp),
|
||||
if (data.notes.isNotEmpty) ...[
|
||||
const SpaceHeight(4.0),
|
||||
Container(
|
||||
|
||||
Reference in New Issue
Block a user