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,48 +31,54 @@ class _CategoryListState extends State<CategoryList> { ...@@ -24,48 +31,54 @@ class _CategoryListState extends State<CategoryList> {
]; ];
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ListView.builder( return BlocBuilder<MenuSelectedBar, List<dynamic>>(
scrollDirection: Axis.horizontal, builder: (contextMenuSelectedBar, selectedBarIndex) {
itemCount: catMenu.length, selectedIndex = selectedBarIndex[0];
itemBuilder: (context, i) { return ListView.builder(
return Container( scrollDirection: Axis.horizontal,
margin: EdgeInsets.only( itemCount: widget.categoryList.length,
left: (i == 0) ? 0 : 28.335, itemBuilder: (context, i) {
right: (i == catMenu.length - 1) ? 0 : 28.335), return GestureDetector(
child: GestureDetector( onTap: () {
onTap: () { context
setState(() { .read<MenuSelectedBar>()
selectedIndex = i; .selectedBarMenu(i, widget.categoryList[i].name);
}); },
}, child: Container(
child: Column( color: backgroundColor,
crossAxisAlignment: CrossAxisAlignment.start, margin: EdgeInsets.only(
children: [ left: (i == 0) ? 0 : 28.335,
defaultText( right: (i == catMenu.length - 1) ? 0 : 28.335),
context, child: Column(
catMenu[i], crossAxisAlignment: CrossAxisAlignment.start,
style: catNameStyle(), children: [
defaultText(
context,
widget.categoryList[i].name,
style: catNameStyle(),
),
AnimatedSwitcher(
duration: Duration(milliseconds: animatedTime),
transitionBuilder:
(Widget child, Animation<double> animation) {
return ScaleTransition(scale: animation, child: child);
},
child: (selectedIndex == i)
? Container(
key: const Key('underline'),
margin: const EdgeInsets.only(top: 27),
width: 30,
height: 2,
color: buttonColor)
: const SizedBox(
key: Key('underline'),
),
)
],
), ),
AnimatedSwitcher( ),
duration: Duration(milliseconds: animatedTime), );
transitionBuilder: },
(Widget child, Animation<double> animation) {
return ScaleTransition(scale: animation, child: child);
},
child: (selectedIndex == i)
? Container(
key: const Key('underline'),
margin: const EdgeInsets.only(top: 27),
width: 30,
height: 2,
color: buttonColor)
: const SizedBox(
key: Key('underline'),
),
)
],
),
),
); );
}, },
); );
......
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,58 +18,57 @@ class FavoriteList extends StatefulWidget { ...@@ -14,58 +18,57 @@ 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 ListView.builder( return BlocBuilder<FavSelectedBar, List<dynamic>>(
scrollDirection: Axis.horizontal, builder: (contextSelectedBar, selectedBarIndex) {
itemCount: favMenu.length, selectedIndex = selectedBarIndex[0];
itemBuilder: (context, i) { return ListView.builder(
return Container( scrollDirection: Axis.horizontal,
margin: EdgeInsets.only( itemCount: widget.favoriteList.length,
left: (i == 0) ? 0 : 12.5, itemBuilder: (context, i) {
right: (i == favMenu.length - 1) ? 0 : 12.5), return GestureDetector(
child: GestureDetector( onTap: () {
onTap: () { context
setState(() { .read<FavSelectedBar>()
selectedIndex = i; .selectedBarFav(i, widget.favoriteList[i].id);
}); },
}, child: Container(
child: Column( color: backgroundColor,
crossAxisAlignment: CrossAxisAlignment.start, margin: EdgeInsets.only(
children: [ left: (i == 0) ? 0 : 12.5,
defaultText( right: (i == widget.favoriteList.length - 1) ? 0 : 12.5),
context, child: Column(
favMenu[i], crossAxisAlignment: CrossAxisAlignment.start,
style: favNameStyle(), children: [
defaultText(
context,
widget.favoriteList[i].name,
style: favNameStyle(),
),
AnimatedSwitcher(
duration: Duration(milliseconds: animatedTime),
transitionBuilder:
(Widget child, Animation<double> animation) {
return ScaleTransition(scale: animation, child: child);
},
child: (selectedIndex == i)
? Container(
key: const Key('underline'),
margin: const EdgeInsets.only(top: 2),
width: 30,
height: 2,
color: buttonColor)
: const SizedBox(
key: Key('underline'),
),
)
],
), ),
AnimatedSwitcher( ),
duration: Duration(milliseconds: animatedTime), );
transitionBuilder: },
(Widget child, Animation<double> animation) {
return ScaleTransition(scale: animation, child: child);
},
child: (selectedIndex == i)
? Container(
key: const Key('underline'),
margin: const EdgeInsets.only(top: 2),
width: 30,
height: 2,
color: buttonColor)
: const SizedBox(
key: Key('underline'),
),
)
],
),
),
); );
}, },
); );
......
// 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,49 +31,60 @@ class NewHome2 extends StatefulWidget { ...@@ -16,49 +31,60 @@ 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) {
}); setState(() {
} else { isScrollableMenu = true;
setState(() { });
isScrollableMenu = false;
});
}
} else { } else {
if (positionCustomScrollView == setState(() {
positionCustomScrollViewSearchFalseFixed) { isScrollableMenu = false;
setState(() { });
isScrollableMenu = true;
});
} else {
setState(() {
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,166 +128,414 @@ class _NewHome2State extends State<NewHome2> { ...@@ -102,166 +128,414 @@ class _NewHome2State extends State<NewHome2> {
categoryFont - categoryFont -
spacerAboveCatList; spacerAboveCatList;
double paddingLeftRight = 20; double paddingLeftRight = 20;
return SafeArea(
child: Scaffold( int tableMode = prefs.getInt('table_mode') ?? defaultTable;
backgroundColor: backgroundColor, double widthScreen = responsiveWidthScreen(context);
body: Container( double maxWidthScreen = getMaxWidthScreen(context, useResponsive);
height: MediaQuery.of(context).size.height, List<CategoryList> categoryList = [];
margin: EdgeInsets.symmetric(horizontal: paddingLeftRight), List<FavoriteGroup> favList = [];
child: Column( List<FilterMenu> categoryNonFav = [];
crossAxisAlignment: CrossAxisAlignment.start, List<FilterMenu> categoryFav = [];
children: [ List<FilterMenu> categoryFavAfterSelect = [];
customAppBar(context, paddingLeftRight, appBarHeight), List<FilterMenu> categoryMenuAfterSelect = [];
SizedBox( return BlocBuilder<BranchExist, String>(
height: (isSearchActive) ? 16 : 20, builder: (contextBracnhExist, restoran) {
), void onTapOkPop() {
AnimatedSwitcher( Navigator.pop(context, true);
duration: Duration(milliseconds: animatedTime), }
transitionBuilder: (Widget child, Animation<double> animation) {
return ScaleTransition(scale: animation, child: child); void onTapOkNoPop() {
}, Navigator.pop(context, false);
child: (isSearchActive) }
? SizedBox(
height: searchFieldHeight, return WillPopScope(
child: TextField( onWillPop: () async {
key: const Key('SearchField'), final shouldPop = await buttonDialogGlobal(
style: TextStyle( context,
color: Colors.black, 'Konfirmasi',
fontFamily: fontFamily, 'Apakah anda ingin keluar dari website ?',
fontSize: 15, 'Ya',
), 'Batal',
decoration: InputDecoration( onTapOkPop,
enabledBorder: OutlineInputBorder( onTapOkNoPop,
borderSide: BorderSide( okButtonColor: buttonColor,
width: 1, cancelButtonColor: cancelColorButton,
color: Colors.grey.withOpacity(0.8), );
),
), return shouldPop ?? false;
focusedBorder: OutlineInputBorder( },
borderSide: BorderSide( child: SafeArea(
width: 1, child: Scaffold(
color: buttonColor, backgroundColor: backgroundColor,
), body: ((restoran == responseByodBranchExist))
), ? BlocBuilder<FilterMenuBloc, List<FilterMenu>>(
prefixIcon: Image( builder: (contextBlocListCat, categoryDefault) {
image: if (categoryDefault.isNotEmpty &&
const AssetImage('assets/icons/search.png'), categoryDefault[0].id == "0") {
color: Colors.grey.withOpacity(0.8), return errorResponseByod(
height: 20, 'Gagal mendapatkan menu, silahkan refresh halaman / scan ulang barcode');
width: 20, } else if (categoryDefault.isNotEmpty) {
), for (var menu in categoryDefault) {
hintText: 'Example: nasi', if (!menu.isFavMenu) {
hintStyle: TextStyle( categoryNonFav.add(menu);
color: Colors.grey.withOpacity(0.8), } else {
fontFamily: fontFamily, categoryFav.add(menu);
fontSize: 10, }
), }
border: OutlineInputBorder( allMenu = categoryNonFav;
borderRadius: BorderRadius.circular(6),
), var nn = {
), "name": "All",
), "id": "0",
) }; // all dulu, biar ada bisa klik all
: const SizedBox( categoryList.add(CategoryList.createCategoryList(nn));
key: Key('SearchField'), for (var nameCat in categoryNonFav) {
), if (nameCat.type == typeCategory) {
), var n = {
Expanded( "id": nameCat.id,
child: CustomScrollView( "name": nameCat.categoryName
controller: _scrollController, };
slivers: [ categoryList
SliverToBoxAdapter( .add(CategoryList.createCategoryList(n));
child: SizedBox( }
height: (isSearchActive) ? spacerHeight : 0, }
), for (var nameFav in categoryFav) {
), if (nameFav.type == typeCategory) {
SliverToBoxAdapter( var nfav = {
child: Container( "name": nameFav.categoryName,
height: favListHeight, "id": nameFav.id
child: const FavoriteList(), };
), favList.add(FavoriteGroup.add(nfav));
), }
const SliverToBoxAdapter( }
child: SizedBox( if (isFirstLoad) {
height: 13.5, context
), .read<FavSelectedBar>()
), .selectedBarFav(0, favList[0].id);
SliverToBoxAdapter( context
child: Container( .read<MenuSelectedBar>()
height: favItemHeight, .selectedBarMenu(0, categoryList[0].id);
child: ListView.builder( }
scrollDirection: Axis.horizontal, }
itemCount: 5,
itemBuilder: (context, i) { return BlocBuilder<FavSelectedBar, List<dynamic>>(
double paddingLeftRigthGrid = 9; builder: (contextFavSelectedBar, listDynamicBar) {
double widthGrid = 136; if (categoryFav.isNotEmpty && favList.isNotEmpty) {
return girdFavItem( List<FilterMenu> temporSelectedFav = [];
i, for (var nameFav in categoryFav) {
widthGrid, if (nameFav.type == typeMenu &&
paddingLeftRigthGrid, listDynamicBar.length == 2 &&
context, 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,
margin: EdgeInsets.symmetric(
horizontal: paddingLeftRight),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
customAppBar(context, paddingLeftRight,
appBarHeight),
SizedBox(
height: (isSearchActive) ? 16 : 20,
),
AnimatedSwitcher(
duration: Duration(
milliseconds: animatedTime),
transitionBuilder: (Widget child,
Animation<double> animation) {
return ScaleTransition(
scale: animation, child: child);
},
child: (isSearchActive)
? SizedBox(
height: searchFieldHeight,
child: TextField(
key: const Key(
'SearchField'),
style: TextStyle(
color: Colors.black,
fontFamily: fontFamily,
fontSize: 15,
),
decoration: InputDecoration(
enabledBorder:
OutlineInputBorder(
borderSide: BorderSide(
width: 1,
color: Colors.grey
.withOpacity(0.8),
),
),
focusedBorder:
OutlineInputBorder(
borderSide: BorderSide(
width: 1,
color: buttonColor,
),
),
prefixIcon: Image(
image: const AssetImage(
'assets/icons/search.png'),
color: Colors.grey
.withOpacity(0.8),
height: 20,
width: 20,
),
hintText: 'Example: nasi',
hintStyle: TextStyle(
color: Colors.grey
.withOpacity(0.8),
fontFamily: fontFamily,
fontSize: 10,
),
border:
OutlineInputBorder(
borderRadius:
BorderRadius
.circular(6),
),
),
),
)
: const SizedBox(
key: Key('SearchField'),
),
),
Expanded(
child: CustomScrollView(
controller: _scrollController,
slivers: [
SliverToBoxAdapter(
child: SizedBox(
height: (isSearchActive)
? spacerHeight
: 0,
),
),
SliverToBoxAdapter(
child: Container(
height: favListHeight,
child: FavoriteList(
favoriteList: favList,
),
),
),
const SliverToBoxAdapter(
child: SizedBox(
height: 13.5,
),
),
SliverToBoxAdapter(
child: Container(
height: favItemHeight,
child: ListView.builder(
scrollDirection:
Axis.horizontal,
itemCount:
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,
itemBuilder: (context, i) {
return MenuListUtama(
categoryNonFav:
categoryMenuAfterSelect,
i: i,
);
},
),
)),
],
),
),
],
),
),
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,
)
],
),
),
)
],
); );
}), },
), );
), });
SliverToBoxAdapter( },
child: SizedBox( )
height: spacerAboveCat, : (restoran == responseByodInActive)
), ? errorResponseByod(
), "Byod tidak aktif, untuk melakukan pesanan silakan memanggil waiter")
SliverToBoxAdapter( : (restoran == responseApiNoSuccess)
child: defaultText( ? errorResponseByod(
context, "Scan QR Atau Kunjungi Alamat Outlet")
'Category', : (restoran == responseApiErrorServer)
style: categoryStyle(), ? errorResponseByod(
), "Something Went Wrong With Our Server")
), : (restoran == responseApiWaiting)
SliverToBoxAdapter( ? ScreenResponsive(
child: SizedBox( widget: ShimmerMenu(
height: spacerAboveCatList, widthScreen: widthScreen,
), maxWidthScreen: maxWidthScreen,
), context: context),
SliverPersistentHeader( widthScreen:
pinned: true, MediaQuery.of(context).size.width,
delegate: Delegate(catListHeight), isCoreLayout: true,
), )
SliverToBoxAdapter( : const SizedBox(),
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: 100,
itemBuilder: (context, i) {
return defaultText(context, 'Teks ke $i');
},
),
)),
],
),
),
],
), ),
), );
), },
); );
} }
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