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(),
],
);
}
}
This diff is collapsed.
This diff is collapsed.
......@@ -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