Commit fabd3fc0 authored by Dio Maulana's avatar Dio Maulana

home page fix

parent 21db6841
{ {
"base_url": "https://romi-dev2.ravku.com/", "base_url": "https://romi-dev2.ravku.com/",
"title": "Ravintola Dev BYOD", "title": "Ravintola Dev BYOD",
"isResponsive": true, "isResponsive": false,
"debug": true "debug": true
} }
\ No newline at end of file
...@@ -335,6 +335,7 @@ class Api { ...@@ -335,6 +335,7 @@ class Api {
"sold_in_store": false, "sold_in_store": false,
"type": typeCategory, "type": typeCategory,
"category_name": dataCat[d]['name'], "category_name": dataCat[d]['name'],
"category_id": dataCat[d]['id'],
"description": '', "description": '',
"group_id": '', "group_id": '',
"group_name": '', "group_name": '',
...@@ -391,6 +392,7 @@ class Api { ...@@ -391,6 +392,7 @@ class Api {
"sold_in_store": false, "sold_in_store": false,
"type": typeGroup, "type": typeGroup,
"category_name": dataCat[d]['name'], "category_name": dataCat[d]['name'],
"category_id": dataCat[d]['id'],
"description": '', "description": '',
"group_id": menuList[i]['group_id'], "group_id": menuList[i]['group_id'],
"group_name": menuList[i]['group_name'], "group_name": menuList[i]['group_name'],
...@@ -411,6 +413,7 @@ class Api { ...@@ -411,6 +413,7 @@ class Api {
"sold_in_store": menuList[i]['sold_in_store'], "sold_in_store": menuList[i]['sold_in_store'],
"type": typeMenu, "type": typeMenu,
"category_name": dataCat[d]['name'], "category_name": dataCat[d]['name'],
"category_id": dataCat[d]['id'],
"description": menuList[i]['description'], "description": menuList[i]['description'],
"group_name": menuList[i]['group_name'], "group_name": menuList[i]['group_name'],
"group_id": menuList[i]['group_id'], "group_id": menuList[i]['group_id'],
...@@ -437,6 +440,7 @@ class Api { ...@@ -437,6 +440,7 @@ class Api {
"sold_in_store": false, "sold_in_store": false,
"type": typeCategory, "type": typeCategory,
"category_name": favGroup[s]['name'], "category_name": favGroup[s]['name'],
"category_id": favGroup[s]['id'],
"description": '', "description": '',
"group_id": '', "group_id": '',
"group_name": '', "group_name": '',
...@@ -486,6 +490,7 @@ class Api { ...@@ -486,6 +490,7 @@ class Api {
"sold_in_store": false, "sold_in_store": false,
"type": typeGroup, "type": typeGroup,
"category_name": favGroup[s]['name'], "category_name": favGroup[s]['name'],
"category_id": favGroup[s]['id'],
"description": '', "description": '',
"group_id": favDetail[i]['group_id'], "group_id": favDetail[i]['group_id'],
"group_name": favDetail[i]['group_name'], "group_name": favDetail[i]['group_name'],
...@@ -507,6 +512,7 @@ class Api { ...@@ -507,6 +512,7 @@ class Api {
"sold_in_store": favDetail[i]['sold_in_store'], "sold_in_store": favDetail[i]['sold_in_store'],
"type": typeMenu, "type": typeMenu,
"category_name": favGroup[s]['name'], "category_name": favGroup[s]['name'],
"category_id": favGroup[s]['id'],
"description": favDetail[i]['description'], "description": favDetail[i]['description'],
"group_name": favDetail[i]['group_name'], "group_name": favDetail[i]['group_name'],
"group_id": favDetail[i]['group_id'], "group_id": favDetail[i]['group_id'],
...@@ -532,6 +538,7 @@ class Api { ...@@ -532,6 +538,7 @@ class Api {
isSell: false, isSell: false,
type: typeCategory, type: typeCategory,
categoryName: '', categoryName: '',
categoryId: '',
description: '', description: '',
groupId: '', groupId: '',
groupName: '', groupName: '',
......
...@@ -26,8 +26,29 @@ import 'package:byod/models/filter_menu.dart'; ...@@ -26,8 +26,29 @@ import 'package:byod/models/filter_menu.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
class SearchMenu extends Cubit<List<dynamic>> { class SearchMenu extends Cubit<List<dynamic>> {
SearchMenu() : super([[], 'All', false]); SearchMenu()
// return arraynya [list<Category>, SelectedCat, bool dari ini lagi search by text or not,] : super([
[
FilterMenu(
id: 'start',
name: '',
price: '',
originalPrice: '',
imageUrlMedium: '',
imageUrlThumbnail: '',
isSell: false,
type: typeMenu,
categoryName: '',
categoryId: '',
description: '',
groupName: '',
groupId: '',
)
],
'All',
false
]);
// return arraynya [list<Category>, SelectedCat, bool dari search by text(typing) or not,]
void searchMenu( void searchMenu(
List<FilterMenu> oldMenu, { List<FilterMenu> oldMenu, {
...@@ -63,22 +84,11 @@ class SearchMenu extends Cubit<List<dynamic>> { ...@@ -63,22 +84,11 @@ class SearchMenu extends Cubit<List<dynamic>> {
if (indexGroupId == -1 && indexGroup != -1) { if (indexGroupId == -1 && indexGroup != -1) {
searchMenu.add(oldMenu[indexGroup]); searchMenu.add(oldMenu[indexGroup]);
} }
searchMenu.add(x); searchMenu.add(x);
} }
// for (var menu in x.menu) {
// if (menu.name.toLowerCase().contains(keyword.toLowerCase())) {
// // searchMenu.add(menu);
// menuSearch.add(menu);
// var x = {
// "id": cat.id,
// "name": cat.name,
// "menu": menuSearch,
// };
// searchMenu.add(Category.createCategory(x));
// }
// }
} }
} else {
searchMenu = oldMenu;
} }
} else { } else {
if (categorySelected != '') { if (categorySelected != '') {
......
...@@ -249,6 +249,8 @@ const textColorTabel = Color(0xff333333); ...@@ -249,6 +249,8 @@ const textColorTabel = Color(0xff333333);
const textColorBlack = Color(0xff000000); const textColorBlack = Color(0xff000000);
const textColorRed = Color(0xffE73636); const textColorRed = Color(0xffE73636);
const textGrey = Color(0xffE0E0E0); const textGrey = Color(0xffE0E0E0);
const textGreyDeskripsi = Color(0xffBDBDBD);
const backgroundColorBottomSheet = Color(0xffE5E5E5);
const textColorModalHeaderNama = Color(0xffCCCCFF); const textColorModalHeaderNama = Color(0xffCCCCFF);
const gridCardBackgroundColor = Color(0xffFFFFFF); const gridCardBackgroundColor = Color(0xffFFFFFF);
Color buttonColor = Color buttonColor =
......
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../helper.dart';
class PoniBottomSheet extends StatelessWidget { class PoniBottomSheet extends StatelessWidget {
const PoniBottomSheet({Key? key}) : super(key: key); const PoniBottomSheet({Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
double widthScreen = responsiveWidthScreen(context);
return Container( return Container(
width: widthScreen * 0.3, width: 50,
height: MediaQuery.of(context).size.height * 0.008, height: 3,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(roundedButton), borderRadius: BorderRadius.circular(7),
color: Colors.grey), color: const Color(0xffD9D9D9)),
// child: Divider( // child: Divider(
// color: buttonColor.withOpacity(0.6), // color: buttonColor.withOpacity(0.6),
// thickness: MediaQuery.of(context).size.height * 0.008, // thickness: MediaQuery.of(context).size.height * 0.008,
......
...@@ -162,11 +162,12 @@ TextStyle deskripsiMenuStyle({ ...@@ -162,11 +162,12 @@ TextStyle deskripsiMenuStyle({
TextStyle amountMenuStyle({ TextStyle amountMenuStyle({
font = 16, font = 16,
Color color = textColorBlack, Color color = textColorBlack,
FontWeight fontWeight = FontWeight.w300,
}) { }) {
return TextStyle( return TextStyle(
fontFamily: (fontFamily == '') ? null : fontFamily, fontFamily: (fontFamily == '') ? null : fontFamily,
fontSize: font, fontSize: font,
fontWeight: FontWeight.w300, fontWeight: fontWeight,
color: color, color: color,
); );
} }
...@@ -212,7 +213,7 @@ TextStyle textCountItem({ ...@@ -212,7 +213,7 @@ TextStyle textCountItem({
Color color = textInButton, Color color = textInButton,
}) { }) {
return TextStyle( return TextStyle(
fontFamily: 'Robot', fontFamily: 'Roboto',
fontSize: font, fontSize: font,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
color: color, color: color,
...@@ -350,6 +351,24 @@ Text textAmountMenu(BuildContext context, int amount) { ...@@ -350,6 +351,24 @@ Text textAmountMenu(BuildContext context, int amount) {
// ); // );
} }
TextStyle textDeskripsiHeader() {
return const TextStyle(
fontFamily: 'Roboto',
fontWeight: FontWeight.w500,
fontSize: 14,
color: textColorBlack,
);
}
TextStyle textDeskripsi() {
return const TextStyle(
fontFamily: 'Roboto',
fontWeight: FontWeight.w400,
fontSize: 14,
color: textGreyDeskripsi,
);
}
Text textAmountCoret(BuildContext context, int hargaCoret) { Text textAmountCoret(BuildContext context, int hargaCoret) {
return defaultText( return defaultText(
context, context,
...@@ -398,7 +417,7 @@ Text textMenuNameBottomShetModalMenu(BuildContext context, String text) { ...@@ -398,7 +417,7 @@ Text textMenuNameBottomShetModalMenu(BuildContext context, String text) {
text, text,
maxLines: 2, maxLines: 2,
overFlow: TextOverflow.ellipsis, overFlow: TextOverflow.ellipsis,
style: textStyleMenuList(context), style: menuNameBottomSheet(),
); );
// return Text( // return Text(
// text, // text,
...@@ -408,6 +427,15 @@ Text textMenuNameBottomShetModalMenu(BuildContext context, String text) { ...@@ -408,6 +427,15 @@ Text textMenuNameBottomShetModalMenu(BuildContext context, String text) {
// ); // );
} }
TextStyle menuNameBottomSheet() {
return const TextStyle(
fontFamily: 'Roboto',
fontWeight: FontWeight.w500,
fontSize: 28,
color: textColorBlack,
);
}
Text textDescriptionBottomShetModalMenu(BuildContext context, String text) { Text textDescriptionBottomShetModalMenu(BuildContext context, String text) {
return defaultText( return defaultText(
context, context,
......
...@@ -10,6 +10,7 @@ class FilterMenu { ...@@ -10,6 +10,7 @@ class FilterMenu {
final bool isSell; final bool isSell;
final int type; final int type;
final String categoryName; final String categoryName;
final String categoryId;
final String description; final String description;
final String groupName; final String groupName;
final String groupId; final String groupId;
...@@ -28,6 +29,7 @@ class FilterMenu { ...@@ -28,6 +29,7 @@ class FilterMenu {
required this.isSell, required this.isSell,
required this.type, required this.type,
required this.categoryName, required this.categoryName,
required this.categoryId,
required this.description, required this.description,
required this.groupName, required this.groupName,
required this.groupId, required this.groupId,
...@@ -39,25 +41,26 @@ class FilterMenu { ...@@ -39,25 +41,26 @@ class FilterMenu {
factory FilterMenu.createMenu(Map<String, dynamic> json) { factory FilterMenu.createMenu(Map<String, dynamic> json) {
return FilterMenu( return FilterMenu(
id: json['id'], id: json['id'],
name: json['name'], name: json['name'],
price: json['price'], price: json['price'],
originalPrice: json['original_price'], originalPrice: json['original_price'],
imageUrlMedium: json['image_medium'], imageUrlMedium: json['image_medium'],
imageUrlThumbnail: json['image_thumbnail'], imageUrlThumbnail: json['image_thumbnail'],
isSell: json['sold_in_store'], isSell: json['sold_in_store'],
type: json['type'], type: json['type'],
categoryName: json['category_name'], categoryName: json['category_name'],
description: json['description'], categoryId: json['category_id'],
groupName: json['group_name'], description: json['description'],
groupId: json['group_id'], groupName: json['group_name'],
isFavMenu: (json['is_fav'] == null) ? false : json['is_fav'], groupId: json['group_id'],
variantCat: json['variant_cat'], isFavMenu: (json['is_fav'] == null) ? false : json['is_fav'],
favGroupId: (json['favorite_group_id'] == null) variantCat: json['variant_cat'],
? '' favGroupId:
: json['favorite_group_id'], (json['favorite_group_id'] == null) ? '' : json['favorite_group_id'],
favGroupName: (json['favorite_group_name'] == null) favGroupName: (json['favorite_group_name'] == null)
? '' ? ''
: json['favorite_group_name']); : json['favorite_group_name'],
);
} }
} }
...@@ -63,50 +63,19 @@ class _ShowMenuModalState extends State<ShowMenuModal> { ...@@ -63,50 +63,19 @@ class _ShowMenuModalState extends State<ShowMenuModal> {
return Container( return Container(
padding: EdgeInsets.symmetric(horizontal: leftRigthPadding), padding: EdgeInsets.symmetric(horizontal: leftRigthPadding),
child: Container( child: Container(
height: MediaQuery.of(context).size.height * 0.9, height: 704,
margin: EdgeInsets.only(
left: widthScreen * 0.005,
right: widthScreen * 0.005,
top: MediaQuery.of(context).size.height * 0.005,
bottom: MediaQuery.of(context).size.height * 0.005),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topRight: Radius.circular(roundedImage),
topLeft: Radius.circular(roundedImage)),
color: backgroundColor),
child: Container( child: Container(
margin: EdgeInsets.only( margin: const EdgeInsets.symmetric(
left: widthScreen * 0.05, horizontal: 16,
right: widthScreen * 0.05, ),
top: MediaQuery.of(context).size.height * 0.02,
bottom: MediaQuery.of(context).size.height * 0.02),
child: Column( child: Column(
children: [ children: [
const PoniBottomSheet(), const SizedBox(
SizedBox( height: 8,
height: MediaQuery.of(context).size.height * 0.03,
), ),
Container( const PoniBottomSheet(),
// height: MediaQuery.of(context).size.height * 0.45, const SizedBox(
width: double.infinity, height: 32,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(roundedImage),
color: disabledColor.withOpacity(0.8),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(roundedImage),
child: (widget.imageUrl != '')
? Image(
fit: BoxFit.fill,
image: NetworkImage(widget.imageUrl),
)
: const Image(
fit: BoxFit.fill,
image: AssetImage('assets/noimage.png')),
),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.02,
), ),
Align( Align(
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
...@@ -115,105 +84,223 @@ class _ShowMenuModalState extends State<ShowMenuModal> { ...@@ -115,105 +84,223 @@ class _ShowMenuModalState extends State<ShowMenuModal> {
widget.namaMenu, widget.namaMenu,
), ),
), ),
SizedBox( const SizedBox(
height: MediaQuery.of(context).size.height * 0.02, height: 30,
),
ClipRRect(
borderRadius: BorderRadius.circular(21),
child: (widget.imageUrl != '')
? Image(
width: 343,
height: 350,
fit: BoxFit.fill,
image: NetworkImage(widget.imageUrl),
)
: const Image(
width: 343,
height: 350,
fit: BoxFit.fill,
image: AssetImage('assets/noimage.png')),
),
const SizedBox(
height: 20,
), ),
(widget.description != '') (widget.description != '')
? Align( ? Align(
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
child: textDescriptionBottomShetModalMenu( child: defaultText(
context, context,
widget.description, 'Deskripsi',
style: textDeskripsiHeader(),
), ),
) )
: const SizedBox(), : const SizedBox(),
const SizedBox(
height: 12,
),
(widget.description != '') (widget.description != '')
? SizedBox( ? Align(
height: MediaQuery.of(context).size.height * 0.02, alignment: Alignment.topLeft,
child: defaultText(
context,
widget.description,
maxLines: 5,
overFlow: TextOverflow.ellipsis,
style: textDeskripsi(),
),
) )
: const SizedBox(), : const SizedBox(),
Align( const SizedBox(
alignment: Alignment.topLeft, height: 31,
child: textAmoutBottomShetModalMenu(
context,
widget.hargaMenu,
),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.02,
), ),
const Spacer(), const Spacer(),
GestureDetector( Container(
onTap: () { padding: const EdgeInsets.only(bottom: 18),
if (widget.isSell) { child: Row(
if (widget.isHavevariant) { mainAxisAlignment: MainAxisAlignment.spaceBetween,
if (indexListOrderan == -1) { children: [
Navigator.pop(context); defaultText(
context context,
.read<OrderVariantTemporaryBloc>() 'Rp ${formatNumber().format(widget.hargaMenu)}',
.insertDataVariant( style: amountMenuStyle(
font: 20, fontWeight: FontWeight.w500),
),
GestureDetector(
onTap: () {
if (widget.isSell) {
if (widget.isHavevariant) {
if (indexListOrderan == -1) {
Navigator.pop(context);
context
.read<OrderVariantTemporaryBloc>()
.insertDataVariant(
widget.id,
widget.hargaMenu,
1,
[]); // check pada bloc untuk mengethui list arraynya
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => VariantCat(
namaMenu: widget.namaMenu,
variantCategories:
widget.variantCat,
initPrice: widget.hargaMenu,
idItem: widget.id,
imageUrl: widget.imageUrl,
listCurrentOrder: list,
orderDetail: OrderDetail(
allIdVariant: '',
totalItem: 0,
totalHarga: 0,
note: '',
orderVariant: []),
)));
} else {
Navigator.pop(context);
showModalBottomSheet(
backgroundColor:
Colors.white.withOpacity(0),
isScrollControlled: true,
context: context,
builder: (context) {
return CustomizeVariant(
orders: list[indexListOrderan],
variantCat: widget.variantCat);
},
);
}
} else {
initialValue += 1;
context.read<OrdersBloc>().insertData([
[
widget.id, widget.id,
widget.namaMenu,
initialValue,
widget.hargaMenu,
list,
widget.imageUrl,
orderVariants,
widget.hargaMenu, widget.hargaMenu,
1, (indexListOrderan != -1)
[]); // check pada bloc untuk mengethui list arraynya ? list[indexListOrderan].note
Navigator.push( : '',
]
], context);
Navigator.pop(context);
}
}
},
child: Container(
height: 38,
width: 119,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6),
color: buttonColor,
),
child: Center(
child: defaultText(
context, context,
MaterialPageRoute( 'Tambah',
builder: (_) => VariantCat( style: addButtonMenu(),
namaMenu: widget.namaMenu, ),
variantCategories: widget.variantCat, ),
initPrice: widget.hargaMenu, ),
idItem: widget.id, )
imageUrl: widget.imageUrl, ],
listCurrentOrder: list,
orderDetail: OrderDetail(
allIdVariant: '',
totalItem: 0,
totalHarga: 0,
note: '',
orderVariant: []),
)));
} else {
Navigator.pop(context);
showModalBottomSheet(
backgroundColor: Colors.white.withOpacity(0),
isScrollControlled: true,
context: context,
builder: (context) {
return CustomizeVariant(
orders: list[indexListOrderan],
variantCat: widget.variantCat);
},
);
}
} 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);
Navigator.pop(context);
}
}
},
child: buttonBottom(
context,
(widget.isSell) ? "Tambahkan Orderan" : "Habis",
(widget.isSell) ? buttonColor : disabledColor,
double.infinity,
), ),
) )
// GestureDetector(
// onTap: () {
// if (widget.isSell) {
// if (widget.isHavevariant) {
// if (indexListOrderan == -1) {
// Navigator.pop(context);
// context
// .read<OrderVariantTemporaryBloc>()
// .insertDataVariant(
// widget.id,
// widget.hargaMenu,
// 1,
// []); // check pada bloc untuk mengethui list arraynya
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (_) => VariantCat(
// namaMenu: widget.namaMenu,
// variantCategories: widget.variantCat,
// initPrice: widget.hargaMenu,
// idItem: widget.id,
// imageUrl: widget.imageUrl,
// listCurrentOrder: list,
// orderDetail: OrderDetail(
// allIdVariant: '',
// totalItem: 0,
// totalHarga: 0,
// note: '',
// orderVariant: []),
// )));
// } else {
// Navigator.pop(context);
// showModalBottomSheet(
// backgroundColor: Colors.white.withOpacity(0),
// isScrollControlled: true,
// context: context,
// builder: (context) {
// return CustomizeVariant(
// orders: list[indexListOrderan],
// variantCat: widget.variantCat);
// },
// );
// }
// } 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);
// Navigator.pop(context);
// }
// }
// },
// child: buttonBottom(
// context,
// (widget.isSell) ? "Tambahkan Orderan" : "Habis",
// (widget.isSell) ? buttonColor : disabledColor,
// double.infinity,
// ),
// )
], ],
), ),
), ),
......
// ignore_for_file: must_be_immutable // ignore_for_file: must_be_immutable
import 'package:byod/bloc/menu_selected_bar.dart'; import 'package:byod/bloc/menu_selected_bar.dart';
import 'package:byod/models/fav_group.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
...@@ -10,9 +11,15 @@ import '../../models/category_list.dart'; ...@@ -10,9 +11,15 @@ import '../../models/category_list.dart';
class CategoryListHome extends StatefulWidget { class CategoryListHome extends StatefulWidget {
List<CategoryList> categoryList; List<CategoryList> categoryList;
List<FavoriteGroup> favList;
ScrollController scrollController;
// ScrollController scrollControllerMenu;
CategoryListHome({ CategoryListHome({
Key? key, Key? key,
required this.categoryList, required this.categoryList,
required this.scrollController,
required this.favList,
// required this.scrollControllerMenu,
}) : super(key: key); }) : super(key: key);
@override @override
...@@ -21,14 +28,7 @@ class CategoryListHome extends StatefulWidget { ...@@ -21,14 +28,7 @@ class CategoryListHome extends StatefulWidget {
class _CategoryListHomeState extends State<CategoryListHome> { class _CategoryListHomeState extends State<CategoryListHome> {
int selectedIndex = 0; int selectedIndex = 0;
List<String> catMenu = [
'All Item',
'New',
'Discount',
'Food',
'Beverage',
'Additional'
];
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocBuilder<MenuSelectedBar, List<dynamic>>( return BlocBuilder<MenuSelectedBar, List<dynamic>>(
...@@ -40,15 +40,25 @@ class _CategoryListHomeState extends State<CategoryListHome> { ...@@ -40,15 +40,25 @@ class _CategoryListHomeState extends State<CategoryListHome> {
itemBuilder: (context, i) { itemBuilder: (context, i) {
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
context context
.read<MenuSelectedBar>() .read<MenuSelectedBar>()
.selectedBarMenu(i, widget.categoryList[i].name); .selectedBarMenu(i, widget.categoryList[i].id);
widget.scrollController.animateTo(
(widget.favList.isNotEmpty) ? 371 : 0,
duration: Duration(milliseconds: animatedTime),
curve: Curves.fastOutSlowIn,
);
}, },
child: Container( child: Container(
color: backgroundColor, color: backgroundColor,
margin: EdgeInsets.only( margin: EdgeInsets.only(
left: (i == 0) ? 0 : 28.335, left: (i == 0) ? 0 : 28.335,
right: (i == catMenu.length - 1) ? 0 : 28.335), right: (i == widget.categoryList.length - 1) ? 0 : 28.335),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
......
...@@ -60,12 +60,17 @@ class FavGridMenu extends StatelessWidget { ...@@ -60,12 +60,17 @@ class FavGridMenu extends StatelessWidget {
height: widthGrid - (2 * paddingLeftRigthGrid), height: widthGrid - (2 * paddingLeftRigthGrid),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
// color: Colors.red, color: disabledColor.withOpacity(0.8),
), ),
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
showModalBottomSheet( showModalBottomSheet(
backgroundColor: backgroundColor.withOpacity(0), backgroundColor: Colors.white,
isScrollControlled: true, isScrollControlled: true,
context: context, context: context,
builder: (context) { builder: (context) {
...@@ -88,11 +93,15 @@ class FavGridMenu extends StatelessWidget { ...@@ -88,11 +93,15 @@ class FavGridMenu extends StatelessWidget {
}, },
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
child: Image( child: (categoryFavAfterSelect[i].imageUrlMedium != '')
fit: BoxFit.fill, ? Image(
image: fit: BoxFit.fill,
NetworkImage(categoryFavAfterSelect[i].imageUrlMedium), image: NetworkImage(
), categoryFavAfterSelect[i].imageUrlMedium),
)
: const Image(
fit: BoxFit.fill,
image: AssetImage('assets/noimage.png')),
), ),
), ),
), ),
...@@ -177,6 +186,11 @@ class FavGridMenu extends StatelessWidget { ...@@ -177,6 +186,11 @@ class FavGridMenu extends StatelessWidget {
? GestureDetector( ? GestureDetector(
key: const Key('AddButton'), key: const Key('AddButton'),
onTap: () { onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
if (menuFav.isSell) { if (menuFav.isSell) {
if (menuFav.variantCat.isNotEmpty) { if (menuFav.variantCat.isNotEmpty) {
if (indexListOrderan == -1) { if (indexListOrderan == -1) {
...@@ -273,6 +287,11 @@ class FavGridMenu extends StatelessWidget { ...@@ -273,6 +287,11 @@ class FavGridMenu extends StatelessWidget {
children: [ children: [
GestureDetector( GestureDetector(
onTap: () { onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
showModalBottomSheet( showModalBottomSheet(
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
isScrollControlled: true, isScrollControlled: true,
...@@ -310,6 +329,11 @@ class FavGridMenu extends StatelessWidget { ...@@ -310,6 +329,11 @@ class FavGridMenu extends StatelessWidget {
), ),
GestureDetector( GestureDetector(
onTap: () { onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
if (initialValue > 0) { if (initialValue > 0) {
initialValue -= 1; initialValue -= 1;
context.read<OrdersBloc>().insertData([ context.read<OrdersBloc>().insertData([
...@@ -350,6 +374,11 @@ class FavGridMenu extends StatelessWidget { ...@@ -350,6 +374,11 @@ class FavGridMenu extends StatelessWidget {
), ),
GestureDetector( GestureDetector(
onTap: () { onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
initialValue += 1; initialValue += 1;
context.read<OrdersBloc>().insertData([ context.read<OrdersBloc>().insertData([
[ [
......
...@@ -30,6 +30,11 @@ class _FavoriteListState extends State<FavoriteList> { ...@@ -30,6 +30,11 @@ class _FavoriteListState extends State<FavoriteList> {
itemBuilder: (context, i) { itemBuilder: (context, i) {
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
context context
.read<FavSelectedBar>() .read<FavSelectedBar>()
.selectedBarFav(i, widget.favoriteList[i].id); .selectedBarFav(i, widget.favoriteList[i].id);
......
// ignore_for_file: sized_box_for_whitespace // ignore_for_file: sized_box_for_whitespace
import 'package:byod/bloc/order_bloc.dart'; import 'package:byod/bloc/order_bloc.dart';
import 'package:byod/helper/widget/poni_bottom_sheet.dart';
import 'package:byod/models/orders.dart'; import 'package:byod/models/orders.dart';
import 'package:byod/ui/home/variant_cat.dart'; import 'package:byod/ui/home/variant_cat.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -13,6 +14,7 @@ import '../../helper/widget/style.dart'; ...@@ -13,6 +14,7 @@ import '../../helper/widget/style.dart';
import '../../models/filter_menu.dart'; import '../../models/filter_menu.dart';
import '../../models/order_details.dart'; import '../../models/order_details.dart';
import '../../models/order_variants.dart'; import '../../models/order_variants.dart';
import 'bottom_sheet_menu.dart';
import 'bottom_sheet_variant.dart'; import 'bottom_sheet_variant.dart';
class MenuListUtama extends StatelessWidget { class MenuListUtama extends StatelessWidget {
...@@ -20,10 +22,14 @@ class MenuListUtama extends StatelessWidget { ...@@ -20,10 +22,14 @@ class MenuListUtama extends StatelessWidget {
Key? key, Key? key,
required this.categoryNonFav, required this.categoryNonFav,
required this.i, required this.i,
required this.widthScreen,
required this.scrollController,
}) : super(key: key); }) : super(key: key);
final List<FilterMenu> categoryNonFav; final List<FilterMenu> categoryNonFav;
final int i; final int i;
final double widthScreen;
final ScrollController scrollController;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -107,17 +113,56 @@ class MenuListUtama extends StatelessWidget { ...@@ -107,17 +113,56 @@ class MenuListUtama extends StatelessWidget {
width: 12, width: 12,
height: double.infinity, height: double.infinity,
), ),
Container( GestureDetector(
width: 125, onTap: () {
height: 125, FocusScopeNode currentFocus =
decoration: BoxDecoration( FocusScope.of(context);
borderRadius: BorderRadius.circular(14)),
child: ClipRRect( if (!currentFocus.hasPrimaryFocus) {
borderRadius: BorderRadius.circular(14), currentFocus.unfocus();
child: Image( }
image: NetworkImage( showModalBottomSheet(
categoryNonFav[i].imageUrlMedium, backgroundColor: Colors.white,
), isScrollControlled: true,
context: context,
builder: (context) {
return ShowMenuModal(
imageUrl: categoryNonFav[i].imageUrlMedium,
namaMenu: categoryNonFav[i].name,
hargaMenu: amountParseToInt(
categoryNonFav[i].price),
isHavevariant:
categoryNonFav[i].variantCat.isNotEmpty
? true
: false,
description: categoryNonFav[i].description,
id: categoryNonFav[i].id,
variantCat: categoryNonFav[i].variantCat,
isSell: categoryNonFav[i].isSell,
);
},
);
},
child: Container(
width: 125,
height: 125,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14),
color: disabledColor.withOpacity(0.8),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(14),
child: (categoryNonFav[i].imageUrlMedium != '')
? Image(
fit: BoxFit.fill,
image: NetworkImage(
categoryNonFav[i].imageUrlMedium,
),
)
: const Image(
fit: BoxFit.fill,
image: AssetImage('assets/noimage.png'),
),
), ),
), ),
) )
...@@ -181,6 +226,12 @@ class MenuListUtama extends StatelessWidget { ...@@ -181,6 +226,12 @@ class MenuListUtama extends StatelessWidget {
const Spacer(), const Spacer(),
GestureDetector( GestureDetector(
onTap: () { onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
if (menuUtama.isSell) { if (menuUtama.isSell) {
if (menuUtama.variantCat.isNotEmpty) { if (menuUtama.variantCat.isNotEmpty) {
if (indexListOrderan == -1) { if (indexListOrderan == -1) {
...@@ -282,6 +333,11 @@ class MenuListUtama extends StatelessWidget { ...@@ -282,6 +333,11 @@ class MenuListUtama extends StatelessWidget {
children: [ children: [
GestureDetector( GestureDetector(
onTap: () { onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
showModalBottomSheet( showModalBottomSheet(
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
isScrollControlled: true, isScrollControlled: true,
...@@ -330,6 +386,12 @@ class MenuListUtama extends StatelessWidget { ...@@ -330,6 +386,12 @@ class MenuListUtama extends StatelessWidget {
left: 0, left: 0,
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
FocusScopeNode currentFocus =
FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
if (initialValue > 0) { if (initialValue > 0) {
initialValue -= 1; initialValue -= 1;
context.read<OrdersBloc>().insertData([ context.read<OrdersBloc>().insertData([
...@@ -365,6 +427,12 @@ class MenuListUtama extends StatelessWidget { ...@@ -365,6 +427,12 @@ class MenuListUtama extends StatelessWidget {
right: 0, right: 0,
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
FocusScopeNode currentFocus =
FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
initialValue += 1; initialValue += 1;
context.read<OrdersBloc>().insertData([ context.read<OrdersBloc>().insertData([
[ [
......
...@@ -4,6 +4,7 @@ import 'package:byod/bloc/branch_exist.dart'; ...@@ -4,6 +4,7 @@ import 'package:byod/bloc/branch_exist.dart';
import 'package:byod/bloc/fav_selected_bar.dart'; import 'package:byod/bloc/fav_selected_bar.dart';
import 'package:byod/bloc/menu_selected_bar.dart'; import 'package:byod/bloc/menu_selected_bar.dart';
import 'package:byod/bloc/order_bloc.dart'; import 'package:byod/bloc/order_bloc.dart';
import 'package:byod/bloc/search_menu.dart';
import 'package:byod/helper/helper.dart'; import 'package:byod/helper/helper.dart';
import 'package:byod/helper/widget/style.dart'; import 'package:byod/helper/widget/style.dart';
import 'package:byod/models/filter_menu.dart'; import 'package:byod/models/filter_menu.dart';
...@@ -11,6 +12,7 @@ import 'package:byod/models/orders.dart'; ...@@ -11,6 +12,7 @@ import 'package:byod/models/orders.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
import '../../bloc/filter_menu.dart'; import '../../bloc/filter_menu.dart';
import '../../helper/widget/button_dialog.dart'; import '../../helper/widget/button_dialog.dart';
...@@ -42,6 +44,7 @@ class _NewHome2State extends State<NewHome2> { ...@@ -42,6 +44,7 @@ class _NewHome2State extends State<NewHome2> {
final _scrollController = ScrollController(); final _scrollController = ScrollController();
final _scrollFavItem = ScrollController(); final _scrollFavItem = ScrollController();
final _scrollMenuItem = ScrollController(); final _scrollMenuItem = ScrollController();
final scrollMenuItemList = ItemScrollController();
late bool isScrollableMenu = false; late bool isScrollableMenu = false;
// final double positionCustomScrollViewFixed = 345.5 - 10; // final double positionCustomScrollViewFixed = 345.5 - 10;
...@@ -67,21 +70,23 @@ class _NewHome2State extends State<NewHome2> { ...@@ -67,21 +70,23 @@ class _NewHome2State extends State<NewHome2> {
setState(() { setState(() {
isFirstLoad = false; isFirstLoad = false;
}); });
// double positionCustomScrollView = _scrollController.position.pixels;
// print(positionCustomScrollView);
// if (_scrollController.position.pixels >= // if (_scrollController.position.pixels >=
// (_scrollController.position.maxScrollExtent - 100)) {} // (_scrollController.position.maxScrollExtent - 100)) {}
double positionCustomScrollView = _scrollController.position.pixels; // double positionCustomScrollView = _scrollController.position.pixels;
double positionCustomScrollViewMax = // double positionCustomScrollViewMax =
_scrollController.position.maxScrollExtent; // _scrollController.position.maxScrollExtent;
// if (isSearchActive) { // if (isSearchActive) {
if (positionCustomScrollView >= positionCustomScrollViewMax) { // if (positionCustomScrollView >= positionCustomScrollViewMax - 50) {
setState(() { // setState(() {
isScrollableMenu = true; // isScrollableMenu = true;
}); // });
} else { // } else {
setState(() { // setState(() {
isScrollableMenu = false; // isScrollableMenu = false;
}); // });
} // }
// } else { // } else {
// if (positionCustomScrollView >= // if (positionCustomScrollView >=
// positionCustomScrollViewSearchFalseFixed) { // positionCustomScrollViewSearchFalseFixed) {
...@@ -105,39 +110,47 @@ class _NewHome2State extends State<NewHome2> { ...@@ -105,39 +110,47 @@ class _NewHome2State extends State<NewHome2> {
} }
} }
}); });
_scrollMenuItem.addListener(() { // _scrollMenuItem.addListener(() {
double positionMenuItemScrollView = _scrollMenuItem.position.pixels; // double positionMenuItemScrollView = _scrollMenuItem.position.pixels;
double positionMenuItemScrollViewMin = // double positionMenuItemScrollViewMin =
_scrollMenuItem.position.minScrollExtent; // _scrollMenuItem.position.minScrollExtent;
double positionMenuItemScrollViewMax = // double positionMenuItemScrollViewMax =
_scrollMenuItem.position.maxScrollExtent; // _scrollMenuItem.position.maxScrollExtent;
if (positionMenuItemScrollView == positionMenuItemScrollViewMin && // if (positionMenuItemScrollView == positionMenuItemScrollViewMin &&
_scrollController.position.pixels == // _scrollController.position.pixels ==
_scrollController.position.maxScrollExtent) { // _scrollController.position.maxScrollExtent) {
setState(() { // setState(() {
isScrollableMenu = false; // isScrollableMenu = false;
}); // });
} // }
if (positionMenuItemScrollView >= positionMenuItemScrollViewMax - 100) { // if (positionMenuItemScrollView >= positionMenuItemScrollViewMax - 100) {
if (allMenu.length >= countMenuToDisplay) { // if (allMenu.length >= countMenuToDisplay) {
_getMoreData(countMenuToDisplay, allMenu); // _getMoreData(countMenuToDisplay, allMenu);
} // }
} // }
}); // });
super.initState(); super.initState();
} }
_getMoreData(int menuToDisplay, List<FilterMenu> allMenu) { // _getMoreData(int menuToDisplay, List<FilterMenu> allMenu) {
setState(() { // setState(() {
if ((allMenu.length - countMenuToDisplay) > maxItemMenu) { // if ((allMenu.length - countMenuToDisplay) > maxItemMenu) {
countMenuToDisplay += maxItemMenu; // countMenuToDisplay += maxItemMenu;
} else { // } else {
countMenuToDisplay = allMenu.length; // countMenuToDisplay = allMenu.length;
} // }
}); // });
} // }
// scrollToMenuCat(id) {
// int indexCategory = categoryNonFav.indexWhere((categoryNonFav) =>
// categoryNonFav.categoryId == id && categoryNonFav.type == typeCategory);
// if (indexCategory != -1 && isScrollableMenu) {
// scrollMenuItemList.jumpTo(index: indexCategory);
// }
// }
_getMoreDataFav(int menuToDisplay, List<FilterMenu> allMenuFav) { _getMoreDataFav(int menuToDisplay, List<FilterMenu> allMenuFav) {
setState(() { setState(() {
...@@ -189,7 +202,6 @@ class _NewHome2State extends State<NewHome2> { ...@@ -189,7 +202,6 @@ class _NewHome2State extends State<NewHome2> {
String userName = prefs.getString("userName") ?? ""; String userName = prefs.getString("userName") ?? "";
double widthScreen = responsiveWidthScreen(context); double widthScreen = responsiveWidthScreen(context);
double maxWidthScreen = getMaxWidthScreen(context, useResponsive); double maxWidthScreen = getMaxWidthScreen(context, useResponsive);
return BlocBuilder<BranchExist, String>( return BlocBuilder<BranchExist, String>(
builder: (contextBracnhExist, restoran) { builder: (contextBracnhExist, restoran) {
void onTapOkPop() { void onTapOkPop() {
...@@ -248,16 +260,17 @@ class _NewHome2State extends State<NewHome2> { ...@@ -248,16 +260,17 @@ class _NewHome2State extends State<NewHome2> {
"id": "0", "id": "0",
}; // all dulu, biar ada bisa klik all }; // all dulu, biar ada bisa klik all
catListTemp.add(CategoryList.createCategoryList(nn)); catListTemp.add(CategoryList.createCategoryList(nn));
categoryList = catListTemp;
for (var nameCat in categoryNonFav) { for (var nameCat in categoryNonFav) {
if (nameCat.type == typeCategory) { if (nameCat.type == typeCategory) {
var n = { var n = {
"id": nameCat.id, "id": nameCat.id,
"name": nameCat.categoryName "name": nameCat.categoryName
}; };
categoryList catListTemp
.add(CategoryList.createCategoryList(n)); .add(CategoryList.createCategoryList(n));
} }
categoryList = catListTemp;
} }
List<FavoriteGroup> favGroupTemp = []; List<FavoriteGroup> favGroupTemp = [];
for (var nameFav in categoryFav) { for (var nameFav in categoryFav) {
...@@ -271,12 +284,16 @@ class _NewHome2State extends State<NewHome2> { ...@@ -271,12 +284,16 @@ class _NewHome2State extends State<NewHome2> {
} }
favList = favGroupTemp; favList = favGroupTemp;
if (isFirstLoad) { if (isFirstLoad) {
context if (favList.isNotEmpty) {
.read<FavSelectedBar>() context
.selectedBarFav(0, favList[0].id); .read<FavSelectedBar>()
context .selectedBarFav(0, favList[0].id);
.read<MenuSelectedBar>() }
.selectedBarMenu(0, categoryList[0].id); if (categoryList.isNotEmpty) {
context
.read<MenuSelectedBar>()
.selectedBarMenu(0, categoryList[0].id);
}
} }
} }
...@@ -294,273 +311,204 @@ class _NewHome2State extends State<NewHome2> { ...@@ -294,273 +311,204 @@ class _NewHome2State extends State<NewHome2> {
categoryFavAfterSelect = temporSelectedFav; categoryFavAfterSelect = temporSelectedFav;
} }
return BlocBuilder<MenuSelectedBar, List<dynamic>>( return BlocBuilder<SearchMenu, List<dynamic>>(
builder: builder: (contextSearch, listSearch) {
(contextSelectedBarMenu, listDynamicBarMenu) { // if (listSearch[0].isNotEmpty) {
if (categoryNonFav.isNotEmpty && // print(listSearch[0]);
categoryList.isNotEmpty) { // }
List<FilterMenu> temprSelectedMenu = [];
for (var nameCat in categoryNonFav) {
if (listDynamicBarMenu.length == 2 &&
nameCat.categoryName ==
listDynamicBarMenu[1]) {
temprSelectedMenu.add(nameCat);
}
}
if (listDynamicBarMenu.length == 2 &&
listDynamicBarMenu[0] == 0) {
categoryMenuAfterSelect = categoryNonFav;
} else {
categoryMenuAfterSelect = temprSelectedMenu;
}
// if (listDynamicBarMenu.length == 2 &&
// listDynamicBarMenu[1] != "0" &&
// isScrollableMenu == true &&
// _scrollController.position.pixels ==
// _scrollController
// .position.maxScrollExtent &&
// _scrollMenuItem.position.pixels > 0) {
// _scrollMenuItem.animateTo(
// 10,
// 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;
int fixTotalItem = 0; return BlocBuilder<MenuSelectedBar,
int totalItemOrderDetail = 0; List<dynamic>>(
int totalItemBukanOrderDetail = 0; builder: (contextSelectedBarMenu,
for (var i = 0; listDynamicBarMenu) {
i < listOrders.length; if (isSearchActive) {
i++) { if (categoryNonFav.isNotEmpty &&
// totalItem += listOrders[i].totalItem; categoryList.isNotEmpty) {
// check apakah ada order detail. kalau ada rekalkulasi total harga sesuai order detail if (listSearch[0].length == 1 &&
if (listOrders[i].orderDetail.isEmpty) { listSearch[0][0].id == 'start') {
totalHargaBukanOrderDetail += List<FilterMenu> temprSelectedMenu = [];
(listOrders[i].totalItem * for (var nameCat in categoryNonFav) {
listOrders[i].totalHarga); if (listDynamicBarMenu.length == 2 &&
totalItemBukanOrderDetail += nameCat.categoryId ==
listOrders[i].totalItem; listDynamicBarMenu[1]) {
temprSelectedMenu.add(nameCat);
}
}
if (listDynamicBarMenu.length == 2 &&
listDynamicBarMenu[0] == 0) {
categoryMenuAfterSelect =
categoryNonFav;
} else {
categoryMenuAfterSelect =
temprSelectedMenu;
}
} else { } else {
for (int kk = 0; // for (var nameCatSearch
kk < // in listSearch[0]) {
listOrders[i] // if (listDynamicBarMenu.length == 2) {
.orderDetail // if (listDynamicBarMenu[1] != "0" &&
.length; // nameCatSearch.categoryId ==
kk++) { // listDynamicBarMenu[1]) {
totalHargaOrderDetail += listOrders[i] // temprSearchMenu
.orderDetail[kk] // .add(nameCatSearch);
.totalHarga; // }
totalItemOrderDetail += listOrders[i] // }
.orderDetail[kk] // }
.totalItem; if (listDynamicBarMenu[1] != "0") {
List<FilterMenu> temprSearchMenu = [];
for (var nameMenuSearch
in listSearch[0]) {
if (listDynamicBarMenu[1] ==
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 (listDynamicBarMenu.length == 2 &&
nameCat.categoryId ==
listDynamicBarMenu[1]) {
temprSelectedMenu.add(nameCat);
} }
fixTotalHarga = totalHargaOrderDetail;
fixTotalItem = totalItemOrderDetail;
} }
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,
// );
// }
} }
totalHarga = fixTotalHarga +
totalHargaBukanOrderDetail;
totalItem = fixTotalItem +
totalItemBukanOrderDetail;
} }
return Stack(
children: [ return BlocBuilder<OrdersBloc, List<Orders>>(
Container( builder: (contextOrders, listOrders) {
height: int totalItem = 0;
MediaQuery.of(context).size.height, int totalHarga = 0;
margin: EdgeInsets.symmetric( if (listOrders.isNotEmpty) {
horizontal: paddingLeftRight), int fixTotalHarga = 0;
child: Column( int totalHargaOrderDetail = 0;
crossAxisAlignment: int totalHargaBukanOrderDetail = 0;
CrossAxisAlignment.start,
children: [ int fixTotalItem = 0;
customAppBar( int totalItemOrderDetail = 0;
context, int totalItemBukanOrderDetail = 0;
paddingLeftRight, for (var i = 0;
appBarHeight, i < listOrders.length;
tableNumber, i++) {
userName, // totalItem += listOrders[i].totalItem;
), // check apakah ada order detail. kalau ada rekalkulasi total harga sesuai order detail
SizedBox( if (listOrders[i]
height: .orderDetail
(isSearchActive) ? 16 : 20, .isEmpty) {
), totalHargaBukanOrderDetail +=
AnimatedSwitcher( (listOrders[i].totalItem *
duration: Duration( listOrders[i].totalHarga);
milliseconds: animatedTime), totalItemBukanOrderDetail +=
transitionBuilder: (Widget child, listOrders[i].totalItem;
Animation<double> animation) { } else {
return ScaleTransition( for (int kk = 0;
scale: animation, kk <
child: child); listOrders[i]
}, .orderDetail
child: (isSearchActive) .length;
? searchField( kk++) {
searchFieldHeight, totalHargaOrderDetail +=
) listOrders[i]
: const SizedBox( .orderDetail[kk]
key: Key('SearchField'), .totalHarga;
), totalItemOrderDetail +=
), listOrders[i]
Expanded( .orderDetail[kk]
child: CustomScrollView( .totalItem;
controller: _scrollController, }
slivers: [ fixTotalHarga =
SliverToBoxAdapter( totalHargaOrderDetail;
child: SizedBox( fixTotalItem = totalItemOrderDetail;
height: (isSearchActive) }
? spacerHeight }
: 0, totalHarga = fixTotalHarga +
), totalHargaBukanOrderDetail;
), totalItem = fixTotalItem +
SliverToBoxAdapter( totalItemBukanOrderDetail;
child: Container( }
height: favListHeight, return ScreenResponsive(
child: FavoriteList( widget: coreHome(
favoriteList: favList, context,
), widthScreen,
), maxWidthScreen,
), paddingLeftRight,
const SliverToBoxAdapter( appBarHeight,
child: SizedBox( tableNumber,
height: 13.5, userName,
), searchFieldHeight,
), spacerHeight,
SliverToBoxAdapter( favListHeight,
child: Container( favItemHeight,
height: favItemHeight, spacerAboveCat,
child: ListView.builder( spacerAboveCatList,
controller: catListHeight,
_scrollFavItem, spacerAboveMenuItem,
scrollDirection: heightLeft,
Axis.horizontal, totalItem,
itemCount: (categoryFavAfterSelect listOrders,
.length) > totalHarga,
countMenuFavToDisplay tableMode,
? countMenuFavToDisplay
: categoryFavAfterSelect
.length,
itemBuilder:
(context, i) {
double
paddingLeftRigthGrid =
9;
double widthGrid =
136;
return FavGridMenu(
categoryFavAfterSelect:
categoryFavAfterSelect,
widthGrid:
widthGrid,
paddingLeftRigthGrid:
paddingLeftRigthGrid,
i: i,
);
}),
),
),
SliverToBoxAdapter(
child: SizedBox(
height: spacerAboveCat,
),
),
SliverToBoxAdapter(
child: defaultText(
context,
'Category',
style: categoryStyle(),
),
),
SliverToBoxAdapter(
child: SizedBox(
height:
spacerAboveCatList,
),
),
SliverPersistentHeader(
pinned: true,
delegate: Delegate(
catListHeight,
categoryList,
),
),
SliverToBoxAdapter(
child: SizedBox(
height:
spacerAboveMenuItem,
),
),
SliverToBoxAdapter(
child: Container(
height: heightLeft,
child: ListView.builder(
controller:
(isScrollableMenu)
? _scrollMenuItem
: null,
physics: (!isScrollableMenu)
? const NeverScrollableScrollPhysics()
: null,
shrinkWrap:
(isScrollableMenu)
? true
: false,
itemCount: (categoryMenuAfterSelect
.length) >
countMenuToDisplay
? countMenuToDisplay
: categoryMenuAfterSelect
.length,
itemBuilder:
(context, i) {
return MenuListUtama(
categoryNonFav:
categoryMenuAfterSelect,
i: i,
);
},
),
)),
],
),
),
],
), ),
), widthScreen:
AnimatedSwitcher( MediaQuery.of(context).size.width,
duration: Duration( isCoreLayout: true,
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'),
),
)
],
); );
}, },
); );
...@@ -596,10 +544,228 @@ class _NewHome2State extends State<NewHome2> { ...@@ -596,10 +544,228 @@ class _NewHome2State extends State<NewHome2> {
); );
} }
SizedBox searchField(double searchFieldHeight) { Stack coreHome(
return SizedBox( BuildContext context,
double widthScreen,
double maxWidthScreen,
double paddingLeftRight,
double appBarHeight,
String tableNumber,
String userName,
double searchFieldHeight,
double spacerHeight,
double favListHeight,
double favItemHeight,
double spacerAboveCat,
double spacerAboveCatList,
double catListHeight,
double spacerAboveMenuItem,
double heightLeft,
int totalItem,
List<Orders> listOrders,
int totalHarga,
int tableMode) {
return Stack(
children: [
Container(
width: widthScreen,
height: MediaQuery.of(context).size.height,
padding: EdgeInsets.symmetric(horizontal: paddingLeftRight),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
customAppBar(
context,
paddingLeftRight,
appBarHeight,
tableNumber,
userName,
),
SizedBox(
height: (isSearchActive) ? 16 : 20,
),
AnimatedSwitcher(
duration: Duration(milliseconds: animatedTime),
transitionBuilder: (Widget child, Animation<double> animation) {
return ScaleTransition(scale: animation, child: child);
},
child: (isSearchActive)
? searchField(
searchFieldHeight,
categoryNonFav,
)
: const SizedBox(
key: Key('SearchField'),
),
),
Expanded(
child: CustomScrollView(
controller: _scrollController,
slivers: [
SliverToBoxAdapter(
child: SizedBox(
height: (isSearchActive) ? spacerHeight : 0,
),
),
SliverToBoxAdapter(
child: (favList.isNotEmpty)
? Container(
height: favListHeight,
child: FavoriteList(
favoriteList: favList,
),
)
: const SizedBox(),
),
SliverToBoxAdapter(
child: SizedBox(
height: (categoryFavAfterSelect.isNotEmpty) ? 13.5 : 0,
),
),
SliverToBoxAdapter(
child: (categoryFavAfterSelect.isNotEmpty)
? Container(
height: favItemHeight,
child: ListView.builder(
controller: _scrollFavItem,
scrollDirection: Axis.horizontal,
itemCount: (categoryFavAfterSelect.length) >
countMenuFavToDisplay
? countMenuFavToDisplay
: categoryFavAfterSelect.length,
itemBuilder: (context, i) {
double paddingLeftRigthGrid = 9;
double widthGrid = 136;
return FavGridMenu(
categoryFavAfterSelect:
categoryFavAfterSelect,
widthGrid: widthGrid,
paddingLeftRigthGrid: paddingLeftRigthGrid,
i: i,
);
},
),
)
: const SizedBox(),
),
SliverToBoxAdapter(
child: SizedBox(
height: (categoryFavAfterSelect.isNotEmpty)
? spacerAboveCat
: 0,
),
),
SliverToBoxAdapter(
child: (categoryFavAfterSelect.isNotEmpty)
? defaultText(
context,
'Category',
style: categoryStyle(),
)
: const SizedBox(),
),
SliverToBoxAdapter(
child: SizedBox(
height: (categoryFavAfterSelect.isNotEmpty)
? spacerAboveCatList
: 0,
),
),
SliverPersistentHeader(
pinned: true,
delegate: Delegate(
catListHeight,
categoryList,
_scrollController,
favList,
),
),
SliverToBoxAdapter(
child: SizedBox(
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) {
return MenuListUtama(
categoryNonFav: categoryMenuAfterSelect,
i: index,
widthScreen: widthScreen,
scrollController: _scrollController,
);
},
childCount: categoryMenuAfterSelect.length,
),
),
],
),
),
],
),
),
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 searchField(
double searchFieldHeight, List<FilterMenu> categoryNonFav) {
return Container(
margin: const EdgeInsets.only(bottom: 5),
height: searchFieldHeight, height: searchFieldHeight,
child: TextField( child: TextField(
onChanged: (sarchValue) {
context.read<SearchMenu>().searchMenu(
categoryNonFav,
keyword: sarchValue.toString(),
isSearch: true,
);
},
key: const Key('SearchField'), key: const Key('SearchField'),
style: TextStyle( style: TextStyle(
color: Colors.black, color: Colors.black,
...@@ -607,6 +773,8 @@ class _NewHome2State extends State<NewHome2> { ...@@ -607,6 +773,8 @@ class _NewHome2State extends State<NewHome2> {
fontSize: 15, fontSize: 15,
), ),
decoration: InputDecoration( decoration: InputDecoration(
filled: true,
fillColor: Colors.white,
enabledBorder: OutlineInputBorder( enabledBorder: OutlineInputBorder(
borderSide: BorderSide( borderSide: BorderSide(
width: 1, width: 1,
...@@ -857,159 +1025,6 @@ class _NewHome2State extends State<NewHome2> { ...@@ -857,159 +1025,6 @@ class _NewHome2State extends State<NewHome2> {
); );
} }
// Container girdFavItem(
// List<FilterMenu> favListItem,
// int i,
// double widthGrid,
// double paddingLeftRigthGrid,
// BuildContext context,
// ) {
// bool addCondition = true;
// return Container(
// margin: EdgeInsets.only(
// left: (i == 0) ? 0 : 8, // paling awal gausah dikasih margin
// right: (i == favListItem.length - 1)
// ? 0
// : 8, // paling akhir gausah dikasi margin
// ),
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(5),
// color: gridCardBackgroundColor,
// ),
// height: double.infinity,
// width: widthGrid,
// child: Container(
// margin: EdgeInsets.only(
// top: 8,
// left: paddingLeftRigthGrid,
// right: paddingLeftRigthGrid,
// bottom: 16,
// ),
// // color: Colors.red,
// child: Column(
// children: [
// Container(
// width: widthGrid - (2 * paddingLeftRigthGrid),
// height: widthGrid - (2 * paddingLeftRigthGrid),
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(8),
// // color: Colors.red,
// ),
// child: ClipRRect(
// borderRadius: BorderRadius.circular(8),
// child: Image(
// fit: BoxFit.fill,
// image: NetworkImage(favListItem[i].imageUrlMedium),
// ),
// ),
// ),
// const SizedBox(
// height: 3,
// ),
// Container(
// width: widthGrid - (2 * paddingLeftRigthGrid),
// height: 28,
// // color: Colors.blue,
// child: Row(
// crossAxisAlignment: CrossAxisAlignment.end,
// children: [
// Expanded(
// child: defaultText(
// context,
// favListItem[i].name,
// maxLines: 2,
// overFlow: TextOverflow.ellipsis,
// style: menuNameGridFav(),
// ),
// ),
// Container(
// width: 40,
// child: defaultText(
// context,
// 'Rp ${formatNumber().format(amountParseToInt(favListItem[i].price))}',
// maxLines: 3,
// overFlow: TextOverflow.ellipsis,
// style: menuPriceGridFav(),
// ),
// )
// ],
// ),
// ),
// const SizedBox(
// height: 16,
// ),
// (addCondition)
// ? Container(
// height: 30,
// width: widthGrid - (2 * paddingLeftRigthGrid),
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(6),
// color: buttonColor,
// ),
// child: Center(
// child: defaultText(
// context,
// 'Tambah',
// style: addButtonGridFav(),
// ),
// ),
// )
// : Container(
// height: 30,
// width: widthGrid - (2 * paddingLeftRigthGrid),
// child: Row(
// children: [
// Container(
// width: 27,
// height: 24,
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(6),
// color: buttonColor,
// ),
// child: const Center(
// child: Image(
// width: 13.33,
// height: 13.33,
// color: textInButton,
// image: AssetImage('assets/icons/note.png'),
// ),
// ),
// ),
// const SizedBox(
// width: 5,
// ),
// Container(
// width: 22,
// height: 22,
// child: const Image(
// image: AssetImage('assets/icons/minus.png'),
// ),
// ),
// Expanded(
// child: Center(
// child: defaultText(
// context,
// '10',
// style: amountGridFav(),
// ),
// ),
// ),
// Container(
// width: 22,
// height: 22,
// child: const Image(
// image: AssetImage('assets/icons/plus.png'),
// ),
// )
// ],
// ),
// )
// ],
// ),
// ),
// );
// }
Container customAppBar(BuildContext context, double paddingLeftRight, Container customAppBar(BuildContext context, double paddingLeftRight,
double appBarHeight, String tableNumber, String userName) { double appBarHeight, String tableNumber, String userName) {
String barName; String barName;
...@@ -1019,8 +1034,6 @@ class _NewHome2State extends State<NewHome2> { ...@@ -1019,8 +1034,6 @@ class _NewHome2State extends State<NewHome2> {
barName = "Meja $tableNumber"; barName = "Meja $tableNumber";
} }
return Container( return Container(
// color: Colors.red,
margin: EdgeInsets.symmetric(horizontal: paddingLeftRight),
height: appBarHeight, height: appBarHeight,
child: Row( child: Row(
children: [ children: [
...@@ -1115,15 +1128,28 @@ class _NewHome2State extends State<NewHome2> { ...@@ -1115,15 +1128,28 @@ class _NewHome2State extends State<NewHome2> {
class Delegate extends SliverPersistentHeaderDelegate { class Delegate extends SliverPersistentHeaderDelegate {
final double catListHeight; final double catListHeight;
final ScrollController scrollController;
// final ScrollController scrollControllerMenu;
final List<CategoryList> categoryList; final List<CategoryList> categoryList;
Delegate(this.catListHeight, this.categoryList); final List<FavoriteGroup> favList;
Delegate(
this.catListHeight,
this.categoryList,
this.scrollController,
this.favList,
// this.scrollControllerMenu,
);
@override @override
Widget build( Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) { BuildContext context, double shrinkOffset, bool overlapsContent) {
return Container( return Container(
color: backgroundColor,
height: catListHeight, height: catListHeight,
child: CategoryListHome( child: CategoryListHome(
categoryList: categoryList, categoryList: categoryList,
scrollController: scrollController,
favList: favList,
// scrollControllerMenu: scrollControllerMenu,
), ),
); );
} }
......
...@@ -261,6 +261,13 @@ packages: ...@@ -261,6 +261,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "6.0.3" version: "6.0.3"
scrollable_positioned_list:
dependency: "direct main"
description:
name: scrollable_positioned_list
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.4"
shared_preferences: shared_preferences:
dependency: "direct main" dependency: "direct main"
description: description:
......
...@@ -34,6 +34,7 @@ dependencies: ...@@ -34,6 +34,7 @@ dependencies:
http: ^0.13.4 http: ^0.13.4
intl: ^0.17.0 intl: ^0.17.0
loading_animations: ^2.2.0 loading_animations: ^2.2.0
scrollable_positioned_list: ^0.3.4
shared_preferences: ^2.0.15 shared_preferences: ^2.0.15
shimmer: ^2.0.0 shimmer: ^2.0.0
url_launcher: ^6.1.5 url_launcher: ^6.1.5
......
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