Commit 5e84548b authored by Dio Maulana's avatar Dio Maulana

edit home screen

parent 08aef001
import 'package:flutter_bloc/flutter_bloc.dart';
class FavSelectedBar extends Cubit<List<dynamic>> {
FavSelectedBar() : super([0]); // default list pertama String 0
void selectedBarFav(int indexBar, String id) {
emit([indexBar, id]); // return index dan ID
}
}
import 'package:flutter_bloc/flutter_bloc.dart';
class MenuSelectedBar extends Cubit<List<dynamic>> {
MenuSelectedBar() : super([0]); // default list pertama String 0
void selectedBarMenu(int indexBar, String name) {
emit([indexBar, name]); // return index dan ID
}
}
...@@ -109,6 +109,78 @@ TextStyle categoryStyle({ ...@@ -109,6 +109,78 @@ TextStyle categoryStyle({
); );
} }
TextStyle subCategoryStyle({
font = 28,
Color color = textColorBlack,
}) {
return TextStyle(
fontFamily: 'Roboto',
fontSize: font,
fontWeight: FontWeight.w500,
color: color,
);
}
TextStyle categoryNameStyle({
font = 20,
Color color = textColorBlack,
}) {
return TextStyle(
fontFamily: (fontFamily == '') ? null : fontFamily,
fontSize: font,
fontWeight: FontWeight.w600,
color: color,
);
}
TextStyle menuNameStyle({
font = 16,
Color color = textColorBlack,
}) {
return TextStyle(
fontFamily: 'Roboto',
fontSize: font,
fontWeight: FontWeight.w500,
color: color,
);
}
TextStyle deskripsiMenuStyle({
font = 12,
Color color = textColorBlack,
}) {
return TextStyle(
fontFamily: 'Roboto',
fontSize: font,
fontWeight: FontWeight.w300,
color: color,
);
}
TextStyle amountMenuStyle({
font = 16,
Color color = textColorBlack,
}) {
return TextStyle(
fontFamily: (fontFamily == '') ? null : fontFamily,
fontSize: font,
fontWeight: FontWeight.w300,
color: color,
);
}
TextStyle addButtonMenu({
font = 12,
Color color = textInButton,
}) {
return TextStyle(
fontFamily: 'OpenSans',
fontSize: font,
fontWeight: FontWeight.w400,
color: color,
);
}
Text fontAwesome(BuildContext context, String unicode, double fontSize, Text fontAwesome(BuildContext context, String unicode, double fontSize,
{Color? color, isBold = true}) { {Color? color, isBold = true}) {
// double widthScreens = responsiveWidthScreen(context); // double widthScreens = responsiveWidthScreen(context);
......
...@@ -19,9 +19,11 @@ import 'package:uuid/uuid.dart'; ...@@ -19,9 +19,11 @@ import 'package:uuid/uuid.dart';
import 'package:web_browser_detect/web_browser_detect.dart'; import 'package:web_browser_detect/web_browser_detect.dart';
import 'bloc/branch_exist.dart'; import 'bloc/branch_exist.dart';
import 'bloc/fav_selected_bar.dart';
import 'bloc/feedback_option.dart'; import 'bloc/feedback_option.dart';
import 'bloc/feedback_select.dart'; import 'bloc/feedback_select.dart';
import 'bloc/filter_menu.dart'; import 'bloc/filter_menu.dart';
import 'bloc/menu_selected_bar.dart';
import 'bloc/order_detail_variant.dart'; import 'bloc/order_detail_variant.dart';
import 'bloc/order_variant_temporary.dart'; import 'bloc/order_variant_temporary.dart';
import 'bloc/order_variant_value.dart'; import 'bloc/order_variant_value.dart';
...@@ -152,6 +154,8 @@ class MyApp extends StatelessWidget { ...@@ -152,6 +154,8 @@ class MyApp extends StatelessWidget {
BlocProvider(create: (_) => FeedbackSelect()), BlocProvider(create: (_) => FeedbackSelect()),
BlocProvider(create: (_) => FilterMenuBloc()), BlocProvider(create: (_) => FilterMenuBloc()),
BlocProvider(create: (_) => VoucherListBloc()), BlocProvider(create: (_) => VoucherListBloc()),
BlocProvider(create: (_) => FavSelectedBar()),
BlocProvider(create: (_) => MenuSelectedBar()),
], ],
child: MaterialApp( child: MaterialApp(
title: (title == null) ? defaultTitle : title, title: (title == null) ? defaultTitle : title,
......
class CategoryList { class CategoryList {
final String name; final String name;
final String id;
CategoryList({required this.name}); CategoryList({
required this.name,
required this.id,
});
factory CategoryList.createCategoryList(Map<String, dynamic> json) { factory CategoryList.createCategoryList(Map<String, dynamic> json) {
return CategoryList( return CategoryList(
id: json['id'],
name: json['name'], name: json['name'],
); );
} }
......
// ignore_for_file: must_be_immutable
import 'package:byod/bloc/menu_selected_bar.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../helper/helper.dart'; import '../../helper/helper.dart';
import '../../helper/widget/style.dart'; import '../../helper/widget/style.dart';
import '../../models/category_list.dart';
class CategoryList extends StatefulWidget { class CategoryListHome extends StatefulWidget {
const CategoryList({ List<CategoryList> categoryList;
CategoryListHome({
Key? key, Key? key,
required this.categoryList,
}) : super(key: key); }) : super(key: key);
@override @override
State<CategoryList> createState() => _CategoryListState(); State<CategoryListHome> createState() => _CategoryListHomeState();
} }
class _CategoryListState extends State<CategoryList> { class _CategoryListHomeState extends State<CategoryListHome> {
int selectedIndex = 0; int selectedIndex = 0;
List<String> catMenu = [ List<String> catMenu = [
'All Item', 'All Item',
...@@ -24,26 +31,30 @@ class _CategoryListState extends State<CategoryList> { ...@@ -24,26 +31,30 @@ class _CategoryListState extends State<CategoryList> {
]; ];
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocBuilder<MenuSelectedBar, List<dynamic>>(
builder: (contextMenuSelectedBar, selectedBarIndex) {
selectedIndex = selectedBarIndex[0];
return ListView.builder( return ListView.builder(
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
itemCount: catMenu.length, itemCount: widget.categoryList.length,
itemBuilder: (context, i) { itemBuilder: (context, i) {
return Container( return GestureDetector(
onTap: () {
context
.read<MenuSelectedBar>()
.selectedBarMenu(i, widget.categoryList[i].name);
},
child: Container(
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 == catMenu.length - 1) ? 0 : 28.335),
child: GestureDetector(
onTap: () {
setState(() {
selectedIndex = i;
});
},
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
defaultText( defaultText(
context, context,
catMenu[i], widget.categoryList[i].name,
style: catNameStyle(), style: catNameStyle(),
), ),
AnimatedSwitcher( AnimatedSwitcher(
...@@ -69,5 +80,7 @@ class _CategoryListState extends State<CategoryList> { ...@@ -69,5 +80,7 @@ class _CategoryListState extends State<CategoryList> {
); );
}, },
); );
},
);
} }
} }
import 'package:flutter/material.dart';
import '../../helper/helper.dart';
import '../../helper/widget/style.dart';
import '../../models/filter_menu.dart';
class FavGridMenu extends StatelessWidget {
const FavGridMenu({
Key? key,
required this.categoryFavAfterSelect,
required this.widthGrid,
required this.paddingLeftRigthGrid,
required this.i,
}) : super(key: key);
final List<FilterMenu> categoryFavAfterSelect;
final double widthGrid;
final double paddingLeftRigthGrid;
final int i;
@override
Widget build(BuildContext context) {
bool addCondition = false;
return Container(
margin: EdgeInsets.only(
left: (i == 0) ? 0 : 8, // paling awal gausah dikasih margin
right: (i == categoryFavAfterSelect.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(categoryFavAfterSelect[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,
categoryFavAfterSelect[i].name,
maxLines: 2,
overFlow: TextOverflow.ellipsis,
style: menuNameGridFav(),
),
),
Container(
width: 40,
child: defaultText(
context,
'Rp ${formatNumber().format(amountParseToInt(categoryFavAfterSelect[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'),
),
)
],
),
)
],
),
),
);
}
}
// ignore_for_file: must_be_immutable
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../bloc/fav_selected_bar.dart';
import '../../helper/helper.dart'; import '../../helper/helper.dart';
import '../../helper/widget/style.dart'; import '../../helper/widget/style.dart';
import '../../models/fav_group.dart';
class FavoriteList extends StatefulWidget { class FavoriteList extends StatefulWidget {
const FavoriteList({ List<FavoriteGroup> favoriteList;
Key? key, FavoriteList({Key? key, required this.favoriteList}) : super(key: key);
}) : super(key: key);
@override @override
State<FavoriteList> createState() => _FavoriteListState(); State<FavoriteList> createState() => _FavoriteListState();
...@@ -14,36 +18,33 @@ class FavoriteList extends StatefulWidget { ...@@ -14,36 +18,33 @@ class FavoriteList extends StatefulWidget {
class _FavoriteListState extends State<FavoriteList> { class _FavoriteListState extends State<FavoriteList> {
int selectedIndex = 0; int selectedIndex = 0;
List<String> favMenu = [
'All',
'Popular',
'Favorite This Month',
'Menu Lainnya',
'Menu Lainnya',
'Menu Lainnya'
];
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocBuilder<FavSelectedBar, List<dynamic>>(
builder: (contextSelectedBar, selectedBarIndex) {
selectedIndex = selectedBarIndex[0];
return ListView.builder( return ListView.builder(
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
itemCount: favMenu.length, itemCount: widget.favoriteList.length,
itemBuilder: (context, i) { itemBuilder: (context, i) {
return Container( return GestureDetector(
margin: EdgeInsets.only(
left: (i == 0) ? 0 : 12.5,
right: (i == favMenu.length - 1) ? 0 : 12.5),
child: GestureDetector(
onTap: () { onTap: () {
setState(() { context
selectedIndex = i; .read<FavSelectedBar>()
}); .selectedBarFav(i, widget.favoriteList[i].id);
}, },
child: Container(
color: backgroundColor,
margin: EdgeInsets.only(
left: (i == 0) ? 0 : 12.5,
right: (i == widget.favoriteList.length - 1) ? 0 : 12.5),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
defaultText( defaultText(
context, context,
favMenu[i], widget.favoriteList[i].name,
style: favNameStyle(), style: favNameStyle(),
), ),
AnimatedSwitcher( AnimatedSwitcher(
...@@ -69,5 +70,7 @@ class _FavoriteListState extends State<FavoriteList> { ...@@ -69,5 +70,7 @@ class _FavoriteListState extends State<FavoriteList> {
); );
}, },
); );
},
);
} }
} }
// ignore_for_file: sized_box_for_whitespace
import 'package:flutter/material.dart';
import '../../helper/helper.dart';
import '../../helper/widget/style.dart';
import '../../models/filter_menu.dart';
class MenuListUtama extends StatelessWidget {
const MenuListUtama({
Key? key,
required this.categoryNonFav,
required this.i,
}) : super(key: key);
final List<FilterMenu> categoryNonFav;
final int i;
@override
Widget build(BuildContext context) {
bool addCondition = false;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
(categoryNonFav[i].type == typeCategory)
? defaultText(
context,
categoryNonFav[i].categoryName,
maxLines: 1,
overFlow: TextOverflow.ellipsis,
style: categoryNameStyle(),
)
: const SizedBox(),
(categoryNonFav[i].type == typeCategory)
? const Divider(
thickness: 1,
color: textColorBlack,
)
: const SizedBox(),
(categoryNonFav[i].type == typeGroup)
? Container(
margin: const EdgeInsets.only(
top: 6,
),
child: defaultText(
context,
maxLines: 3,
overFlow: TextOverflow.ellipsis,
categoryNonFav[i].groupName,
style: subCategoryStyle(),
),
)
: const SizedBox(),
(categoryNonFav[i].type == typeMenu)
? Container(
margin: const EdgeInsets.symmetric(vertical: 19),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Container(
height: 125,
width: double.infinity,
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
defaultText(
context,
categoryNonFav[i].name,
style: menuNameStyle(),
),
const Spacer(),
defaultText(
maxLines: 2,
overFlow: TextOverflow.ellipsis,
context,
categoryNonFav[i].description,
style: deskripsiMenuStyle(),
),
const SizedBox(
height: 4,
),
defaultText(
maxLines: 1,
overFlow: TextOverflow.ellipsis,
context,
'Rp ${formatNumber().format(amountParseToInt(categoryNonFav[i].price))}',
style: amountMenuStyle(),
)
],
),
),
Container(
width: 12,
height: double.infinity,
),
Container(
width: 125,
height: 125,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14)),
child: ClipRRect(
borderRadius: BorderRadius.circular(14),
child: Image(
image: NetworkImage(
categoryNonFav[i].imageUrlMedium,
),
),
),
)
],
),
),
Container(
height: 8,
width: double.infinity,
),
(addCondition)
? Container(
height: 36,
width: double.infinity,
child: Row(
children: [
const Spacer(),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: buttonColor,
),
height: double.infinity,
width: 125,
child: Center(
child: defaultText(
context,
'Tambah',
style: addButtonMenu(),
),
),
)
],
),
)
: Container(
height: 36,
width: 125,
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,
),
Expanded(
child: Container(
height: 22,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
color: Colors.white,
),
child: Stack(
children: [
Positioned(
left: 0,
child: Container(
width: 22,
height: 22,
child: const Image(
image: AssetImage(
'assets/icons/minus.png'),
),
),
),
Positioned(
right: 0,
child: Container(
width: 22,
height: 22,
child: const Image(
image: AssetImage(
'assets/icons/plus.png'),
),
),
),
Center(
child: Container(
height: 22,
child: Center(
child: defaultText(
context,
'10',
style: amountGridFav(),
),
),
),
),
],
),
),
),
],
),
)
],
),
)
: const SizedBox(),
],
);
}
}
// ignore_for_file: sized_box_for_whitespace // // ignore_for_file: sized_box_for_whitespace
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:flutter/material.dart'; // import 'package:flutter/material.dart';
import 'cat_list.dart'; // import 'cat_list.dart';
import 'fav_list.dart'; // import 'fav_list.dart';
class NewHome extends StatefulWidget { // class NewHome extends StatefulWidget {
const NewHome({Key? key}) : super(key: key); // const NewHome({Key? key}) : super(key: key);
@override // @override
State<NewHome> createState() => _NewHomeState(); // State<NewHome> createState() => _NewHomeState();
} // }
class _NewHomeState extends State<NewHome> { // class _NewHomeState extends State<NewHome> {
bool isSearchActive = true; // bool isSearchActive = true;
final searchController = TextEditingController(); // final searchController = TextEditingController();
@override // @override
Widget build(BuildContext context) { // Widget build(BuildContext context) {
double paddingLeftRight = 20; // double paddingLeftRight = 20;
return SafeArea( // return SafeArea(
child: Scaffold( // child: Scaffold(
backgroundColor: backgroundColor, // backgroundColor: backgroundColor,
body: Container( // body: Container(
height: MediaQuery.of(context).size.height, // height: MediaQuery.of(context).size.height,
margin: EdgeInsets.symmetric(horizontal: paddingLeftRight), // margin: EdgeInsets.symmetric(horizontal: paddingLeftRight),
child: Column( // child: Column(
crossAxisAlignment: CrossAxisAlignment.start, // crossAxisAlignment: CrossAxisAlignment.start,
children: [ // children: [
customAppBar(context, paddingLeftRight), // customAppBar(context, paddingLeftRight),
SizedBox( // SizedBox(
height: (isSearchActive) ? 16 : 20, // height: (isSearchActive) ? 16 : 20,
), // ),
AnimatedSwitcher( // AnimatedSwitcher(
duration: Duration(milliseconds: animatedTime), // duration: Duration(milliseconds: animatedTime),
transitionBuilder: (Widget child, Animation<double> animation) { // transitionBuilder: (Widget child, Animation<double> animation) {
return ScaleTransition(scale: animation, child: child); // return ScaleTransition(scale: animation, child: child);
}, // },
child: (isSearchActive) // child: (isSearchActive)
? SizedBox( // ? SizedBox(
height: 36, // height: 36,
child: TextField( // child: TextField(
key: const Key('SearchField'), // key: const Key('SearchField'),
style: TextStyle( // style: TextStyle(
color: Colors.black, // color: Colors.black,
fontFamily: fontFamily, // fontFamily: fontFamily,
fontSize: 15, // fontSize: 15,
), // ),
decoration: InputDecoration( // decoration: InputDecoration(
enabledBorder: OutlineInputBorder( // enabledBorder: OutlineInputBorder(
borderSide: BorderSide( // borderSide: BorderSide(
width: 1, // width: 1,
color: Colors.grey.withOpacity(0.8), // color: Colors.grey.withOpacity(0.8),
), // ),
), // ),
focusedBorder: OutlineInputBorder( // focusedBorder: OutlineInputBorder(
borderSide: BorderSide( // borderSide: BorderSide(
width: 1, // width: 1,
color: buttonColor, // color: buttonColor,
), // ),
), // ),
prefixIcon: Image( // prefixIcon: Image(
image: // image:
const AssetImage('assets/icons/search.png'), // const AssetImage('assets/icons/search.png'),
color: Colors.grey.withOpacity(0.8), // color: Colors.grey.withOpacity(0.8),
height: 20, // height: 20,
width: 20, // width: 20,
), // ),
hintText: 'Example: nasi', // hintText: 'Example: nasi',
hintStyle: TextStyle( // hintStyle: TextStyle(
color: Colors.grey.withOpacity(0.8), // color: Colors.grey.withOpacity(0.8),
fontFamily: fontFamily, // fontFamily: fontFamily,
fontSize: 10, // fontSize: 10,
), // ),
border: OutlineInputBorder( // border: OutlineInputBorder(
borderRadius: BorderRadius.circular(6), // borderRadius: BorderRadius.circular(6),
), // ),
), // ),
), // ),
) // )
: const SizedBox( // : const SizedBox(
key: Key('SearchField'), // key: Key('SearchField'),
), // ),
), // ),
SizedBox( // SizedBox(
height: (isSearchActive) ? 20 : 0, // height: (isSearchActive) ? 20 : 0,
), // ),
Container( // Container(
height: 35, // height: 35,
child: const FavoriteList(), // child: FavoriteList(),
), // ),
const SizedBox( // const SizedBox(
height: 13.5, // height: 13.5,
), // ),
Container( // Container(
height: 219, // height: 219,
child: ListView.builder( // child: ListView.builder(
scrollDirection: Axis.horizontal, // scrollDirection: Axis.horizontal,
itemCount: 5, // itemCount: 5,
itemBuilder: (context, i) { // itemBuilder: (context, i) {
double paddingLeftRigthGrid = 9; // double paddingLeftRigthGrid = 9;
double widthGrid = 136; // double widthGrid = 136;
return girdFavItem( // return girdFavItem(
i, // i,
widthGrid, // widthGrid,
paddingLeftRigthGrid, // paddingLeftRigthGrid,
context, // context,
); // );
}), // }),
), // ),
const SizedBox( // const SizedBox(
height: 16, // height: 16,
), // ),
defaultText( // defaultText(
context, // context,
'Category', // 'Category',
style: categoryStyle(), // style: categoryStyle(),
), // ),
const SizedBox( // const SizedBox(
height: 42, // height: 42,
), // ),
Container( // Container(
height: 51, // height: 51,
child: const CategoryList(), // child: const CategoryListHome(),
), // ),
const SizedBox( // const SizedBox(
height: 25, // height: 25,
), // ),
Expanded( // Expanded(
child: ListView.builder( // child: ListView.builder(
itemCount: 1000, // itemCount: 1000,
itemBuilder: (context, i) { // itemBuilder: (context, i) {
return Text('aaa'); // return Text('aaa');
}, // },
), // ),
) // )
], // ],
), // ),
), // ),
), // ),
); // );
} // }
Container girdFavItem(int i, double widthGrid, double paddingLeftRigthGrid, // Container girdFavItem(int i, double widthGrid, double paddingLeftRigthGrid,
BuildContext context) { // BuildContext context) {
bool addCondition = true; // bool addCondition = true;
return Container( // return Container(
margin: EdgeInsets.only( // margin: EdgeInsets.only(
left: (i == 0) ? 0 : 8, // left: (i == 0) ? 0 : 8,
right: (i == 5 - 1) ? 0 : 8, // right: (i == 5 - 1) ? 0 : 8,
), // ),
decoration: BoxDecoration( // decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5), // borderRadius: BorderRadius.circular(5),
color: gridCardBackgroundColor, // color: gridCardBackgroundColor,
), // ),
height: double.infinity, // height: double.infinity,
width: widthGrid, // width: widthGrid,
child: Container( // child: Container(
margin: EdgeInsets.only( // margin: EdgeInsets.only(
top: 8, // top: 8,
left: paddingLeftRigthGrid, // left: paddingLeftRigthGrid,
right: paddingLeftRigthGrid, // right: paddingLeftRigthGrid,
bottom: 16, // bottom: 16,
), // ),
// color: Colors.red, // // color: Colors.red,
child: Column( // child: Column(
children: [ // children: [
Container( // Container(
width: widthGrid - (2 * paddingLeftRigthGrid), // width: widthGrid - (2 * paddingLeftRigthGrid),
height: widthGrid - (2 * paddingLeftRigthGrid), // height: widthGrid - (2 * paddingLeftRigthGrid),
decoration: BoxDecoration( // decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8), // borderRadius: BorderRadius.circular(8),
color: Colors.red, // color: Colors.red,
), // ),
), // ),
const SizedBox( // const SizedBox(
height: 3, // height: 3,
), // ),
Container( // Container(
width: widthGrid - (2 * paddingLeftRigthGrid), // width: widthGrid - (2 * paddingLeftRigthGrid),
height: 28, // height: 28,
// color: Colors.blue, // // color: Colors.blue,
child: Row( // child: Row(
crossAxisAlignment: CrossAxisAlignment.end, // crossAxisAlignment: CrossAxisAlignment.end,
children: [ // children: [
Expanded( // Expanded(
child: defaultText( // child: defaultText(
context, // context,
'BBQ Chicken Nachos', // 'BBQ Chicken Nachos',
maxLines: 2, // maxLines: 2,
overFlow: TextOverflow.ellipsis, // overFlow: TextOverflow.ellipsis,
style: menuNameGridFav(), // style: menuNameGridFav(),
), // ),
), // ),
Container( // Container(
width: 40, // width: 40,
child: defaultText( // child: defaultText(
context, // context,
'Rp 25,000', // 'Rp 25,000',
maxLines: 3, // maxLines: 3,
overFlow: TextOverflow.ellipsis, // overFlow: TextOverflow.ellipsis,
style: menuPriceGridFav(), // style: menuPriceGridFav(),
), // ),
) // )
], // ],
), // ),
), // ),
const SizedBox( // const SizedBox(
height: 16, // height: 16,
), // ),
(addCondition) // (addCondition)
? Container( // ? Container(
height: 30, // height: 30,
width: widthGrid - (2 * paddingLeftRigthGrid), // width: widthGrid - (2 * paddingLeftRigthGrid),
decoration: BoxDecoration( // decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6), // borderRadius: BorderRadius.circular(6),
color: buttonColor, // color: buttonColor,
), // ),
child: Center( // child: Center(
child: defaultText( // child: defaultText(
context, // context,
'Tambah', // 'Tambah',
style: addButtonGridFav(), // style: addButtonGridFav(),
), // ),
), // ),
) // )
: Container( // : Container(
height: 30, // height: 30,
width: widthGrid - (2 * paddingLeftRigthGrid), // width: widthGrid - (2 * paddingLeftRigthGrid),
child: Row( // child: Row(
children: [ // children: [
Container( // Container(
width: 27, // width: 27,
height: 24, // height: 24,
decoration: BoxDecoration( // decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6), // borderRadius: BorderRadius.circular(6),
color: buttonColor, // color: buttonColor,
), // ),
child: const Center( // child: const Center(
child: Image( // child: Image(
width: 13.33, // width: 13.33,
height: 13.33, // height: 13.33,
color: textInButton, // color: textInButton,
image: AssetImage('assets/icons/note.png'), // image: AssetImage('assets/icons/note.png'),
), // ),
), // ),
), // ),
const SizedBox( // const SizedBox(
width: 5, // width: 5,
), // ),
Container( // Container(
width: 22, // width: 22,
height: 22, // height: 22,
child: const Image( // child: const Image(
image: AssetImage('assets/icons/minus.png'), // image: AssetImage('assets/icons/minus.png'),
), // ),
), // ),
Expanded( // Expanded(
child: Center( // child: Center(
child: defaultText( // child: defaultText(
context, // context,
'10', // '10',
style: amountGridFav(), // style: amountGridFav(),
), // ),
), // ),
), // ),
Container( // Container(
width: 22, // width: 22,
height: 22, // height: 22,
child: const Image( // child: const Image(
image: AssetImage('assets/icons/plus.png'), // image: AssetImage('assets/icons/plus.png'),
), // ),
) // )
], // ],
), // ),
) // )
], // ],
), // ),
), // ),
); // );
} // }
Container customAppBar(BuildContext context, double paddingLeftRight) { // Container customAppBar(BuildContext context, double paddingLeftRight) {
return Container( // return Container(
// color: Colors.red, // // color: Colors.red,
height: 40, // height: 40,
child: CustomScrollView( // child: CustomScrollView(
slivers: [ // slivers: [
SliverAppBar( // SliverAppBar(
automaticallyImplyLeading: false, // automaticallyImplyLeading: false,
title: defaultText( // title: defaultText(
context, // context,
'Meja 12', // 'Meja 12',
style: tableNameStyle(), // style: tableNameStyle(),
), // ),
backgroundColor: Colors.transparent, // backgroundColor: Colors.transparent,
pinned: true, // pinned: true,
actions: [ // actions: [
GestureDetector( // GestureDetector(
onTap: () { // onTap: () {
setState(() { // setState(() {
isSearchActive = !isSearchActive; // isSearchActive = !isSearchActive;
}); // });
}, // },
child: const Image( // child: const Image(
image: AssetImage('assets/icons/search.png'), // image: AssetImage('assets/icons/search.png'),
height: 20, // height: 20,
width: 20, // width: 20,
), // ),
), // ),
const SizedBox( // const SizedBox(
width: 16, // width: 16,
), // ),
const Image( // const Image(
image: AssetImage('assets/icons/book.png'), // image: AssetImage('assets/icons/book.png'),
height: 20, // height: 20,
width: 20, // width: 20,
), // ),
SizedBox( // SizedBox(
width: paddingLeftRight, // width: paddingLeftRight,
), // ),
], // ],
), // ),
], // ],
), // ),
); // );
} // }
AnimatedSwitcher seearchField(BuildContext context) { // AnimatedSwitcher seearchField(BuildContext context) {
return AnimatedSwitcher( // return AnimatedSwitcher(
duration: const Duration(milliseconds: 500), // duration: const Duration(milliseconds: 500),
transitionBuilder: (Widget child, Animation<double> animation) { // transitionBuilder: (Widget child, Animation<double> animation) {
return ScaleTransition(scale: animation, child: child); // return ScaleTransition(scale: animation, child: child);
}, // },
child: TextField( // child: TextField(
key: const Key('SearchField'), // key: const Key('SearchField'),
decoration: InputDecoration( // decoration: InputDecoration(
focusedBorder: OutlineInputBorder( // focusedBorder: OutlineInputBorder(
borderSide: BorderSide( // borderSide: BorderSide(
width: 1, // width: 1,
color: buttonColor, // color: buttonColor,
), // ),
), // ),
prefixIcon: const Image( // prefixIcon: const Image(
image: AssetImage('assets/icons/search.png'), // image: AssetImage('assets/icons/search.png'),
height: 20, // height: 20,
width: 20, // width: 20,
), // ),
hintText: 'Example: nasi', // hintText: 'Example: nasi',
border: OutlineInputBorder( // border: OutlineInputBorder(
borderRadius: BorderRadius.circular(6), // borderRadius: BorderRadius.circular(6),
), // ),
), // ),
), // ),
); // );
} // }
} // }
// ignore_for_file: sized_box_for_whitespace // ignore_for_file: sized_box_for_whitespace
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/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:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../bloc/filter_menu.dart';
import '../../helper/widget/button_dialog.dart';
import '../../main.dart';
import '../../models/fav_group.dart';
import '../screen_responsive.dart';
import 'cat_list.dart'; import 'cat_list.dart';
import 'fav_grid_menu.dart';
import 'fav_list.dart'; import 'fav_list.dart';
import 'package:byod/models/category_list.dart';
import 'menu_list_utama.dart';
import 'shimmer_menu.dart';
class NewHome2 extends StatefulWidget { class NewHome2 extends StatefulWidget {
const NewHome2({Key? key}) : super(key: key); const NewHome2({Key? key}) : super(key: key);
...@@ -16,34 +31,31 @@ class NewHome2 extends StatefulWidget { ...@@ -16,34 +31,31 @@ class NewHome2 extends StatefulWidget {
class _NewHome2State extends State<NewHome2> { class _NewHome2State extends State<NewHome2> {
bool isSearchActive = false; bool isSearchActive = false;
bool isFirstLoad = true;
final searchController = TextEditingController(); final searchController = TextEditingController();
final _scrollController = ScrollController(); final _scrollController = ScrollController();
final _scrollMenuItem = ScrollController(); final _scrollMenuItem = ScrollController();
late bool isScrollableMenu = false; late bool isScrollableMenu = false;
final double positionCustomScrollViewFixed = 345.5; // final double positionCustomScrollViewFixed = 345.5 - 10;
final double positionCustomScrollViewSearchFalseFixed = 349.5; // final double positionCustomScrollViewSearchFalseFixed = 349.5 - 10;
late List<FilterMenu> allMenu = [];
@override @override
void initState() { void initState() {
_scrollController.addListener( _scrollController.addListener(
() { () {
setState(() {
isFirstLoad = false;
});
// 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;
if (isSearchActive) { double positionCustomScrollViewMax =
if (positionCustomScrollView == positionCustomScrollViewFixed) { _scrollController.position.maxScrollExtent;
setState(() { // if (isSearchActive) {
isScrollableMenu = true; if (positionCustomScrollView >= positionCustomScrollViewMax) {
});
} else {
setState(() {
isScrollableMenu = false;
});
}
} else {
if (positionCustomScrollView ==
positionCustomScrollViewSearchFalseFixed) {
setState(() { setState(() {
isScrollableMenu = true; isScrollableMenu = true;
}); });
...@@ -52,13 +64,27 @@ class _NewHome2State extends State<NewHome2> { ...@@ -52,13 +64,27 @@ class _NewHome2State extends State<NewHome2> {
isScrollableMenu = false; isScrollableMenu = false;
}); });
} }
} // } else {
// if (positionCustomScrollView >=
// positionCustomScrollViewSearchFalseFixed) {
// setState(() {
// isScrollableMenu = true;
// });
// } else {
// setState(() {
// isScrollableMenu = false;
// });
// }
// }
}, },
); );
_scrollMenuItem.addListener(() { _scrollMenuItem.addListener(() {
double positionMenuItemScrollView = _scrollMenuItem.position.pixels; double positionMenuItemScrollView = _scrollMenuItem.position.pixels;
double positionMenuItemScrollViewMin =
if (positionMenuItemScrollView == 0) { _scrollMenuItem.position.minScrollExtent;
if (positionMenuItemScrollView == positionMenuItemScrollViewMin &&
_scrollController.position.pixels ==
_scrollController.position.maxScrollExtent) {
setState(() { setState(() {
isScrollableMenu = false; isScrollableMenu = false;
}); });
...@@ -102,62 +128,210 @@ class _NewHome2State extends State<NewHome2> { ...@@ -102,62 +128,210 @@ class _NewHome2State extends State<NewHome2> {
categoryFont - categoryFont -
spacerAboveCatList; spacerAboveCatList;
double paddingLeftRight = 20; double paddingLeftRight = 20;
return SafeArea(
int tableMode = prefs.getInt('table_mode') ?? defaultTable;
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() {
Navigator.pop(context, true);
}
void onTapOkNoPop() {
Navigator.pop(context, false);
}
return WillPopScope(
onWillPop: () async {
final shouldPop = await buttonDialogGlobal(
context,
'Konfirmasi',
'Apakah anda ingin keluar dari website ?',
'Ya',
'Batal',
onTapOkPop,
onTapOkNoPop,
okButtonColor: buttonColor,
cancelButtonColor: cancelColorButton,
);
return shouldPop ?? false;
},
child: SafeArea(
child: Scaffold( child: Scaffold(
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
body: Container( body: ((restoran == responseByodBranchExist))
? BlocBuilder<FilterMenuBloc, List<FilterMenu>>(
builder: (contextBlocListCat, categoryDefault) {
if (categoryDefault.isNotEmpty &&
categoryDefault[0].id == "0") {
return errorResponseByod(
'Gagal mendapatkan menu, silahkan refresh halaman / scan ulang barcode');
} else if (categoryDefault.isNotEmpty) {
for (var menu in categoryDefault) {
if (!menu.isFavMenu) {
categoryNonFav.add(menu);
} else {
categoryFav.add(menu);
}
}
allMenu = categoryNonFav;
var nn = {
"name": "All",
"id": "0",
}; // all dulu, biar ada bisa klik all
categoryList.add(CategoryList.createCategoryList(nn));
for (var nameCat in categoryNonFav) {
if (nameCat.type == typeCategory) {
var n = {
"id": nameCat.id,
"name": nameCat.categoryName
};
categoryList
.add(CategoryList.createCategoryList(n));
}
}
for (var nameFav in categoryFav) {
if (nameFav.type == typeCategory) {
var nfav = {
"name": nameFav.categoryName,
"id": nameFav.id
};
favList.add(FavoriteGroup.add(nfav));
}
}
if (isFirstLoad) {
context
.read<FavSelectedBar>()
.selectedBarFav(0, favList[0].id);
context
.read<MenuSelectedBar>()
.selectedBarMenu(0, categoryList[0].id);
}
}
return BlocBuilder<FavSelectedBar, List<dynamic>>(
builder: (contextFavSelectedBar, listDynamicBar) {
if (categoryFav.isNotEmpty && favList.isNotEmpty) {
List<FilterMenu> temporSelectedFav = [];
for (var nameFav in categoryFav) {
if (nameFav.type == typeMenu &&
listDynamicBar.length == 2 &&
nameFav.favGroupId == listDynamicBar[1]) {
temporSelectedFav.add(nameFav);
}
}
categoryFavAfterSelect = temporSelectedFav;
}
return BlocBuilder<MenuSelectedBar, List<dynamic>>(
builder:
(contextSelectedBarMenu, listDynamicBarMenu) {
if (categoryNonFav.isNotEmpty &&
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) {
// _scrollMenuItem.animateTo(
// 10,
// duration:
// Duration(milliseconds: animatedTime),
// curve: Curves.fastOutSlowIn,
// );
// }
}
return Stack(
children: [
Container(
height: MediaQuery.of(context).size.height, height: MediaQuery.of(context).size.height,
margin: EdgeInsets.symmetric(horizontal: paddingLeftRight), margin: EdgeInsets.symmetric(
horizontal: paddingLeftRight),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment:
CrossAxisAlignment.start,
children: [ children: [
customAppBar(context, paddingLeftRight, appBarHeight), customAppBar(context, paddingLeftRight,
appBarHeight),
SizedBox( SizedBox(
height: (isSearchActive) ? 16 : 20, height: (isSearchActive) ? 16 : 20,
), ),
AnimatedSwitcher( AnimatedSwitcher(
duration: Duration(milliseconds: animatedTime), duration: Duration(
transitionBuilder: (Widget child, Animation<double> animation) { milliseconds: animatedTime),
return ScaleTransition(scale: animation, child: child); transitionBuilder: (Widget child,
Animation<double> animation) {
return ScaleTransition(
scale: animation, child: child);
}, },
child: (isSearchActive) child: (isSearchActive)
? SizedBox( ? SizedBox(
height: searchFieldHeight, height: searchFieldHeight,
child: TextField( child: TextField(
key: const Key('SearchField'), key: const Key(
'SearchField'),
style: TextStyle( style: TextStyle(
color: Colors.black, color: Colors.black,
fontFamily: fontFamily, fontFamily: fontFamily,
fontSize: 15, fontSize: 15,
), ),
decoration: InputDecoration( decoration: InputDecoration(
enabledBorder: OutlineInputBorder( enabledBorder:
OutlineInputBorder(
borderSide: BorderSide( borderSide: BorderSide(
width: 1, width: 1,
color: Colors.grey.withOpacity(0.8), color: Colors.grey
.withOpacity(0.8),
), ),
), ),
focusedBorder: OutlineInputBorder( focusedBorder:
OutlineInputBorder(
borderSide: BorderSide( borderSide: BorderSide(
width: 1, width: 1,
color: buttonColor, color: buttonColor,
), ),
), ),
prefixIcon: Image( prefixIcon: Image(
image: image: const AssetImage(
const AssetImage('assets/icons/search.png'), 'assets/icons/search.png'),
color: Colors.grey.withOpacity(0.8), color: Colors.grey
.withOpacity(0.8),
height: 20, height: 20,
width: 20, width: 20,
), ),
hintText: 'Example: nasi', hintText: 'Example: nasi',
hintStyle: TextStyle( hintStyle: TextStyle(
color: Colors.grey.withOpacity(0.8), color: Colors.grey
.withOpacity(0.8),
fontFamily: fontFamily, fontFamily: fontFamily,
fontSize: 10, fontSize: 10,
), ),
border: OutlineInputBorder( border:
borderRadius: BorderRadius.circular(6), OutlineInputBorder(
borderRadius:
BorderRadius
.circular(6),
), ),
), ),
), ),
...@@ -172,13 +346,17 @@ class _NewHome2State extends State<NewHome2> { ...@@ -172,13 +346,17 @@ class _NewHome2State extends State<NewHome2> {
slivers: [ slivers: [
SliverToBoxAdapter( SliverToBoxAdapter(
child: SizedBox( child: SizedBox(
height: (isSearchActive) ? spacerHeight : 0, height: (isSearchActive)
? spacerHeight
: 0,
), ),
), ),
SliverToBoxAdapter( SliverToBoxAdapter(
child: Container( child: Container(
height: favListHeight, height: favListHeight,
child: const FavoriteList(), child: FavoriteList(
favoriteList: favList,
),
), ),
), ),
const SliverToBoxAdapter( const SliverToBoxAdapter(
...@@ -190,16 +368,24 @@ class _NewHome2State extends State<NewHome2> { ...@@ -190,16 +368,24 @@ class _NewHome2State extends State<NewHome2> {
child: Container( child: Container(
height: favItemHeight, height: favItemHeight,
child: ListView.builder( child: ListView.builder(
scrollDirection: Axis.horizontal, scrollDirection:
itemCount: 5, Axis.horizontal,
itemBuilder: (context, i) { itemCount:
double paddingLeftRigthGrid = 9; categoryFavAfterSelect
.length,
itemBuilder:
(context, i) {
double
paddingLeftRigthGrid =
9;
double widthGrid = 136; double widthGrid = 136;
return girdFavItem( return FavGridMenu(
i, categoryFavAfterSelect:
widthGrid, categoryFavAfterSelect,
widthGrid: widthGrid,
paddingLeftRigthGrid:
paddingLeftRigthGrid, paddingLeftRigthGrid,
context, i: i,
); );
}), }),
), ),
...@@ -223,7 +409,10 @@ class _NewHome2State extends State<NewHome2> { ...@@ -223,7 +409,10 @@ class _NewHome2State extends State<NewHome2> {
), ),
SliverPersistentHeader( SliverPersistentHeader(
pinned: true, pinned: true,
delegate: Delegate(catListHeight), delegate: Delegate(
catListHeight,
categoryList,
),
), ),
SliverToBoxAdapter( SliverToBoxAdapter(
child: SizedBox( child: SizedBox(
...@@ -234,14 +423,24 @@ class _NewHome2State extends State<NewHome2> { ...@@ -234,14 +423,24 @@ class _NewHome2State extends State<NewHome2> {
child: Container( child: Container(
height: heightLeft, height: heightLeft,
child: ListView.builder( child: ListView.builder(
controller: (isScrollableMenu) ? _scrollMenuItem : null, controller: (isScrollableMenu)
? _scrollMenuItem
: null,
physics: (!isScrollableMenu) physics: (!isScrollableMenu)
? const NeverScrollableScrollPhysics() ? const NeverScrollableScrollPhysics()
: null, : null,
shrinkWrap: (isScrollableMenu) ? true : false, shrinkWrap: (isScrollableMenu)
itemCount: 100, ? true
: false,
itemCount:
categoryMenuAfterSelect
.length,
itemBuilder: (context, i) { itemBuilder: (context, i) {
return defaultText(context, 'Teks ke $i'); return MenuListUtama(
categoryNonFav:
categoryMenuAfterSelect,
i: i,
);
}, },
), ),
)), )),
...@@ -251,17 +450,92 @@ class _NewHome2State extends State<NewHome2> { ...@@ -251,17 +450,92 @@ class _NewHome2State extends State<NewHome2> {
], ],
), ),
), ),
Positioned(
bottom: 0,
child: Container(
width: MediaQuery.of(context).size.width,
height: 61,
decoration: BoxDecoration(
color: buttonColor,
borderRadius: const BorderRadius.only(
topRight: Radius.circular(30)),
),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
Expanded(
child: Container(
margin: EdgeInsets.only(
left: paddingLeftRight),
child: defaultText(
context, 'Rp 25,000'),
),
),
Container(
width: 134,
height: 36,
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(28),
color: Colors.white,
),
),
const SizedBox(
width: 23,
)
],
),
), ),
)
],
);
},
);
});
},
)
: (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(),
),
),
);
},
); );
} }
Container girdFavItem(int i, double widthGrid, double paddingLeftRigthGrid, Container girdFavItem(
BuildContext context) { List<FilterMenu> favListItem,
int i,
double widthGrid,
double paddingLeftRigthGrid,
BuildContext context,
) {
bool addCondition = true; bool addCondition = true;
return Container( return Container(
margin: EdgeInsets.only( margin: EdgeInsets.only(
left: (i == 0) ? 0 : 8, left: (i == 0) ? 0 : 8, // paling awal gausah dikasih margin
right: (i == 5 - 1) ? 0 : 8, right: (i == favListItem.length - 1)
? 0
: 8, // paling akhir gausah dikasi margin
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5), borderRadius: BorderRadius.circular(5),
...@@ -284,7 +558,14 @@ class _NewHome2State extends State<NewHome2> { ...@@ -284,7 +558,14 @@ class _NewHome2State extends State<NewHome2> {
height: widthGrid - (2 * paddingLeftRigthGrid), height: widthGrid - (2 * paddingLeftRigthGrid),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
color: Colors.red, // color: Colors.red,
),
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Image(
fit: BoxFit.fill,
image: NetworkImage(favListItem[i].imageUrlMedium),
),
), ),
), ),
const SizedBox( const SizedBox(
...@@ -300,7 +581,7 @@ class _NewHome2State extends State<NewHome2> { ...@@ -300,7 +581,7 @@ class _NewHome2State extends State<NewHome2> {
Expanded( Expanded(
child: defaultText( child: defaultText(
context, context,
'BBQ Chicken Nachos', favListItem[i].name,
maxLines: 2, maxLines: 2,
overFlow: TextOverflow.ellipsis, overFlow: TextOverflow.ellipsis,
style: menuNameGridFav(), style: menuNameGridFav(),
...@@ -310,7 +591,7 @@ class _NewHome2State extends State<NewHome2> { ...@@ -310,7 +591,7 @@ class _NewHome2State extends State<NewHome2> {
width: 40, width: 40,
child: defaultText( child: defaultText(
context, context,
'Rp 25,000', 'Rp ${formatNumber().format(amountParseToInt(favListItem[i].price))}',
maxLines: 3, maxLines: 3,
overFlow: TextOverflow.ellipsis, overFlow: TextOverflow.ellipsis,
style: menuPriceGridFav(), style: menuPriceGridFav(),
...@@ -432,6 +713,29 @@ class _NewHome2State extends State<NewHome2> { ...@@ -432,6 +713,29 @@ class _NewHome2State extends State<NewHome2> {
)); ));
} }
Center errorResponseByod(String message) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
fontAwesome(
context,
timesCircleIcon,
timesCircleIconSize,
color: dangerColor,
isBold: false,
),
defaultText(
context,
message,
textAlign: TextAlign.center,
style: textStyleNormalFont(context),
)
],
),
);
}
AnimatedSwitcher seearchField(BuildContext context) { AnimatedSwitcher seearchField(BuildContext context) {
return AnimatedSwitcher( return AnimatedSwitcher(
duration: const Duration(milliseconds: 500), duration: const Duration(milliseconds: 500),
...@@ -464,13 +768,16 @@ class _NewHome2State extends State<NewHome2> { ...@@ -464,13 +768,16 @@ class _NewHome2State extends State<NewHome2> {
class Delegate extends SliverPersistentHeaderDelegate { class Delegate extends SliverPersistentHeaderDelegate {
final double catListHeight; final double catListHeight;
Delegate(this.catListHeight); final List<CategoryList> categoryList;
Delegate(this.catListHeight, this.categoryList);
@override @override
Widget build( Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) { BuildContext context, double shrinkOffset, bool overlapsContent) {
return Container( return Container(
height: catListHeight, height: catListHeight,
child: const CategoryList(), child: CategoryListHome(
categoryList: categoryList,
),
); );
} }
......
...@@ -8,12 +8,12 @@ class ScreenResponsive extends StatefulWidget { ...@@ -8,12 +8,12 @@ class ScreenResponsive extends StatefulWidget {
Widget widget; Widget widget;
double widthScreen; double widthScreen;
bool isCoreLayout; bool isCoreLayout;
ScreenResponsive( ScreenResponsive({
{Key? key, Key? key,
required this.widget, required this.widget,
required this.widthScreen, required this.widthScreen,
required this.isCoreLayout}) required this.isCoreLayout,
: super(key: key); }) : super(key: key);
@override @override
State<ScreenResponsive> createState() => _ScreenResponsiveState(); State<ScreenResponsive> createState() => _ScreenResponsiveState();
......
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