Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
B
Byodv2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dio Maulana
Byodv2
Commits
7e2362fc
Commit
7e2362fc
authored
Sep 28, 2022
by
Dio Maulana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change ordersbloc from array to json
parent
89abd9a1
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
729 additions
and
558 deletions
+729
-558
order_bloc.dart
lib/bloc/order_bloc.dart
+227
-111
order_detail_variant.dart
lib/bloc/order_detail_variant.dart
+6
-3
note_modal_bottom_sheet.dart
lib/helper/widget/note_modal_bottom_sheet.dart
+12
-13
bottom_sheet_menu.dart
lib/ui/home/bottom_sheet_menu.dart
+16
-15
bottom_sheet_menu_new.dart
lib/ui/home/bottom_sheet_menu_new.dart
+16
-15
bottom_sheet_note.dart
lib/ui/home/bottom_sheet_note.dart
+14
-13
fav_grid_menu.dart
lib/ui/home/fav_grid_menu.dart
+39
-41
menu.dart
lib/ui/home/menu.dart
+40
-46
menu_favorite.dart
lib/ui/home/menu_favorite.dart
+183
-183
menu_list_utama.dart
lib/ui/home/menu_list_utama.dart
+56
-45
variant_cat.dart
lib/ui/home/variant_cat.dart
+14
-15
variant_cat_new.dart
lib/ui/home/variant_cat_new.dart
+57
-15
view_bill_new.dart
lib/ui/viewbill/view_bill_new.dart
+49
-43
No files found.
lib/bloc/order_bloc.dart
View file @
7e2362fc
import
'package:byod/models/order_details.dart'
;
import
'package:flutter/cupertino.dart'
;
import
'package:flutter_bloc/flutter_bloc.dart'
;
import
'../models/orders.dart'
;
class
OrdersBloc
extends
Cubit
<
List
<
Orders
>>
{
OrdersBloc
()
:
super
([]);
void
insertData
(
List
<
dynamic
>
list
,
BuildContext
context
)
{
if
(
list
[
0
][
0
]
==
'editVariant'
)
{
void
insertData
(
Map
<
String
,
dynamic
>
json
)
{
if
(
json
[
'action'
]
==
'editVariant'
)
{
// hanya ketika bottom sheet muncul untuk order yang mempunyai variant
// Orders singleOrder = list[0][1];
List
<
Orders
>
listOrders
=
list
[
0
][
2
];
OrderDetail
singleOrderDetail
=
list
[
0
][
3
];
List
<
Orders
>
listOrders
=
json
[
'list_orders'
];
OrderDetail
singleOrderDetail
=
json
[
'single_order_detail'
];
int
indexListOrder
=
0
;
int
indexListOrderDetail
=
0
;
...
...
@@ -36,7 +35,7 @@ class OrdersBloc extends Cubit<List<Orders>> {
}
emit
(
listOrders
);
}
else
{
var
listOrderOld
=
list
[
0
][
4
];
// orderan lama
var
listOrderOld
=
json
[
'old_order'
];
// orderan lama
List
<
Orders
>
orders
=
[];
if
(
listOrderOld
.
length
!=
0
)
{
// orders = listOrderOld;
...
...
@@ -68,123 +67,240 @@ class OrdersBloc extends Cubit<List<Orders>> {
}
}
for
(
var
i
=
0
;
i
<
list
.
length
;
i
++)
{
// check apakah ada order dengan ID menu
int
index
=
orders
.
indexWhere
((
order
)
=>
order
.
id
==
list
[
i
][
0
]);
if
(
index
==
-
1
)
{
List
<
OrderDetail
>
orderDetail
=
[];
if
(
list
[
i
][
6
].
length
>
0
)
{
var
strItem
=
list
[
i
][
2
].
toString
();
var
intItem
=
int
.
parse
(
strItem
);
String
allIdVariant
=
''
;
for
(
int
ii
=
0
;
ii
<
list
[
i
][
6
].
length
;
ii
++)
{
allIdVariant
=
allIdVariant
+
list
[
i
][
6
][
ii
].
id
;
}
var
ss
=
{
'all_id_variant'
:
allIdVariant
,
'total_item'
:
intItem
,
'total_harga'
:
list
[
i
][
7
],
'note'
:
list
[
i
][
8
],
'variants'
:
list
[
i
][
6
],
};
orderDetail
.
add
(
OrderDetail
.
createOrderDetail
(
ss
));
int
index
=
orders
.
indexWhere
((
order
)
=>
order
.
id
==
json
[
'menu_id'
]);
if
(
index
==
-
1
)
{
List
<
OrderDetail
>
orderDetail
=
[];
if
(
json
[
'order_variant'
].
length
>
0
)
{
var
strItem
=
json
[
'initvalue'
].
toString
();
var
intItem
=
int
.
parse
(
strItem
);
String
allIdVariant
=
''
;
for
(
int
ii
=
0
;
ii
<
json
[
'order_variant'
].
length
;
ii
++)
{
allIdVariant
=
allIdVariant
+
json
[
'order_variant'
][
ii
].
id
;
}
if
(
list
[
i
][
2
]
!=
0
)
{
var
x
=
{
'id'
:
list
[
i
][
0
],
'namaMenu'
:
list
[
i
][
1
],
'totalItem'
:
list
[
i
][
2
],
'satuanHarga'
:
list
[
i
][
3
],
'image_url'
:
list
[
i
][
5
],
'order_detail'
:
orderDetail
,
'totalHarga'
:
list
[
i
][
7
],
'note'
:
list
[
i
][
8
],
var
ss
=
{
'all_id_variant'
:
allIdVariant
,
'total_item'
:
intItem
,
'total_harga'
:
json
[
'total_price'
],
'note'
:
json
[
'note'
],
'variants'
:
json
[
'order_variant'
],
};
orderDetail
.
add
(
OrderDetail
.
createOrderDetail
(
ss
));
}
if
(
json
[
'initvalue'
]
!=
0
)
{
var
x
=
{
'id'
:
json
[
'menu_id'
],
'namaMenu'
:
json
[
'menu_name'
],
'totalItem'
:
json
[
'initvalue'
],
'satuanHarga'
:
json
[
'menu_price'
],
'image_url'
:
json
[
'image_url'
],
'order_detail'
:
orderDetail
,
'totalHarga'
:
json
[
'total_price'
],
'note'
:
json
[
'note'
],
};
orders
.
add
(
Orders
.
createOrders
(
x
));
}
}
else
{
int
finalTotalItem
=
0
;
int
finalTotalHarga
=
0
;
if
(
orders
[
index
].
orderDetail
.
isNotEmpty
)
{
List
<
OrderDetail
>
oldOrderDetail
=
[];
// oldOrderDetail = orders[index].orderDetail;
// harus di looping orderan lama, kalau gak blocnya gak ke update, gatau kenapa ?????
for
(
int
yx
=
0
;
yx
<
orders
[
index
].
orderDetail
.
length
;
yx
++)
{
var
ty
=
{
"all_id_variant"
:
orders
[
index
].
orderDetail
[
yx
].
allIdVariant
,
"total_item"
:
orders
[
index
].
orderDetail
[
yx
].
totalItem
,
"total_harga"
:
orders
[
index
].
orderDetail
[
yx
].
totalHarga
,
"note"
:
orders
[
index
].
orderDetail
[
yx
].
note
,
"variants"
:
orders
[
index
].
orderDetail
[
yx
].
orderVariant
,
};
o
rders
.
add
(
Orders
.
createOrders
(
x
));
o
ldOrderDetail
.
add
(
OrderDetail
.
createOrderDetail
(
ty
));
}
}
else
{
int
finalTotalItem
=
0
;
int
finalTotalHarga
=
0
;
if
(
orders
[
index
].
orderDetail
.
isNotEmpty
)
{
List
<
OrderDetail
>
oldOrderDetail
=
[];
// oldOrderDetail = orders[index].orderDetail;
// harus di looping orderan lama, kalau gak blocnya gak ke update, gatau kenapa ?????
for
(
int
yx
=
0
;
yx
<
orders
[
index
].
orderDetail
.
length
;
yx
++)
{
var
ty
=
{
"all_id_variant"
:
orders
[
index
].
orderDetail
[
yx
].
allIdVariant
,
"total_item"
:
orders
[
index
].
orderDetail
[
yx
].
totalItem
,
"total_harga"
:
orders
[
index
].
orderDetail
[
yx
].
totalHarga
,
"note"
:
orders
[
index
].
orderDetail
[
yx
].
note
,
"variants"
:
orders
[
index
].
orderDetail
[
yx
].
orderVariant
,
// check apakah order detail dengan variant yang sama ada atau tidak
String
allIdVariantCheck
=
''
;
for
(
int
ii
=
0
;
ii
<
json
[
'order_variant'
].
length
;
ii
++)
{
allIdVariantCheck
=
allIdVariantCheck
+
json
[
'order_variant'
][
ii
].
id
;
}
int
indexOrderDetail
=
oldOrderDetail
.
indexWhere
((
detail
)
=>
detail
.
allIdVariant
==
allIdVariantCheck
);
if
(
indexOrderDetail
==
-
1
)
{
// ini jika tidak ada maka tambahkan order detail yang baru
if
(
json
[
'order_variant'
].
length
>
0
)
{
String
allIdVariant
=
''
;
for
(
int
ii
=
0
;
ii
<
json
[
'order_variant'
].
length
;
ii
++)
{
allIdVariant
=
allIdVariant
+
json
[
'order_variant'
][
ii
].
id
;
}
var
ss
=
{
'all_id_variant'
:
allIdVariant
,
'total_item'
:
json
[
'initvalue'
],
'total_harga'
:
json
[
'total_price'
],
'note'
:
json
[
'note'
],
'variants'
:
json
[
'order_variant'
],
};
oldOrderDetail
.
add
(
OrderDetail
.
createOrderDetail
(
ty
));
}
// check apakah order detail dengan variant yang sama ada atau tidak
String
allIdVariantCheck
=
''
;
for
(
int
ii
=
0
;
ii
<
list
[
i
][
6
].
length
;
ii
++)
{
allIdVariantCheck
=
allIdVariantCheck
+
list
[
i
][
6
][
ii
].
id
;
oldOrderDetail
.
add
(
OrderDetail
.
createOrderDetail
(
ss
));
}
int
indexOrderDetail
=
oldOrderDetail
.
indexWhere
(
(
detail
)
=>
detail
.
allIdVariant
==
allIdVariantCheck
);
if
(
indexOrderDetail
==
-
1
)
{
// ini jika tidak ada maka tambahkan order detail yang baru
if
(
list
[
i
][
6
].
length
>
0
)
{
String
allIdVariant
=
''
;
for
(
int
ii
=
0
;
ii
<
list
[
i
][
6
].
length
;
ii
++)
{
allIdVariant
=
allIdVariant
+
list
[
i
][
6
][
ii
].
id
;
}
var
ss
=
{
'all_id_variant'
:
allIdVariant
,
'total_item'
:
list
[
i
][
2
],
'total_harga'
:
list
[
i
][
7
],
'note'
:
list
[
i
][
8
],
'variants'
:
list
[
i
][
6
],
};
oldOrderDetail
.
add
(
OrderDetail
.
createOrderDetail
(
ss
));
}
int
totalItemOrderDetail
=
0
;
int
totalHargaOrderDetail
=
0
;
for
(
int
ky
=
0
;
ky
<
oldOrderDetail
.
length
;
ky
++)
{
totalItemOrderDetail
+=
oldOrderDetail
[
ky
].
totalItem
;
totalHargaOrderDetail
+=
oldOrderDetail
[
ky
].
totalHarga
;
}
orders
[
index
].
orderDetail
=
oldOrderDetail
;
finalTotalItem
=
totalItemOrderDetail
;
finalTotalHarga
=
totalHargaOrderDetail
;
}
else
{
// jika sama, maka hanya tambahkan total item dan total harga
orders
[
index
].
orderDetail
[
indexOrderDetail
].
totalItem
=
orders
[
index
].
orderDetail
[
indexOrderDetail
].
totalItem
+
int
.
parse
(
list
[
i
][
2
].
toString
());
finalTotalItem
=
orders
[
index
].
orderDetail
[
indexOrderDetail
].
totalItem
+
int
.
parse
(
list
[
i
][
2
].
toString
());
orders
[
index
].
orderDetail
[
indexOrderDetail
].
totalHarga
=
orders
[
index
].
orderDetail
[
indexOrderDetail
].
totalHarga
+
int
.
parse
(
list
[
i
][
7
].
toString
());
finalTotalHarga
=
orders
[
index
].
orderDetail
[
indexOrderDetail
].
totalHarga
+
int
.
parse
(
list
[
i
][
7
].
toString
());
int
totalItemOrderDetail
=
0
;
int
totalHargaOrderDetail
=
0
;
for
(
int
ky
=
0
;
ky
<
oldOrderDetail
.
length
;
ky
++)
{
totalItemOrderDetail
+=
oldOrderDetail
[
ky
].
totalItem
;
totalHargaOrderDetail
+=
oldOrderDetail
[
ky
].
totalHarga
;
}
orders
[
index
].
orderDetail
=
oldOrderDetail
;
finalTotalItem
=
totalItemOrderDetail
;
finalTotalHarga
=
totalHargaOrderDetail
;
}
else
{
var
s
=
list
[
i
][
2
].
toString
();
var
ss
=
int
.
parse
(
s
);
finalTotalItem
=
ss
;
finalTotalHarga
=
int
.
parse
(
list
[
i
][
7
].
toString
());
}
orders
[
index
].
note
=
list
[
i
][
8
];
// note di array ke 8
// jika sama, maka hanya tambahkan total item dan total harga
orders
[
index
].
orderDetail
[
indexOrderDetail
].
totalItem
=
orders
[
index
].
orderDetail
[
indexOrderDetail
].
totalItem
+
int
.
parse
(
json
[
'initvalue'
].
toString
());
finalTotalItem
=
orders
[
index
].
orderDetail
[
indexOrderDetail
].
totalItem
+
int
.
parse
(
json
[
'initvalue'
].
toString
());
orders
[
index
].
totalItem
=
finalTotalItem
;
orders
[
index
].
totalHarga
=
finalTotalHarga
;
if
(
orders
[
index
].
totalItem
==
0
)
{
orders
.
removeAt
(
index
);
orders
[
index
].
orderDetail
[
indexOrderDetail
].
totalHarga
=
orders
[
index
].
orderDetail
[
indexOrderDetail
].
totalHarga
+
int
.
parse
(
json
[
'total_price'
].
toString
());
finalTotalHarga
=
orders
[
index
].
orderDetail
[
indexOrderDetail
].
totalHarga
+
int
.
parse
(
json
[
'total_price'
].
toString
());
}
}
else
{
var
s
=
json
[
'initvalue'
].
toString
();
var
ss
=
int
.
parse
(
s
);
finalTotalItem
=
ss
;
finalTotalHarga
=
int
.
parse
(
json
[
'total_price'
].
toString
());
}
orders
[
index
].
note
=
json
[
'note'
];
// note di array ke 8
orders
[
index
].
totalItem
=
finalTotalItem
;
orders
[
index
].
totalHarga
=
finalTotalHarga
;
if
(
orders
[
index
].
totalItem
==
0
)
{
orders
.
removeAt
(
index
);
}
}
emit
(
orders
);
// for (var i = 0; i < list.length; i++) {
// // check apakah ada order dengan ID menu
// int index = orders.indexWhere((order) => order.id == list[i][0]);
// if (index == -1) {
// List<OrderDetail> orderDetail = [];
// if (list[i][6].length > 0) {
// var strItem = list[i][2].toString();
// var intItem = int.parse(strItem);
// String allIdVariant = '';
// for (int ii = 0; ii < list[i][6].length; ii++) {
// allIdVariant = allIdVariant + list[i][6][ii].id;
// }
// var ss = {
// 'all_id_variant': allIdVariant,
// 'total_item': intItem,
// 'total_harga': list[i][7],
// 'note': list[i][8],
// 'variants': list[i][6],
// };
// orderDetail.add(OrderDetail.createOrderDetail(ss));
// }
// if (list[i][2] != 0) {
// var x = {
// 'id': list[i][0],
// 'namaMenu': list[i][1],
// 'totalItem': list[i][2],
// 'satuanHarga': list[i][3],
// 'image_url': list[i][5],
// 'order_detail': orderDetail,
// 'totalHarga': list[i][7],
// 'note': list[i][8],
// };
// orders.add(Orders.createOrders(x));
// }
// } else {
// int finalTotalItem = 0;
// int finalTotalHarga = 0;
// if (orders[index].orderDetail.isNotEmpty) {
// List<OrderDetail> oldOrderDetail = [];
// // oldOrderDetail = orders[index].orderDetail;
// // harus di looping orderan lama, kalau gak blocnya gak ke update, gatau kenapa ?????
// for (int yx = 0; yx < orders[index].orderDetail.length; yx++) {
// var ty = {
// "all_id_variant": orders[index].orderDetail[yx].allIdVariant,
// "total_item": orders[index].orderDetail[yx].totalItem,
// "total_harga": orders[index].orderDetail[yx].totalHarga,
// "note": orders[index].orderDetail[yx].note,
// "variants": orders[index].orderDetail[yx].orderVariant,
// };
// oldOrderDetail.add(OrderDetail.createOrderDetail(ty));
// }
// // check apakah order detail dengan variant yang sama ada atau tidak
// String allIdVariantCheck = '';
// for (int ii = 0; ii < list[i][6].length; ii++) {
// allIdVariantCheck = allIdVariantCheck + list[i][6][ii].id;
// }
// int indexOrderDetail = oldOrderDetail.indexWhere(
// (detail) => detail.allIdVariant == allIdVariantCheck);
// if (indexOrderDetail == -1) {
// // ini jika tidak ada maka tambahkan order detail yang baru
// if (list[i][6].length > 0) {
// String allIdVariant = '';
// for (int ii = 0; ii < list[i][6].length; ii++) {
// allIdVariant = allIdVariant + list[i][6][ii].id;
// }
// var ss = {
// 'all_id_variant': allIdVariant,
// 'total_item': list[i][2],
// 'total_harga': list[i][7],
// 'note': list[i][8],
// 'variants': list[i][6],
// };
// oldOrderDetail.add(OrderDetail.createOrderDetail(ss));
// }
// int totalItemOrderDetail = 0;
// int totalHargaOrderDetail = 0;
// for (int ky = 0; ky < oldOrderDetail.length; ky++) {
// totalItemOrderDetail += oldOrderDetail[ky].totalItem;
// totalHargaOrderDetail += oldOrderDetail[ky].totalHarga;
// }
// orders[index].orderDetail = oldOrderDetail;
// finalTotalItem = totalItemOrderDetail;
// finalTotalHarga = totalHargaOrderDetail;
// } else {
// // jika sama, maka hanya tambahkan total item dan total harga
// orders[index].orderDetail[indexOrderDetail].totalItem =
// orders[index].orderDetail[indexOrderDetail].totalItem +
// int.parse(list[i][2].toString());
// finalTotalItem =
// orders[index].orderDetail[indexOrderDetail].totalItem +
// int.parse(list[i][2].toString());
// orders[index].orderDetail[indexOrderDetail].totalHarga =
// orders[index].orderDetail[indexOrderDetail].totalHarga +
// int.parse(list[i][7].toString());
// finalTotalHarga =
// orders[index].orderDetail[indexOrderDetail].totalHarga +
// int.parse(list[i][7].toString());
// }
// } else {
// var s = list[i][2].toString();
// var ss = int.parse(s);
// finalTotalItem = ss;
// finalTotalHarga = int.parse(list[i][7].toString());
// }
// orders[index].note = list[i][8]; // note di array ke 8
// orders[index].totalItem = finalTotalItem;
// orders[index].totalHarga = finalTotalHarga;
// if (orders[index].totalItem == 0) {
// orders.removeAt(index);
// }
// }
// }
// emit(orders);
}
}
...
...
lib/bloc/order_detail_variant.dart
View file @
7e2362fc
...
...
@@ -30,9 +30,12 @@ class OrderDetailVariant extends Cubit<OrderDetail> {
totalHarga:
totalHarga
,
note:
note
,
orderVariant:
orderVariant
);
context
.
read
<
OrdersBloc
>().
insertData
([
[
'editVariant'
,
orders
,
listCurrentOrder
,
orderDetailNow
]
],
context
);
Map
<
String
,
dynamic
>
insertData
=
{
'action'
:
'editVariant'
,
'list_orders'
:
listCurrentOrder
,
'single_order_detail'
:
orderDetailNow
,
};
context
.
read
<
OrdersBloc
>().
insertData
(
insertData
);
emit
(
orderDetailNow
);
}
...
...
lib/helper/widget/note_modal_bottom_sheet.dart
View file @
7e2362fc
...
...
@@ -86,19 +86,18 @@ class NoteModalBottomSheet extends StatelessWidget {
GestureDetector
(
onTap:
()
{
if
(
from
==
fromMenu
)
{
context
.
read
<
OrdersBloc
>().
insertData
([
[
menuItem
.
id
,
menuItem
.
name
,
initialValue
,
amountParseToInt
(
menuItem
.
price
),
lisrOrders
,
menuItem
.
imageUrlMedium
,
orderVariants
,
amountParseToInt
(
menuItem
.
price
),
noteController
.
text
]
],
context
);
Map
<
String
,
dynamic
>
insertData
=
{
'menu_id'
:
menuItem
.
id
,
'menu_name'
:
menuItem
.
name
,
'initvalue'
:
initialValue
,
'menu_price'
:
amountParseToInt
(
menuItem
.
price
),
'old_order'
:
lisrOrders
,
'image_url'
:
menuItem
.
imageUrlMedium
,
'total_price'
:
amountParseToInt
(
menuItem
.
price
),
'order_variant'
:
orderVariants
,
'note'
:
noteController
.
text
,
};
context
.
read
<
OrdersBloc
>().
insertData
(
insertData
);
}
else
if
(
from
==
fromBill
)
{
if
(
idOrderan
!=
''
)
{
Api
.
changeOrderDetail
(
...
...
lib/ui/home/bottom_sheet_menu.dart
View file @
7e2362fc
...
...
@@ -192,21 +192,22 @@ class _ShowMenuModalState extends State<ShowMenuModal> {
}
}
else
{
initialValue
+=
1
;
context
.
read
<
OrdersBloc
>().
insertData
([
[
widget
.
id
,
widget
.
namaMenu
,
initialValue
,
widget
.
hargaMenu
,
list
,
widget
.
imageUrl
,
orderVariants
,
widget
.
hargaMenu
,
(
indexListOrderan
!=
-
1
)
?
list
[
indexListOrderan
].
note
:
''
,
]
],
context
);
Map
<
String
,
dynamic
>
insertData
=
{
'menu_id'
:
widget
.
id
,
'menu_name'
:
widget
.
namaMenu
,
'initvalue'
:
initialValue
,
'menu_price'
:
widget
.
hargaMenu
,
'total_price'
:
widget
.
hargaMenu
,
'old_order'
:
list
,
'image_url'
:
widget
.
imageUrl
,
'order_variant'
:
[],
'note'
:
(
indexListOrderan
!=
-
1
)
?
list
[
indexListOrderan
].
note
:
''
,
};
context
.
read
<
OrdersBloc
>()
.
insertData
(
insertData
);
Navigator
.
pop
(
context
);
}
}
...
...
lib/ui/home/bottom_sheet_menu_new.dart
View file @
7e2362fc
...
...
@@ -158,21 +158,22 @@ class ShowMenuBottomSheet extends StatelessWidget {
}
}
else
{
initialValue
+=
1
;
context
.
read
<
OrdersBloc
>().
insertData
([
[
menuDetail
[
i
].
id
,
menuDetail
[
i
].
name
,
initialValue
,
amountParseToInt
(
menuDetail
[
i
].
price
),
list
,
menuDetail
[
i
].
imageUrlMedium
,
[],
amountParseToInt
(
menuDetail
[
i
].
price
),
(
indexListOrderan
!=
-
1
)
?
list
[
indexListOrderan
].
note
:
''
,
]
],
context
);
Map
<
String
,
dynamic
>
insertData
=
{
'menu_id'
:
menuDetail
[
i
].
id
,
'menu_name'
:
menuDetail
[
i
].
name
,
'initvalue'
:
initialValue
,
'menu_price'
:
amountParseToInt
(
menuDetail
[
i
].
price
),
'total_price'
:
amountParseToInt
(
menuDetail
[
i
].
price
),
'old_order'
:
list
,
'image_url'
:
menuDetail
[
i
].
imageUrlMedium
,
'order_variant'
:
[],
'note'
:
(
indexListOrderan
!=
-
1
)
?
list
[
indexListOrderan
].
note
:
''
,
};
context
.
read
<
OrdersBloc
>().
insertData
(
insertData
);
Navigator
.
pop
(
context
);
}
}
...
...
lib/ui/home/bottom_sheet_note.dart
View file @
7e2362fc
...
...
@@ -109,19 +109,20 @@ GestureDetector noteMenu(
onPressed:
()
async
{
// list[index].note = noteController.text;
if
(
callFrom
==
fromMenu
)
{
context
.
read
<
OrdersBloc
>().
insertData
([
[
id
,
namaMenu
,
initialValue
,
hargaFix
,
list
,
imageUrl
,
orderVariants
,
hargaFix
,
noteController
.
text
]
],
context
);
Map
<
String
,
dynamic
>
insertData
=
{
'menu_id'
:
id
,
'menu_name'
:
namaMenu
,
'initvalue'
:
initialValue
,
'menu_price'
:
hargaFix
,
'total_price'
:
hargaFix
,
'old_order'
:
list
,
'image_url'
:
imageUrl
,
'order_variant'
:
[],
'note'
:
noteController
.
text
,
};
context
.
read
<
OrdersBloc
>()
.
insertData
(
insertData
);
}
else
if
(
callFrom
==
fromBill
)
{
await
Api
.
changeOrderDetail
(
context
,
...
...
lib/ui/home/fav_grid_menu.dart
View file @
7e2362fc
...
...
@@ -222,19 +222,19 @@ class FavGridMenu extends StatelessWidget {
}
if
(
initialValue
>
0
)
{
initialValue
-=
1
;
context
.
read
<
OrdersBloc
>().
insertData
([
[
menuFav
.
id
,
menuFav
.
nam
e
,
initialValue
,
amountParseToInt
(
menuFav
.
price
)
,
list
,
menuFav
.
imageUrlMedium
,
orderVariants
,
amountParseToInt
(
menuFav
.
price
),
(
indexListOrderan
!=
-
1
)
?
list
[
indexListOrderan
].
note
:
''
]
],
context
);
Map
<
String
,
dynamic
>
insertData
=
{
'menu_id'
:
menuFav
.
id
,
'menu_name'
:
menuFav
.
name
,
'initvalue'
:
initialValu
e
,
'menu_price'
:
amountParseToInt
(
menuFav
.
price
)
,
'old_order'
:
list
,
'total_price'
:
amountParseToInt
(
menuFav
.
price
)
,
'image_url'
:
menuFav
.
imageUrlMedium
,
'order_variant'
:
[]
,
'note'
:
(
indexListOrderan
!=
-
1
)
?
list
[
indexListOrderan
].
note
:
''
,
};
context
.
read
<
OrdersBloc
>().
insertData
(
insertData
);
// setState(() {});
}
}
...
...
@@ -246,19 +246,18 @@ class FavGridMenu extends StatelessWidget {
currentFocus
.
unfocus
();
}
initialValue
+=
1
;
context
.
read
<
OrdersBloc
>().
insertData
([
[
menuFav
.
id
,
menuFav
.
name
,
initialValue
,
amountParseToInt
(
menuFav
.
price
),
list
,
menuFav
.
imageUrlMedium
,
orderVariants
,
amountParseToInt
(
menuFav
.
price
),
(
indexListOrderan
!=
-
1
)
?
list
[
indexListOrderan
].
note
:
''
,
]
],
context
);
Map
<
String
,
dynamic
>
insertData
=
{
'menu_id'
:
menuFav
.
id
,
'menu_name'
:
menuFav
.
name
,
'initvalue'
:
initialValue
,
'menu_price'
:
amountParseToInt
(
menuFav
.
price
),
'total_price'
:
amountParseToInt
(
menuFav
.
price
),
'old_order'
:
list
,
'image_url'
:
menuFav
.
imageUrlMedium
,
'order_variant'
:
[],
'note'
:
(
indexListOrderan
!=
-
1
)
?
list
[
indexListOrderan
].
note
:
''
,
};
context
.
read
<
OrdersBloc
>().
insertData
(
insertData
);
}
return
AnimatedSwitcher
(
...
...
@@ -320,21 +319,20 @@ class FavGridMenu extends StatelessWidget {
}
else
{
if
(
initialValue
==
0
)
{
initialValue
+=
1
;
context
.
read
<
OrdersBloc
>().
insertData
([
[
menuFav
.
id
,
menuFav
.
name
,
initialValue
,
amountParseToInt
(
menuFav
.
price
),
list
,
menuFav
.
imageUrlMedium
,
orderVariants
,
amountParseToInt
(
menuFav
.
price
),
(
indexListOrderan
!=
-
1
)
?
list
[
indexListOrderan
].
note
:
''
]
],
context
);
Map
<
String
,
dynamic
>
insertData
=
{
'menu_id'
:
menuFav
.
id
,
'menu_name'
:
menuFav
.
name
,
'initvalue'
:
initialValue
,
'menu_price'
:
amountParseToInt
(
menuFav
.
price
),
'total_price'
:
amountParseToInt
(
menuFav
.
price
),
'old_order'
:
list
,
'image_url'
:
menuFav
.
imageUrlMedium
,
'order_variant'
:
[],
'note'
:
(
indexListOrderan
!=
-
1
)
?
list
[
indexListOrderan
].
note
:
''
,
};
context
.
read
<
OrdersBloc
>().
insertData
(
insertData
);
// setState(() {});
}
}
...
...
lib/ui/home/menu.dart
View file @
7e2362fc
...
...
@@ -278,21 +278,19 @@ class _MenuViewState extends State<MenuView> {
}
else
{
if
(
initialValue
==
0
)
{
initialValue
+=
1
;
context
.
read
<
OrdersBloc
>().
insertData
([
[
widget
.
id
,
widget
.
namaMenu
,
initialValue
,
widget
.
hargaFix
,
list
,
widget
.
imageUrl
,
orderVariants
,
widget
.
hargaFix
,
(
indexListOrderan
!=
-
1
)
?
list
[
indexListOrderan
].
note
:
''
]
],
context
);
Map
<
String
,
dynamic
>
insertData
=
{
'menu_id'
:
widget
.
id
,
'menu_name'
:
widget
.
namaMenu
,
'initvalue'
:
initialValue
,
'menu_price'
:
widget
.
hargaFix
,
'old_order'
:
list
,
'image_url'
:
widget
.
imageUrl
,
'order_variant'
:
[],
'note'
:
(
indexListOrderan
!=
-
1
)
?
list
[
indexListOrderan
].
note
:
''
,
};
context
.
read
<
OrdersBloc
>().
insertData
(
insertData
);
// setState(() {});
}
}
...
...
@@ -339,24 +337,21 @@ class _MenuViewState extends State<MenuView> {
onTap:
()
{
if
(
initialValue
>
0
)
{
initialValue
-=
1
;
Map
<
String
,
dynamic
>
insertData
=
{
'menu_id'
:
widget
.
id
,
'menu_name'
:
widget
.
namaMenu
,
'initvalue'
:
initialValue
,
'menu_price'
:
widget
.
hargaFix
,
'old_order'
:
list
,
'image_url'
:
widget
.
imageUrl
,
'order_variant'
:
[],
'note'
:
(
indexListOrderan
!=
-
1
)
?
list
[
indexListOrderan
].
note
:
''
,
};
context
.
read
<
OrdersBloc
>()
.
insertData
([
[
widget
.
id
,
widget
.
namaMenu
,
initialValue
,
widget
.
hargaFix
,
list
,
widget
.
imageUrl
,
orderVariants
,
widget
.
hargaFix
,
(
indexListOrderan
!=
-
1
)
?
list
[
indexListOrderan
]
.
note
:
''
]
],
context
);
.
insertData
(
insertData
);
// setState(() {});
}
},
...
...
@@ -394,23 +389,22 @@ class _MenuViewState extends State<MenuView> {
GestureDetector
(
onTap:
()
{
initialValue
+=
1
;
Map
<
String
,
dynamic
>
insertData
=
{
'menu_id'
:
widget
.
id
,
'menu_name'
:
widget
.
namaMenu
,
'initvalue'
:
initialValue
,
'menu_price'
:
widget
.
hargaFix
,
'total_price'
:
widget
.
hargaFix
,
'old_order'
:
list
,
'image_url'
:
widget
.
imageUrl
,
'order_variant'
:
[],
'note'
:
(
indexListOrderan
!=
-
1
)
?
list
[
indexListOrderan
].
note
:
''
,
};
context
.
read
<
OrdersBloc
>()
.
insertData
([
[
widget
.
id
,
widget
.
namaMenu
,
initialValue
,
widget
.
hargaFix
,
list
,
widget
.
imageUrl
,
orderVariants
,
widget
.
hargaFix
,
(
indexListOrderan
!=
-
1
)
?
list
[
indexListOrderan
].
note
:
''
,
]
],
context
);
.
insertData
(
insertData
);
// setState(() {});
},
child:
Container
(
...
...
lib/ui/home/menu_favorite.dart
View file @
7e2362fc
// ignore_for_file: must_be_immutable
//
//
ignore_for_file: must_be_immutable
import
'package:byod/models/orders.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_bloc/flutter_bloc.dart'
;
//
import 'package:byod/models/orders.dart';
//
import 'package:flutter/material.dart';
//
import 'package:flutter_bloc/flutter_bloc.dart';
import
'../../bloc/order_bloc.dart'
;
import
'../../helper/helper.dart'
;
//
import '../../bloc/order_bloc.dart';
//
import '../../helper/helper.dart';
class
MenuFavorite
extends
StatefulWidget
{
String
id
;
int
hargaFix
;
int
hargaCoret
;
String
namaMenu
;
MenuFavorite
(
{
Key
?
key
,
required
this
.
id
,
required
this
.
hargaFix
,
required
this
.
hargaCoret
,
required
this
.
namaMenu
})
:
super
(
key:
key
);
//
class MenuFavorite extends StatefulWidget {
//
String id;
//
int hargaFix;
//
int hargaCoret;
//
String namaMenu;
//
MenuFavorite(
//
{Key? key,
//
required this.id,
//
required this.hargaFix,
//
required this.hargaCoret,
//
required this.namaMenu})
//
: super(key: key);
@override
State
<
MenuFavorite
>
createState
()
=>
_MenuFavoriteState
();
}
//
@override
//
State<MenuFavorite> createState() => _MenuFavoriteState();
//
}
class
_MenuFavoriteState
extends
State
<
MenuFavorite
>
{
int
initialValue
=
0
;
//
class _MenuFavoriteState extends State<MenuFavorite> {
//
int initialValue = 0;
@override
Widget
build
(
BuildContext
context
)
{
return
Container
(
// alignment: Alignment.center,
padding:
const
EdgeInsets
.
only
(
top:
5
),
decoration:
BoxDecoration
(
// color: Colors.red,
borderRadius:
BorderRadius
.
circular
(
15
)),
child:
BlocBuilder
<
OrdersBloc
,
List
<
Orders
>>(
builder:
(
context
,
list
)
{
return
Column
(
children:
[
Container
(
height:
MediaQuery
.
of
(
context
).
size
.
height
*
0.25
,
decoration:
BoxDecoration
(
// color: Colors.red,
borderRadius:
BorderRadius
.
circular
(
15
)),
child:
ClipRRect
(
borderRadius:
BorderRadius
.
circular
(
15
),
child:
const
Image
(
fit:
BoxFit
.
fill
,
image:
NetworkImage
(
'https://www.siftandsimmer.com/wp-content/uploads/2021/03/matcha-espresso-fusion1.jpg'
),
),
),
),
Container
(
height:
MediaQuery
.
of
(
context
).
size
.
height
*
0.075
,
width:
double
.
infinity
,
margin:
EdgeInsets
.
only
(
top:
MediaQuery
.
of
(
context
).
size
.
height
*
0.01
,
bottom:
MediaQuery
.
of
(
context
).
size
.
width
*
0.01
),
// color: Colors.green,
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Text
(
widget
.
namaMenu
,
maxLines:
2
,
overflow:
TextOverflow
.
ellipsis
,
style:
const
TextStyle
(
fontWeight:
FontWeight
.
w500
,
fontSize:
20
),
),
const
SizedBox
(
height:
10
),
Row
(
children:
[
Text
(
formatNumber
().
format
(
widget
.
hargaFix
),
overflow:
TextOverflow
.
clip
,
style:
const
TextStyle
(
fontWeight:
FontWeight
.
w500
,
fontSize:
15
),
),
const
SizedBox
(
width:
5
),
Text
(
formatNumber
().
format
(
widget
.
hargaCoret
),
overflow:
TextOverflow
.
clip
,
style:
const
TextStyle
(
fontWeight:
FontWeight
.
w400
,
fontSize:
15
,
color:
Colors
.
black45
,
decoration:
TextDecoration
.
lineThrough
),
),
],
),
],
),
),
GestureDetector
(
onTap:
()
{
if
(
initialValue
==
0
)
{
initialValue
+=
1
;
context
.
read
<
OrdersBloc
>().
insertData
([
[
widget
.
id
,
widget
.
namaMenu
,
1
,
widget
.
hargaFix
,
list
]
],
context
);
setState
(()
{});
}
},
child:
Container
(
height:
MediaQuery
.
of
(
context
).
size
.
height
*
0.04
,
width:
MediaQuery
.
of
(
context
).
size
.
width
*
0.3
,
decoration:
BoxDecoration
(
color:
(
initialValue
==
0
)
?
buttonColor
:
null
,
borderRadius:
BorderRadius
.
circular
(
20
)),
child:
AnimatedSwitcher
(
duration:
Duration
(
milliseconds:
animatedTime
),
transitionBuilder:
(
child
,
animation
)
=>
ScaleTransition
(
scale:
animation
,
child:
child
),
child:
(
initialValue
>
0
)
?
Row
(
key:
const
Key
(
'1'
),
mainAxisAlignment:
MainAxisAlignment
.
spaceAround
,
children:
[
GestureDetector
(
onTap:
()
{
if
(
initialValue
>
0
)
{
initialValue
-=
1
;
context
.
read
<
OrdersBloc
>().
insertData
([
[
widget
.
id
,
widget
.
namaMenu
,
-
1
,
widget
.
hargaFix
,
list
]
],
context
);
setState
(()
{});
}
},
child:
Icon
(
Icons
.
remove_circle_outline_rounded
,
color:
buttonColor
,
),
),
// const SizedBox(width: 10),
Text
(
initialValue
.
toString
(),
style:
const
TextStyle
(
fontSize:
20
,
fontWeight:
FontWeight
.
w400
,
color:
Colors
.
black54
),
),
// const SizedBox(width: 10),
GestureDetector
(
onTap:
()
{
initialValue
+=
1
;
context
.
read
<
OrdersBloc
>().
insertData
([
[
widget
.
id
,
widget
.
namaMenu
,
1
,
widget
.
hargaFix
,
list
]
],
context
);
setState
(()
{});
},
child:
Icon
(
Icons
.
add_circle_outline_rounded
,
color:
buttonColor
,
),
),
],
)
:
const
Center
(
key:
Key
(
'2'
),
child:
Text
(
"Add"
,
style:
TextStyle
(
fontWeight:
FontWeight
.
w600
,
color:
textInButton
),
)),
)),
)
],
);
},
),
);
}
}
//
@override
//
Widget build(BuildContext context) {
//
return Container(
//
// alignment: Alignment.center,
//
padding: const EdgeInsets.only(top: 5),
//
decoration: BoxDecoration(
//
// color: Colors.red,
//
borderRadius: BorderRadius.circular(15)),
//
child: BlocBuilder<OrdersBloc, List<Orders>>(
//
builder: (context, list) {
//
return Column(
//
children: [
//
Container(
//
height: MediaQuery.of(context).size.height * 0.25,
//
decoration: BoxDecoration(
//
// color: Colors.red,
//
borderRadius: BorderRadius.circular(15)),
//
child: ClipRRect(
//
borderRadius: BorderRadius.circular(15),
//
child: const Image(
//
fit: BoxFit.fill,
//
image: NetworkImage(
//
'https://www.siftandsimmer.com/wp-content/uploads/2021/03/matcha-espresso-fusion1.jpg'),
//
),
//
),
//
),
//
Container(
//
height: MediaQuery.of(context).size.height * 0.075,
//
width: double.infinity,
//
margin: EdgeInsets.only(
//
top: MediaQuery.of(context).size.height * 0.01,
//
bottom: MediaQuery.of(context).size.width * 0.01),
//
// color: Colors.green,
//
child: Column(
//
crossAxisAlignment: CrossAxisAlignment.start,
//
children: [
//
Text(
//
widget.namaMenu,
//
maxLines: 2,
//
overflow: TextOverflow.ellipsis,
//
style: const TextStyle(
//
fontWeight: FontWeight.w500, fontSize: 20),
//
),
//
const SizedBox(height: 10),
//
Row(
//
children: [
//
Text(
//
formatNumber().format(widget.hargaFix),
//
overflow: TextOverflow.clip,
//
style: const TextStyle(
//
fontWeight: FontWeight.w500, fontSize: 15),
//
),
//
const SizedBox(width: 5),
//
Text(
//
formatNumber().format(widget.hargaCoret),
//
overflow: TextOverflow.clip,
//
style: const TextStyle(
//
fontWeight: FontWeight.w400,
//
fontSize: 15,
//
color: Colors.black45,
//
decoration: TextDecoration.lineThrough),
//
),
//
],
//
),
//
],
//
),
//
),
//
GestureDetector(
//
onTap: () {
//
if (initialValue == 0) {
//
initialValue += 1;
//
context.read<OrdersBloc>().insertData([
//
[widget.id, widget.namaMenu, 1, widget.hargaFix, list]
//
], context);
//
setState(() {});
//
}
//
},
//
child: Container(
//
height: MediaQuery.of(context).size.height * 0.04,
//
width: MediaQuery.of(context).size.width * 0.3,
//
decoration: BoxDecoration(
//
color: (initialValue == 0) ? buttonColor : null,
//
borderRadius: BorderRadius.circular(20)),
//
child: AnimatedSwitcher(
//
duration: Duration(milliseconds: animatedTime),
//
transitionBuilder: (child, animation) =>
//
ScaleTransition(scale: animation, child: child),
//
child: (initialValue > 0)
//
? Row(
//
key: const Key('1'),
//
mainAxisAlignment: MainAxisAlignment.spaceAround,
//
children: [
//
GestureDetector(
//
onTap: () {
//
if (initialValue > 0) {
//
initialValue -= 1;
//
context.read<OrdersBloc>().insertData([
//
[
//
widget.id,
//
widget.namaMenu,
//
-1,
//
widget.hargaFix,
//
list
//
]
//
], context);
//
setState(() {});
//
}
//
},
//
child: Icon(
//
Icons.remove_circle_outline_rounded,
//
color: buttonColor,
//
),
//
),
//
// const SizedBox(width: 10),
//
Text(
//
initialValue.toString(),
//
style: const TextStyle(
//
fontSize: 20,
//
fontWeight: FontWeight.w400,
//
color: Colors.black54),
//
),
//
// const SizedBox(width: 10),
//
GestureDetector(
//
onTap: () {
//
initialValue += 1;
//
context.read<OrdersBloc>().insertData([
//
[
//
widget.id,
//
widget.namaMenu,
//
1,
//
widget.hargaFix,
//
list
//
]
//
], context);
//
setState(() {});
//
},
//
child: Icon(
//
Icons.add_circle_outline_rounded,
//
color: buttonColor,
//
),
//
),
//
],
//
)
//
: const Center(
//
key: Key('2'),
//
child: Text(
//
"Add",
//
style: TextStyle(
//
fontWeight: FontWeight.w600,
//
color: textInButton),
//
)),
//
)),
//
)
//
],
//
);
//
},
//
),
//
);
//
}
//
}
lib/ui/home/menu_list_utama.dart
View file @
7e2362fc
...
...
@@ -4,7 +4,6 @@ import 'package:byod/bloc/order_bloc.dart';
import
'package:byod/helper/widget/button_modal.dart'
;
import
'package:byod/helper/widget/plus_minus_button.dart'
;
import
'package:byod/models/orders.dart'
;
import
'package:byod/ui/home/variant_cat.dart'
;
import
'package:byod/ui/screen_responsive.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_bloc/flutter_bloc.dart'
;
...
...
@@ -14,7 +13,6 @@ import '../../helper/helper.dart';
import
'../../helper/widget/note_modal_bottom_sheet.dart'
;
import
'../../helper/widget/style.dart'
;
import
'../../models/filter_menu.dart'
;
import
'../../models/order_details.dart'
;
import
'../../models/order_variants.dart'
;
import
'bottom_sheet_menu_new.dart'
;
import
'bottom_sheet_variant.dart'
;
...
...
@@ -195,7 +193,7 @@ class MenuListUtama extends StatelessWidget {
addCondition
;
// true untuk menampilkan tambah, false untuk menampilkan quantity plus minus
int
indexListOrderan
=
list
.
indexWhere
((
listOrderan
)
=>
listOrderan
.
id
==
menuUtama
.
id
);
int
initialValue
;
int
initialValue
=
0
;
if
(
indexListOrderan
!=
-
1
)
{
if
(
menuUtama
.
variantCat
.
isNotEmpty
)
{
addCondition
=
true
;
// kalau menu itu ada variantnya, biarin true
...
...
@@ -203,7 +201,15 @@ class MenuListUtama extends StatelessWidget {
addCondition
=
false
;
}
initialValue
=
list
[
indexListOrderan
].
totalItem
;
if
(
list
[
indexListOrderan
].
orderDetail
.
isNotEmpty
)
{
for
(
int
d
=
0
;
d
<
list
[
indexListOrderan
].
orderDetail
.
length
;
d
++)
{
initialValue
+=
list
[
indexListOrderan
].
orderDetail
[
d
].
totalItem
;
}
}
else
{
initialValue
=
list
[
indexListOrderan
].
totalItem
;
}
}
else
{
addCondition
=
true
;
initialValue
=
0
;
...
...
@@ -225,19 +231,19 @@ class MenuListUtama extends StatelessWidget {
}
if
(
initialValue
>
0
)
{
initialValue
-=
1
;
context
.
read
<
OrdersBloc
>().
insertData
([
[
menuUtama
.
id
,
menuUtama
.
nam
e
,
initialValue
,
amountParseToInt
(
menuUtama
.
price
),
list
,
menuUtama
.
imageUrlMedium
,
orderVariants
,
amountParseToInt
(
menuUtama
.
price
),
(
indexListOrderan
!=
-
1
)
?
list
[
indexListOrderan
].
note
:
''
]
],
context
);
Map
<
String
,
dynamic
>
insertData
=
{
'menu_id'
:
menuUtama
.
id
,
'menu_name'
:
menuUtama
.
name
,
'initvalue'
:
initialValu
e
,
'menu_price'
:
amountParseToInt
(
menuUtama
.
price
)
,
'total_price'
:
amountParseToInt
(
menuUtama
.
price
),
'old_order'
:
list
,
'image_url'
:
menuUtama
.
imageUrlMedium
,
'order_variant'
:
[]
,
'note'
:
(
indexListOrderan
!=
-
1
)
?
list
[
indexListOrderan
].
note
:
''
,
};
context
.
read
<
OrdersBloc
>().
insertData
(
insertData
);
// setState(() {});
}
}
...
...
@@ -249,19 +255,18 @@ class MenuListUtama extends StatelessWidget {
currentFocus
.
unfocus
();
}
initialValue
+=
1
;
context
.
read
<
OrdersBloc
>().
insertData
([
[
menuUtama
.
id
,
menuUtama
.
name
,
initialValue
,
amountParseToInt
(
menuUtama
.
price
),
list
,
menuUtama
.
imageUrlMedium
,
orderVariants
,
amountParseToInt
(
menuUtama
.
price
),
(
indexListOrderan
!=
-
1
)
?
list
[
indexListOrderan
].
note
:
''
,
]
],
context
);
Map
<
String
,
dynamic
>
insertData
=
{
'menu_id'
:
menuUtama
.
id
,
'menu_name'
:
menuUtama
.
name
,
'initvalue'
:
initialValue
,
'menu_price'
:
amountParseToInt
(
menuUtama
.
price
),
'total_price'
:
amountParseToInt
(
menuUtama
.
price
),
'old_order'
:
list
,
'image_url'
:
menuUtama
.
imageUrlMedium
,
'order_variant'
:
[],
'note'
:
(
indexListOrderan
!=
-
1
)
?
list
[
indexListOrderan
].
note
:
''
,
};
context
.
read
<
OrdersBloc
>().
insertData
(
insertData
);
}
return
AnimatedSwitcher
(
...
...
@@ -325,6 +330,9 @@ class MenuListUtama extends StatelessWidget {
amountParseToInt
(
menuUtama
.
price
),
variantCategories:
menuUtama
.
variantCat
,
namaMenu:
menuUtama
.
name
,
idItem:
menuUtama
.
id
,
imageUrl:
menuUtama
.
imageUrlMedium
,
listCurrentOrder:
list
,
),
),
);
...
...
@@ -343,21 +351,24 @@ class MenuListUtama extends StatelessWidget {
}
else
{
if
(
initialValue
==
0
)
{
initialValue
+=
1
;
context
.
read
<
OrdersBloc
>().
insertData
([
[
menuUtama
.
id
,
menuUtama
.
name
,
initialValue
,
amountParseToInt
(
menuUtama
.
price
),
list
,
menuUtama
.
imageUrlMedium
,
orderVariants
,
amountParseToInt
(
menuUtama
.
price
),
(
indexListOrderan
!=
-
1
)
?
list
[
indexListOrderan
].
note
:
''
]
],
context
);
Map
<
String
,
dynamic
>
insertData
=
{
'menu_id'
:
menuUtama
.
id
,
'menu_name'
:
menuUtama
.
name
,
'initvalue'
:
initialValue
,
'menu_price'
:
amountParseToInt
(
menuUtama
.
price
),
'total_price'
:
amountParseToInt
(
menuUtama
.
price
),
'old_order'
:
list
,
'image_url'
:
menuUtama
.
imageUrlMedium
,
'order_variant'
:
[],
'note'
:
(
indexListOrderan
!=
-
1
)
?
list
[
indexListOrderan
].
note
:
''
,
};
context
.
read
<
OrdersBloc
>()
.
insertData
(
insertData
);
// setState(() {});
}
}
...
...
lib/ui/home/variant_cat.dart
View file @
7e2362fc
...
...
@@ -345,21 +345,20 @@ class _VariantCatState extends State<VariantCat> {
}
}
if
(
prosesOrderan
)
{
context
.
read
<
OrdersBloc
>().
insertData
([
[
widget
.
idItem
,
widget
.
namaMenu
,
initialValue
,
widget
.
initPrice
,
widget
.
listCurrentOrder
,
widget
.
imageUrl
,
orderVariants
,
totalPrice
,
(
noteCatController
.
text
.
isEmpty
)
?
''
:
noteCatController
.
text
]
],
context
);
Map
<
String
,
dynamic
>
insertData
=
{
'menu_id'
:
widget
.
idItem
,
'menu_name'
:
widget
.
namaMenu
,
'initvalue'
:
initialValue
,
'menu_price'
:
widget
.
initPrice
,
'total_price'
:
totalPrice
,
'old_order'
:
widget
.
listCurrentOrder
,
'image_url'
:
widget
.
imageUrl
,
'order_variant'
:
orderVariants
,
'note'
:
(
noteCatController
.
text
.
isEmpty
)
?
''
:
noteCatController
.
text
,
};
context
.
read
<
OrdersBloc
>().
insertData
(
insertData
);
Navigator
.
pop
(
context
);
}
else
{
EasyLoading
.
showToast
(
...
...
lib/ui/home/variant_cat_new.dart
View file @
7e2362fc
// ignore_for_file: sized_box_for_whitespace, must_be_immutable
import
'package:byod/helper/helper.dart'
;
import
'package:byod/helper/widget/button_modal.dart'
;
import
'package:byod/helper/widget/style.dart'
;
import
'package:byod/models/order_details.dart'
;
import
'package:byod/ui/home/variant_new.dart'
;
import
'package:byod/ui/screen_responsive.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_bloc/flutter_bloc.dart'
;
import
'package:flutter_easyloading/flutter_easyloading.dart'
;
import
'../../bloc/order_bloc.dart'
;
import
'../../bloc/order_variant_temporary.dart'
;
import
'../../bloc/order_variant_value.dart'
;
import
'../../helper/widget/plus_minus_button.dart'
;
import
'../../main.dart'
;
import
'../../models/order_variants.dart'
;
import
'../../models/orders.dart'
;
import
'../../models/variant_categories.dart'
;
class
VariantCatNew
extends
StatefulWidget
{
final
List
<
VariantCategories
>
variantCategories
;
final
int
initPrice
;
final
String
namaMenu
;
final
String
idItem
;
final
List
<
Orders
>
listCurrentOrder
;
final
String
imageUrl
;
const
VariantCatNew
({
Key
?
key
,
required
this
.
variantCategories
,
required
this
.
initPrice
,
required
this
.
namaMenu
,
required
this
.
idItem
,
required
this
.
listCurrentOrder
,
required
this
.
imageUrl
,
})
:
super
(
key:
key
);
@override
...
...
@@ -93,6 +103,8 @@ class _VariantCatNewState extends State<VariantCatNew> {
satuanPrice:
satuanPrice
,
totalPrice:
totalPrice
,
context:
context
,
orderVariants:
orderVariants
,
noteCatController:
noteCatController
,
),
isCoreLayout:
true
,
widthScreen:
MediaQuery
.
of
(
context
).
size
.
width
,
...
...
@@ -118,6 +130,8 @@ class CoreVariant extends StatelessWidget {
required
this
.
satuanPrice
,
required
this
.
totalPrice
,
required
this
.
context
,
required
this
.
orderVariants
,
required
this
.
noteCatController
,
})
:
super
(
key:
key
);
final
double
widthScreen
;
...
...
@@ -129,6 +143,8 @@ class CoreVariant extends StatelessWidget {
final
int
satuanPrice
;
final
int
totalPrice
;
final
BuildContext
context
;
final
List
<
OrderVariant
>
orderVariants
;
final
TextEditingController
noteCatController
;
void
plus
()
{
initialValue
+=
1
;
context
...
...
@@ -301,6 +317,7 @@ class CoreVariant extends StatelessWidget {
Container
(
height:
35
,
child:
TextField
(
controller:
noteCatController
,
maxLength:
maxLengthTextField
,
autofocus:
false
,
style:
const
TextStyle
(
...
...
@@ -397,21 +414,46 @@ class CoreVariant extends StatelessWidget {
const
SizedBox
(
height:
14
,
),
Container
(
height:
43
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
33
),
color:
buttonColor
,
),
child:
Center
(
child:
defaultText
(
context
,
'Tambahkan - Rp
${formatNumber().format(totalPrice)}
'
,
style:
addButton
(
font:
14
,
),
),
),
GestureDetector
(
onTap:
()
{
bool
prosesOrderan
=
true
;
for
(
int
y
=
0
;
y
<
widget
.
variantCategories
.
length
;
y
++)
{
if
(
widget
.
variantCategories
[
y
].
type
==
typeMandatory
)
{
int
index
=
orderVariants
.
indexWhere
((
order
)
=>
order
.
categoryId
==
widget
.
variantCategories
[
y
].
id
);
if
(
index
==
-
1
)
{
prosesOrderan
=
false
;
}
}
}
if
(
prosesOrderan
)
{
Map
<
String
,
dynamic
>
insertData
=
{
'menu_id'
:
widget
.
idItem
,
'menu_name'
:
widget
.
namaMenu
,
'initvalue'
:
initialValue
,
'menu_price'
:
widget
.
initPrice
,
'old_order'
:
widget
.
listCurrentOrder
,
'image_url'
:
widget
.
imageUrl
,
'order_variant'
:
orderVariants
,
'note'
:
(
noteCatController
.
text
.
isEmpty
)
?
''
:
noteCatController
.
text
,
'total_price'
:
totalPrice
,
};
context
.
read
<
OrdersBloc
>().
insertData
(
insertData
);
Navigator
.
pop
(
context
);
}
else
{
EasyLoading
.
showToast
(
'Masih ada variant yang belum dipilih'
);
}
},
child:
ButtonComponent
(
buttonColor:
buttonColor
,
teksButton:
'Tambahkan - Rp
${formatNumber().format(totalPrice)}
'
),
)
],
),
...
...
lib/ui/viewbill/view_bill_new.dart
View file @
7e2362fc
...
...
@@ -512,10 +512,9 @@ class CoreBill extends StatelessWidget {
isHistory:
isHistory
,
tableStatus:
dataBill
[
0
].
tableStatus
,
),
const
SizedBox
(
height:
24
,
),
const
AddMoreOrder
(),
(
dataBill
[
0
].
tableStatus
==
tableStatusOpen
)
?
const
AddMoreOrder
()
:
const
SizedBox
(),
const
SizedBox
(
height:
24
,
),
...
...
@@ -1838,52 +1837,59 @@ class AddMoreOrder extends StatelessWidget {
color:
backgroundWhite
,
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
paddingLeftRight
),
// color: Colors.red,
child:
Row
(
child:
Column
(
children:
[
Expanded
(
child:
Container
(
child:
defaultText
(
context
,
'Tambahkan menu lainnya?'
,
maxLines:
2
,
overFlow:
TextOverflow
.
ellipsis
,
style:
viewbillStyle
(
font:
16
,
fontWeight:
FontWeight
.
w400
,
),
),
),
),
const
SizedBox
(
width:
19
,
height:
24
,
),
GestureDetector
(
onTap:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
_
)
=>
const
NewHome2
(),
Row
(
children:
[
Expanded
(
child:
Container
(
child:
defaultText
(
context
,
'Tambahkan menu lainnya?'
,
maxLines:
2
,
overFlow:
TextOverflow
.
ellipsis
,
style:
viewbillStyle
(
font:
16
,
fontWeight:
FontWeight
.
w400
,
),
),
),
);
},
child:
Container
(
width:
98
,
height:
30
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
21
),
color:
buttonColor
,
),
child:
Center
(
child:
defaultText
(
context
,
'Tambah'
,
style:
addButton
(
font:
8
,
const
SizedBox
(
width:
19
,
),
GestureDetector
(
onTap:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
_
)
=>
const
NewHome2
(),
),
);
},
child:
Container
(
width:
98
,
height:
30
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
21
),
color:
buttonColor
,
),
child:
Center
(
child:
defaultText
(
context
,
'Tambah'
,
style:
addButton
(
font:
8
,
),
),
),
),
)
,
)
,
)
)
]
,
)
,
],
),
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment