Commit 1296ca98 authored by Dio Maulana's avatar Dio Maulana

s

parent 41f23cb1
{
"base_url": "https://neo.ravku.com/",
"base_url": "https://58a4-125-165-98-228.ap.ngrok.io/",
"title": "Ravintola Dev BYOD",
"isResponsive": true,
"debug": true
......
......@@ -47,7 +47,8 @@ class Api {
String role, String cashierName, String orderId) async {
String baseUrl = getBaseUrl();
String apiUrl = '$baseUrl${endPoint}get_branch';
String latitude = getLatitude();
String longitude = getLongitude();
String currentSessionId = getSessionId();
const uuidInit = Uuid();
var uuid = uuidInit.v4();
......@@ -65,7 +66,10 @@ class Api {
"cashier_name": cashierName,
"order_id": orderId,
"session_id": sessionId,
"from": fromByod
"from": fromByod,
"url_lookup": 'https://dimas.com',
"customer_lat": latitude,
"customer_long": longitude,
};
var bodies = json.encode(data);
// var apiResult = await http.post(Uri.parse(apiUrl), body: bodies);
......@@ -102,14 +106,12 @@ class Api {
setListHistory(listHistory);
}
setOrderId(jsonObject['data']['order_id']);
// setTableMode(jsonObject['data']['table_mode']);
setLogoUrl(jsonObject['data']['logo']);
setSesssionId(jsonObject['data']['session_id']);
setSecretKey(jsonObject['data']['secret_key']);
setSessionCounter(jsonObject['data']['session_counter']);
//** save sessionID and Table Mode */
// return jsonObject['data']['name'];
setBranch(jsonObject['data']['code']);
setBrand(jsonObject['data']['brand_code']);
return responseByodBranchExist;
} else if (jsonObject['status'] == 'error' &&
(jsonObject['code'] == 'BYOD_ALWAYS_OFF' ||
......@@ -325,8 +327,8 @@ class Api {
"session_id": sessionId,
"count": sessionC,
"sign": signString,
"branch_code": branchCode,
"brand_code": brandCode,
"branch_code": getBranchPref(),
"brand_code": getBrand(),
"role": role,
"cashier_name": cashierName,
"secure_token": tokenUser,
......@@ -803,7 +805,7 @@ class Api {
"total": orderDetail[d]['total'],
"service": orderDetail[d]['service'],
"service_tax": orderDetail[d]['service_tax'],
"order_status": orderDetail[d]['order_status'],
"order_status": orderDetail[d]['order_detail_state'],
"notes": orderDetail[d]['notes'],
"image": orderDetail[d]['image_small'],
"variant": variants
......@@ -827,13 +829,14 @@ class Api {
"total": orderDetail[d]['total'],
"service": orderDetail[d]['service'],
"service_tax": orderDetail[d]['service_tax'],
"order_status": orderDetail[d]['order_status'],
"order_status": orderDetail[d]['order_detail_state'],
"notes": orderDetail[d]['notes'],
"image": orderDetail[d]['image_small'],
"variant": variants
};
billDetail.add(BillDetail.createBillDetail(z));
int totalPerCustomer = amountParseToInt(z['total']);
var i = {
"id": jsonObject['data']['id'],
"total": jsonObject['data']['total'],
......@@ -842,7 +845,7 @@ class Api {
"customer_name": orderDetail[d]['customer_name'],
"table_status": jsonObject['data']['table_status'],
"order_status": jsonObject['data']['order_status'],
"state": jsonObject['data']['state'],
"order_state": jsonObject['data']['order_state'],
"order_detail": billDetail,
"payment_list": paymentList,
"outstanding": jsonObject['data']['outstanding'],
......@@ -852,7 +855,7 @@ class Api {
"my_self_outstanding": jsonObject['data']
['my_self_outstanding'],
"discount_total": jsonObject['data']['discount'],
"table_number": jsonObject['data']['table_number'],
"table_number": jsonObject['data']['table_number'] ?? '',
"is_feedback": jsonObject['data']['is_feedback'],
"doku_minimum_payment": jsonObject['data']
['doku_minimum_payment'],
......
......@@ -581,4 +581,12 @@ const int typeMenu = 3;
//** constanta redirect */
const String goBill = 'go';
//** constanta redirect */
//** No Route Identification */
String emptyUri = 'emptyUri';
String gpsNotActive = 'gpsDisabled';
String locationPermissinDenied = 'locationdisabled';
String configError = 'configError';
String titleError = 'titleError';
//** No Route Identification */
//** END CONSTANT */
......@@ -19,6 +19,11 @@ const String _listHistory = 'list_history';
const String _logo = 'logo';
const String _role = 'role';
const String _cashierName = 'cashier_name';
const String _urlLookUp = 'url';
const String _latitude = 'lat';
const String _longitude = 'long';
const String _titleWeb = 'title';
const String _isDeliveryPickup = 'is_delivery_pickup';
String getBaseUrl() {
return prefs.getString(_baseUrl) ?? '';
......@@ -159,3 +164,43 @@ String getCashierName() {
Future<void> setCashierName(String value) async {
prefs.setString(_cashierName, value);
}
String getUrlLookUp() {
return prefs.getString(_urlLookUp) ?? '';
}
Future<void> setUrlLookUp(String value) async {
prefs.setString(_urlLookUp, value);
}
String getLatitude() {
return prefs.getString(_latitude) ?? '';
}
Future<void> setLatitude(String value) async {
prefs.setString(_latitude, value);
}
String getLongitude() {
return prefs.getString(_longitude) ?? '';
}
Future<void> setLongitude(String value) async {
prefs.setString(_longitude, value);
}
String getTitleWeb() {
return prefs.getString(_titleWeb) ?? '';
}
Future<void> setTitleWeb(String value) async {
prefs.setString(_titleWeb, value);
}
bool getIsDeliveryPickup() {
return prefs.getBool(_isDeliveryPickup) ?? false;
}
Future<void> setIsDeliveryPickup(bool value) async {
prefs.setBool(_isDeliveryPickup, value);
}
......@@ -8,7 +8,9 @@ import 'package:byod/bloc/member_info.dart';
import 'package:byod/bloc/order_bloc.dart';
import 'package:byod/bloc/search_menu.dart';
import 'package:byod/helper/helper.dart';
import 'package:byod/helper/logger.dart';
import 'package:byod/helper/prefs.dart';
import 'package:byod/ui/home/shimmer_menu_new.dart';
import 'package:byod/ui/no_route.dart';
import 'package:byod/ui/splash.dart';
import 'package:flutter/material.dart';
......@@ -33,6 +35,7 @@ import 'bloc/search_active.dart';
import 'bloc/search_history.dart';
import 'bloc/view_bill.dart';
import 'package:flutter/services.dart' as bundle_root;
import 'package:geolocator/geolocator.dart';
import 'bloc/voucher_list.dart';
......@@ -60,13 +63,13 @@ void main() async {
setPathUrlStrategy();
WidgetsFlutterBinding.ensureInitialized();
prefs = await SharedPreferences.getInstance();
configLoading();
loadAssetConfig().then((value) {
loadAssetConfig().then((title) {
setTitleWeb(title);
runApp(
MyApp(
title: value,
title: title,
),
);
});
......@@ -109,7 +112,7 @@ Future<String> loadAssetConfig() async {
}
// ignore: must_be_immutable
class MyApp extends StatelessWidget {
class MyApp extends StatefulWidget {
// String myUrl, branch, brand, tn, role, cashierName, toViewBill;
String title;
MyApp({
......@@ -117,6 +120,38 @@ class MyApp extends StatelessWidget {
required this.title,
}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
Position? _currentPosition;
bool? permissionLocation;
_getCurrentLocation() {
Geolocator.checkPermission().then((value) {
if (value != LocationPermission.denied) {
permissionLocation = true;
Geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.best,
forceAndroidLocationManager: true)
.then((Position position) {
setLatitude(position.latitude.toString());
setLongitude(position.longitude.toString());
setState(() {
_currentPosition = position;
});
}).catchError((e) {
if (debug) {
logd('GET CURRENTLOCATION, MAIN.DART', 'ERROR: $e');
}
});
} else {
permissionLocation = false;
}
});
}
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
......@@ -143,6 +178,16 @@ class MyApp extends StatelessWidget {
String cashierNameStrg = '';
String tokenUser = '';
// Future<bool> getLocationStatus() async {
// LocationPermission? permission;
// permission = await _geolocatorPlatform.requestPermission();
// if (permission == LocationPermission.denied) {
// return false;
// }
// return true;
// }
return MultiBlocProvider(
providers: [
BlocProvider(create: (_) => OrdersBloc()),
......@@ -166,19 +211,29 @@ class MyApp extends StatelessWidget {
BlocProvider(create: (_) => SearchHistory()),
],
child: MaterialApp(
title: (title == null) ? defaultTitle : title,
title: (widget.title == null) ? defaultTitle : widget.title,
builder: EasyLoading.init(),
debugShowCheckedModeBanner: false,
onGenerateRoute: (routes) {
var uri = Uri.parse(routes.name!);
if (uri.pathSegments.isEmpty) {
setTableMode(closebill);
setUrlLookUp(Uri.base.toString());
setIsDeliveryPickup(true);
return MaterialPageRoute(
builder: (context) => NoRoute(
identification: 'emptyUri',
builder: (_) => Splash(
branch: branchStrg,
brand: brandStrg,
tn: tnStrg,
role: roleStrg,
cashierName: cashierNameStrg,
toBill: toBill,
orderId: orderId,
token: tokenUser,
),
);
} else if (uri.pathSegments.length == 2) {
setIsDeliveryPickup(false);
String firstPath = uri.pathSegments.first;
if (firstPath == 'o') {
setTableMode(openBill);
......@@ -199,6 +254,7 @@ class MyApp extends StatelessWidget {
),
);
} else if (uri.pathSegments.length == 3) {
setIsDeliveryPickup(false);
brandStrg = uri.pathSegments.first;
branchStrg = uri.pathSegments[1];
tnStrg = uri.pathSegments[2];
......@@ -216,6 +272,7 @@ class MyApp extends StatelessWidget {
),
);
} else if (uri.pathSegments.length == 4) {
setIsDeliveryPickup(false);
brandStrg = uri.pathSegments.first;
branchStrg = uri.pathSegments[1];
tnStrg = uri.pathSegments[2];
......@@ -240,6 +297,7 @@ class MyApp extends StatelessWidget {
),
);
} else if (uri.pathSegments.length == 5) {
setIsDeliveryPickup(false);
brandStrg = uri.pathSegments.first;
branchStrg = uri.pathSegments[1];
tnStrg = uri.pathSegments[2];
......@@ -267,6 +325,7 @@ class MyApp extends StatelessWidget {
);
}
return null;
}));
}),
);
}
}
......@@ -58,7 +58,7 @@ class Bill {
customerName: json['customer_name'],
tableStatus: json['table_status'],
orderStatus: json['order_status'],
state: json['state'],
state: json['order_state'],
billDetail: json['order_detail'],
paymentList: json['payment_list'],
outStandingPay: json['outstanding'],
......
// ignore_for_file: must_be_immutable
// ignore_for_file: must_be_immutable, avoid_unnecessary_containers
import 'package:byod/helper/helper.dart';
import 'package:byod/helper/prefs.dart';
import 'package:byod/helper/widget/style.dart';
import 'package:byod/main.dart';
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import '../helper/widget/button_modal.dart';
class NoRoute extends StatelessWidget {
String identification;
......@@ -32,26 +37,66 @@ class NoRoute extends StatelessWidget {
SizedBox(
height: MediaQuery.of(context).size.height * 0.05,
),
(identification == 'titleError')
(identification == titleError)
? defaultText(
context,
"Scan QR Atau Kunjungi Alamat Outlet (Error: title)",
textAlign: TextAlign.center,
style: textStyleNormalFont(context),
)
: (identification == 'configError')
: (identification == configError)
? defaultText(
context,
"Scan QR Atau Kunjungi Alamat Outlet (Error: config)",
textAlign: TextAlign.center,
style: textStyleNormalFont(context),
)
: (identification == gpsNotActive)
? defaultText(
context,
"Delivery/Pickup order memerlukan akses GPS",
textAlign: TextAlign.center,
style: textStyleNormalFont(context),
)
: (identification == locationPermissinDenied)
? defaultText(
context,
"Delivery/Pickup order memerlukan akses lokasi anda",
textAlign: TextAlign.center,
style: textStyleNormalFont(context),
)
: defaultText(
context,
"Scan QR Atau Kunjungi Alamat Outlet",
textAlign: TextAlign.center,
style: textStyleNormalFont(context),
),
(identification == locationPermissinDenied)
? GestureDetector(
onTap: () {
Geolocator.requestPermission().then((value) {
if (value != LocationPermission.denied) {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (_) => MyApp(
title: getTitleWeb(),
),
),
);
}
});
},
child: Container(
margin: const EdgeInsets.only(top: 15),
width: 200,
child: ButtonComponent(
buttonColor: buttonColor,
teksButton: 'Aktifkan Lokasi',
),
),
)
: const SizedBox()
],
),
)));
......
......@@ -9,19 +9,29 @@ import 'package:byod/ui/no_route.dart';
import 'package:byod/ui/viewbill/view_bill_new.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:geolocator/geolocator.dart';
import '../bloc/branch_exist.dart';
import '../main.dart';
import 'package:flutter/services.dart' as bundle_root;
import 'home/new_home2.dart';
import 'home/shimmer_menu.dart';
import 'home/shimmer_menu_new.dart';
import 'screen_responsive.dart';
class Splash extends StatefulWidget {
final String branch, brand, tn, role, cashierName, toBill, orderId, token;
const Splash(
{Key? key,
final String branch,
brand,
tn,
role,
cashierName,
toBill,
orderId,
token,
url,
lat,
long;
const Splash({
Key? key,
required this.branch,
required this.brand,
required this.tn,
......@@ -29,8 +39,11 @@ class Splash extends StatefulWidget {
required this.cashierName,
required this.toBill,
required this.orderId,
required this.token})
: super(key: key);
required this.token,
this.url = '',
this.lat = '',
this.long = '',
}) : super(key: key);
@override
State<Splash> createState() => _SplashState();
......@@ -55,6 +68,11 @@ class _SplashState extends State<Splash> {
@override
void initState() {
loadBaseUrl().then((baseUrl) {
Geolocator.checkPermission().then((permission) {
if (permission != LocationPermission.denied) {
Geolocator.getCurrentPosition().then((position) {
setLatitude(position.latitude.toString());
setLongitude(position.longitude.toString());
setBaseUrl(baseUrl);
context.read<BranchExist>().branchExist(
widget.branch,
......@@ -65,6 +83,19 @@ class _SplashState extends State<Splash> {
context,
getMenu: true,
);
});
} else {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (_) => NoRoute(
identification: locationPermissinDenied,
),
),
);
}
});
// context.read<CategoryMenu>().catAndMenu(widget.branch, widget.brand,
// widget.role, widget.cashierName, widget.token);
......@@ -76,8 +107,8 @@ class _SplashState extends State<Splash> {
}
Future.delayed(const Duration(milliseconds: 1000), () async {
setToken(widget.token);
setBranch(widget.branch);
setBrand(widget.brand);
// setBranch(widget.branch);
// setBrand(widget.brand);
setTableNumber(widget.tn);
setRole(widget.role);
setCashierName(widget.cashierName);
......
......@@ -23,7 +23,7 @@ class CustomAppBar extends StatelessWidget {
String brandCode = getBrand();
String role = getRole();
String cashierName = getCashierName();
String sessionId = getOrderId();
String orderId = getOrderId();
return Container(
padding: const EdgeInsets.only(
top: 15,
......@@ -46,7 +46,7 @@ class CustomAppBar extends StatelessWidget {
brandCode,
role,
cashierName,
sessionId,
orderId,
context,
);
} else {
......
......@@ -5,10 +5,12 @@
import FlutterMacOS
import Foundation
import geolocator_apple
import shared_preferences_macos
import url_launcher_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
}
......@@ -135,6 +135,48 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
geolocator:
dependency: "direct main"
description:
name: geolocator
url: "https://pub.dartlang.org"
source: hosted
version: "9.0.2"
geolocator_android:
dependency: transitive
description:
name: geolocator_android
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.3"
geolocator_apple:
dependency: transitive
description:
name: geolocator_apple
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.2"
geolocator_platform_interface:
dependency: transitive
description:
name: geolocator_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.6"
geolocator_web:
dependency: transitive
description:
name: geolocator_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.6"
geolocator_windows:
dependency: transitive
description:
name: geolocator_windows
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.1"
html:
dependency: transitive
description:
......
......@@ -33,6 +33,7 @@ dependencies:
sdk: flutter
flutter_bloc: ^8.0.1
flutter_easyloading: ^3.0.3
geolocator: ^9.0.2
http: ^0.13.4
intl: ^0.17.0
loading_animations: ^2.2.0
......
......@@ -6,9 +6,12 @@
#include "generated_plugin_registrant.h"
#include <geolocator_windows/geolocator_windows.h>
#include <url_launcher_windows/url_launcher_windows.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
GeolocatorWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("GeolocatorWindows"));
UrlLauncherWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
}
......@@ -3,6 +3,7 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
geolocator_windows
url_launcher_windows
)
......
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