Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:flutter_svg/svg.dart';
- import 'package:provider/provider.dart';
- import 'package:supplier/expired_product_notifier.dart';
- import 'package:supplier/util.dart';
- class ProductItemCheckout extends StatefulWidget {
- final ExpiredProduct expiredProduct;
- ProductItemCheckout(this.expiredProduct);
- @override
- _ProductItemCheckoutState createState() => _ProductItemCheckoutState();
- }
- class _ProductItemCheckoutState extends State<ProductItemCheckout> {
- TextEditingController _dateController = TextEditingController();
- TextEditingController _quantityController = TextEditingController();
- List<Widget> tanggalKadaluarsaWidgets(ExpiredProductNotifier bn) {
- return widget.expiredProduct.expiredQuantities.map((item) {
- _dateController.text = item.expired == null ? '' : Util.format(item.expired);
- _quantityController.text = item.quantity.toString() == null ? '' : item.quantity.toString();
- DateTime now = DateTime.now();
- return Padding(
- padding: const EdgeInsets.only(bottom: 8.0),
- child: Row(
- children: <Widget>[
- Container(
- width: 190,
- height: 44,
- child: TextFormField(
- style: TextStyle(fontSize: 14, color: Color(0xFF4F4F4F)),
- controller: _dateController,
- decoration: InputDecoration(
- contentPadding: EdgeInsets.all(8),
- suffixIcon: Padding(
- padding: EdgeInsetsDirectional.only(top: 8, bottom: 8),
- child: SvgPicture.asset('assets/calendar.svg')),
- enabledBorder: OutlineInputBorder(
- borderSide: BorderSide(color: Colors.grey),
- borderRadius: BorderRadius.circular(4)
- ),
- focusedBorder: OutlineInputBorder(
- borderSide: BorderSide(color: Color(0xFF68C93E)),
- borderRadius: BorderRadius.circular(4)
- )
- ),
- onTap: () async {
- now = await
- showDatePicker(
- context: context,
- initialDate: now,
- firstDate: now,
- lastDate: DateTime(DateTime.now().year + 1),
- builder: (BuildContext context, Widget child) {
- return Theme(
- child: child,
- data: ThemeData.light().copyWith(
- primaryColor: Color(0xFF68C93E),
- accentColor: Color(0xFF68C93E)
- ),
- );
- },
- );
- bn.setDate(widget.expiredProduct.product, item.id, now);
- _dateController.text = Util.format(now);
- }
- ),
- ),
- SizedBox(width: 17),
- Container(
- width: 70,
- height: 44,
- child: TextFormField(
- cursorColor: Color(0xFF68C93E),
- keyboardType: TextInputType.number,
- style: TextStyle(fontSize: 14, color: Color(0xFF4F4F4F)), textAlign: TextAlign.center,
- controller: _quantityController,
- decoration: InputDecoration(
- contentPadding: EdgeInsets.all(8),
- enabledBorder: OutlineInputBorder(
- borderSide: BorderSide(color: Colors.grey),
- borderRadius: BorderRadius.circular(4)
- ),
- focusedBorder: OutlineInputBorder(
- borderSide: BorderSide(color: Color(0xFF68C93E)),
- borderRadius: BorderRadius.circular(4)
- ),
- ),
- onTap: () async {
- bn.setQuantity(widget.expiredProduct.product, item.id, _quantityController);
- },
- ),
- ),
- SizedBox(width: 27),
- InkWell(
- onTap: () {
- bn.deleteExpired(widget.expiredProduct);
- },
- child: Icon(Icons.clear, color: Colors.grey)
- ),
- ],
- ),
- );
- }).toList();
- }
- @override
- Widget build(BuildContext context) {
- return Consumer<ExpiredProductNotifier>(
- builder: (_, bn, __) {
- return Container(
- color: Colors.white,
- padding: EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 8.0),
- child: Column(
- children: <Widget>[
- Row(
- mainAxisAlignment: MainAxisAlignment.start,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget> [
- Icon(Icons.check_circle, color: Color(0xFF68C93E), size: 20),
- SizedBox(width: 16),
- Container(
- height: 77.0,
- width: 77.0,
- decoration: BoxDecoration(
- image: DecorationImage(
- image: NetworkImage(widget.expiredProduct.product.thumbnail),
- fit: BoxFit.fill,
- ),
- border: Border.all(color: Color(0xFF68C93E)),
- borderRadius: BorderRadius.circular(5)
- ),
- ),
- SizedBox(width: 16),
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Text(
- widget.expiredProduct.product.name,
- style: TextStyle(color: Color(0xFF4F4F4F), fontWeight: FontWeight.bold),
- textAlign: TextAlign.left,
- maxLines: 2),
- SizedBox(height: 24),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text('Stok: 50 Karton', style: TextStyle(fontSize: 14, color: Color(0xFF4F4F4F))),
- InkWell(
- onTap: () {
- bn.deleteProduct(widget.expiredProduct.product);
- },
- child: SvgPicture.asset('assets/trash_fill.svg'))
- ],
- )
- ],
- ),
- ),
- ],
- ),
- SizedBox(height: 16.0),
- Divider(),
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- FlatButton(
- onPressed: () {
- bn.addExpired(widget.expiredProduct);
- },
- color: Color(0xFF68C93E),
- child: Text('+ Tambah Tanggal Kadaluarsa', style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(14)
- ),
- ),
- SizedBox(height: 16.0),
- Row(
- children: <Widget>[
- Text('Tanggal Kadaluarsa', style: TextStyle(color: Color(0xFF4F4F4F), fontWeight: FontWeight.bold)),
- SizedBox(width: 80),
- Text('Jumlah SKU', style: TextStyle(color: Color(0xFF4F4F4F), fontWeight: FontWeight.bold))
- ],
- ),
- SizedBox(height: 16.0),
- ...tanggalKadaluarsaWidgets(bn)],
- )
- ],
- ),
- );
- }
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement