Commit ec2a72b9 authored by Dio Maulana's avatar Dio Maulana

home page dan variant page

parent 21f22719
......@@ -244,10 +244,11 @@ double heightTombol = 0.06; // untuk dikalikan di height media query
//** core warna */
// const Color backgroundColor = Colors.white;
const Color backgroundColor = Color(0xffE5E5E5);
const Color backgroundColor = Color(0xffF4F4F4);
const textColorTabel = Color(0xff333333);
const textColorBlack = Color(0xff000000);
const textColorRed = Color(0xffE73636);
const textColorPlaceHolder = Color(0xffA89C9C);
const textGrey = Color(0xffE0E0E0);
const textGreyDeskripsi = Color(0xffBDBDBD);
const backgroundColorBottomSheet = Color(0xffE5E5E5);
......@@ -420,6 +421,10 @@ const heigthButtonBottom = 0.08;
const positionedBottom = 0.01;
//** padding bottom untuk button stack */
//** padding left right page */
const double paddingLeftRight = 20;
//** padding left right page */
//** Max widht screen */
bool useResponsive = isResponsive;
const double maxWidthScreens = 500;
......@@ -471,6 +476,9 @@ const double pencilSize = 0.02;
const String backIcon = '\uf060';
const double backIconSize = 0.03;
const String arrowBack = '\uf060';
const double arrowBackSize = 17;
const String shopingBag = '\uf290';
const double shopingBagSize = 0.03;
......
import 'dart:ui';
import 'package:byod/helper/helper.dart';
import 'package:flutter/material.dart';
......@@ -26,6 +24,15 @@ Text defaultText(
);
}
TextStyle appBarNameVariant({font = 17, Color color = textColorBlack}) {
return TextStyle(
fontFamily: 'Mulish',
fontSize: font,
fontWeight: FontWeight.w700,
color: color,
);
}
TextStyle tableNameStyle({font = 20, Color color = textColorTabel}) {
return TextStyle(
fontFamily: (fontFamily == '') ? null : fontFamily,
......@@ -58,7 +65,7 @@ TextStyle menuNameGridFav(
return TextStyle(
fontFamily: 'Roboto',
fontSize: font,
fontWeight: FontWeight.w500,
fontWeight: FontWeight.w600,
color: color,
);
}
......@@ -118,7 +125,7 @@ TextStyle subCategoryStyle({
return TextStyle(
fontFamily: 'Roboto',
fontSize: font,
fontWeight: FontWeight.w500,
fontWeight: FontWeight.w600,
color: color,
);
}
......@@ -142,7 +149,7 @@ TextStyle menuNameStyle({
return TextStyle(
fontFamily: 'Roboto',
fontSize: font,
fontWeight: FontWeight.w500,
fontWeight: FontWeight.w600,
color: color,
);
}
......@@ -272,6 +279,19 @@ Text fontAwesome(BuildContext context, String unicode, double fontSize,
);
}
Text fontAwesomeNew(String unicode, double fontSize,
{Color? color, isBold = true}) {
return Text(
unicode,
style: TextStyle(
fontFamily: 'FontAwesome',
fontSize: fontSize,
color: color,
fontWeight: (isBold) ? FontWeight.w600 : FontWeight.w400,
),
);
}
Text fontAwesomeCart(BuildContext context, String unicode, double fontSize,
{Color? color, isBold = true}) {
// double widthScreens = responsiveWidthScreen(context);
......@@ -533,6 +553,20 @@ TextStyle textStyleAddButton(
);
}
TextStyle variantStyleText(
{Color? textColor,
TextDecoration? decoration,
font = 20,
FontWeight? fontWeight}) {
return TextStyle(
fontFamily: (fontFamily == '') ? null : fontFamily,
fontSize: font,
fontWeight: (fontWeight == null) ? FontWeight.w600 : fontWeight,
color: (textColor == null) ? null : textColorBlack,
decoration: (decoration == null) ? null : decoration,
);
}
TextStyle textStyleRefresh(context) {
return TextStyle(
fontFamily: (fontFamily == '') ? null : fontFamily,
......
class CategoryList {
final String name;
final String id;
final double offset;
CategoryList({
required this.name,
required this.id,
required this.offset,
});
factory CategoryList.createCategoryList(Map<String, dynamic> json) {
return CategoryList(
id: json['id'],
name: json['name'],
offset: json['offset'] ?? 0,
);
}
}
......@@ -49,8 +49,10 @@ class _CategoryListHomeState extends State<CategoryListHome> {
.read<MenuSelectedBar>()
.selectedBarMenu(i, widget.categoryList[i].id);
widget.scrollController.animateTo(
(widget.favList.isNotEmpty) ? 371 : 0,
duration: Duration(milliseconds: animatedTime),
(widget.favList.isNotEmpty)
? 371
: 0, // 371 sudah dihituing pixelnya untuk awal banget dari menu item
duration: const Duration(milliseconds: 500),
curve: Curves.fastOutSlowIn,
);
},
......@@ -78,7 +80,7 @@ class _CategoryListHomeState extends State<CategoryListHome> {
key: const Key('underline'),
margin: const EdgeInsets.only(top: 27),
width: 30,
height: 2,
height: 1,
color: buttonColor)
: const SizedBox(
key: Key('underline'),
......
......@@ -357,9 +357,8 @@ class FavGridMenu extends StatelessWidget {
child: Container(
width: 22,
height: 22,
child: Image(
color: buttonColor,
image: const AssetImage('assets/icons/minus.png'),
child: const Image(
image: AssetImage('assets/icons/minus-blue.png'),
),
),
),
......
......@@ -63,7 +63,7 @@ class _FavoriteListState extends State<FavoriteList> {
key: const Key('underline'),
margin: const EdgeInsets.only(top: 2),
width: 30,
height: 2,
height: 1,
color: buttonColor)
: const SizedBox(
key: Key('underline'),
......
......@@ -15,6 +15,7 @@ import '../../models/order_details.dart';
import '../../models/order_variants.dart';
import 'bottom_sheet_menu.dart';
import 'bottom_sheet_variant.dart';
import 'variant_cat_new.dart';
class MenuListUtama extends StatelessWidget {
const MenuListUtama({
......@@ -242,27 +243,37 @@ class MenuListUtama extends StatelessWidget {
1,
[],
); // check pada bloc untuk mengethui list arraynya
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (_) => VariantCat(
// namaMenu: menuUtama.name,
// variantCategories:
// menuUtama.variantCat,
// initPrice: amountParseToInt(
// menuUtama.price),
// idItem: menuUtama.id,
// imageUrl:
// menuUtama.imageUrlThumbnail,
// listCurrentOrder: list,
// orderDetail: OrderDetail(
// allIdVariant: '',
// totalItem: 0,
// totalHarga: 0,
// note: '',
// orderVariant: [],
// ),
// )));
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => VariantCat(
namaMenu: menuUtama.name,
variantCategories:
menuUtama.variantCat,
initPrice: amountParseToInt(
menuUtama.price),
idItem: menuUtama.id,
imageUrl:
menuUtama.imageUrlThumbnail,
listCurrentOrder: list,
orderDetail: OrderDetail(
allIdVariant: '',
totalItem: 0,
totalHarga: 0,
note: '',
orderVariant: [],
),
)));
context,
MaterialPageRoute(
builder: (_) => VariantCatNew(
initPrice:
amountParseToInt(menuUtama.price),
variantCategories: menuUtama.variantCat,
),
),
);
} else {
showModalBottomSheet(
backgroundColor: Colors.white.withOpacity(0),
......@@ -417,7 +428,7 @@ class MenuListUtama extends StatelessWidget {
child: Image(
color: buttonColor,
image: const AssetImage(
'assets/icons/minus.png'),
'assets/icons/minus-blue.png'),
),
),
),
......
......@@ -198,7 +198,6 @@ class _NewHome2State extends State<NewHome2> {
favListHeight -
categoryFont -
spacerAboveCatList;
double paddingLeftRight = 20;
int tableMode = prefs.getInt('table_mode') ?? defaultTable;
String tableNumber = prefs.getString("table_number") ?? "";
......@@ -232,103 +231,149 @@ class _NewHome2State extends State<NewHome2> {
return shouldPop ?? false;
},
child: SafeArea(
child: Scaffold(
backgroundColor: backgroundColor,
body: (restoran == responseByodBranchExist)
? BlocBuilder<FilterMenuBloc, List<FilterMenu>>(
builder: (contextBlocListCat, categoryDefault) {
if (categoryDefault.isNotEmpty &&
categoryDefault[0].id == "0") {
return errorResponseByod(
'Gagal mendapatkan menu, silahkan refresh halaman / scan ulang barcode');
} else if (categoryDefault.isNotEmpty) {
List<FilterMenu> categoryFavTemp = [];
List<FilterMenu> categoryNonFavTemp = [];
child: GestureDetector(
onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
for (var menu in categoryDefault) {
if (!menu.isFavMenu) {
categoryNonFavTemp.add(menu);
} else {
categoryFavTemp.add(menu);
}
}
categoryNonFav = categoryNonFavTemp;
categoryFav = categoryFavTemp;
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
},
child: Scaffold(
backgroundColor: backgroundColor,
body: (restoran == responseByodBranchExist)
? BlocBuilder<FilterMenuBloc, List<FilterMenu>>(
builder: (contextBlocListCat, categoryDefault) {
if (categoryDefault.isNotEmpty &&
categoryDefault[0].id == "0") {
return errorResponseByod(
'Gagal mendapatkan menu, silahkan refresh halaman / scan ulang barcode');
} else if (categoryDefault.isNotEmpty) {
List<FilterMenu> categoryFavTemp = [];
List<FilterMenu> categoryNonFavTemp = [];
allMenu = categoryNonFav;
allMenuFav = categoryFav;
List<CategoryList> catListTemp = [];
var nn = {
"name": "All",
"id": "0",
}; // all dulu, biar ada bisa klik all
catListTemp.add(CategoryList.createCategoryList(nn));
for (var nameCat in categoryNonFav) {
if (nameCat.type == typeCategory) {
var n = {
"id": nameCat.id,
"name": nameCat.categoryName
};
catListTemp
.add(CategoryList.createCategoryList(n));
for (var menu in categoryDefault) {
if (!menu.isFavMenu) {
categoryNonFavTemp.add(menu);
} else {
categoryFavTemp.add(menu);
}
}
categoryNonFav = categoryNonFavTemp;
categoryFav = categoryFavTemp;
categoryList = catListTemp;
}
List<FavoriteGroup> favGroupTemp = [];
for (var nameFav in categoryFav) {
if (nameFav.type == typeCategory) {
var nfav = {
"name": nameFav.categoryName,
"id": nameFav.id
};
favGroupTemp.add(FavoriteGroup.add(nfav));
allMenu = categoryNonFav;
allMenuFav = categoryFav;
List<CategoryList> catListTemp = [];
var nn = {
"name": "All",
"id": "0",
"offset": 0,
}; // all dulu, biar ada bisa klik all
catListTemp
.add(CategoryList.createCategoryList(nn));
for (var nameCat in categoryNonFav) {
if (nameCat.type == typeCategory) {
var n = {
"id": nameCat.id,
"name": nameCat.categoryName,
};
catListTemp
.add(CategoryList.createCategoryList(n));
}
}
}
favList = favGroupTemp;
if (isFirstLoad) {
if (favList.isNotEmpty) {
context
.read<FavSelectedBar>()
.selectedBarFav(0, favList[0].id);
categoryList = catListTemp;
List<FavoriteGroup> favGroupTemp = [];
for (var nameFav in categoryFav) {
if (nameFav.type == typeCategory) {
var nfav = {
"name": nameFav.categoryName,
"id": nameFav.id
};
favGroupTemp.add(FavoriteGroup.add(nfav));
}
}
if (categoryList.isNotEmpty) {
context
.read<MenuSelectedBar>()
.selectedBarMenu(0, categoryList[0].id);
favList = favGroupTemp;
if (isFirstLoad) {
if (favList.isNotEmpty) {
context
.read<FavSelectedBar>()
.selectedBarFav(0, favList[0].id);
}
if (categoryList.isNotEmpty) {
context
.read<MenuSelectedBar>()
.selectedBarMenu(0, categoryList[0].id);
}
}
}
}
return BlocBuilder<FavSelectedBar,
Map<String, dynamic>>(
builder: (contextFavSelectedBar, listDynamicBar) {
if (categoryFav.isNotEmpty && favList.isNotEmpty) {
List<FilterMenu> temporSelectedFav = [];
for (var nameFav in categoryFav) {
if (nameFav.type == typeMenu &&
nameFav.favGroupId == listDynamicBar['id']) {
temporSelectedFav.add(nameFav);
return BlocBuilder<FavSelectedBar,
Map<String, dynamic>>(
builder: (contextFavSelectedBar, listDynamicBar) {
if (categoryFav.isNotEmpty && favList.isNotEmpty) {
List<FilterMenu> temporSelectedFav = [];
for (var nameFav in categoryFav) {
if (nameFav.type == typeMenu &&
nameFav.favGroupId ==
listDynamicBar['id']) {
temporSelectedFav.add(nameFav);
}
}
categoryFavAfterSelect = temporSelectedFav;
}
categoryFavAfterSelect = temporSelectedFav;
}
return BlocBuilder<SearchMenu, List<dynamic>>(
builder: (contextSearch, listSearch) {
// if (listSearch[0].isNotEmpty) {
// print(listSearch[0]);
// }
return BlocBuilder<MenuSelectedBar,
Map<String, dynamic>>(
builder: (contextSelectedBarMenu,
listDynamicBarMenu) {
if (isSearchActive) {
if (categoryNonFav.isNotEmpty &&
categoryList.isNotEmpty) {
if (listSearch[0].length == 1 &&
listSearch[0][0].id == 'start') {
return BlocBuilder<SearchMenu, List<dynamic>>(
builder: (contextSearch, listSearch) {
return BlocBuilder<MenuSelectedBar,
Map<String, dynamic>>(
builder: (contextSelectedBarMenu,
listDynamicBarMenu) {
if (isSearchActive) {
if (categoryNonFav.isNotEmpty &&
categoryList.isNotEmpty) {
if (listSearch[0].length == 1 &&
listSearch[0][0].id == 'start') {
List<FilterMenu> temprSelectedMenu =
[];
for (var nameCat in categoryNonFav) {
if (nameCat.categoryId ==
listDynamicBarMenu['id']) {
temprSelectedMenu.add(nameCat);
}
}
if (listDynamicBarMenu['index'] ==
0) {
categoryMenuAfterSelect =
categoryNonFav;
} else {
categoryMenuAfterSelect =
temprSelectedMenu;
}
} else {
if (listDynamicBarMenu['id'] != "0") {
List<FilterMenu> temprSearchMenu =
[];
for (var nameMenuSearch
in listSearch[0]) {
if (listDynamicBarMenu['id'] ==
nameMenuSearch.categoryId) {
temprSearchMenu
.add(nameMenuSearch);
}
}
categoryMenuAfterSelect =
temprSearchMenu;
} else {
categoryMenuAfterSelect =
listSearch[0];
}
}
}
} else {
if (categoryNonFav.isNotEmpty &&
categoryList.isNotEmpty) {
List<FilterMenu> temprSelectedMenu = [];
for (var nameCat in categoryNonFav) {
if (nameCat.categoryId ==
......@@ -343,199 +388,118 @@ class _NewHome2State extends State<NewHome2> {
categoryMenuAfterSelect =
temprSelectedMenu;
}
} else {
// for (var nameCatSearch
// in listSearch[0]) {
// if (listDynamicBarMenu.length == 2) {
// if (listDynamicBarMenu[1] != "0" &&
// nameCatSearch.categoryId ==
// listDynamicBarMenu[1]) {
// temprSearchMenu
// .add(nameCatSearch);
// }
// }
// }
if (listDynamicBarMenu['id'] != "0") {
List<FilterMenu> temprSearchMenu = [];
for (var nameMenuSearch
in listSearch[0]) {
if (listDynamicBarMenu['id'] ==
nameMenuSearch.categoryId) {
temprSearchMenu
.add(nameMenuSearch);
}
}
categoryMenuAfterSelect =
temprSearchMenu;
} else {
categoryMenuAfterSelect =
listSearch[0];
}
// if (listDynamicBarMenu.length == 2 &&
// listDynamicBarMenu[0] == 0) {
// categoryMenuAfterSelect =
// categoryNonFav;
// } else {
// categoryMenuAfterSelect =
// temprSelectedMenu;
// }
}
// if (listDynamicBarMenu.length == 2 &&
// isScrollableMenu == true &&
// _scrollController.position.pixels ==
// _scrollController
// .position.maxScrollExtent &&
// _scrollMenuItem.position.pixels > 0) {
// _scrollMenuItem.animateTo(
// 1,
// duration:
// Duration(milliseconds: animatedTime),
// curve: Curves.fastOutSlowIn,
// );
// }
}
} else {
if (categoryNonFav.isNotEmpty &&
categoryList.isNotEmpty) {
List<FilterMenu> temprSelectedMenu = [];
for (var nameCat in categoryNonFav) {
if (nameCat.categoryId ==
listDynamicBarMenu['id']) {
temprSelectedMenu.add(nameCat);
}
}
if (listDynamicBarMenu['index'] == 0) {
categoryMenuAfterSelect =
categoryNonFav;
} else {
categoryMenuAfterSelect =
temprSelectedMenu;
}
// if (listDynamicBarMenu.length == 2 &&
// isScrollableMenu == true &&
// _scrollController.position.pixels ==
// _scrollController
// .position.maxScrollExtent &&
// _scrollMenuItem.position.pixels > 0) {
// _scrollMenuItem.animateTo(
// 1,
// duration:
// Duration(milliseconds: animatedTime),
// curve: Curves.fastOutSlowIn,
// );
// }
}
}
return BlocBuilder<OrdersBloc, List<Orders>>(
builder: (contextOrders, listOrders) {
int totalItem = 0;
int totalHarga = 0;
if (listOrders.isNotEmpty) {
int fixTotalHarga = 0;
int totalHargaOrderDetail = 0;
int totalHargaBukanOrderDetail = 0;
return BlocBuilder<OrdersBloc,
List<Orders>>(
builder: (contextOrders, listOrders) {
int totalItem = 0;
int totalHarga = 0;
if (listOrders.isNotEmpty) {
int fixTotalHarga = 0;
int totalHargaOrderDetail = 0;
int totalHargaBukanOrderDetail = 0;
int fixTotalItem = 0;
int totalItemOrderDetail = 0;
int totalItemBukanOrderDetail = 0;
for (var i = 0;
i < listOrders.length;
i++) {
// totalItem += listOrders[i].totalItem;
// check apakah ada order detail. kalau ada rekalkulasi total harga sesuai order detail
if (listOrders[i]
.orderDetail
.isEmpty) {
totalHargaBukanOrderDetail +=
(listOrders[i].totalItem *
listOrders[i].totalHarga);
totalItemBukanOrderDetail +=
listOrders[i].totalItem;
} else {
for (int kk = 0;
kk <
int fixTotalItem = 0;
int totalItemOrderDetail = 0;
int totalItemBukanOrderDetail = 0;
for (var i = 0;
i < listOrders.length;
i++) {
// totalItem += listOrders[i].totalItem;
// check apakah ada order detail. kalau ada rekalkulasi total harga sesuai order detail
if (listOrders[i]
.orderDetail
.isEmpty) {
totalHargaBukanOrderDetail +=
(listOrders[i].totalItem *
listOrders[i].totalHarga);
totalItemBukanOrderDetail +=
listOrders[i].totalItem;
} else {
for (int kk = 0;
kk <
listOrders[i]
.orderDetail
.length;
kk++) {
totalHargaOrderDetail +=
listOrders[i]
.orderDetail
.length;
kk++) {
totalHargaOrderDetail +=
listOrders[i]
.orderDetail[kk]
.totalHarga;
totalItemOrderDetail +=
listOrders[i]
.orderDetail[kk]
.totalItem;
.orderDetail[kk]
.totalHarga;
totalItemOrderDetail +=
listOrders[i]
.orderDetail[kk]
.totalItem;
}
fixTotalHarga =
totalHargaOrderDetail;
fixTotalItem =
totalItemOrderDetail;
}
fixTotalHarga =
totalHargaOrderDetail;
fixTotalItem = totalItemOrderDetail;
}
totalHarga = fixTotalHarga +
totalHargaBukanOrderDetail;
totalItem = fixTotalItem +
totalItemBukanOrderDetail;
}
totalHarga = fixTotalHarga +
totalHargaBukanOrderDetail;
totalItem = fixTotalItem +
totalItemBukanOrderDetail;
}
return ScreenResponsive(
widget: coreHome(
context,
widthScreen,
maxWidthScreen,
paddingLeftRight,
appBarHeight,
tableNumber,
userName,
searchFieldHeight,
spacerHeight,
favListHeight,
favItemHeight,
spacerAboveCat,
spacerAboveCatList,
catListHeight,
spacerAboveMenuItem,
heightLeft,
totalItem,
listOrders,
totalHarga,
tableMode,
),
return ScreenResponsive(
widget: coreHome(
context,
widthScreen,
maxWidthScreen,
appBarHeight,
tableNumber,
userName,
searchFieldHeight,
spacerHeight,
favListHeight,
favItemHeight,
spacerAboveCat,
spacerAboveCatList,
catListHeight,
spacerAboveMenuItem,
heightLeft,
totalItem,
listOrders,
totalHarga,
tableMode,
),
widthScreen:
MediaQuery.of(context).size.width,
isCoreLayout: true,
);
},
);
},
);
},
);
});
},
)
: (restoran == responseByodInActive)
? errorResponseByod(
"Byod tidak aktif, untuk melakukan pesanan silakan memanggil waiter")
: (restoran == responseApiNoSuccess)
? errorResponseByod(
"Scan QR Atau Kunjungi Alamat Outlet")
: (restoran == responseApiErrorServer)
? errorResponseByod(
"Something Went Wrong With Our Server")
: (restoran == responseApiWaiting)
? ScreenResponsive(
widget: ShimmerMenu(
widthScreen: widthScreen,
maxWidthScreen: maxWidthScreen,
context: context),
widthScreen:
MediaQuery.of(context).size.width,
isCoreLayout: true,
);
},
);
},
);
},
);
});
},
)
: (restoran == responseByodInActive)
? errorResponseByod(
"Byod tidak aktif, untuk melakukan pesanan silakan memanggil waiter")
: (restoran == responseApiNoSuccess)
? errorResponseByod(
"Scan QR Atau Kunjungi Alamat Outlet")
: (restoran == responseApiErrorServer)
? errorResponseByod(
"Something Went Wrong With Our Server")
: (restoran == responseApiWaiting)
? ScreenResponsive(
widget: ShimmerMenu(
widthScreen: widthScreen,
maxWidthScreen: maxWidthScreen,
context: context),
widthScreen:
MediaQuery.of(context).size.width,
isCoreLayout: true,
)
: const SizedBox(),
)
: const SizedBox(),
),
),
),
);
......@@ -547,7 +511,6 @@ class _NewHome2State extends State<NewHome2> {
BuildContext context,
double widthScreen,
double maxWidthScreen,
double paddingLeftRight,
double appBarHeight,
String tableNumber,
String userName,
......@@ -569,7 +532,7 @@ class _NewHome2State extends State<NewHome2> {
Container(
width: widthScreen,
height: MediaQuery.of(context).size.height,
padding: EdgeInsets.symmetric(horizontal: paddingLeftRight),
padding: const EdgeInsets.symmetric(horizontal: paddingLeftRight),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
......@@ -684,32 +647,6 @@ class _NewHome2State extends State<NewHome2> {
height: spacerAboveMenuItem,
),
),
// SliverToBoxAdapter(
// child: Container(
// height: heightLeft,
// child: ListView.builder(
// controller:
// (isScrollableMenu) ? _scrollMenuItem : null,
// // itemScrollController:
// // (isScrollableMenu) ? scrollMenuItemList : null,
// physics: (!isScrollableMenu)
// ? const NeverScrollableScrollPhysics()
// : null,
// shrinkWrap: (isScrollableMenu) ? true : false,
// // itemCount: (categoryMenuAfterSelect.length) >
// // countMenuToDisplay
// // ? countMenuToDisplay
// // : categoryMenuAfterSelect.length,
// itemCount: categoryMenuAfterSelect.length,
// itemBuilder: (context, i) {
// return MenuListUtama(
// categoryNonFav: categoryMenuAfterSelect,
// i: i,
// );
// },
// ),
// ),
// ),
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
......@@ -729,24 +666,28 @@ class _NewHome2State extends State<NewHome2> {
],
),
),
AnimatedSwitcher(
duration: Duration(milliseconds: animatedTime),
transitionBuilder: (Widget child, Animation<double> animation) {
return ScaleTransition(scale: animation, child: child);
},
child: (totalItem > 0)
? goTocheckOut(
context,
listOrders,
paddingLeftRight,
totalItem,
totalHarga,
tableMode,
userName,
)
: const SizedBox(
key: Key('ButtonBottomCart'),
),
Container(
width: widthScreen,
child: AnimatedSwitcher(
duration: Duration(milliseconds: animatedTime),
transitionBuilder: (Widget child, Animation<double> animation) {
return ScaleTransition(scale: animation, child: child);
},
child: (totalItem > 0)
? goTocheckOut(
context,
listOrders,
paddingLeftRight,
totalItem,
totalHarga,
tableMode,
userName,
widthScreen,
)
: const SizedBox(
key: Key('ButtonBottomCart'),
),
),
)
],
);
......@@ -813,7 +754,8 @@ class _NewHome2State extends State<NewHome2> {
int totalItem,
int totalHarga,
int tableMode,
String namaPelanggan) {
String namaPelanggan,
double widthScreen) {
String itemString;
if (totalItem > 1) {
itemString = '$totalItem Items';
......@@ -931,13 +873,15 @@ class _NewHome2State extends State<NewHome2> {
Positioned(
bottom: 0,
child: Container(
width: MediaQuery.of(context).size.width,
width: widthScreen,
height: 61,
decoration: BoxDecoration(
color: buttonColor,
borderRadius: const BorderRadius.only(
topRight: Radius.circular(20),
topLeft: Radius.circular(10),
// bottomLeft: Radius.circular(50),
// bottomRight: Radius.circular(50),
),
),
child: Row(
......@@ -1001,11 +945,12 @@ class _NewHome2State extends State<NewHome2> {
left: paddingLeftRight,
),
height: 43,
width: MediaQuery.of(context).size.width - 157,
width: widthScreen - 157,
decoration: BoxDecoration(
color: buttonColor,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(20),
bottomRight: Radius.circular(20),
),
),
child: Align(
......@@ -1033,6 +978,7 @@ class _NewHome2State extends State<NewHome2> {
barName = "Meja $tableNumber";
}
return Container(
margin: const EdgeInsets.only(top: 24),
height: appBarHeight,
child: Row(
children: [
......@@ -1050,8 +996,8 @@ class _NewHome2State extends State<NewHome2> {
},
child: const Image(
image: AssetImage('assets/icons/search.png'),
height: 20,
width: 20,
height: 24,
width: 24,
),
),
const SizedBox(
......@@ -1064,8 +1010,8 @@ class _NewHome2State extends State<NewHome2> {
},
child: const Image(
image: AssetImage('assets/icons/book.png'),
height: 20,
width: 20,
height: 24,
width: 24,
),
),
],
......@@ -1094,35 +1040,6 @@ class _NewHome2State extends State<NewHome2> {
),
);
}
// AnimatedSwitcher seearchField(BuildContext context) {
// return AnimatedSwitcher(
// duration: const Duration(milliseconds: 500),
// transitionBuilder: (Widget child, Animation<double> animation) {
// return ScaleTransition(scale: animation, child: child);
// },
// child: TextField(
// key: const Key('SearchField'),
// decoration: InputDecoration(
// focusedBorder: OutlineInputBorder(
// borderSide: BorderSide(
// width: 1,
// color: buttonColor,
// ),
// ),
// prefixIcon: const Image(
// image: AssetImage('assets/icons/search.png'),
// height: 20,
// width: 20,
// ),
// hintText: 'Example: nasi',
// border: OutlineInputBorder(
// borderRadius: BorderRadius.circular(6),
// ),
// ),
// ),
// );
// }
}
class Delegate extends SliverPersistentHeaderDelegate {
......@@ -1170,20 +1087,33 @@ class CustomClipPath extends CustomClipper<Path> {
Path getClip(Size size) {
// buat clipnya di https://shapemaker.web.app/#/
// Path path0 = Path();
// path0.moveTo(0, 0);
// path0.lineTo(0, size.height);
// path0.lineTo(size.width, size.height);
// path0.quadraticBezierTo(size.width, size.height * 0.6250000, size.width,
// size.height * 0.5042857);
// path0.cubicTo(
// size.width * 0.8616667,
// size.height * 0.4364286,
// size.width * 0.9810417,
// size.height * 0.0007143,
// size.width * 0.7191667,
// 0);
// path0.quadraticBezierTo(size.width * 0.5468750, 0, 0, 0);
// path0.close();
double w = size.width;
Path path0 = Path();
path0.moveTo(0, 0);
path0.lineTo(0, size.height);
path0.lineTo(size.width, size.height);
path0.quadraticBezierTo(size.width, size.height * 0.6250000, size.width,
size.height * 0.5042857);
path0.cubicTo(
size.width * 0.8616667,
size.height * 0.4364286,
size.width * 0.9810417,
size.height * 0.0007143,
size.width * 0.7191667,
0);
path0.quadraticBezierTo(size.width * 0.5468750, 0, 0, 0);
path0.lineTo(w, size.height);
path0.quadraticBezierTo(
w * 1.0004167, size.height * 0.6267857, w, size.height * 0.5985714);
path0.cubicTo(w * 0.9452083, size.height * 0.4360714, w * 0.9633333,
size.height * 0.3653571, w * 0.9500000, size.height * 0.2142857);
path0.quadraticBezierTo(
w * 0.9337500, size.height * 0.0164286, w * 0.8716667, 0);
path0.lineTo(0, 0);
path0.close();
return path0;
}
......
// ignore_for_file: sized_box_for_whitespace, must_be_immutable
import 'package:byod/helper/helper.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:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../bloc/order_variant_value.dart';
import '../../main.dart';
import '../../models/variant_categories.dart';
class VariantCatNew extends StatefulWidget {
final List<VariantCategories> variantCategories;
final int initPrice;
const VariantCatNew({
Key? key,
required this.variantCategories,
required this.initPrice,
}) : super(key: key);
@override
State<VariantCatNew> createState() => _VariantCatNewState();
}
class _VariantCatNewState extends State<VariantCatNew> {
final noteCatController = TextEditingController();
OrderDetail orderDetail = OrderDetail(
allIdVariant: '',
totalItem: 0,
totalHarga: 0,
note: '',
orderVariant: [],
);
@override
void initState() {
context
.read<OrderVariantValueBloc>()
.setOrderVariant('', '', '', 0, 0, [], '');
super.initState();
}
@override
Widget build(BuildContext context) {
FocusScopeNode currentFocus = FocusScope.of(context);
double widthScreen = responsiveWidthScreen(context);
return SafeArea(
child: GestureDetector(
onTap: () {
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
},
child: Scaffold(
backgroundColor: backgroundColor,
body: Container(
padding: const EdgeInsets.symmetric(horizontal: paddingLeftRight),
child: Column(
children: [
Container(
margin: const EdgeInsets.only(
top: 15,
bottom: 20,
),
child: Row(
children: [
GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: Container(
width: 24,
height: 24,
child: Center(
child: fontAwesomeNew(
arrowBack,
arrowBackSize,
),
),
),
),
const SizedBox(
width: 16,
),
Center(
child: defaultText(
context,
'Custom Pesanan',
style: appBarNameVariant(),
),
),
],
),
),
Expanded(
child: ListView(
children: [
ListView.builder(
physics:
const NeverScrollableScrollPhysics(), // to disable GridView's scrolling
shrinkWrap: true,
itemCount: widget.variantCategories.length,
itemBuilder: ((context, index) {
return Container(
width: double.infinity,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
margin: EdgeInsets.only(
bottom:
MediaQuery.of(context).size.height *
0.01,
top: MediaQuery.of(context).size.height *
0.01),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
defaultText(
context,
widget.variantCategories[index].caption,
style: variantStyleText(),
),
defaultText(
context,
(widget.variantCategories[index].type ==
typeMandatory)
? 'Pilih Salah Satu'
: (widget.variantCategories[index]
.type ==
typeAutoInsert)
? 'Sudah termasuk'
: 'Optional',
style: variantStyleText(
font: 12,
fontWeight: FontWeight.w300,
),
)
],
),
),
const Divider(
thickness: 0.5,
color: textColorBlack,
),
VariantNew(
variants:
widget.variantCategories[index].variant,
captioncategories:
widget.variantCategories[index].caption,
type: widget.variantCategories[index].type,
initPrice: widget.initPrice,
idCategory:
widget.variantCategories[index].id,
orderDetail: orderDetail,
),
],
),
);
})),
const SizedBox(
height: 74,
),
defaultText(
context,
"Note :",
style: variantStyleText(
font: 20,
fontWeight: FontWeight.w400,
),
),
const SizedBox(
height: 12,
),
// TextField(
// maxLength: maxLengthTextField,
// maxLines: 2,
// autofocus: false,
// keyboardType: TextInputType.text,
// controller: noteCatController,
// style: textStyleNormalFont(context),
// decoration: InputDecoration(
// prefixIcon: Image(
// image: const AssetImage('assets/icons/search.png'),
// color: Colors.grey.withOpacity(0.8),
// height: 20,
// width: 20,
// ),
// hintText: placeHolderNote,
// hintStyle: TextStyle(
// color: Colors.grey,
// fontSize:
// MediaQuery.of(context).size.height * normalFont,
// ),
// ),
// ),
Container(
height: 35,
child: TextField(
maxLength: maxLengthTextField,
autofocus: false,
style: const TextStyle(
color: textColorBlack,
fontFamily: 'OpenSans',
fontSize: 10,
fontWeight: FontWeight.w400,
),
textAlignVertical: TextAlignVertical.center,
decoration: InputDecoration(
counterText: "",
filled: true,
enabledBorder: OutlineInputBorder(
borderSide: const BorderSide(
width: 1,
color: textColorPlaceHolder,
),
borderRadius: BorderRadius.circular(21),
),
focusedBorder: OutlineInputBorder(
borderSide: const BorderSide(
width: 1,
color: textColorPlaceHolder,
),
borderRadius: BorderRadius.circular(21),
),
prefixIcon: const Image(
image: AssetImage('assets/icons/note-grey.png'),
color: textColorPlaceHolder,
height: 13.33,
width: 13.33,
),
fillColor: backgroundColor,
contentPadding: EdgeInsets.zero,
hintText: placeHolderNote,
hintStyle: const TextStyle(
color: textColorPlaceHolder,
fontFamily: 'OpenSans',
fontSize: 10,
fontWeight: FontWeight.w400,
),
),
),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.03,
),
(isExcelso)
? (!currentFocus.hasPrimaryFocus)
? SizedBox(
height:
MediaQuery.of(context).size.height * 0.5,
)
: const SizedBox()
: const SizedBox()
],
),
)
],
),
),
),
));
}
}
// ignore_for_file: sized_box_for_whitespace
import 'package:byod/bloc/order_variant_temporary.dart';
import 'package:byod/bloc/order_variant_value.dart';
import 'package:byod/helper/widget/style.dart';
import 'package:byod/models/order_details.dart';
import 'package:byod/models/order_variants.dart';
import 'package:byod/models/variants.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../helper/helper.dart';
// ignore: must_be_immutable
class VariantNew extends StatefulWidget {
List<Variants> variants;
String captioncategories;
int type;
int initPrice;
String idCategory;
OrderDetail orderDetail;
VariantNew(
{Key? key,
required this.variants,
required this.captioncategories,
required this.type,
required this.initPrice,
required this.idCategory,
required this.orderDetail})
: super(key: key);
@override
State<VariantNew> createState() => _VariantNewState();
}
class _VariantNewState extends State<VariantNew> {
String variantMenu = '';
List<dynamic> variantRadio = [];
List<String> optionalVariant = [];
@override
Widget build(BuildContext context) {
double widthScreen = responsiveWidthScreen(context);
double currentScreen = MediaQuery.of(context).size.width;
double maxWidthScreen = getMaxWidthScreen(context, useResponsive);
// if (variantRadio.isNotEmpty) {
// print(variantRadio[0]);
// }
FocusScopeNode currentFocus = FocusScope.of(context);
return BlocBuilder<OrderVariantValueBloc, List<OrderVariant>>(
builder: (context, orderVariants) {
return ListView.builder(
physics:
const NeverScrollableScrollPhysics(), // to disable GridView's scrolling
shrinkWrap: true,
itemCount: widget.variants.length,
itemBuilder: ((context, i) {
var priceVariant = amountParseToInt(widget.variants[i].price);
return BlocBuilder<OrderVariantTemporaryBloc, List<dynamic>>(
builder: (context, listOrders) {
var listOrder = listOrders[0];
var itemId = listOrder[0];
var satuanPrice = listOrder[1];
var initialValue = listOrder[2];
return variantList(
widthScreen,
i,
context,
priceVariant,
itemId,
satuanPrice,
initialValue,
orderVariants,
maxWidthScreen,
currentFocus);
// return variantList(widthScreen, i, context, priceVariant,
// itemId, satuanPrice, initialValue, orderVariants);
},
);
}));
},
);
}
Container variantList(
double widthScreen,
int i,
BuildContext context,
int priceVariant,
itemId,
satuanPrice,
initialValue,
List<OrderVariant> orderVariants,
double maxWidthScreen,
FocusScopeNode currentFocus,
) {
return Container(
width: (widthScreen > maxWidthScreen) ? maxWidthScreen : widthScreen,
child: Column(
children: [
Row(
children: [
Container(
width: 160,
child: defaultText(
context,
widget.variants[i].name,
maxLines: 2,
overFlow: TextOverflow.ellipsis,
style: variantStyleText(
fontWeight: FontWeight.w300,
font: 12,
),
),
),
Expanded(
// width: 170,
// color: Colors.blue,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
child: defaultText(
context,
(priceVariant > 0)
? formatNumber().format(priceVariant)
: "Free",
style: variantStyleText(
fontWeight: FontWeight.w300,
font: 12,
),
)),
(widget.type == typeMandatory)
? radioButton(
i,
itemId,
satuanPrice,
initialValue,
variantRadio,
priceVariant,
widget.idCategory,
orderVariants,
currentFocus,
)
: (widget.type == typeOptional)
? checkBoxButton(
i,
itemId,
satuanPrice,
initialValue,
variantRadio,
priceVariant,
widget.idCategory,
orderVariants,
currentFocus,
)
: const SizedBox()
],
),
),
],
)
],
),
);
}
Checkbox checkBoxButton(
int i,
String itemId,
int satuanHarga,
int initialValue,
List<dynamic> variantRadio,
int priceVariant,
String idCategory,
List<OrderVariant> orderVariants,
FocusScopeNode currentFocus,
) {
return Checkbox(
activeColor: buttonColor,
value: (optionalVariant.contains(widget.variants[i].id) == true)
? true
: false,
onChanged: (value) {
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
(value == true)
? optionalVariant.add(widget.variants[i].id)
: optionalVariant.remove(widget.variants[i].id);
context.read<OrderVariantValueBloc>().setOrderVariant(
idCategory,
widget.variants[i].id,
widget.variants[i].name,
priceVariant,
typeOptional,
orderVariants,
widget.captioncategories,
forChecBox: value);
setState(() {});
});
}
Radio<String> radioButton(
int i,
String itemId,
int satuanHarga,
int initialValue,
List<dynamic> variantRadio,
int priceVariant,
String idCategory,
List<OrderVariant> orderVariants,
FocusScopeNode currentFocus) {
return Radio(
value: widget.variants[i].id,
groupValue: variantMenu,
hoverColor: buttonColor,
activeColor: buttonColor,
onChanged: (newValue) {
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
// buat list untuk radio button
variantMenu = newValue.toString();
context.read<OrderVariantValueBloc>().setOrderVariant(
idCategory,
variantMenu.toString(),
widget.variants[i].name,
priceVariant,
typeMandatory,
orderVariants,
widget.captioncategories,
);
setState(() {});
});
}
}
......@@ -62,7 +62,7 @@ flutter:
- asset: assets/fonts/roboto/Roboto-Regular.ttf
- family: OpenSans
fonts:
- asset: assets/fonts/roboto/Roboto-Regular.ttf
- asset: assets/fonts/open_sans/OpenSans-Regular.ttf
- family: RobotoFlex
fonts:
- asset: assets/fonts/roboto_flex/RobotoFlex-Regular.ttf
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment