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({
);
}
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,
{Color? color, isBold = true}) {
// double widthScreens = responsiveWidthScreen(context);
......
......@@ -19,9 +19,11 @@ import 'package:uuid/uuid.dart';
import 'package:web_browser_detect/web_browser_detect.dart';
import 'bloc/branch_exist.dart';
import 'bloc/fav_selected_bar.dart';
import 'bloc/feedback_option.dart';
import 'bloc/feedback_select.dart';
import 'bloc/filter_menu.dart';
import 'bloc/menu_selected_bar.dart';
import 'bloc/order_detail_variant.dart';
import 'bloc/order_variant_temporary.dart';
import 'bloc/order_variant_value.dart';
......@@ -152,6 +154,8 @@ class MyApp extends StatelessWidget {
BlocProvider(create: (_) => FeedbackSelect()),
BlocProvider(create: (_) => FilterMenuBloc()),
BlocProvider(create: (_) => VoucherListBloc()),
BlocProvider(create: (_) => FavSelectedBar()),
BlocProvider(create: (_) => MenuSelectedBar()),
],
child: MaterialApp(
title: (title == null) ? defaultTitle : title,
......
class CategoryList {
final String name;
final String id;
CategoryList({required this.name});
CategoryList({
required this.name,
required this.id,
});
factory CategoryList.createCategoryList(Map<String, dynamic> json) {
return CategoryList(
id: json['id'],
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_bloc/flutter_bloc.dart';
import '../../helper/helper.dart';
import '../../helper/widget/style.dart';
import '../../models/category_list.dart';
class CategoryList extends StatefulWidget {
const CategoryList({
class CategoryListHome extends StatefulWidget {
List<CategoryList> categoryList;
CategoryListHome({
Key? key,
required this.categoryList,
}) : super(key: key);
@override
State<CategoryList> createState() => _CategoryListState();
State<CategoryListHome> createState() => _CategoryListHomeState();
}
class _CategoryListState extends State<CategoryList> {
class _CategoryListHomeState extends State<CategoryListHome> {
int selectedIndex = 0;
List<String> catMenu = [
'All Item',
......@@ -24,48 +31,54 @@ class _CategoryListState extends State<CategoryList> {
];
@override
Widget build(BuildContext context) {
return ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: catMenu.length,
itemBuilder: (context, i) {
return Container(
margin: EdgeInsets.only(
left: (i == 0) ? 0 : 28.335,
right: (i == catMenu.length - 1) ? 0 : 28.335),
child: GestureDetector(
onTap: () {
setState(() {
selectedIndex = i;
});
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
defaultText(
context,
catMenu[i],
style: catNameStyle(),
return BlocBuilder<MenuSelectedBar, List<dynamic>>(
builder: (contextMenuSelectedBar, selectedBarIndex) {
selectedIndex = selectedBarIndex[0];
return ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: widget.categoryList.length,
itemBuilder: (context, i) {
return GestureDetector(
onTap: () {
context
.read<MenuSelectedBar>()
.selectedBarMenu(i, widget.categoryList[i].name);
},
child: Container(
color: backgroundColor,
margin: EdgeInsets.only(
left: (i == 0) ? 0 : 28.335,
right: (i == catMenu.length - 1) ? 0 : 28.335),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
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_bloc/flutter_bloc.dart';
import '../../bloc/fav_selected_bar.dart';
import '../../helper/helper.dart';
import '../../helper/widget/style.dart';
import '../../models/fav_group.dart';
class FavoriteList extends StatefulWidget {
const FavoriteList({
Key? key,
}) : super(key: key);
List<FavoriteGroup> favoriteList;
FavoriteList({Key? key, required this.favoriteList}) : super(key: key);
@override
State<FavoriteList> createState() => _FavoriteListState();
......@@ -14,58 +18,57 @@ class FavoriteList extends StatefulWidget {
class _FavoriteListState extends State<FavoriteList> {
int selectedIndex = 0;
List<String> favMenu = [
'All',
'Popular',
'Favorite This Month',
'Menu Lainnya',
'Menu Lainnya',
'Menu Lainnya'
];
@override
Widget build(BuildContext context) {
return ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: favMenu.length,
itemBuilder: (context, i) {
return Container(
margin: EdgeInsets.only(
left: (i == 0) ? 0 : 12.5,
right: (i == favMenu.length - 1) ? 0 : 12.5),
child: GestureDetector(
onTap: () {
setState(() {
selectedIndex = i;
});
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
defaultText(
context,
favMenu[i],
style: favNameStyle(),
return BlocBuilder<FavSelectedBar, List<dynamic>>(
builder: (contextSelectedBar, selectedBarIndex) {
selectedIndex = selectedBarIndex[0];
return ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: widget.favoriteList.length,
itemBuilder: (context, i) {
return GestureDetector(
onTap: () {
context
.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(
crossAxisAlignment: CrossAxisAlignment.start,
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/widget/style.dart';
import 'package:flutter/material.dart';
// import 'package:byod/helper/helper.dart';
// import 'package:byod/helper/widget/style.dart';
// import 'package:flutter/material.dart';
import 'cat_list.dart';
import 'fav_list.dart';
// import 'cat_list.dart';
// import 'fav_list.dart';
class NewHome extends StatefulWidget {
const NewHome({Key? key}) : super(key: key);
// class NewHome extends StatefulWidget {
// const NewHome({Key? key}) : super(key: key);
@override
State<NewHome> createState() => _NewHomeState();
}
// @override
// State<NewHome> createState() => _NewHomeState();
// }
class _NewHomeState extends State<NewHome> {
bool isSearchActive = true;
final searchController = TextEditingController();
// class _NewHomeState extends State<NewHome> {
// bool isSearchActive = true;
// final searchController = TextEditingController();
@override
Widget build(BuildContext context) {
double paddingLeftRight = 20;
return SafeArea(
child: Scaffold(
backgroundColor: backgroundColor,
body: Container(
height: MediaQuery.of(context).size.height,
margin: EdgeInsets.symmetric(horizontal: paddingLeftRight),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
customAppBar(context, paddingLeftRight),
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: 36,
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'),
),
),
SizedBox(
height: (isSearchActive) ? 20 : 0,
),
Container(
height: 35,
child: const FavoriteList(),
),
const SizedBox(
height: 13.5,
),
Container(
height: 219,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: 5,
itemBuilder: (context, i) {
double paddingLeftRigthGrid = 9;
double widthGrid = 136;
return girdFavItem(
i,
widthGrid,
paddingLeftRigthGrid,
context,
);
}),
),
const SizedBox(
height: 16,
),
defaultText(
context,
'Category',
style: categoryStyle(),
),
const SizedBox(
height: 42,
),
Container(
height: 51,
child: const CategoryList(),
),
const SizedBox(
height: 25,
),
Expanded(
child: ListView.builder(
itemCount: 1000,
itemBuilder: (context, i) {
return Text('aaa');
},
),
)
],
),
),
),
);
}
// @override
// Widget build(BuildContext context) {
// double paddingLeftRight = 20;
// return SafeArea(
// child: Scaffold(
// backgroundColor: backgroundColor,
// body: Container(
// height: MediaQuery.of(context).size.height,
// margin: EdgeInsets.symmetric(horizontal: paddingLeftRight),
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// customAppBar(context, paddingLeftRight),
// 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: 36,
// 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'),
// ),
// ),
// SizedBox(
// height: (isSearchActive) ? 20 : 0,
// ),
// Container(
// height: 35,
// child: FavoriteList(),
// ),
// const SizedBox(
// height: 13.5,
// ),
// Container(
// height: 219,
// child: ListView.builder(
// scrollDirection: Axis.horizontal,
// itemCount: 5,
// itemBuilder: (context, i) {
// double paddingLeftRigthGrid = 9;
// double widthGrid = 136;
// return girdFavItem(
// i,
// widthGrid,
// paddingLeftRigthGrid,
// context,
// );
// }),
// ),
// const SizedBox(
// height: 16,
// ),
// defaultText(
// context,
// 'Category',
// style: categoryStyle(),
// ),
// const SizedBox(
// height: 42,
// ),
// Container(
// height: 51,
// child: const CategoryListHome(),
// ),
// const SizedBox(
// height: 25,
// ),
// Expanded(
// child: ListView.builder(
// itemCount: 1000,
// itemBuilder: (context, i) {
// return Text('aaa');
// },
// ),
// )
// ],
// ),
// ),
// ),
// );
// }
Container girdFavItem(int i, double widthGrid, double paddingLeftRigthGrid,
BuildContext context) {
bool addCondition = true;
return Container(
margin: EdgeInsets.only(
left: (i == 0) ? 0 : 8,
right: (i == 5 - 1) ? 0 : 8,
),
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,
),
),
const SizedBox(
height: 3,
),
Container(
width: widthGrid - (2 * paddingLeftRigthGrid),
height: 28,
// color: Colors.blue,
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(
child: defaultText(
context,
'BBQ Chicken Nachos',
maxLines: 2,
overFlow: TextOverflow.ellipsis,
style: menuNameGridFav(),
),
),
Container(
width: 40,
child: defaultText(
context,
'Rp 25,000',
maxLines: 3,
overFlow: TextOverflow.ellipsis,
style: menuPriceGridFav(),
),
)
],
),
),
const SizedBox(
height: 16,
),
(addCondition)
? Container(
height: 30,
width: widthGrid - (2 * paddingLeftRigthGrid),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6),
color: buttonColor,
),
child: Center(
child: defaultText(
context,
'Tambah',
style: addButtonGridFav(),
),
),
)
: Container(
height: 30,
width: widthGrid - (2 * paddingLeftRigthGrid),
child: Row(
children: [
Container(
width: 27,
height: 24,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6),
color: buttonColor,
),
child: const Center(
child: Image(
width: 13.33,
height: 13.33,
color: textInButton,
image: AssetImage('assets/icons/note.png'),
),
),
),
const SizedBox(
width: 5,
),
Container(
width: 22,
height: 22,
child: const Image(
image: AssetImage('assets/icons/minus.png'),
),
),
Expanded(
child: Center(
child: defaultText(
context,
'10',
style: amountGridFav(),
),
),
),
Container(
width: 22,
height: 22,
child: const Image(
image: AssetImage('assets/icons/plus.png'),
),
)
],
),
)
],
),
),
);
}
// Container girdFavItem(int i, double widthGrid, double paddingLeftRigthGrid,
// BuildContext context) {
// bool addCondition = true;
// return Container(
// margin: EdgeInsets.only(
// left: (i == 0) ? 0 : 8,
// right: (i == 5 - 1) ? 0 : 8,
// ),
// 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,
// ),
// ),
// const SizedBox(
// height: 3,
// ),
// Container(
// width: widthGrid - (2 * paddingLeftRigthGrid),
// height: 28,
// // color: Colors.blue,
// child: Row(
// crossAxisAlignment: CrossAxisAlignment.end,
// children: [
// Expanded(
// child: defaultText(
// context,
// 'BBQ Chicken Nachos',
// maxLines: 2,
// overFlow: TextOverflow.ellipsis,
// style: menuNameGridFav(),
// ),
// ),
// Container(
// width: 40,
// child: defaultText(
// context,
// 'Rp 25,000',
// maxLines: 3,
// overFlow: TextOverflow.ellipsis,
// style: menuPriceGridFav(),
// ),
// )
// ],
// ),
// ),
// const SizedBox(
// height: 16,
// ),
// (addCondition)
// ? Container(
// height: 30,
// width: widthGrid - (2 * paddingLeftRigthGrid),
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(6),
// color: buttonColor,
// ),
// child: Center(
// child: defaultText(
// context,
// 'Tambah',
// style: addButtonGridFav(),
// ),
// ),
// )
// : Container(
// height: 30,
// width: widthGrid - (2 * paddingLeftRigthGrid),
// child: Row(
// children: [
// Container(
// width: 27,
// height: 24,
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(6),
// color: buttonColor,
// ),
// child: const Center(
// child: Image(
// width: 13.33,
// height: 13.33,
// color: textInButton,
// image: AssetImage('assets/icons/note.png'),
// ),
// ),
// ),
// const SizedBox(
// width: 5,
// ),
// Container(
// width: 22,
// height: 22,
// child: const Image(
// image: AssetImage('assets/icons/minus.png'),
// ),
// ),
// Expanded(
// child: Center(
// child: defaultText(
// context,
// '10',
// style: amountGridFav(),
// ),
// ),
// ),
// Container(
// width: 22,
// height: 22,
// child: const Image(
// image: AssetImage('assets/icons/plus.png'),
// ),
// )
// ],
// ),
// )
// ],
// ),
// ),
// );
// }
Container customAppBar(BuildContext context, double paddingLeftRight) {
return Container(
// color: Colors.red,
height: 40,
child: CustomScrollView(
slivers: [
SliverAppBar(
automaticallyImplyLeading: false,
title: defaultText(
context,
'Meja 12',
style: tableNameStyle(),
),
backgroundColor: Colors.transparent,
pinned: true,
actions: [
GestureDetector(
onTap: () {
setState(() {
isSearchActive = !isSearchActive;
});
},
child: const Image(
image: AssetImage('assets/icons/search.png'),
height: 20,
width: 20,
),
),
const SizedBox(
width: 16,
),
const Image(
image: AssetImage('assets/icons/book.png'),
height: 20,
width: 20,
),
SizedBox(
width: paddingLeftRight,
),
],
),
],
),
);
}
// Container customAppBar(BuildContext context, double paddingLeftRight) {
// return Container(
// // color: Colors.red,
// height: 40,
// child: CustomScrollView(
// slivers: [
// SliverAppBar(
// automaticallyImplyLeading: false,
// title: defaultText(
// context,
// 'Meja 12',
// style: tableNameStyle(),
// ),
// backgroundColor: Colors.transparent,
// pinned: true,
// actions: [
// GestureDetector(
// onTap: () {
// setState(() {
// isSearchActive = !isSearchActive;
// });
// },
// child: const Image(
// image: AssetImage('assets/icons/search.png'),
// height: 20,
// width: 20,
// ),
// ),
// const SizedBox(
// width: 16,
// ),
// const Image(
// image: AssetImage('assets/icons/book.png'),
// height: 20,
// width: 20,
// ),
// SizedBox(
// width: paddingLeftRight,
// ),
// ],
// ),
// ],
// ),
// );
// }
AnimatedSwitcher seearchField(BuildContext context) {
return AnimatedSwitcher(
duration: const Duration(milliseconds: 500),
transitionBuilder: (Widget child, Animation<double> animation) {
return ScaleTransition(scale: animation, child: child);
},
child: TextField(
key: const Key('SearchField'),
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 1,
color: buttonColor,
),
),
prefixIcon: const Image(
image: AssetImage('assets/icons/search.png'),
height: 20,
width: 20,
),
hintText: 'Example: nasi',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(6),
),
),
),
);
}
}
// AnimatedSwitcher seearchField(BuildContext context) {
// return AnimatedSwitcher(
// duration: const Duration(milliseconds: 500),
// transitionBuilder: (Widget child, Animation<double> animation) {
// return ScaleTransition(scale: animation, child: child);
// },
// child: TextField(
// key: const Key('SearchField'),
// decoration: InputDecoration(
// focusedBorder: OutlineInputBorder(
// borderSide: BorderSide(
// width: 1,
// color: buttonColor,
// ),
// ),
// prefixIcon: const Image(
// image: AssetImage('assets/icons/search.png'),
// height: 20,
// width: 20,
// ),
// hintText: 'Example: nasi',
// border: OutlineInputBorder(
// borderRadius: BorderRadius.circular(6),
// ),
// ),
// ),
// );
// }
// }
// 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/widget/style.dart';
import 'package:byod/models/filter_menu.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 'fav_grid_menu.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 {
const NewHome2({Key? key}) : super(key: key);
......@@ -16,49 +31,60 @@ class NewHome2 extends StatefulWidget {
class _NewHome2State extends State<NewHome2> {
bool isSearchActive = false;
bool isFirstLoad = true;
final searchController = TextEditingController();
final _scrollController = ScrollController();
final _scrollMenuItem = ScrollController();
late bool isScrollableMenu = false;
final double positionCustomScrollViewFixed = 345.5;
final double positionCustomScrollViewSearchFalseFixed = 349.5;
// final double positionCustomScrollViewFixed = 345.5 - 10;
// final double positionCustomScrollViewSearchFalseFixed = 349.5 - 10;
late List<FilterMenu> allMenu = [];
@override
void initState() {
_scrollController.addListener(
() {
setState(() {
isFirstLoad = false;
});
// if (_scrollController.position.pixels >=
// (_scrollController.position.maxScrollExtent - 100)) {}
double positionCustomScrollView = _scrollController.position.pixels;
if (isSearchActive) {
if (positionCustomScrollView == positionCustomScrollViewFixed) {
setState(() {
isScrollableMenu = true;
});
} else {
setState(() {
isScrollableMenu = false;
});
}
double positionCustomScrollViewMax =
_scrollController.position.maxScrollExtent;
// if (isSearchActive) {
if (positionCustomScrollView >= positionCustomScrollViewMax) {
setState(() {
isScrollableMenu = true;
});
} else {
if (positionCustomScrollView ==
positionCustomScrollViewSearchFalseFixed) {
setState(() {
isScrollableMenu = true;
});
} else {
setState(() {
isScrollableMenu = false;
});
}
setState(() {
isScrollableMenu = false;
});
}
// } else {
// if (positionCustomScrollView >=
// positionCustomScrollViewSearchFalseFixed) {
// setState(() {
// isScrollableMenu = true;
// });
// } else {
// setState(() {
// isScrollableMenu = false;
// });
// }
// }
},
);
_scrollMenuItem.addListener(() {
double positionMenuItemScrollView = _scrollMenuItem.position.pixels;
if (positionMenuItemScrollView == 0) {
double positionMenuItemScrollViewMin =
_scrollMenuItem.position.minScrollExtent;
if (positionMenuItemScrollView == positionMenuItemScrollViewMin &&
_scrollController.position.pixels ==
_scrollController.position.maxScrollExtent) {
setState(() {
isScrollableMenu = false;
});
......@@ -102,166 +128,414 @@ class _NewHome2State extends State<NewHome2> {
categoryFont -
spacerAboveCatList;
double paddingLeftRight = 20;
return SafeArea(
child: Scaffold(
backgroundColor: backgroundColor,
body: 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: const FavoriteList(),
),
),
const SliverToBoxAdapter(
child: SizedBox(
height: 13.5,
),
),
SliverToBoxAdapter(
child: Container(
height: favItemHeight,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: 5,
itemBuilder: (context, i) {
double paddingLeftRigthGrid = 9;
double widthGrid = 136;
return girdFavItem(
i,
widthGrid,
paddingLeftRigthGrid,
context,
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(
backgroundColor: backgroundColor,
body: ((restoran == responseByodBranchExist))
? BlocBuilder<FilterMenuBloc, List<FilterMenu>>(
builder: (contextBlocListCat, categoryDefault) {
if (categoryDefault.isNotEmpty &&
categoryDefault[0].id == "0") {
return errorResponseByod(
'Gagal mendapatkan menu, silahkan refresh halaman / scan ulang barcode');
} else if (categoryDefault.isNotEmpty) {
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,
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,
),
),
SliverToBoxAdapter(
child: defaultText(
context,
'Category',
style: categoryStyle(),
),
),
SliverToBoxAdapter(
child: SizedBox(
height: spacerAboveCatList,
),
),
SliverPersistentHeader(
pinned: true,
delegate: Delegate(catListHeight),
),
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: 100,
itemBuilder: (context, i) {
return defaultText(context, 'Teks ke $i');
},
),
)),
],
),
),
],
},
);
});
},
)
: (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,
BuildContext context) {
Container girdFavItem(
List<FilterMenu> favListItem,
int i,
double widthGrid,
double paddingLeftRigthGrid,
BuildContext context,
) {
bool addCondition = true;
return Container(
margin: EdgeInsets.only(
left: (i == 0) ? 0 : 8,
right: (i == 5 - 1) ? 0 : 8,
left: (i == 0) ? 0 : 8, // paling awal gausah dikasih margin
right: (i == favListItem.length - 1)
? 0
: 8, // paling akhir gausah dikasi margin
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
......@@ -284,7 +558,14 @@ class _NewHome2State extends State<NewHome2> {
height: widthGrid - (2 * paddingLeftRigthGrid),
decoration: BoxDecoration(
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(
......@@ -300,7 +581,7 @@ class _NewHome2State extends State<NewHome2> {
Expanded(
child: defaultText(
context,
'BBQ Chicken Nachos',
favListItem[i].name,
maxLines: 2,
overFlow: TextOverflow.ellipsis,
style: menuNameGridFav(),
......@@ -310,7 +591,7 @@ class _NewHome2State extends State<NewHome2> {
width: 40,
child: defaultText(
context,
'Rp 25,000',
'Rp ${formatNumber().format(amountParseToInt(favListItem[i].price))}',
maxLines: 3,
overFlow: TextOverflow.ellipsis,
style: menuPriceGridFav(),
......@@ -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) {
return AnimatedSwitcher(
duration: const Duration(milliseconds: 500),
......@@ -464,13 +768,16 @@ class _NewHome2State extends State<NewHome2> {
class Delegate extends SliverPersistentHeaderDelegate {
final double catListHeight;
Delegate(this.catListHeight);
final List<CategoryList> categoryList;
Delegate(this.catListHeight, this.categoryList);
@override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
return Container(
height: catListHeight,
child: const CategoryList(),
child: CategoryListHome(
categoryList: categoryList,
),
);
}
......
......@@ -8,12 +8,12 @@ class ScreenResponsive extends StatefulWidget {
Widget widget;
double widthScreen;
bool isCoreLayout;
ScreenResponsive(
{Key? key,
required this.widget,
required this.widthScreen,
required this.isCoreLayout})
: super(key: key);
ScreenResponsive({
Key? key,
required this.widget,
required this.widthScreen,
required this.isCoreLayout,
}) : super(key: key);
@override
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