112 lines
3.0 KiB
Dart
Raw Normal View History

2025-07-31 19:25:45 +07:00
import 'package:enaklo_pos/core/constants/colors.dart';
2025-07-30 22:38:44 +07:00
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:enaklo_pos/presentation/home/bloc/checkout/checkout_bloc.dart';
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
import '../../../core/components/buttons.dart';
import '../../../core/components/spaces.dart';
class ItemNotesDialog extends StatefulWidget {
final ProductQuantity item;
2025-07-31 19:25:45 +07:00
2025-07-30 22:38:44 +07:00
const ItemNotesDialog({
super.key,
required this.item,
});
@override
State<ItemNotesDialog> createState() => _ItemNotesDialogState();
}
class _ItemNotesDialogState extends State<ItemNotesDialog> {
late TextEditingController notesController;
@override
void initState() {
super.initState();
notesController = TextEditingController(text: widget.item.notes);
}
@override
void dispose() {
notesController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return AlertDialog(
2025-07-31 19:25:45 +07:00
backgroundColor: Colors.white,
title: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.item.product.name ?? 'Catatan Item',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: AppColors.black,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 4.0),
Text(
'Masukkan catatan untuk item ini',
style: TextStyle(
fontSize: 14,
color: Colors.grey,
),
),
],
),
),
SpaceWidth(12),
IconButton(
icon: const Icon(Icons.close, color: AppColors.black),
onPressed: () {
Navigator.of(context).pop();
},
),
],
),
2025-07-30 22:38:44 +07:00
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextField(
controller: notesController,
maxLines: 3,
decoration: const InputDecoration(
2025-07-31 19:25:45 +07:00
hintText: 'Masukkan catatan untuk item ini',
2025-07-30 22:38:44 +07:00
border: OutlineInputBorder(),
),
),
],
),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: const Text('Cancel'),
),
Button.filled(
onPressed: () {
context.read<CheckoutBloc>().add(
2025-07-31 19:25:45 +07:00
CheckoutEvent.updateItemNotes(
widget.item.product,
notesController.text,
),
);
2025-07-30 22:38:44 +07:00
Navigator.of(context).pop();
},
label: 'Save',
),
],
);
}
2025-07-31 19:25:45 +07:00
}