Commit 21db6841 authored by Dio Maulana's avatar Dio Maulana

14/09/22 new home byod

parent 0add2b63
......@@ -247,7 +247,9 @@ double heightTombol = 0.06; // untuk dikalikan di height media query
const Color backgroundColor = Color(0xffE5E5E5);
const textColorTabel = Color(0xff333333);
const textColorBlack = Color(0xff000000);
const textColorRed = Color(0xffE73636);
const textGrey = Color(0xffE0E0E0);
const textColorModalHeaderNama = Color(0xffCCCCFF);
const gridCardBackgroundColor = Color(0xffFFFFFF);
Color buttonColor =
(!isExcelso) ? const Color(0xff003366) : const Color(0xffccb46c);
......@@ -477,6 +479,7 @@ const double refreshIconSize = 0.02;
//** max item menu */
const int maxItemMenu = 10;
const int maxItemMenuFav = 10;
//** max item menu */
//** type menu */
......
import 'package:byod/helper/widget/style.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../bloc/order_bloc.dart';
import '../../models/filter_menu.dart';
import '../../models/order_variants.dart';
import '../../models/orders.dart';
import '../helper.dart';
class NoteModalBottomSheet extends StatelessWidget {
const NoteModalBottomSheet({
Key? key,
required this.noteController,
required this.initialValue,
required this.orderVariants,
required this.menuItem,
required this.lisrOrders,
}) : super(key: key);
final TextEditingController noteController;
final int initialValue;
final List<OrderVariant> orderVariants;
final FilterMenu menuItem;
final List<Orders> lisrOrders;
@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.symmetric(horizontal: 20),
height: MediaQuery.of(context).size.height * 0.9,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
margin: const EdgeInsets.only(
top: 20,
bottom: 20,
),
child: defaultText(
context,
'catatan untuk pesanan',
style: textHeaderNote(),
),
),
const Divider(
thickness: 2,
color: Colors.white,
),
TextField(
maxLength: maxLengthTextField,
maxLines: 5,
autofocus: true,
keyboardType: TextInputType.text,
controller: noteController,
style: noteModal(),
decoration: InputDecoration(
border: InputBorder.none,
hintText: placeHolderNote,
hintStyle: const TextStyle(
color: Colors.grey,
fontFamily: 'OpenSans',
fontSize: 14,
),
),
),
const Divider(
thickness: 2,
color: Colors.white,
),
const SizedBox(
height: 20,
),
GestureDetector(
onTap: () {
context.read<OrdersBloc>().insertData([
[
menuItem.id,
menuItem.name,
initialValue,
amountParseToInt(menuItem.price),
lisrOrders,
menuItem.imageUrlMedium,
orderVariants,
amountParseToInt(menuItem.price),
noteController.text
]
], context);
Navigator.pop(context);
},
child: Align(
alignment: Alignment.centerRight,
child: Container(
height: 36,
width: 89,
decoration: BoxDecoration(
color: buttonColor,
borderRadius: BorderRadius.circular(21),
),
child: Center(
child: defaultText(
context,
"Simpan",
style: simpanButtonNote(),
),
),
),
),
)
],
),
);
}
}
import 'dart:ui';
import 'package:byod/helper/helper.dart';
import 'package:flutter/material.dart';
......@@ -205,6 +207,55 @@ TextStyle textAmountButtonBottomCart({
);
}
TextStyle textCountItem({
font = 20,
Color color = textInButton,
}) {
return TextStyle(
fontFamily: 'Robot',
fontSize: font,
fontWeight: FontWeight.w500,
color: color,
);
}
TextStyle textHeaderNote({
font = 20,
Color color = textColorBlack,
}) {
return TextStyle(
fontFamily: 'Mulish',
fontSize: font,
fontWeight: FontWeight.w700,
color: color,
);
}
TextStyle simpanButtonNote({
font = 16,
Color color = textInButton,
FontWeight fontWeight = FontWeight.w400,
}) {
return TextStyle(
fontFamily: 'OpenSans',
fontSize: font,
fontWeight: fontWeight,
color: color,
);
}
TextStyle modalNamaHeader({
font = 14,
Color color = textColorModalHeaderNama,
}) {
return TextStyle(
fontFamily: 'OpenSans',
fontSize: font,
fontWeight: FontWeight.w400,
color: color,
);
}
Text fontAwesome(BuildContext context, String unicode, double fontSize,
{Color? color, isBold = true}) {
// double widthScreens = responsiveWidthScreen(context);
......@@ -389,6 +440,15 @@ Text textAddButton(BuildContext context, String text) {
// ));
}
TextStyle noteModal() {
return const TextStyle(
fontFamily: 'OpenSans',
fontWeight: FontWeight.w400,
color: textColorBlack,
fontSize: 14,
);
}
TextStyle textStyleListHistoryOrder(context,
{font = listHistoryFontName, isBold = false}) {
return TextStyle(
......
// ignore_for_file: sized_box_for_whitespace, avoid_unnecessary_containers
import 'package:byod/models/orders.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../bloc/order_bloc.dart';
import '../../bloc/order_variant_temporary.dart';
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.dart';
import 'bottom_sheet_variant.dart';
import 'variant_cat.dart';
class FavGridMenu extends StatelessWidget {
const FavGridMenu({
......@@ -20,7 +32,6 @@ class FavGridMenu extends StatelessWidget {
@override
Widget build(BuildContext context) {
bool addCondition = false;
return Container(
margin: EdgeInsets.only(
left: (i == 0) ? 0 : 8, // paling awal gausah dikasih margin
......@@ -51,11 +62,37 @@ class FavGridMenu extends StatelessWidget {
borderRadius: BorderRadius.circular(8),
// color: Colors.red,
),
child: GestureDetector(
onTap: () {
showModalBottomSheet(
backgroundColor: backgroundColor.withOpacity(0),
isScrollControlled: true,
context: context,
builder: (context) {
return ShowMenuModal(
imageUrl: categoryFavAfterSelect[i].imageUrlMedium,
namaMenu: categoryFavAfterSelect[i].name,
hargaMenu:
amountParseToInt(categoryFavAfterSelect[i].price),
isHavevariant:
categoryFavAfterSelect[i].variantCat.isNotEmpty
? true
: false,
description: categoryFavAfterSelect[i].description,
id: categoryFavAfterSelect[i].id,
variantCat: categoryFavAfterSelect[i].variantCat,
isSell: categoryFavAfterSelect[i].isSell,
);
},
);
},
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Image(
fit: BoxFit.fill,
image: NetworkImage(categoryFavAfterSelect[i].imageUrlMedium),
image:
NetworkImage(categoryFavAfterSelect[i].imageUrlMedium),
),
),
),
),
......@@ -94,28 +131,164 @@ class FavGridMenu extends StatelessWidget {
const SizedBox(
height: 16,
),
(addCondition)
? Container(
addRemoveQuantity(context, categoryFavAfterSelect[i])
],
),
),
);
}
BlocBuilder addRemoveQuantity(BuildContext context, FilterMenu menuFav) {
List<OrderVariant> orderVariants = [];
return BlocBuilder<OrdersBloc, List<Orders>>(
builder: (contextOrders, list) {
bool
addCondition; // true untuk menampilkan tambah, false untuk menampilkan quantity plus minus
int indexListOrderan =
list.indexWhere((listOrderan) => listOrderan.id == menuFav.id);
int initialValue;
if (indexListOrderan != -1) {
if (menuFav.variantCat.isNotEmpty) {
addCondition = true; // kalau menu itu ada variantnya, biarin true
} else {
addCondition = false;
}
initialValue = list[indexListOrderan].totalItem;
} else {
addCondition = true;
initialValue = 0;
}
String variantButtonCount = '';
if (initialValue == 1 && menuFav.variantCat.isNotEmpty) {
variantButtonCount = '$initialValue Item';
} else if (initialValue > 1 && menuFav.variantCat.isNotEmpty) {
variantButtonCount = '$initialValue Items';
}
final noteController = TextEditingController(
text: (indexListOrderan != -1) ? list[indexListOrderan].note : '');
return AnimatedSwitcher(
duration: Duration(milliseconds: animatedTime),
transitionBuilder: (Widget child, Animation<double> animation) {
return ScaleTransition(scale: animation, child: child);
},
child: (addCondition)
? GestureDetector(
key: const Key('AddButton'),
onTap: () {
if (menuFav.isSell) {
if (menuFav.variantCat.isNotEmpty) {
if (indexListOrderan == -1) {
context
.read<OrderVariantTemporaryBloc>()
.insertDataVariant(
menuFav.id,
amountParseToInt(menuFav.price),
1,
[],
); // check pada bloc untuk mengethui list arraynya
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => VariantCat(
namaMenu: menuFav.name,
variantCategories: menuFav.variantCat,
initPrice:
amountParseToInt(menuFav.price),
idItem: menuFav.id,
imageUrl: menuFav.imageUrlThumbnail,
listCurrentOrder: list,
orderDetail: OrderDetail(
allIdVariant: '',
totalItem: 0,
totalHarga: 0,
note: '',
orderVariant: [],
),
)));
} else {
showModalBottomSheet(
backgroundColor: Colors.white.withOpacity(0),
isScrollControlled: true,
context: context,
builder: (context) {
return CustomizeVariant(
orders: list[indexListOrderan],
variantCat: menuFav.variantCat);
},
);
}
} 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);
// setState(() {});
}
}
}
},
child: Container(
height: 30,
width: widthGrid - (2 * paddingLeftRigthGrid),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6),
color: buttonColor,
color: (menuFav.isSell) ? buttonColor : Colors.grey,
),
child: Center(
child: defaultText(
context,
'Tambah',
(menuFav.isSell == false)
? 'Habis'
: (initialValue == 0)
? 'Tambah'
: (initialValue > 0 &&
menuFav.variantCat.isNotEmpty)
? variantButtonCount
: 'Tambah',
style: addButtonGridFav(),
),
),
),
)
: Container(
key: const Key('AddButton'),
height: 30,
width: widthGrid - (2 * paddingLeftRigthGrid),
child: Row(
children: [
Container(
GestureDetector(
onTap: () {
showModalBottomSheet(
backgroundColor: backgroundColor,
isScrollControlled: true,
context: context,
builder: (context) {
return NoteModalBottomSheet(
noteController: noteController,
initialValue: initialValue,
orderVariants: orderVariants,
menuItem: menuFav,
lisrOrders: list,
);
},
);
},
child: Container(
width: 27,
height: 24,
decoration: BoxDecoration(
......@@ -131,38 +304,82 @@ class FavGridMenu extends StatelessWidget {
),
),
),
),
const SizedBox(
width: 5,
),
Container(
GestureDetector(
onTap: () {
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);
// setState(() {});
}
},
child: Container(
width: 22,
height: 22,
child: const Image(
image: AssetImage('assets/icons/minus.png'),
child: Image(
color: buttonColor,
image: const AssetImage('assets/icons/minus.png'),
),
),
),
Expanded(
child: Center(
child: defaultText(
context,
'10',
initialValue.toString(),
style: amountGridFav(),
),
),
),
Container(
GestureDetector(
onTap: () {
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);
},
child: Container(
width: 22,
height: 22,
child: const Image(
image: AssetImage('assets/icons/plus.png'),
),
)
],
),
)
],
),
),
);
},
);
}
}
// ignore_for_file: sized_box_for_whitespace
import 'package:byod/bloc/order_bloc.dart';
import 'package:byod/models/orders.dart';
import 'package:byod/ui/home/variant_cat.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../bloc/order_variant_temporary.dart';
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_variant.dart';
class MenuListUtama extends StatelessWidget {
const MenuListUtama({
......@@ -18,7 +27,6 @@ class MenuListUtama extends StatelessWidget {
@override
Widget build(BuildContext context) {
bool addCondition = false;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
......@@ -53,7 +61,10 @@ class MenuListUtama extends StatelessWidget {
: const SizedBox(),
(categoryNonFav[i].type == typeMenu)
? Container(
margin: const EdgeInsets.symmetric(vertical: 19),
margin: EdgeInsets.only(
top: 19,
bottom: (i + 1 == categoryNonFav.length) ? 85 : 19,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
......@@ -117,14 +128,127 @@ class MenuListUtama extends StatelessWidget {
height: 8,
width: double.infinity,
),
(addCondition)
addRemoveQuantity(context, categoryNonFav[i])
],
),
)
: const SizedBox(),
],
);
}
BlocBuilder addRemoveQuantity(BuildContext context, FilterMenu menuUtama) {
List<OrderVariant> orderVariants = [];
return BlocBuilder<OrdersBloc, List<Orders>>(
builder: (contextOrders, list) {
bool
addCondition; // true untuk menampilkan tambah, false untuk menampilkan quantity plus minus
int indexListOrderan =
list.indexWhere((listOrderan) => listOrderan.id == menuUtama.id);
int initialValue;
if (indexListOrderan != -1) {
if (menuUtama.variantCat.isNotEmpty) {
addCondition = true; // kalau menu itu ada variantnya, biarin true
} else {
addCondition = false;
}
initialValue = list[indexListOrderan].totalItem;
} else {
addCondition = true;
initialValue = 0;
}
String variantButtonCount = '';
if (initialValue == 1 && menuUtama.variantCat.isNotEmpty) {
variantButtonCount = '$initialValue Item';
} else if (initialValue > 1 && menuUtama.variantCat.isNotEmpty) {
variantButtonCount = '$initialValue Items';
}
final noteController = TextEditingController(
text: (indexListOrderan != -1) ? list[indexListOrderan].note : '');
return AnimatedSwitcher(
duration: Duration(milliseconds: animatedTime),
transitionBuilder: (Widget child, Animation<double> animation) {
return ScaleTransition(scale: animation, child: child);
},
child: (addCondition)
? Container(
key: const Key('AddButtonMenuKey'),
height: 36,
width: double.infinity,
child: Row(
children: [
const Spacer(),
Container(
GestureDetector(
onTap: () {
if (menuUtama.isSell) {
if (menuUtama.variantCat.isNotEmpty) {
if (indexListOrderan == -1) {
context
.read<OrderVariantTemporaryBloc>()
.insertDataVariant(
menuUtama.id,
amountParseToInt(menuUtama.price),
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: [],
),
)));
} else {
showModalBottomSheet(
backgroundColor: Colors.white.withOpacity(0),
isScrollControlled: true,
context: context,
builder: (context) {
return CustomizeVariant(
orders: list[indexListOrderan],
variantCat: menuUtama.variantCat);
},
);
}
} 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);
// setState(() {});
}
}
}
},
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: buttonColor,
......@@ -134,20 +258,46 @@ class MenuListUtama extends StatelessWidget {
child: Center(
child: defaultText(
context,
'Tambah',
(menuUtama.isSell == false)
? 'Habis'
: (initialValue == 0)
? 'Tambah'
: (initialValue > 0 &&
menuUtama.variantCat.isNotEmpty)
? variantButtonCount
: 'Tambah',
style: addButtonMenu(),
),
),
),
)
],
),
)
: Container(
key: const Key('AddButtonMenuKey'),
height: 36,
width: 125,
child: Row(
children: [
Container(
GestureDetector(
onTap: () {
showModalBottomSheet(
backgroundColor: backgroundColor,
isScrollControlled: true,
context: context,
builder: (context) {
return NoteModalBottomSheet(
noteController: noteController,
initialValue: initialValue,
orderVariants: orderVariants,
menuItem: menuUtama,
lisrOrders: list,
);
},
);
},
child: Container(
width: 27,
height: 24,
decoration: BoxDecoration(
......@@ -159,8 +309,8 @@ class MenuListUtama extends StatelessWidget {
width: 13.33,
height: 13.33,
color: textInButton,
image:
AssetImage('assets/icons/note.png'),
image: AssetImage('assets/icons/note.png'),
),
),
),
),
......@@ -178,23 +328,67 @@ class MenuListUtama extends StatelessWidget {
children: [
Positioned(
left: 0,
child: GestureDetector(
onTap: () {
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);
// setState(() {});
}
},
child: Container(
width: 22,
height: 22,
child: const Image(
image: AssetImage(
child: Image(
color: buttonColor,
image: const AssetImage(
'assets/icons/minus.png'),
),
),
),
),
Positioned(
right: 0,
child: GestureDetector(
onTap: () {
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);
},
child: Container(
width: 22,
height: 22,
child: const Image(
image: AssetImage(
'assets/icons/plus.png'),
image:
AssetImage('assets/icons/plus.png'),
),
),
),
),
......@@ -204,7 +398,7 @@ class MenuListUtama extends StatelessWidget {
child: Center(
child: defaultText(
context,
'10',
initialValue.toString(),
style: amountGridFav(),
),
),
......@@ -216,12 +410,9 @@ class MenuListUtama extends StatelessWidget {
),
],
),
)
],
),
)
: const SizedBox(),
],
);
},
);
}
}
......@@ -3,17 +3,23 @@
import 'package:byod/bloc/branch_exist.dart';
import 'package:byod/bloc/fav_selected_bar.dart';
import 'package:byod/bloc/menu_selected_bar.dart';
import 'package:byod/bloc/order_bloc.dart';
import 'package:byod/helper/helper.dart';
import 'package:byod/helper/widget/style.dart';
import 'package:byod/models/filter_menu.dart';
import 'package:byod/models/orders.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import '../../bloc/filter_menu.dart';
import '../../helper/widget/button_dialog.dart';
import '../../main.dart';
import '../../models/fav_group.dart';
import '../checkout/checkout.dart';
import '../checkout/fuction.dart';
import '../screen_responsive.dart';
import '../viewbill/view_bill.dart';
import 'cat_list.dart';
import 'fav_grid_menu.dart';
import 'fav_list.dart';
......@@ -34,6 +40,7 @@ class _NewHome2State extends State<NewHome2> {
bool isFirstLoad = true;
final searchController = TextEditingController();
final _scrollController = ScrollController();
final _scrollFavItem = ScrollController();
final _scrollMenuItem = ScrollController();
late bool isScrollableMenu = false;
......@@ -41,6 +48,17 @@ class _NewHome2State extends State<NewHome2> {
// final double positionCustomScrollViewSearchFalseFixed = 349.5 - 10;
late List<FilterMenu> allMenu = [];
late List<FilterMenu> allMenuFav = [];
List<CategoryList> categoryList = [];
List<FavoriteGroup> favList = [];
List<FilterMenu> categoryNonFav = [];
List<FilterMenu> categoryFav = [];
List<FilterMenu> categoryFavAfterSelect = [];
List<FilterMenu> categoryMenuAfterSelect = [];
late int countMenuToDisplay = maxItemMenu;
late int countMenuFavToDisplay = maxItemMenuFav;
@override
void initState() {
......@@ -78,10 +96,22 @@ class _NewHome2State extends State<NewHome2> {
// }
},
);
_scrollFavItem.addListener(() {
double positionMenuFavScroll = _scrollFavItem.position.pixels;
double positionMenuFavMax = _scrollFavItem.position.maxScrollExtent;
if (positionMenuFavScroll >= positionMenuFavMax - 50) {
if (allMenuFav.length >= countMenuFavToDisplay) {
_getMoreDataFav(countMenuFavToDisplay, allMenuFav);
}
}
});
_scrollMenuItem.addListener(() {
double positionMenuItemScrollView = _scrollMenuItem.position.pixels;
double positionMenuItemScrollViewMin =
_scrollMenuItem.position.minScrollExtent;
double positionMenuItemScrollViewMax =
_scrollMenuItem.position.maxScrollExtent;
if (positionMenuItemScrollView == positionMenuItemScrollViewMin &&
_scrollController.position.pixels ==
_scrollController.position.maxScrollExtent) {
......@@ -89,11 +119,36 @@ class _NewHome2State extends State<NewHome2> {
isScrollableMenu = false;
});
}
if (positionMenuItemScrollView >= positionMenuItemScrollViewMax - 100) {
if (allMenu.length >= countMenuToDisplay) {
_getMoreData(countMenuToDisplay, allMenu);
}
}
});
super.initState();
}
_getMoreData(int menuToDisplay, List<FilterMenu> allMenu) {
setState(() {
if ((allMenu.length - countMenuToDisplay) > maxItemMenu) {
countMenuToDisplay += maxItemMenu;
} else {
countMenuToDisplay = allMenu.length;
}
});
}
_getMoreDataFav(int menuToDisplay, List<FilterMenu> allMenuFav) {
setState(() {
if ((allMenuFav.length - countMenuFavToDisplay) > maxItemMenuFav) {
countMenuFavToDisplay += maxItemMenuFav;
} else {
countMenuFavToDisplay = allMenuFav.length;
}
});
}
@override
void dispose() {
_scrollController.removeListener(() {});
......@@ -130,14 +185,11 @@ class _NewHome2State extends State<NewHome2> {
double paddingLeftRight = 20;
int tableMode = prefs.getInt('table_mode') ?? defaultTable;
String tableNumber = prefs.getString("table_number") ?? "";
String userName = prefs.getString("userName") ?? "";
double widthScreen = responsiveWidthScreen(context);
double maxWidthScreen = getMaxWidthScreen(context, useResponsive);
List<CategoryList> categoryList = [];
List<FavoriteGroup> favList = [];
List<FilterMenu> categoryNonFav = [];
List<FilterMenu> categoryFav = [];
List<FilterMenu> categoryFavAfterSelect = [];
List<FilterMenu> categoryMenuAfterSelect = [];
return BlocBuilder<BranchExist, String>(
builder: (contextBracnhExist, restoran) {
void onTapOkPop() {
......@@ -167,7 +219,7 @@ class _NewHome2State extends State<NewHome2> {
child: SafeArea(
child: Scaffold(
backgroundColor: backgroundColor,
body: ((restoran == responseByodBranchExist))
body: (restoran == responseByodBranchExist)
? BlocBuilder<FilterMenuBloc, List<FilterMenu>>(
builder: (contextBlocListCat, categoryDefault) {
if (categoryDefault.isNotEmpty &&
......@@ -175,20 +227,28 @@ class _NewHome2State extends State<NewHome2> {
return errorResponseByod(
'Gagal mendapatkan menu, silahkan refresh halaman / scan ulang barcode');
} else if (categoryDefault.isNotEmpty) {
List<FilterMenu> categoryFavTemp = [];
List<FilterMenu> categoryNonFavTemp = [];
for (var menu in categoryDefault) {
if (!menu.isFavMenu) {
categoryNonFav.add(menu);
categoryNonFavTemp.add(menu);
} else {
categoryFav.add(menu);
categoryFavTemp.add(menu);
}
}
allMenu = categoryNonFav;
categoryNonFav = categoryNonFavTemp;
categoryFav = categoryFavTemp;
allMenu = categoryNonFav;
allMenuFav = categoryFav;
List<CategoryList> catListTemp = [];
var nn = {
"name": "All",
"id": "0",
}; // all dulu, biar ada bisa klik all
categoryList.add(CategoryList.createCategoryList(nn));
catListTemp.add(CategoryList.createCategoryList(nn));
categoryList = catListTemp;
for (var nameCat in categoryNonFav) {
if (nameCat.type == typeCategory) {
var n = {
......@@ -199,15 +259,17 @@ class _NewHome2State extends State<NewHome2> {
.add(CategoryList.createCategoryList(n));
}
}
List<FavoriteGroup> favGroupTemp = [];
for (var nameFav in categoryFav) {
if (nameFav.type == typeCategory) {
var nfav = {
"name": nameFav.categoryName,
"id": nameFav.id
};
favList.add(FavoriteGroup.add(nfav));
favGroupTemp.add(FavoriteGroup.add(nfav));
}
}
favList = favGroupTemp;
if (isFirstLoad) {
context
.read<FavSelectedBar>()
......@@ -253,7 +315,11 @@ class _NewHome2State extends State<NewHome2> {
}
// if (listDynamicBarMenu.length == 2 &&
// listDynamicBarMenu[1] != "0" &&
// isScrollableMenu == true) {
// isScrollableMenu == true &&
// _scrollController.position.pixels ==
// _scrollController
// .position.maxScrollExtent &&
// _scrollMenuItem.position.pixels > 0) {
// _scrollMenuItem.animateTo(
// 10,
// duration:
......@@ -262,20 +328,73 @@ class _NewHome2State extends State<NewHome2> {
// );
// }
}
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 <
listOrders[i]
.orderDetail
.length;
kk++) {
totalHargaOrderDetail += listOrders[i]
.orderDetail[kk]
.totalHarga;
totalItemOrderDetail += listOrders[i]
.orderDetail[kk]
.totalItem;
}
fixTotalHarga = totalHargaOrderDetail;
fixTotalItem = totalItemOrderDetail;
}
}
totalHarga = fixTotalHarga +
totalHargaBukanOrderDetail;
totalItem = fixTotalItem +
totalItemBukanOrderDetail;
}
return Stack(
children: [
Container(
height: MediaQuery.of(context).size.height,
height:
MediaQuery.of(context).size.height,
margin: EdgeInsets.symmetric(
horizontal: paddingLeftRight),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
customAppBar(context, paddingLeftRight,
appBarHeight),
customAppBar(
context,
paddingLeftRight,
appBarHeight,
tableNumber,
userName,
),
SizedBox(
height: (isSearchActive) ? 16 : 20,
height:
(isSearchActive) ? 16 : 20,
),
AnimatedSwitcher(
duration: Duration(
......@@ -283,58 +402,12 @@ class _NewHome2State extends State<NewHome2> {
transitionBuilder: (Widget child,
Animation<double> animation) {
return ScaleTransition(
scale: animation, child: child);
scale: animation,
child: child);
},
child: (isSearchActive)
? SizedBox(
height: searchFieldHeight,
child: TextField(
key: const Key(
'SearchField'),
style: TextStyle(
color: Colors.black,
fontFamily: fontFamily,
fontSize: 15,
),
decoration: InputDecoration(
enabledBorder:
OutlineInputBorder(
borderSide: BorderSide(
width: 1,
color: Colors.grey
.withOpacity(0.8),
),
),
focusedBorder:
OutlineInputBorder(
borderSide: BorderSide(
width: 1,
color: buttonColor,
),
),
prefixIcon: Image(
image: const AssetImage(
'assets/icons/search.png'),
color: Colors.grey
.withOpacity(0.8),
height: 20,
width: 20,
),
hintText: 'Example: nasi',
hintStyle: TextStyle(
color: Colors.grey
.withOpacity(0.8),
fontFamily: fontFamily,
fontSize: 10,
),
border:
OutlineInputBorder(
borderRadius:
BorderRadius
.circular(6),
),
),
),
? searchField(
searchFieldHeight,
)
: const SizedBox(
key: Key('SearchField'),
......@@ -368,21 +441,28 @@ class _NewHome2State extends State<NewHome2> {
child: Container(
height: favItemHeight,
child: ListView.builder(
controller:
_scrollFavItem,
scrollDirection:
Axis.horizontal,
itemCount:
categoryFavAfterSelect
itemCount: (categoryFavAfterSelect
.length) >
countMenuFavToDisplay
? countMenuFavToDisplay
: categoryFavAfterSelect
.length,
itemBuilder:
(context, i) {
double
paddingLeftRigthGrid =
9;
double widthGrid = 136;
double widthGrid =
136;
return FavGridMenu(
categoryFavAfterSelect:
categoryFavAfterSelect,
widthGrid: widthGrid,
widthGrid:
widthGrid,
paddingLeftRigthGrid:
paddingLeftRigthGrid,
i: i,
......@@ -404,7 +484,8 @@ class _NewHome2State extends State<NewHome2> {
),
SliverToBoxAdapter(
child: SizedBox(
height: spacerAboveCatList,
height:
spacerAboveCatList,
),
),
SliverPersistentHeader(
......@@ -416,26 +497,33 @@ class _NewHome2State extends State<NewHome2> {
),
SliverToBoxAdapter(
child: SizedBox(
height: spacerAboveMenuItem,
height:
spacerAboveMenuItem,
),
),
SliverToBoxAdapter(
child: Container(
height: heightLeft,
child: ListView.builder(
controller: (isScrollableMenu)
controller:
(isScrollableMenu)
? _scrollMenuItem
: null,
physics: (!isScrollableMenu)
? const NeverScrollableScrollPhysics()
: null,
shrinkWrap: (isScrollableMenu)
shrinkWrap:
(isScrollableMenu)
? true
: false,
itemCount:
categoryMenuAfterSelect
itemCount: (categoryMenuAfterSelect
.length) >
countMenuToDisplay
? countMenuToDisplay
: categoryMenuAfterSelect
.length,
itemBuilder: (context, i) {
itemBuilder:
(context, i) {
return MenuListUtama(
categoryNonFav:
categoryMenuAfterSelect,
......@@ -450,21 +538,229 @@ class _NewHome2State extends State<NewHome2> {
],
),
),
Positioned(
bottom: 40,
left: 0,
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'),
),
)
],
);
},
);
},
);
});
},
)
: (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(),
),
),
);
},
);
}
SizedBox searchField(double searchFieldHeight) {
return SizedBox(
height: searchFieldHeight,
child: TextField(
key: const Key('SearchField'),
style: TextStyle(
color: Colors.black,
fontFamily: fontFamily,
fontSize: 15,
),
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 1,
color: Colors.grey.withOpacity(0.8),
),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 1,
color: buttonColor,
),
),
prefixIcon: Image(
image: const AssetImage('assets/icons/search.png'),
color: Colors.grey.withOpacity(0.8),
height: 20,
width: 20,
),
hintText: 'Example: nasi',
hintStyle: TextStyle(
color: Colors.grey.withOpacity(0.8),
fontFamily: fontFamily,
fontSize: 10,
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(6),
),
),
),
);
}
GestureDetector goTocheckOut(
BuildContext context,
List<Orders> listOrders,
double paddingLeftRight,
int totalItem,
int totalHarga,
int tableMode,
String namaPelanggan) {
String itemString;
if (totalItem > 1) {
itemString = '$totalItem Items';
} else {
itemString = '$totalItem Item';
}
final nameController = TextEditingController();
return GestureDetector(
onTap: () {
if (tableMode == singleTable) {
if (namaPelanggan != '') {
checkOut(context, listOrders, namaPelanggan);
} else {
showDialog(
context: context,
builder: (BuildContext context) {
return AnimatedContainer(
duration: const Duration(milliseconds: 300),
child: AlertDialog(
scrollable: true,
title: defaultText(
context,
"Masukkan Nama",
style: modalNamaHeader(),
),
content: SizedBox(
height: 216,
width: 303,
child: Column(
children: [
TextField(
keyboardType: TextInputType.text,
controller: nameController,
style: textStyleNormalFont(context),
decoration: const InputDecoration(
labelText: 'Nama panggilan',
labelStyle: TextStyle(
fontFamily: 'OpenSans',
fontSize: 14,
color: textColorModalHeaderNama,
),
),
),
const SizedBox(
height: 47,
),
GestureDetector(
onTap: () {
if (nameController.text != '' ||
namaPelanggan != '') {
checkOut(
context, listOrders, nameController.text);
} else {
EasyLoading.showToast("Nama wajib diisi");
}
},
child: Container(
height: 43,
width: MediaQuery.of(context).size.width -
147,
decoration: BoxDecoration(
color: buttonColor,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(30),
borderRadius: BorderRadius.circular(31),
color: buttonColor),
child: Center(
child: defaultText(
context,
"Simpan",
style: simpanButtonNote(
font: 14,
fontWeight: FontWeight.w600,
),
),
),
),
),
const SizedBox(
height: 20,
),
GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: Container(
height: 43,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(31),
color: Colors.transparent,
),
child: Center(
child: defaultText(
context,
"Batal",
style: simpanButtonNote(
font: 14,
fontWeight: FontWeight.w600,
color: textColorRed,
),
),
),
),
),
],
),
),
),
);
});
}
} else {
Navigator.push(context,
MaterialPageRoute(builder: (context) => const CheckOut()));
}
},
child: Stack(
key: const Key('ButtonBottomCart'),
children: [
Positioned(
bottom: 0,
child: Container(
......@@ -473,23 +769,20 @@ class _NewHome2State extends State<NewHome2> {
decoration: BoxDecoration(
color: buttonColor,
borderRadius: const BorderRadius.only(
topRight: Radius.circular(30),
topRight: Radius.circular(20),
topLeft: Radius.circular(10),
),
),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Container(
margin: EdgeInsets.only(
left: paddingLeftRight),
margin: EdgeInsets.only(left: paddingLeftRight),
child: defaultText(
context,
'Rp 25,000',
style:
textAmountButtonBottomCart(),
"Rp ${formatNumber().format(totalHarga)}",
style: textAmountButtonBottomCart(),
),
),
),
......@@ -497,18 +790,14 @@ class _NewHome2State extends State<NewHome2> {
width: 134,
height: 36,
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(28),
borderRadius: BorderRadius.circular(28),
color: Colors.white,
),
child: Container(
padding:
const EdgeInsets.symmetric(
horizontal: 26,
vertical: 8),
padding: const EdgeInsets.symmetric(
horizontal: 26, vertical: 8),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
defaultText(
context,
......@@ -520,12 +809,10 @@ class _NewHome2State extends State<NewHome2> {
const SizedBox(
width: 7,
),
// fontAwesome(
// context,
// shoppingCart,
// 1,
// color: buttonColor,
// )
const Image(
width: 20,
height: 20,
image: AssetImage('assets/icons/cart.png'))
],
),
),
......@@ -536,38 +823,37 @@ class _NewHome2State extends State<NewHome2> {
],
),
),
)
],
);
},
);
});
},
)
: (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(),
),
Positioned(
bottom: 40,
left: 0,
child: ClipPath(
clipper: CustomClipPath(),
child: Container(
padding: EdgeInsets.only(
left: paddingLeftRight,
),
height: 43,
width: MediaQuery.of(context).size.width - 157,
decoration: BoxDecoration(
color: buttonColor,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(20),
),
),
child: Align(
alignment: Alignment.centerLeft,
child: defaultText(
context,
itemString,
style: textCountItem(),
),
),
),
),
),
],
),
);
},
);
}
......@@ -724,8 +1010,14 @@ class _NewHome2State extends State<NewHome2> {
// );
// }
Container customAppBar(
BuildContext context, double paddingLeftRight, double appBarHeight) {
Container customAppBar(BuildContext context, double paddingLeftRight,
double appBarHeight, String tableNumber, String userName) {
String barName;
if (userName != '') {
barName = 'Meja $tableNumber - $userName';
} else {
barName = "Meja $tableNumber";
}
return Container(
// color: Colors.red,
margin: EdgeInsets.symmetric(horizontal: paddingLeftRight),
......@@ -734,7 +1026,7 @@ class _NewHome2State extends State<NewHome2> {
children: [
defaultText(
context,
'Meja 12',
barName,
style: tableNameStyle(),
),
const Spacer(),
......@@ -753,11 +1045,17 @@ class _NewHome2State extends State<NewHome2> {
const SizedBox(
width: 16,
),
const Image(
GestureDetector(
onTap: () {
Navigator.push(
context, MaterialPageRoute(builder: (_) => ViewBill()));
},
child: const Image(
image: AssetImage('assets/icons/book.png'),
height: 20,
width: 20,
),
),
],
));
}
......@@ -785,34 +1083,34 @@ 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),
),
),
),
);
}
// 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 {
......@@ -841,3 +1139,32 @@ class Delegate extends SliverPersistentHeaderDelegate {
return true;
}
}
class CustomClipPath extends CustomClipper<Path> {
@override
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();
return path0;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) {
return false;
}
}
......@@ -11,6 +11,7 @@ import 'package:byod/helper/widget/style.dart';
import 'package:byod/main.dart';
import 'package:byod/models/bill.dart';
import 'package:byod/models/member_info.dart';
import 'package:byod/ui/home/new_home2.dart';
import 'package:byod/ui/payment/payment.dart';
import 'package:byod/ui/screen_responsive.dart';
import 'package:byod/ui/viewbill/shimmer_bill.dart';
......@@ -419,7 +420,7 @@ Mohon menuju kasir untuk meminta bukti pembayaran''';
context,
MaterialPageRoute(
builder: (_) =>
const Home()));
const NewHome2()));
},
child: Container(
padding: EdgeInsets.symmetric(
......@@ -753,7 +754,7 @@ Mohon menuju kasir untuk meminta bukti pembayaran''';
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const Home()));
builder: (_) => const NewHome2()));
},
child: Container(
padding: EdgeInsets.symmetric(
......@@ -1246,8 +1247,8 @@ Mohon menuju kasir untuk meminta bukti pembayaran''';
GestureDetector(
onTap: () {
if (!widget.isHistory) {
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (_) => Home()));
Navigator.pushReplacement(context,
MaterialPageRoute(builder: (_) => const NewHome2()));
context.read<BranchExist>().branchExist(
branchCode, brandCode, role, cashierName, sessionId);
} else {
......
......@@ -73,6 +73,9 @@ flutter:
- asset: assets/fonts/font_awesome/fa-solid-900.ttf
weight: 600
- asset: assets/fonts/font_awesome/fa-regular-400.ttf
- family: Mulish
fonts:
- asset: assets/fonts/mulish/Mulish-Regular.ttf
# - family: NotoSans
# fonts:
# - asset: assets/fonts/noto_sans/NotoSans-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