Commit 0b825b15 authored by Dio Maulana's avatar Dio Maulana

viewbill new pge

parent 4dcaa98f
...@@ -77,7 +77,10 @@ class Api { ...@@ -77,7 +77,10 @@ class Api {
"table": tableNumber, "table": tableNumber,
"user_name": userName, "user_name": userName,
"total_order": totalOrder, "total_order": totalOrder,
"date_order": dateOrder, "date_order": localDate(
dateOrder,
isHistory: true,
),
"branch_code": branchCode, "branch_code": branchCode,
"brand": brandCode, "brand": brandCode,
"token": token, "token": token,
...@@ -88,6 +91,8 @@ class Api { ...@@ -88,6 +91,8 @@ class Api {
} }
await prefs.setString('sessionId', jsonObject['data']['session_id']); await prefs.setString('sessionId', jsonObject['data']['session_id']);
await prefs.setInt('table_mode', jsonObject['data']['table_mode']); await prefs.setInt('table_mode', jsonObject['data']['table_mode']);
await prefs.setString('logoUrl', jsonObject['data']['image']);
//** save sessionID and Table Mode */ //** save sessionID and Table Mode */
// return jsonObject['data']['name']; // return jsonObject['data']['name'];
......
import 'package:flutter_bloc/flutter_bloc.dart';
class SearchHistory extends Cubit<List<String>> {
SearchHistory() : super(['start']);
void search(List<String> historyOrder, String keyword) {
if (keyword == '') {
emit(historyOrder);
} else {
List<String> result = [];
for (var history in historyOrder) {
if (history.toLowerCase().contains(keyword.toLowerCase())) {
result.add(history);
}
}
emit(result);
}
}
}
...@@ -229,7 +229,7 @@ String localDate(String date, {isHistory = false}) { ...@@ -229,7 +229,7 @@ String localDate(String date, {isHistory = false}) {
} }
break; break;
} }
return "$day $resultMonth $year"; return "$day-$resultMonth-$year";
} }
//** convert UTC to local */ //** convert UTC to local */
...@@ -242,6 +242,12 @@ String localDate(String date, {isHistory = false}) { ...@@ -242,6 +242,12 @@ String localDate(String date, {isHistory = false}) {
double heightTombol = 0.06; // untuk dikalikan di height media query double heightTombol = 0.06; // untuk dikalikan di height media query
//**Height tombol */ //**Height tombol */
//** kalkulasi pixel dihome */
double imageHeight = 96;
double heighScrollWithImage = 371 + imageHeight;
double heighScrollWithOutImage = 371;
//** */
//** core warna */ //** core warna */
// const Color backgroundColor = Colors.white; // const Color backgroundColor = Colors.white;
const Color backgroundColor = Color(0xffF4F4F4); const Color backgroundColor = Color(0xffF4F4F4);
...@@ -484,6 +490,9 @@ const double backIconSize = 0.03; ...@@ -484,6 +490,9 @@ const double backIconSize = 0.03;
const String arrowBack = '\uf060'; const String arrowBack = '\uf060';
const double arrowBackSize = 17; const double arrowBackSize = 17;
const String arrowNext = '\uf105';
const double arrowNextSize = 14;
const String shopingBag = '\uf290'; const String shopingBag = '\uf290';
const double shopingBagSize = 0.03; const double shopingBagSize = 0.03;
......
...@@ -15,7 +15,6 @@ Future<dynamic> buttonDialogGlobal( ...@@ -15,7 +15,6 @@ Future<dynamic> buttonDialogGlobal(
void Function() ontapCancel, void Function() ontapCancel,
{Color okButtonColor = Colors.indigo, {Color okButtonColor = Colors.indigo,
Color cancelButtonColor = Colors.red}) { Color cancelButtonColor = Colors.red}) {
double widthScreen = responsiveWidthScreen(context);
return showDialog( return showDialog(
context: context, context: context,
builder: (BuildContext context) => AlertDialog( builder: (BuildContext context) => AlertDialog(
...@@ -29,56 +28,29 @@ Future<dynamic> buttonDialogGlobal( ...@@ -29,56 +28,29 @@ Future<dynamic> buttonDialogGlobal(
title, title,
// style: textStyleNormalFont(context), // style: textStyleNormalFont(context),
), ),
content: SizedBox( content: Column(
height: MediaQuery.of(context).size.height * 0.38, mainAxisSize: MainAxisSize.min,
width: widthScreen * widhtDialog,
child: Column(
children: [ children: [
Container( Align(
height: MediaQuery.of(context).size.height * 0.2,
child: Align(
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
// child: Text(
// description,
// textScaleFactor: textScaleFactor,
// style: textStyleNormalFont(context),
// // style: TextStyle(
// // fontWeight: FontWeight.w400,
// // fontSize:
// // MediaQuery.of(context).size.height * normalFont),
// ),
child: defaultText( child: defaultText(
context, context,
description, description,
style: textStyleNormalFont(context), style: textStyleNormalFont(context),
), ),
), ),
), const SizedBox(height: 10),
SizedBox(height: MediaQuery.of(context).size.height * 0.01),
GestureDetector( GestureDetector(
onTap: () { onTap: () {
ontapOk(); ontapOk();
}, },
child: Container( child: Container(
height: MediaQuery.of(context).size.height * heightTombol, width: double.infinity,
height: 40,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(roundedButton), borderRadius: BorderRadius.circular(roundedButton),
color: okButtonColor), color: okButtonColor),
child: Align( child: Center(
// child: Text(
// textOnOk,
// textScaleFactor: textScaleFactor,
// // style: TextStyle(
// // fontWeight: FontWeight.w500,
// // fontSize:
// // MediaQuery.of(context).size.height * normalFont,
// // color: textInButton,
// // ),
// style: textStyleNormalFont(
// context,
// color: textInButton,
// ),
// ),
child: defaultText( child: defaultText(
context, context,
textOnOk, textOnOk,
...@@ -90,34 +62,19 @@ Future<dynamic> buttonDialogGlobal( ...@@ -90,34 +62,19 @@ Future<dynamic> buttonDialogGlobal(
), ),
), ),
), ),
SizedBox( const SizedBox(height: 10),
height: MediaQuery.of(context).size.height * 0.02,
),
GestureDetector( GestureDetector(
onTap: () { onTap: () {
ontapCancel(); ontapCancel();
}, },
child: Container( child: Container(
height: MediaQuery.of(context).size.height * heightTombol, width: double.infinity,
height: 40,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(roundedButton), borderRadius: BorderRadius.circular(roundedButton),
color: Colors.transparent, color: Colors.transparent,
), ),
child: Align( child: Center(
// child: Text(
// textOnCancel,
// textScaleFactor: textScaleFactor,
// // style: TextStyle(
// // fontWeight: FontWeight.w500,
// // fontSize:
// // MediaQuery.of(context).size.height * normalFont,
// // color: textInButton,
// // ),
// style: textStyleNormalFont(
// context,
// color: textInButton,
// ),
// ),
child: defaultText( child: defaultText(
context, context,
textOnCancel, textOnCancel,
...@@ -131,6 +88,5 @@ Future<dynamic> buttonDialogGlobal( ...@@ -131,6 +88,5 @@ Future<dynamic> buttonDialogGlobal(
) )
], ],
), ),
),
)); ));
} }
...@@ -74,6 +74,7 @@ class EmoticonRateNew extends StatelessWidget { ...@@ -74,6 +74,7 @@ class EmoticonRateNew extends StatelessWidget {
defaultText( defaultText(
context, context,
'Bagaimana pengalaman anda bertransaksi di excelso ?', 'Bagaimana pengalaman anda bertransaksi di excelso ?',
textAlign: TextAlign.center,
style: emojiStyle(), style: emojiStyle(),
), ),
const SizedBox( const SizedBox(
......
// ignore_for_file: sized_box_for_whitespace
import 'package:byod/helper/widget/style.dart';
import 'package:flutter/material.dart';
import '../helper.dart';
class PlusMinusButton extends StatelessWidget {
const PlusMinusButton({
Key? key,
required this.initialValue,
required this.minus,
required this.plus,
this.backgroundAmountColor = backgroundColor,
this.isFromVariant = false,
this.widthInitialValue = 94,
}) : super(key: key);
final int initialValue;
final void Function() minus;
final void Function() plus;
final Color backgroundAmountColor;
final bool isFromVariant;
final double widthInitialValue;
@override
Widget build(BuildContext context) {
return Stack(
children: [
Container(
width: widthInitialValue,
height: 22,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
color: backgroundAmountColor,
),
child: Center(
child: defaultText(
context,
initialValue.toString(),
style: amountViewBillButton(),
),
),
),
Positioned(
left: 0,
child: GestureDetector(
onTap: () {
// if (initialValue > 1) {
// initialValue += -1;
// context
// .read<OrderVariantTemporaryBloc>()
// .insertDataVariant(itemId, satuanPrice,
// initialValue, []);
// }
minus();
},
child: Container(
width: 22,
height: 22,
child: Image(
image: AssetImage((initialValue < 2 && isFromVariant)
? 'assets/icons/minus.png'
: 'assets/icons/minus-blue.png'),
),
),
),
),
Positioned(
right: 0,
child: GestureDetector(
onTap: () {
// initialValue += 1;
// context
// .read<OrderVariantTemporaryBloc>()
// .insertDataVariant(
// itemId, satuanPrice, initialValue, []);
plus();
},
child: Container(
width: 22,
height: 22,
child: const Image(
image: AssetImage('assets/icons/plus.png'),
),
),
),
)
],
);
}
}
...@@ -46,6 +46,19 @@ TextStyle emojiStyle({ ...@@ -46,6 +46,19 @@ TextStyle emojiStyle({
); );
} }
TextStyle historyOrderStyle({
font = 12,
Color color = textColorBlack,
FontWeight fontWeight = FontWeight.w400,
}) {
return TextStyle(
fontFamily: (fontFamily == '') ? null : fontFamily,
fontSize: font,
fontWeight: fontWeight,
color: color,
);
}
TextStyle appBarNameViewBill({font = 17, Color color = textColorBlack}) { TextStyle appBarNameViewBill({font = 17, Color color = textColorBlack}) {
return TextStyle( return TextStyle(
fontFamily: 'Mulish', fontFamily: 'Mulish',
...@@ -281,7 +294,7 @@ TextStyle rincianPembayaran({ ...@@ -281,7 +294,7 @@ TextStyle rincianPembayaran({
FontStyle? fontStyle, FontStyle? fontStyle,
}) { }) {
return TextStyle( return TextStyle(
fontFamily: 'OpenSans', fontFamily: (fontFamily == '') ? null : fontFamily,
fontSize: font, fontSize: font,
fontWeight: fontWeight, fontWeight: fontWeight,
color: color, color: color,
......
...@@ -28,6 +28,7 @@ import 'bloc/order_detail_variant.dart'; ...@@ -28,6 +28,7 @@ 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';
import 'bloc/search_active.dart'; import 'bloc/search_active.dart';
import 'bloc/search_history.dart';
import 'bloc/view_bill.dart'; import 'bloc/view_bill.dart';
import 'package:flutter/services.dart' as bundle_root; import 'package:flutter/services.dart' as bundle_root;
...@@ -158,6 +159,7 @@ class MyApp extends StatelessWidget { ...@@ -158,6 +159,7 @@ class MyApp extends StatelessWidget {
BlocProvider(create: (_) => FavSelectedBar()), BlocProvider(create: (_) => FavSelectedBar()),
BlocProvider(create: (_) => MenuSelectedBar()), BlocProvider(create: (_) => MenuSelectedBar()),
BlocProvider(create: (_) => SearchActive()), BlocProvider(create: (_) => SearchActive()),
BlocProvider(create: (_) => SearchHistory()),
], ],
child: MaterialApp( child: MaterialApp(
title: (title == null) ? defaultTitle : title, title: (title == null) ? defaultTitle : title,
......
// ignore_for_file: sized_box_for_whitespace
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../bloc/search_history.dart';
import '../../helper/helper.dart';
import '../../helper/widget/style.dart';
class CustomAppBar extends StatelessWidget {
CustomAppBar({
Key? key,
required this.historyOrder,
}) : super(key: key);
final List<String> historyOrder;
final _searchController = TextEditingController();
@override
Widget build(BuildContext context) {
return Container(
color: backgroundWhite,
padding: const EdgeInsets.symmetric(
horizontal: paddingLeftRight, vertical: 15),
child: Column(
children: [
Row(
// mainAxisAlignment: MainAxisAlignment.start,
children: [
GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: Container(
width: 24,
height: 24,
child: Center(
child: fontAwesomeNew(
arrowBack,
arrowBackSize,
),
),
),
),
const SizedBox(
width: 16,
),
Center(
child: defaultText(
context,
'Riwayat Transaksi',
maxLines: 1,
overFlow: TextOverflow.ellipsis,
style: appBarNameViewBill(),
),
),
],
),
const SizedBox(
height: 16,
),
Container(
height: 36,
child: TextField(
controller: _searchController,
// autofocus: true,
onChanged: (sarchValue) {
context.read<SearchHistory>().search(
historyOrder,
_searchController.text,
);
},
key: const Key('SearchField'),
style: TextStyle(
color: Colors.black,
fontFamily: fontFamily,
fontSize: 15,
),
decoration: InputDecoration(
filled: true,
fillColor: Colors.white,
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: September',
hintStyle: TextStyle(
color: Colors.grey.withOpacity(0.8),
fontFamily: fontFamily,
fontSize: 10,
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(6),
),
),
),
),
],
),
);
}
}
// ignore_for_file: sized_box_for_whitespace
import 'dart:convert';
import 'package:byod/helper/helper.dart';
import 'package:byod/helper/widget/style.dart';
import 'package:byod/ui/history_order/app_bar.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../bloc/search_history.dart';
import '../viewbill/view_bill_new.dart';
class HistoryOrderNew extends StatelessWidget {
const HistoryOrderNew({
super.key,
required this.historyOrder,
});
final List<String> historyOrder;
@override
Widget build(BuildContext context) {
return SafeArea(
child: GestureDetector(
onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
},
child: Scaffold(
backgroundColor: backgroundColor,
body: Column(
children: [
CustomAppBar(
historyOrder: historyOrder,
),
const SizedBox(
height: 16,
),
BlocBuilder<SearchHistory, List<String>>(
builder: (ctxSearch, historyOrderSearch) {
List<String> historyOrderAfterSearch;
if (historyOrderSearch.isNotEmpty &&
historyOrderSearch[0] == 'start') {
historyOrderAfterSearch = historyOrder;
} else {
historyOrderAfterSearch = historyOrderSearch;
}
return Expanded(
child: ListView.builder(
itemCount: historyOrderAfterSearch.length,
itemBuilder: (ctxHistory, i) {
var jsonDecodeHistory = jsonDecode(
historyOrderAfterSearch[
historyOrderAfterSearch.length - (i + 1)]);
return GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => ViewBillNew(
isHistory: true,
sessionId: jsonDecodeHistory['session'],
branchCodeH: jsonDecodeHistory['branch_code'],
brandCodeH: jsonDecodeHistory['brand'],
token: jsonDecodeHistory['token'],
userName: jsonDecodeHistory['user_name'],
),
),
);
},
child: Container(
margin: const EdgeInsets.only(
bottom: 8,
left: paddingLeftRight,
right: paddingLeftRight,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6),
color: backgroundWhite,
),
height: 72,
child: Container(
padding: const EdgeInsets.only(
left: 16,
right: 12,
bottom: 16,
top: 5,
),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
defaultText(
context,
jsonDecodeHistory['user_name'],
style: historyOrderStyle(),
),
const SizedBox(
height: 4,
),
defaultText(
context,
"Rp ${formatNumber().format(amountParseToInt(jsonDecodeHistory['total_order']))}",
style: historyOrderStyle(),
)
],
),
),
Container(
width: 145,
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
defaultText(
context,
(jsonDecodeHistory['date_order'] ==
null)
? ''
: jsonDecodeHistory['date_order'],
style: historyOrderStyle(
color: textGreyDeskripsi,
),
),
const SizedBox(
height: 15,
),
fontAwesomeNew(
arrowNext,
16,
)
],
),
)
],
),
),
),
);
},
),
);
},
)
],
),
),
));
}
}
...@@ -52,8 +52,8 @@ class _CategoryListHomeState extends State<CategoryListHome> { ...@@ -52,8 +52,8 @@ class _CategoryListHomeState extends State<CategoryListHome> {
.selectedBarMenu(i, widget.categoryList[i].id); .selectedBarMenu(i, widget.categoryList[i].id);
widget.scrollController.animateTo( widget.scrollController.animateTo(
(widget.favList.isNotEmpty) (widget.favList.isNotEmpty)
? 371 ? heighScrollWithImage
: 0, // 371 sudah dihituing pixelnya untuk awal banget dari menu item : imageHeight, // 371 sudah dihituing pixelnya untuk awal banget dari menu item
duration: const Duration(milliseconds: 500), duration: const Duration(milliseconds: 500),
curve: Curves.fastOutSlowIn, curve: Curves.fastOutSlowIn,
); );
......
// ignore_for_file: sized_box_for_whitespace, avoid_unnecessary_containers // ignore_for_file: sized_box_for_whitespace, avoid_unnecessary_containers
import 'package:byod/helper/widget/plus_minus_button.dart';
import 'package:byod/models/orders.dart'; import 'package:byod/models/orders.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
...@@ -211,6 +212,54 @@ class FavGridMenu extends StatelessWidget { ...@@ -211,6 +212,54 @@ class FavGridMenu extends StatelessWidget {
} }
final noteController = TextEditingController( final noteController = TextEditingController(
text: (indexListOrderan != -1) ? list[indexListOrderan].note : ''); text: (indexListOrderan != -1) ? list[indexListOrderan].note : '');
void minus() {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
if (initialValue > 0) {
initialValue -= 1;
context.read<OrdersBloc>().insertData([
[
menuFav.id,
menuFav.name,
initialValue,
amountParseToInt(menuFav.price),
list,
menuFav.imageUrlMedium,
orderVariants,
amountParseToInt(menuFav.price),
(indexListOrderan != -1) ? list[indexListOrderan].note : ''
]
], context);
// setState(() {});
}
}
void plus() {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
initialValue += 1;
context.read<OrdersBloc>().insertData([
[
menuFav.id,
menuFav.name,
initialValue,
amountParseToInt(menuFav.price),
list,
menuFav.imageUrlMedium,
orderVariants,
amountParseToInt(menuFav.price),
(indexListOrderan != -1) ? list[indexListOrderan].note : '',
]
], context);
}
return AnimatedSwitcher( return AnimatedSwitcher(
duration: Duration(milliseconds: animatedTime), duration: Duration(milliseconds: animatedTime),
transitionBuilder: (Widget child, Animation<double> animation) { transitionBuilder: (Widget child, Animation<double> animation) {
...@@ -363,82 +412,89 @@ class FavGridMenu extends StatelessWidget { ...@@ -363,82 +412,89 @@ class FavGridMenu extends StatelessWidget {
const SizedBox( const SizedBox(
width: 5, width: 5,
), ),
GestureDetector( PlusMinusButton(
onTap: () { initialValue: initialValue,
FocusScopeNode currentFocus = FocusScope.of(context); minus: minus,
plus: plus,
backgroundAmountColor: backgroundWhite,
widthInitialValue: 86,
)
// GestureDetector(
// onTap: () {
// FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) { // if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus(); // currentFocus.unfocus();
} // }
if (initialValue > 0) { // if (initialValue > 0) {
initialValue -= 1; // initialValue -= 1;
context.read<OrdersBloc>().insertData([ // context.read<OrdersBloc>().insertData([
[ // [
menuFav.id, // menuFav.id,
menuFav.name, // menuFav.name,
initialValue, // initialValue,
amountParseToInt(menuFav.price), // amountParseToInt(menuFav.price),
list, // list,
menuFav.imageUrlMedium, // menuFav.imageUrlMedium,
orderVariants, // orderVariants,
amountParseToInt(menuFav.price), // amountParseToInt(menuFav.price),
(indexListOrderan != -1) // (indexListOrderan != -1)
? list[indexListOrderan].note // ? list[indexListOrderan].note
: '' // : ''
] // ]
], context); // ], context);
// setState(() {}); // // setState(() {});
} // }
}, // },
child: Container( // child: Container(
width: 22, // width: 22,
height: 22, // height: 22,
child: const Image( // child: const Image(
image: AssetImage('assets/icons/minus-blue.png'), // image: AssetImage('assets/icons/minus-blue.png'),
), // ),
), // ),
), // ),
Expanded( // Expanded(
child: Center( // child: Center(
child: defaultText( // child: defaultText(
context, // context,
initialValue.toString(), // initialValue.toString(),
style: amountGridFav(), // style: amountGridFav(),
), // ),
), // ),
), // ),
GestureDetector( // GestureDetector(
onTap: () { // onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context); // FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) { // if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus(); // currentFocus.unfocus();
} // }
initialValue += 1; // initialValue += 1;
context.read<OrdersBloc>().insertData([ // context.read<OrdersBloc>().insertData([
[ // [
menuFav.id, // menuFav.id,
menuFav.name, // menuFav.name,
initialValue, // initialValue,
amountParseToInt(menuFav.price), // amountParseToInt(menuFav.price),
list, // list,
menuFav.imageUrlMedium, // menuFav.imageUrlMedium,
orderVariants, // orderVariants,
amountParseToInt(menuFav.price), // amountParseToInt(menuFav.price),
(indexListOrderan != -1) // (indexListOrderan != -1)
? list[indexListOrderan].note // ? list[indexListOrderan].note
: '', // : '',
] // ]
], context); // ], context);
}, // },
child: Container( // child: 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'),
), // ),
), // ),
) // )
], ],
), ),
), ),
......
This diff is collapsed.
...@@ -591,35 +591,83 @@ class _NewHome2State extends State<NewHome2> { ...@@ -591,35 +591,83 @@ class _NewHome2State extends State<NewHome2> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
// customAppBar(
// context,
// paddingLeftRight,
// appBarHeight,
// tableNumber,
// userName,
// isSearchActive,
// ),
// SizedBox(
// height: (isSearchActive) ? 16 : 20,
// ),
// AnimatedSwitcher(
// duration: Duration(milliseconds: animatedTime),
// transitionBuilder: (Widget child, Animation<double> animation) {
// return ScaleTransition(scale: animation, child: child);
// },
// child: (isSearchActive)
// ? searchField(
// searchFieldHeight,
// categoryNonFav,
// )
// : const SizedBox(
// key: Key('SearchField'),
// ),
// ),
Expanded(
child: CustomScrollView(
controller: _scrollController,
slivers: [
SliverToBoxAdapter(
child: Container(
padding: const EdgeInsets.only(
top: 16,
),
child: Row(
children: [
const Spacer(),
Container(
width: 209,
height: 80,
child: const Image(
width: 209,
height: 80,
fit: BoxFit.fill,
image: AssetImage('assets/emoji/excelso.png'),
),
),
const Spacer(),
],
),
),
),
SliverPersistentHeader(
pinned: true,
delegate: DelegateAppBar(
appBarHeight + searchFieldHeight,
customAppBar( customAppBar(
context, context,
paddingLeftRight, paddingLeftRight,
appBarHeight, appBarHeight + searchFieldHeight,
tableNumber, tableNumber,
userName, userName,
isSearchActive, isSearchActive,
), ),
SizedBox(
height: (isSearchActive) ? 16 : 20,
), ),
AnimatedSwitcher( ),
duration: Duration(milliseconds: animatedTime), SliverPersistentHeader(
transitionBuilder: (Widget child, Animation<double> animation) { pinned: true,
return ScaleTransition(scale: animation, child: child); delegate: DelegateSearchField(
}, isSearchActive,
child: (isSearchActive) searchFieldHeight,
? searchField( searchField(
searchFieldHeight, searchFieldHeight,
categoryNonFav, categoryNonFav,
)
: const SizedBox(
key: Key('SearchField'),
), ),
), ),
Expanded( ),
child: CustomScrollView(
controller: _scrollController,
slivers: [
SliverToBoxAdapter( SliverToBoxAdapter(
child: SizedBox( child: SizedBox(
height: (isSearchActive) ? spacerHeight : 0, height: (isSearchActive) ? spacerHeight : 0,
...@@ -792,10 +840,12 @@ class _NewHome2State extends State<NewHome2> { ...@@ -792,10 +840,12 @@ class _NewHome2State extends State<NewHome2> {
Container searchField( Container searchField(
double searchFieldHeight, List<FilterMenu> categoryNonFav) { double searchFieldHeight, List<FilterMenu> categoryNonFav) {
return Container( return Container(
margin: const EdgeInsets.only(bottom: 5), padding: const EdgeInsets.only(bottom: 10),
height: searchFieldHeight, height: searchFieldHeight,
color: backgroundColor,
child: TextField( child: TextField(
autofocus: true, autofocus: true,
textAlignVertical: TextAlignVertical.center,
onChanged: (sarchValue) { onChanged: (sarchValue) {
context.read<SearchMenu>().searchMenu( context.read<SearchMenu>().searchMenu(
categoryNonFav, categoryNonFav,
...@@ -812,6 +862,7 @@ class _NewHome2State extends State<NewHome2> { ...@@ -812,6 +862,7 @@ class _NewHome2State extends State<NewHome2> {
decoration: InputDecoration( decoration: InputDecoration(
filled: true, filled: true,
fillColor: Colors.white, fillColor: Colors.white,
contentPadding: EdgeInsets.zero,
enabledBorder: OutlineInputBorder( enabledBorder: OutlineInputBorder(
borderSide: BorderSide( borderSide: BorderSide(
width: 1, width: 1,
...@@ -1080,8 +1131,9 @@ class _NewHome2State extends State<NewHome2> { ...@@ -1080,8 +1131,9 @@ class _NewHome2State extends State<NewHome2> {
barName = "Meja $tableNumber"; barName = "Meja $tableNumber";
} }
return Container( return Container(
margin: const EdgeInsets.only(top: 24), padding: const EdgeInsets.only(top: 10),
height: appBarHeight, height: appBarHeight,
color: backgroundColor,
child: Row( child: Row(
children: [ children: [
defaultText( defaultText(
...@@ -1101,8 +1153,8 @@ class _NewHome2State extends State<NewHome2> { ...@@ -1101,8 +1153,8 @@ class _NewHome2State extends State<NewHome2> {
); );
_scrollController.animateTo( _scrollController.animateTo(
(favList.isNotEmpty) (favList.isNotEmpty)
? 371 ? heighScrollWithImage
: 0, // 371 sudah dihituing pixelnya untuk awal banget dari menu item : imageHeight, // 371 sudah dihituing pixelnya untuk awal banget dari menu item
duration: const Duration(milliseconds: 500), duration: const Duration(milliseconds: 500),
curve: Curves.fastOutSlowIn, curve: Curves.fastOutSlowIn,
); );
...@@ -1197,6 +1249,65 @@ class Delegate extends SliverPersistentHeaderDelegate { ...@@ -1197,6 +1249,65 @@ class Delegate extends SliverPersistentHeaderDelegate {
} }
} }
class DelegateAppBar extends SliverPersistentHeaderDelegate {
final double appBarHeight;
final Widget customAppBar;
DelegateAppBar(
this.appBarHeight,
this.customAppBar,
);
@override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
return customAppBar;
}
@override
double get maxExtent => appBarHeight;
@override
double get minExtent => appBarHeight;
@override
bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) {
return true;
}
}
class DelegateSearchField extends SliverPersistentHeaderDelegate {
final bool isSearchActive;
final double searchFieldHeight;
final Widget searchField;
DelegateSearchField(
this.isSearchActive, this.searchFieldHeight, this.searchField);
@override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
return AnimatedSwitcher(
duration: Duration(milliseconds: animatedTime),
transitionBuilder: (Widget child, Animation<double> animation) {
return ScaleTransition(scale: animation, child: child);
},
child: (isSearchActive)
? searchField
: const SizedBox(
key: Key('SearchField'),
),
);
}
@override
double get maxExtent => (isSearchActive) ? searchFieldHeight : 0;
@override
double get minExtent => (isSearchActive) ? searchFieldHeight : 0;
@override
bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) {
return true;
}
}
class CustomClipPath extends CustomClipper<Path> { class CustomClipPath extends CustomClipper<Path> {
@override @override
Path getClip(Size size) { Path getClip(Size size) {
......
...@@ -4,11 +4,15 @@ import 'package:byod/helper/helper.dart'; ...@@ -4,11 +4,15 @@ import 'package:byod/helper/helper.dart';
import 'package:byod/helper/widget/style.dart'; import 'package:byod/helper/widget/style.dart';
import 'package:byod/models/order_details.dart'; import 'package:byod/models/order_details.dart';
import 'package:byod/ui/home/variant_new.dart'; import 'package:byod/ui/home/variant_new.dart';
import 'package:byod/ui/screen_responsive.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import '../../bloc/order_variant_temporary.dart';
import '../../bloc/order_variant_value.dart'; import '../../bloc/order_variant_value.dart';
import '../../helper/widget/plus_minus_button.dart';
import '../../main.dart'; import '../../main.dart';
import '../../models/order_variants.dart';
import '../../models/variant_categories.dart'; import '../../models/variant_categories.dart';
class VariantCatNew extends StatefulWidget { class VariantCatNew extends StatefulWidget {
...@@ -48,7 +52,7 @@ class _VariantCatNewState extends State<VariantCatNew> { ...@@ -48,7 +52,7 @@ class _VariantCatNewState extends State<VariantCatNew> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
FocusScopeNode currentFocus = FocusScope.of(context); FocusScopeNode currentFocus = FocusScope.of(context);
// double widthScreen = responsiveWidthScreen(context); double widthScreen = responsiveWidthScreen(context);
return SafeArea( return SafeArea(
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
...@@ -58,7 +62,96 @@ class _VariantCatNewState extends State<VariantCatNew> { ...@@ -58,7 +62,96 @@ class _VariantCatNewState extends State<VariantCatNew> {
}, },
child: Scaffold( child: Scaffold(
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
body: Container( body: BlocBuilder<OrderVariantValueBloc, List<OrderVariant>>(
builder: (contextVB, orderVariants) {
return BlocBuilder<OrderVariantTemporaryBloc, List<dynamic>>(
builder: (contextTmp, listOrders) {
var listOrder = listOrders[0];
var itemId = listOrder[0];
var satuanPrice = listOrder[1];
int totalPrice;
var initialValue = listOrder[2];
// var listVariant = listOrder[3];
if (orderVariants.isNotEmpty) {
// totalPrice = 0;
int priceVariant = 0;
for (int z = 0; z < orderVariants.length; z++) {
priceVariant += orderVariants[z].price;
}
totalPrice = (listOrder[1] + priceVariant) * initialValue;
} else {
totalPrice = listOrder[1] * initialValue;
}
return ScreenResponsive(
widget: CoreVariant(
widthScreen: widthScreen,
widget: widget,
orderDetail: orderDetail,
currentFocus: currentFocus,
initialValue: initialValue,
itemId: itemId,
satuanPrice: satuanPrice,
totalPrice: totalPrice,
context: context,
),
isCoreLayout: true,
widthScreen: MediaQuery.of(context).size.width,
);
},
);
},
),
),
));
}
}
class CoreVariant extends StatelessWidget {
CoreVariant({
Key? key,
required this.widthScreen,
required this.widget,
required this.orderDetail,
required this.currentFocus,
required this.initialValue,
required this.itemId,
required this.satuanPrice,
required this.totalPrice,
required this.context,
}) : super(key: key);
final double widthScreen;
final VariantCatNew widget;
final OrderDetail orderDetail;
final FocusScopeNode currentFocus;
late int initialValue;
final String itemId;
final int satuanPrice;
final int totalPrice;
final BuildContext context;
void plus() {
initialValue += 1;
context
.read<OrderVariantTemporaryBloc>()
.insertDataVariant(itemId, satuanPrice, initialValue, []);
}
void minus() {
if (initialValue > 1) {
initialValue += -1;
context
.read<OrderVariantTemporaryBloc>()
.insertDataVariant(itemId, satuanPrice, initialValue, []);
}
}
@override
Widget build(BuildContext context) {
return Container(
width: widthScreen,
child: Stack(
children: [
Container(
padding: const EdgeInsets.symmetric(horizontal: paddingLeftRight), padding: const EdgeInsets.symmetric(horizontal: paddingLeftRight),
child: Column( child: Column(
children: [ children: [
...@@ -118,7 +211,8 @@ class _VariantCatNewState extends State<VariantCatNew> { ...@@ -118,7 +211,8 @@ class _VariantCatNewState extends State<VariantCatNew> {
bottom: bottom:
MediaQuery.of(context).size.height * MediaQuery.of(context).size.height *
0.01, 0.01,
top: MediaQuery.of(context).size.height * top:
MediaQuery.of(context).size.height *
0.01), 0.01),
child: Column( child: Column(
crossAxisAlignment: crossAxisAlignment:
...@@ -126,12 +220,14 @@ class _VariantCatNewState extends State<VariantCatNew> { ...@@ -126,12 +220,14 @@ class _VariantCatNewState extends State<VariantCatNew> {
children: [ children: [
defaultText( defaultText(
context, context,
widget.variantCategories[index].caption, widget
.variantCategories[index].caption,
style: variantStyleText(), style: variantStyleText(),
), ),
defaultText( defaultText(
context, context,
(widget.variantCategories[index].type == (widget.variantCategories[index]
.type ==
typeMandatory) typeMandatory)
? 'Pilih Salah Satu' ? 'Pilih Salah Satu'
: (widget.variantCategories[index] : (widget.variantCategories[index]
...@@ -266,7 +362,63 @@ class _VariantCatNewState extends State<VariantCatNew> { ...@@ -266,7 +362,63 @@ class _VariantCatNewState extends State<VariantCatNew> {
], ],
), ),
), ),
Positioned(
bottom: 0,
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: paddingLeftRight,
), ),
)); width: widthScreen,
height: 118,
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16),
topRight: Radius.circular(16),
),
color: backgroundWhite,
),
child: Column(
children: [
const SizedBox(
height: 21,
),
Row(
children: [
defaultText(context, 'Jumlah Pesanan'),
const Spacer(),
PlusMinusButton(
initialValue: initialValue,
plus: plus,
minus: minus,
isFromVariant: true,
),
],
),
const SizedBox(
height: 14,
),
Container(
height: 43,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(33),
color: buttonColor,
),
child: Center(
child: defaultText(
context,
'Tambahkan - Rp ${formatNumber().format(totalPrice)}',
style: addButton(
font: 14,
),
),
),
)
],
),
),
)
],
),
);
} }
} }
...@@ -25,11 +25,14 @@ class CustomAppBar extends StatelessWidget { ...@@ -25,11 +25,14 @@ class CustomAppBar extends StatelessWidget {
String cashierName = prefs.getString('cashier_name') ?? ''; String cashierName = prefs.getString('cashier_name') ?? '';
String sessionId = prefs.getString('sessionId') ?? ''; String sessionId = prefs.getString('sessionId') ?? '';
return Container( return Container(
margin: const EdgeInsets.only( padding: const EdgeInsets.only(
top: 15, top: 15,
bottom: 30, bottom: 19,
left: paddingLeftRight,
right: paddingLeftRight,
), ),
padding: const EdgeInsets.symmetric(horizontal: paddingLeftRight), // padding: const EdgeInsets.symmetric(horizontal: paddingLeftRight),
color: backgroundWhite,
child: Row( child: Row(
// mainAxisAlignment: MainAxisAlignment.start, // mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
......
This diff is collapsed.
...@@ -24,7 +24,7 @@ class RincianPembayaran extends StatelessWidget { ...@@ -24,7 +24,7 @@ class RincianPembayaran extends StatelessWidget {
vertical: 16, vertical: 16,
), ),
height: 209, height: 209,
// color: Colors.red, color: backgroundWhite,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
......
This diff is collapsed.
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