101 lines
3.6 KiB
Dart
101 lines
3.6 KiB
Dart
import 'package:aman_kassa_flutter/redux/actions/kassa_actions.dart';
|
|
import 'package:aman_kassa_flutter/redux/store.dart';
|
|
import 'package:aman_kassa_flutter/shared/shared_styles.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:aman_kassa_flutter/shared/app_colors.dart';
|
|
import 'package:aman_kassa_flutter/core/models/product_dao.dart';
|
|
|
|
class ProductListItem extends StatelessWidget {
|
|
final ProductDao item;
|
|
final int index;
|
|
|
|
ProductListItem({this.item, this.index});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
color: index % 2 == 1 ? fillColor : whiteColor,
|
|
child: Padding(
|
|
padding: EdgeInsets.symmetric(vertical: 4, horizontal: 4),
|
|
child: Column(
|
|
children: <Widget>[
|
|
Row(
|
|
children: <Widget>[
|
|
Expanded(
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 4),
|
|
child: Text(item.name ?? 'name', style: productTextStyle,)),
|
|
),
|
|
Expanded(
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 4),
|
|
child: Text(
|
|
'${item.price?.toString()} x ${item.count?.toString()} = ${item.total?.toString()}',
|
|
textAlign: TextAlign.right, style: productTextStyle)),
|
|
)
|
|
],
|
|
),
|
|
Container(
|
|
margin: const EdgeInsets.only(bottom: 10.0),
|
|
child: Row(
|
|
children: <Widget>[
|
|
Expanded(
|
|
flex: 1,
|
|
child: Container(),
|
|
),
|
|
Expanded(
|
|
flex: 1,
|
|
child: Container(
|
|
//margin: const EdgeInsets.symmetric(horizontal: 4),
|
|
child: Row(
|
|
children: <Widget>[
|
|
buildClipRect(primaryColor,Icons.remove, () {
|
|
Redux.store.dispatch(counterProductFromKassaItems(index, -1));
|
|
}),
|
|
buildClipRect(primaryColor,Icons.add, () {
|
|
Redux.store.dispatch(counterProductFromKassaItems(index, 1));
|
|
}),
|
|
Expanded(
|
|
child: Container(
|
|
),
|
|
),
|
|
buildClipRect(redColor,Icons.close, () {
|
|
Redux.store.dispatch(removeProductFromKassaItems(index));
|
|
}),
|
|
],
|
|
)),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
Divider(
|
|
height: 1,
|
|
color: Colors.black38,
|
|
//thickness: 1,
|
|
indent: 4,
|
|
endIndent: 4,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
ClipRect buildClipRect(Color color, IconData icon, VoidCallback onPress) {
|
|
return ClipRect(
|
|
child: Container(
|
|
margin: const EdgeInsets.all(5),
|
|
decoration: BoxDecoration(
|
|
color: color
|
|
),
|
|
height: 35,
|
|
width: 35,
|
|
child: IconButton(
|
|
icon: Icon(icon, color: whiteColor, size: 20),
|
|
onPressed: onPress,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|