final
This commit is contained in:
@@ -3,10 +3,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:photo_view/photo_view.dart';
|
||||
|
||||
class ImageViewer extends StatefulWidget {
|
||||
final Key key;
|
||||
final ImageProvider imageProvider;
|
||||
|
||||
ImageViewer(this.imageProvider, {this.key}) :
|
||||
ImageViewer(this.imageProvider, {Key? key}) :
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
|
||||
@@ -33,18 +33,15 @@ AlertDialog logoutDialog(BuildContext context) {
|
||||
.yes_i_am_sure),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
Utils.getBox().then((box) {
|
||||
box.delete(Constants.KEY_USER_ID);
|
||||
box.delete(
|
||||
Constants.KEY_ACCESS_TOKEN);
|
||||
store.dispatch(
|
||||
new UpdateCurrentUser(null));
|
||||
eventBus.fire(
|
||||
new OnCurrentUserUpdated());
|
||||
Routes.router.navigateTo(
|
||||
context, '/', replace: true,
|
||||
clearStack: true);
|
||||
});
|
||||
Utils.prefs?.remove(Constants.KEY_USER_ID);
|
||||
Utils.prefs?.remove(Constants.KEY_ACCESS_TOKEN);
|
||||
store.dispatch(
|
||||
new UpdateCurrentUser(null));
|
||||
eventBus.fire(
|
||||
new OnCurrentUserUpdated());
|
||||
Routes.router.navigateTo(
|
||||
context, '/', replace: true,
|
||||
clearStack: true);
|
||||
},
|
||||
)
|
||||
],
|
||||
|
||||
@@ -87,7 +87,7 @@ class OnProductWillAddToCart {
|
||||
double price;
|
||||
String description;
|
||||
Business business;
|
||||
GlobalKey buttonKey;
|
||||
GlobalKey? buttonKey;
|
||||
OnProductWillAddToCart(this.product, this.selections, this.price, this.description, this.business, {this.buttonKey});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:catcher/catcher.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:flutter_wisetronic/pages/buy_service.dart';
|
||||
@@ -14,12 +9,8 @@ import 'pages/create_online_store_1.dart';
|
||||
import 'pages/download.dart';
|
||||
import 'pages/me.dart';
|
||||
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
||||
import 'package:splashscreen/splashscreen.dart';
|
||||
// import 'package:uni_links/uni_links.dart';
|
||||
|
||||
import 'constants.dart';
|
||||
import 'events/eventbus.dart';
|
||||
import 'events/events.dart';
|
||||
import 'generated/l10n.dart';
|
||||
import 'pages/home.dart';
|
||||
import 'pages/plain_page.dart';
|
||||
@@ -34,20 +25,14 @@ import 'utils/utils.dart';
|
||||
|
||||
void main() {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
// Enable configureApp will cause route problem.
|
||||
// configureApp();
|
||||
setPathUrlStrategy();
|
||||
runApp(MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
String _to = '/';
|
||||
|
||||
MyApp() {
|
||||
Routes.configure();
|
||||
Utils().init();
|
||||
Util().init();
|
||||
// getCurrentPosition();
|
||||
}
|
||||
|
||||
static getCurrentPosition() async {
|
||||
@@ -95,27 +80,8 @@ class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
Widget _buildBody() {
|
||||
return SplashScreen(
|
||||
seconds: 5,
|
||||
routeName: _to,
|
||||
navigateAfterSeconds: Home(title: Constants.APP_TITLE,),
|
||||
styleTextUnderTheLoader: new TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 20.0,
|
||||
),
|
||||
imageBackground: (Image.network(Constants.BASE_API_URL + 'gallery/get-minimanager-splash/')).image,
|
||||
backgroundColor: Colors.white,
|
||||
onClick: () {
|
||||
|
||||
},
|
||||
loaderColor: Colors.blue,
|
||||
);
|
||||
}
|
||||
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: Constants.DEBUG,
|
||||
navigatorKey: kIsWeb ? null : Catcher.navigatorKey,
|
||||
localizationsDelegates: [
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
@@ -124,20 +90,26 @@ class MyApp extends StatelessWidget {
|
||||
S.delegate,
|
||||
],
|
||||
supportedLocales: S.delegate.supportedLocales,
|
||||
localeResolutionCallback: (Locale locale, Iterable<Locale> supportedLocales) {
|
||||
print('Language code: ${locale.languageCode}, Country code: ${locale.countryCode}');
|
||||
for (final supportedLocale in supportedLocales) {
|
||||
if (supportedLocale.languageCode == locale.languageCode) {
|
||||
store.dispatch(UpdateLocale(locale));
|
||||
return supportedLocale;
|
||||
localeResolutionCallback: (Locale? locale, Iterable<Locale>? supportedLocales) {
|
||||
print('Language code: ${locale?.languageCode}, Country code: ${locale?.countryCode}');
|
||||
if (locale != null && supportedLocales != null) {
|
||||
for (final supportedLocale in supportedLocales) {
|
||||
if (supportedLocale.languageCode == locale.languageCode) {
|
||||
store.dispatch(UpdateLocale(locale));
|
||||
return supportedLocale;
|
||||
}
|
||||
}
|
||||
}
|
||||
store.dispatch(UpdateLocale(supportedLocales.first));
|
||||
store.dispatch(UpdateLocale(supportedLocales.first));
|
||||
return supportedLocales.first;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
onGenerateRoute: (RouteSettings settings) {
|
||||
final List<String> pathElements = settings.name.split('/');
|
||||
print('path elements: $pathElements');
|
||||
final uri = Uri.parse(settings.name!);
|
||||
final path = uri.path;
|
||||
print('path: $path');
|
||||
final List<String> pathElements = path.split('/');
|
||||
print('path elements --> $pathElements');
|
||||
if (pathElements[0] != '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class Address {
|
||||
int id;
|
||||
String addressLine1;
|
||||
String addressLine2;
|
||||
String city;
|
||||
String state;
|
||||
String country;
|
||||
String zip;
|
||||
String phone;
|
||||
String fax;
|
||||
String email;
|
||||
String contactName;
|
||||
int gender;
|
||||
String lat;
|
||||
String lng;
|
||||
String fullAddress;
|
||||
int? id;
|
||||
String? addressLine1;
|
||||
String? addressLine2;
|
||||
String? city;
|
||||
String? state;
|
||||
String? country;
|
||||
String? zip;
|
||||
String? phone;
|
||||
String? fax;
|
||||
String? email;
|
||||
String? contactName;
|
||||
int? gender;
|
||||
String? lat;
|
||||
String? lng;
|
||||
String? fullAddress;
|
||||
|
||||
Address.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
|
||||
@@ -58,7 +58,7 @@ class Business {
|
||||
String chaseXLogin;
|
||||
String chaseTransactionKey;
|
||||
String chaseResponseKey;
|
||||
DistanceInfo distanceInfo;
|
||||
DistanceInfo? distanceInfo;
|
||||
int commentsCount;
|
||||
bool forceClose;
|
||||
bool isPublic;
|
||||
|
||||
@@ -7,18 +7,18 @@ import 'cart_line_item.dart';
|
||||
import 'extra_fee.dart';
|
||||
|
||||
class CartInfo {
|
||||
int id;
|
||||
double originPrice;
|
||||
double discountPrice;
|
||||
double totalPrice;
|
||||
Business businessInfo;
|
||||
List<CartLineItem> productList;
|
||||
List<ExtraFee> extraFeeList;
|
||||
List<ExtraFee> discountList;
|
||||
int deliveryMethod;
|
||||
String shippingMethod;
|
||||
double amountPaid;
|
||||
String extraData;
|
||||
int? id;
|
||||
double? originPrice;
|
||||
double? discountPrice;
|
||||
double? totalPrice;
|
||||
Business? businessInfo;
|
||||
List<CartLineItem>? productList;
|
||||
List<ExtraFee>? extraFeeList;
|
||||
List<ExtraFee>? discountList;
|
||||
int? deliveryMethod;
|
||||
String? shippingMethod;
|
||||
double? amountPaid;
|
||||
String? extraData;
|
||||
|
||||
CartInfo.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
@@ -53,7 +53,7 @@ class CartInfo {
|
||||
if (productList == null) {
|
||||
productList = [item];
|
||||
} else {
|
||||
productList.add(item);
|
||||
productList!.add(item);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -74,19 +74,19 @@ class CartInfo {
|
||||
originPrice = 0.0;
|
||||
discountPrice = 0.0;
|
||||
totalPrice = 0.0;
|
||||
for (var i = 0; i < productList.length; i++) {
|
||||
newTotal += productList[i].getTotalPrice();
|
||||
for (var i = 0; i < productList!.length; i++) {
|
||||
newTotal += productList![i].getTotalPrice();
|
||||
}
|
||||
originPrice = newTotal;
|
||||
totalPrice = newTotal;
|
||||
return totalPrice;
|
||||
return totalPrice!;
|
||||
}
|
||||
|
||||
int getProductListTotalQuantity() {
|
||||
int qty = 0;
|
||||
if (productList != null && productList.length > 0) {
|
||||
for (var i = 0; i < productList.length; i++) {
|
||||
qty += productList[i].quantity.round();
|
||||
if (productList != null && productList!.length > 0) {
|
||||
for (var i = 0; i < productList!.length; i++) {
|
||||
qty += productList![i].quantity!.round();
|
||||
}
|
||||
}
|
||||
return qty;
|
||||
|
||||
@@ -6,15 +6,15 @@ import 'package:uuid/uuid.dart';
|
||||
import 'product.dart';
|
||||
|
||||
class CartLineItem {
|
||||
int id;
|
||||
double unitPrice;
|
||||
double totalPrice;
|
||||
Product product;
|
||||
String name;
|
||||
String description;
|
||||
double quantity;
|
||||
String uuid;
|
||||
String parentUuid;
|
||||
int? id;
|
||||
double? unitPrice;
|
||||
double? totalPrice;
|
||||
Product? product;
|
||||
String? name;
|
||||
String? description;
|
||||
double? quantity;
|
||||
String? uuid;
|
||||
String? parentUuid;
|
||||
|
||||
CartLineItem() {
|
||||
uuid = Uuid().v4();
|
||||
@@ -48,7 +48,7 @@ class CartLineItem {
|
||||
}
|
||||
|
||||
double getTotalPrice() {
|
||||
totalPrice = unitPrice * quantity;
|
||||
return totalPrice;
|
||||
totalPrice = unitPrice! * quantity!;
|
||||
return totalPrice!;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ class Coupon {
|
||||
String description;
|
||||
String expirationDate;
|
||||
double minAmount;
|
||||
Business store;
|
||||
Business? store;
|
||||
double valueAmount;
|
||||
bool isPercentage;
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@ import 'dart:convert';
|
||||
import 'text_value.dart';
|
||||
|
||||
class DistanceInfo {
|
||||
TextValue duration;
|
||||
TextValue distance;
|
||||
String status;
|
||||
TextValue? duration;
|
||||
TextValue? distance;
|
||||
String? status;
|
||||
|
||||
DistanceInfo.fromJson(Map<String, dynamic> json)
|
||||
: duration = json['duration'] != null ? TextValue.fromJson(json['duration']) : null,
|
||||
|
||||
@@ -14,8 +14,8 @@ class Order {
|
||||
int id;
|
||||
int userId;
|
||||
int businessId;
|
||||
Business businessInfo;
|
||||
CartInfo cartInfo;
|
||||
Business? businessInfo;
|
||||
CartInfo? cartInfo;
|
||||
int status;
|
||||
double originPrice;
|
||||
double discountPrice;
|
||||
@@ -23,7 +23,7 @@ class Order {
|
||||
String consignee;
|
||||
String phone;
|
||||
String address;
|
||||
Address shippingAddress;
|
||||
Address? shippingAddress;
|
||||
int payMethod;
|
||||
String remark;
|
||||
String orderNum;
|
||||
@@ -33,11 +33,11 @@ class Order {
|
||||
String paymentStatus; // UNPAID, PAID, PARTIALPAID
|
||||
double amountPaid;
|
||||
List<Fulfillment> fulfillments;
|
||||
String extraData;
|
||||
String? extraData;
|
||||
bool hasComment;
|
||||
double fee;
|
||||
UserPosition shipperPosition;
|
||||
DistanceInfo deliveryDistance;
|
||||
DistanceInfo? deliveryDistance;
|
||||
|
||||
Order.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
@@ -100,8 +100,10 @@ class Order {
|
||||
|
||||
double getSubtotal() {
|
||||
double subtotal = 0.0;
|
||||
for (CartLineItem lineItem in cartInfo.productList) {
|
||||
subtotal += lineItem.getTotalPrice();
|
||||
if (cartInfo != null) {
|
||||
for (CartLineItem lineItem in cartInfo!.productList!) {
|
||||
subtotal += lineItem.getTotalPrice();
|
||||
}
|
||||
}
|
||||
return subtotal;
|
||||
}
|
||||
|
||||
@@ -6,19 +6,19 @@ import 'package:flutter/cupertino.dart';
|
||||
import '../generated/l10n.dart';
|
||||
|
||||
class PaymentPlatform {
|
||||
int id;
|
||||
String name;
|
||||
String code;
|
||||
String method;
|
||||
String icon;
|
||||
String xLogin;
|
||||
String transactionKey;
|
||||
String responseKey;
|
||||
String squareAppId;
|
||||
String squareAccessToken;
|
||||
String squareLocationId;
|
||||
String publishableKey;
|
||||
String merchantId;
|
||||
int? id;
|
||||
String? name;
|
||||
String? code;
|
||||
String? method;
|
||||
String? icon;
|
||||
String? xLogin;
|
||||
String? transactionKey;
|
||||
String? responseKey;
|
||||
String? squareAppId;
|
||||
String? squareAccessToken;
|
||||
String? squareLocationId;
|
||||
String? publishableKey;
|
||||
String? merchantId;
|
||||
|
||||
PaymentPlatform(this.code);
|
||||
|
||||
@@ -57,16 +57,12 @@ class PaymentPlatform {
|
||||
switch(code) {
|
||||
case 'chase':
|
||||
return S.of(context).credit_debit_card;
|
||||
break;
|
||||
case 'web-credit-card':
|
||||
return S.of(context).credit_card;
|
||||
break;
|
||||
case 'ALIPAY':
|
||||
return S.of(context).alipay;
|
||||
break;
|
||||
case 'WECHATPAY':
|
||||
return S.of(context).wechatpay;
|
||||
break;
|
||||
case 'paypal':
|
||||
return S.of(context).paypal;
|
||||
case 'payondeliverypickup':
|
||||
|
||||
@@ -3,7 +3,7 @@ class Position {
|
||||
final double latitude;
|
||||
final double longitude;
|
||||
|
||||
Position({this.latitude, this.longitude});
|
||||
Position({required this.latitude, required this.longitude});
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
|
||||
@@ -5,23 +5,23 @@ import 'Subproduct.dart';
|
||||
import 'product_attribute.dart';
|
||||
|
||||
class Product {
|
||||
int id;
|
||||
int businessId;
|
||||
int categoryId;
|
||||
String name;
|
||||
double price;
|
||||
double regularPrice;
|
||||
String description;
|
||||
String detailDescription;
|
||||
String imagePath;
|
||||
String secondImagePath;
|
||||
double monthSales;
|
||||
int rate;
|
||||
double leftNum;
|
||||
List<ProductAttribute> productAttributes;
|
||||
bool nonInventory;
|
||||
String extraData;
|
||||
List<Subproduct> subproducts;
|
||||
int? id;
|
||||
int? businessId;
|
||||
int? categoryId;
|
||||
String? name;
|
||||
double? price;
|
||||
double? regularPrice;
|
||||
String? description;
|
||||
String? detailDescription;
|
||||
String? imagePath;
|
||||
String? secondImagePath;
|
||||
double? monthSales;
|
||||
int? rate;
|
||||
double? leftNum;
|
||||
List<ProductAttribute>? productAttributes;
|
||||
bool? nonInventory;
|
||||
String? extraData;
|
||||
List<Subproduct>? subproducts;
|
||||
|
||||
Product(int id, int businessId, String name, double price, String description,
|
||||
String imagePath, List<ProductAttribute> productAttributes) {
|
||||
|
||||
@@ -10,7 +10,7 @@ class ProductAttribute {
|
||||
bool singleSelection;
|
||||
bool byQuantity;
|
||||
bool required;
|
||||
String extra;
|
||||
String? extra;
|
||||
bool disabled;
|
||||
|
||||
ProductAttribute.fromJson(Map<String, dynamic> json)
|
||||
|
||||
@@ -4,8 +4,8 @@ import 'dart:convert';
|
||||
import 'waiting_line_item.dart';
|
||||
|
||||
class WaitingLine {
|
||||
List<WaitingLineItem> waitingLines;
|
||||
String storeSn;
|
||||
List<WaitingLineItem>? waitingLines;
|
||||
String? storeSn;
|
||||
|
||||
WaitingLine.fromJson(Map<String, dynamic> json)
|
||||
: waitingLines = (json['waiting_lines'] as List).map((i) => WaitingLineItem.fromJson(i)).toList(),
|
||||
|
||||
@@ -8,19 +8,16 @@ import '../models/product.dart';
|
||||
class AttributeSelection extends StatelessWidget {
|
||||
final Product product;
|
||||
final Business business;
|
||||
final GlobalKey startKey;
|
||||
final GlobalKey? startKey;
|
||||
|
||||
const AttributeSelection({Key key, this.product, this.business, this.startKey}) : super(key: key);
|
||||
const AttributeSelection({Key? key, required this.product, required this.business, this.startKey}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ResponsiveBuilder(
|
||||
builder: (context, sizingInformation) =>
|
||||
ScreenTypeLayout(
|
||||
mobile: MobileAttributeSelection(product: product, business: business, startKey: startKey,),
|
||||
tablet: MobileAttributeSelection(product: product, business: business, startKey: startKey,),
|
||||
desktop: MobileAttributeSelection(product: product, business: business, startKey: startKey,),
|
||||
),
|
||||
return ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileAttributeSelection(product: product, business: business, startKey: startKey),
|
||||
tablet: (context) => MobileAttributeSelection(product: product, business: business, startKey: startKey),
|
||||
desktop: (context) => MobileAttributeSelection(product: product, business: business, startKey: startKey),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,24 +8,20 @@ import '../widgets/desktop/desktop_blog.dart';
|
||||
import '../widgets/mobile/mobile_blog.dart';
|
||||
|
||||
class Blog extends StatelessWidget {
|
||||
final Key key;
|
||||
final int businessId;
|
||||
|
||||
const Blog({this.key, int businessId}) :
|
||||
const Blog({Key? key, required int businessId}) :
|
||||
businessId = businessId ?? Constants.BUSINESS_ID;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ResponsiveBuilder(
|
||||
builder: (context, sizingInformation) =>
|
||||
ScreenTypeLayout(
|
||||
mobile: MobileBlog(businessId: businessId,),
|
||||
tablet: DesktopBlog(businessId: businessId,),
|
||||
desktop: Scrollbar(
|
||||
isAlwaysShown: true,
|
||||
child: DesktopBlog(businessId: businessId,),
|
||||
),
|
||||
),
|
||||
return ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileBlog(businessId: businessId),
|
||||
tablet: (context) => DesktopBlog(businessId: businessId),
|
||||
desktop: (context) => Scrollbar(
|
||||
thumbVisibility: true,
|
||||
child: DesktopBlog(businessId: businessId),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ import '../widgets/mobile/mobile_renew_license.dart';
|
||||
class BuyService extends StatefulWidget {
|
||||
final int gid;
|
||||
final String serviceName;
|
||||
final String domain;
|
||||
final int sid;
|
||||
final String? domain;
|
||||
final int? sid;
|
||||
|
||||
const BuyService(this.gid, this.serviceName, {Key key, this.domain, this.sid = 0}) :
|
||||
const BuyService(this.gid, this.serviceName, {Key? key, this.domain, this.sid = 0}) :
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
@@ -30,7 +30,7 @@ class BuyService extends StatefulWidget {
|
||||
}
|
||||
|
||||
class BuyServiceState extends State<BuyService> {
|
||||
Map<String, dynamic> data;
|
||||
Map<String, dynamic>? data;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -48,13 +48,10 @@ class BuyServiceState extends State<BuyService> {
|
||||
);
|
||||
}
|
||||
|
||||
return ResponsiveBuilder(
|
||||
builder: (context, sizingInformation) =>
|
||||
ScreenTypeLayout(
|
||||
mobile: MobileBuyService(data),
|
||||
tablet: DesktopBuyService(data),
|
||||
desktop: DesktopBuyService(data),
|
||||
),
|
||||
return ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileBuyService(data),
|
||||
tablet: (context) => DesktopBuyService(data),
|
||||
desktop: (context) => DesktopBuyService(data),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -73,7 +70,7 @@ class BuyServiceState extends State<BuyService> {
|
||||
}
|
||||
).then((value) {
|
||||
data = value;
|
||||
data['domain'] = widget.domain;
|
||||
data?['domain'] = widget.domain;
|
||||
print('data: $data');
|
||||
setState(() {});
|
||||
}).onError((error, stackTrace) {
|
||||
|
||||
@@ -15,7 +15,7 @@ import '../widgets/mobile/mobile_change_mobile_or_email.dart';
|
||||
class ChangeMobileOrEmail extends StatelessWidget {
|
||||
final bool isMobile;
|
||||
|
||||
const ChangeMobileOrEmail(this.isMobile, {Key key}) : super(key: key);
|
||||
const ChangeMobileOrEmail(this.isMobile, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -31,15 +31,15 @@ class ChangeMobileOrEmail extends StatelessWidget {
|
||||
breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT,
|
||||
),
|
||||
drawer: null,
|
||||
body: ScreenTypeLayout(
|
||||
mobile: MobileChangeMobileOrEmail(isMobile),
|
||||
tablet: DesktopChangeMobileOrEmail(isMobile),
|
||||
desktop: DesktopChangeMobileOrEmail(isMobile),
|
||||
body: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileChangeMobileOrEmail(isMobile),
|
||||
tablet: (context) => DesktopChangeMobileOrEmail(isMobile),
|
||||
desktop: (context) => DesktopChangeMobileOrEmail(isMobile),
|
||||
),
|
||||
bottomNavigationBar: ScreenTypeLayout(
|
||||
mobile: MobileBottomNav(currentIndex: 0,),
|
||||
tablet: BottomNav(),
|
||||
desktop: BottomNav(),
|
||||
bottomNavigationBar: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileBottomNav(currentIndex: 0,),
|
||||
tablet: (context) => BottomNav(),
|
||||
desktop: (context) => BottomNav(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -29,15 +29,15 @@ class ChangePassword extends StatelessWidget {
|
||||
breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT,
|
||||
),
|
||||
drawer: null,
|
||||
body: ScreenTypeLayout(
|
||||
mobile: MobileChangePassword(),
|
||||
tablet: DesktopChangePassword(),
|
||||
desktop: DesktopChangePassword(),
|
||||
body: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileChangePassword(),
|
||||
tablet: (context) => DesktopChangePassword(),
|
||||
desktop: (context) => DesktopChangePassword(),
|
||||
),
|
||||
bottomNavigationBar: ScreenTypeLayout(
|
||||
mobile: MobileBottomNav(currentIndex: 0,),
|
||||
tablet: BottomNav(),
|
||||
desktop: BottomNav(),
|
||||
bottomNavigationBar: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileBottomNav(currentIndex: 0,),
|
||||
tablet: (context) => BottomNav(),
|
||||
desktop: (context) => BottomNav(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -11,7 +11,7 @@ import '../widgets/mobile/mobile_checkout.dart';
|
||||
class Checkout extends StatelessWidget {
|
||||
final int businessId;
|
||||
|
||||
const Checkout(this.businessId, {Key key}) :
|
||||
const Checkout(this.businessId, {Key? key}) :
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
@@ -20,10 +20,10 @@ class Checkout extends StatelessWidget {
|
||||
|
||||
return ResponsiveBuilder(
|
||||
builder: (context, sizingInformation) =>
|
||||
ScreenTypeLayout(
|
||||
mobile: MobileCheckout(businessId),
|
||||
tablet: DesktopCheckout(businessId),
|
||||
desktop: DesktopCheckout(businessId),
|
||||
ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileCheckout(businessId),
|
||||
tablet: (context) => DesktopCheckout(businessId),
|
||||
desktop: (context) => DesktopCheckout(businessId),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import '../widgets/mobile/mobile_contact_us.dart';
|
||||
class ContactUs extends StatefulWidget {
|
||||
final int businessId;
|
||||
|
||||
const ContactUs({this.businessId, Key key}) :
|
||||
const ContactUs({required this.businessId, Key? key}) :
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
@@ -22,7 +22,7 @@ class ContactUs extends StatefulWidget {
|
||||
}
|
||||
|
||||
class ContactUsState extends State<ContactUs> {
|
||||
Business business;
|
||||
Business? business;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -42,10 +42,10 @@ class ContactUsState extends State<ContactUs> {
|
||||
|
||||
return ResponsiveBuilder(
|
||||
builder: (context, sizingInformation) =>
|
||||
ScreenTypeLayout(
|
||||
mobile: MobileContactUs(business),
|
||||
tablet: DesktopContactUs(business),
|
||||
desktop: DesktopContactUs(business),
|
||||
ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileContactUs(business!),
|
||||
tablet: (context) => DesktopContactUs(business!),
|
||||
desktop: (context) => DesktopContactUs(business!),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import '../widgets/mobile/mobile_coupons.dart';
|
||||
class Coupons extends StatelessWidget {
|
||||
final int contactId;
|
||||
|
||||
const Coupons(this.contactId, {Key key}) :
|
||||
const Coupons(this.contactId, {Key? key}) :
|
||||
super(key: key);
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ class Coupons extends StatelessWidget {
|
||||
|
||||
return ResponsiveBuilder(
|
||||
builder: (context, sizingInformation) =>
|
||||
ScreenTypeLayout(
|
||||
mobile: MobileCoupons(contactId,),
|
||||
tablet: DesktopCoupons(contactId,),
|
||||
desktop: DesktopCoupons(contactId,),
|
||||
ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileCoupons(contactId,),
|
||||
tablet: (context) => DesktopCoupons(contactId,),
|
||||
desktop: (context) => DesktopCoupons(contactId,),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import '../widgets/mobile/create_online_store_1.dart' as mobile;
|
||||
|
||||
class CreateOnlineStore1 extends StatefulWidget {
|
||||
|
||||
const CreateOnlineStore1({Key key}) :
|
||||
const CreateOnlineStore1({Key? key}) :
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
@@ -33,10 +33,10 @@ class CreateOnlineStore1State extends State<CreateOnlineStore1> {
|
||||
|
||||
return ResponsiveBuilder(
|
||||
builder: (context, sizingInformation) =>
|
||||
ScreenTypeLayout(
|
||||
mobile: mobile.CreateOnlineStore1(Constants.BUSINESS_ID),
|
||||
tablet: desktop.CreateOnlineStore1(Constants.BUSINESS_ID),
|
||||
desktop: desktop.CreateOnlineStore1(Constants.BUSINESS_ID),
|
||||
ScreenTypeLayout.builder(
|
||||
mobile: (context) => mobile.CreateOnlineStore1(Constants.BUSINESS_ID),
|
||||
tablet: (context) => desktop.CreateOnlineStore1(Constants.BUSINESS_ID),
|
||||
desktop: (context) => desktop.CreateOnlineStore1(Constants.BUSINESS_ID),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class Download extends StatefulWidget {
|
||||
|
||||
class DownloadState extends State<Download> {
|
||||
final _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
Map<String, dynamic> data;
|
||||
Map<String, dynamic>? data;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -57,18 +57,18 @@ class DownloadState extends State<Download> {
|
||||
breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT,
|
||||
),
|
||||
drawer: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? MobileNavigationDrawer() : null,
|
||||
body: ScreenTypeLayout(
|
||||
mobile: MobileDownloadApps(data),
|
||||
tablet: DesktopDownloadApps(data),
|
||||
desktop: Scrollbar(
|
||||
isAlwaysShown: true,
|
||||
child: DesktopDownloadApps(data),
|
||||
body: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileDownloadApps(data!),
|
||||
tablet: (context) => DesktopDownloadApps(data!),
|
||||
desktop: (context) => Scrollbar(
|
||||
thumbVisibility: true,
|
||||
child: DesktopDownloadApps(data!),
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: ScreenTypeLayout(
|
||||
mobile: MobileBottomNav(),
|
||||
tablet: BottomNav(),
|
||||
desktop: BottomNav(),
|
||||
bottomNavigationBar: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileBottomNav(),
|
||||
tablet: (context) => BottomNav(),
|
||||
desktop: (context) => BottomNav(),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -79,7 +79,7 @@ class DownloadState extends State<Download> {
|
||||
super.initState();
|
||||
eventBus.on<OpenDrawer>().listen((event) {
|
||||
if (mounted) {
|
||||
_scaffoldKey.currentState.openDrawer();
|
||||
_scaffoldKey.currentState?.openDrawer();
|
||||
}
|
||||
});
|
||||
_loadData();
|
||||
|
||||
@@ -13,20 +13,19 @@ import '../widgets/general/navigationbar.dart';
|
||||
import '../widgets/mobile/MobileBottomNav.dart';
|
||||
|
||||
class EditAddress extends StatelessWidget {
|
||||
final Key key;
|
||||
final Address address;
|
||||
final int businessId;
|
||||
const EditAddress(this.address, {this.key, int businessId}) :
|
||||
final Address? address;
|
||||
final int? businessId;
|
||||
const EditAddress(this.address, {Key? key, int? businessId}) :
|
||||
businessId = businessId ?? Constants.BUSINESS_ID;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ResponsiveBuilder(
|
||||
builder: (context, sizingInformation) =>
|
||||
ScreenTypeLayout(
|
||||
mobile: MobileEditAddress(address, businessId: businessId,),
|
||||
tablet: DesktopEditAddress(address, businessId: businessId,),
|
||||
desktop: DesktopEditAddress(address, businessId: businessId,),
|
||||
ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileEditAddress(address, businessId: businessId,),
|
||||
tablet: (context) => DesktopEditAddress(address, businessId: businessId,),
|
||||
desktop: (context) => DesktopEditAddress(address, businessId: businessId,),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import '../widgets/general/navigationbar.dart';
|
||||
import '../widgets/mobile/MobileBottomNav.dart';
|
||||
|
||||
class ForgotPassword extends StatelessWidget {
|
||||
const ForgotPassword({Key key}) : super(key: key);
|
||||
const ForgotPassword({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -28,15 +28,15 @@ class ForgotPassword extends StatelessWidget {
|
||||
breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT,
|
||||
),
|
||||
drawer: null,
|
||||
body: ScreenTypeLayout(
|
||||
mobile: MobileForgotPassword(),
|
||||
tablet: DesktopForgotPassword(),
|
||||
desktop: DesktopForgotPassword(),
|
||||
body: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileForgotPassword(),
|
||||
tablet: (context) => DesktopForgotPassword(),
|
||||
desktop: (context) => DesktopForgotPassword(),
|
||||
),
|
||||
bottomNavigationBar: ScreenTypeLayout(
|
||||
mobile: MobileBottomNav(currentIndex: 0,),
|
||||
tablet: BottomNav(),
|
||||
desktop: BottomNav(),
|
||||
bottomNavigationBar: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileBottomNav(currentIndex: 0,),
|
||||
tablet: (context) => BottomNav(),
|
||||
desktop: (context) => BottomNav(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -34,7 +34,7 @@ import '../widgets/mobile/mobile_navigation_drawer.dart';
|
||||
class Home extends StatefulWidget {
|
||||
final String title;
|
||||
|
||||
Home({Key key, this.title = ''}) : super(key: key);
|
||||
Home({Key? key, this.title = ''}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -46,11 +46,11 @@ class Home extends StatefulWidget {
|
||||
class HomeState extends State<Home> {
|
||||
final _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
List<Gallery> galleries = [];
|
||||
String content1Message;
|
||||
Map<String, dynamic> content2;
|
||||
String? content1Message;
|
||||
Map<String, dynamic>? content2;
|
||||
|
||||
StreamSubscription _sub;
|
||||
Uri _latestUri;
|
||||
StreamSubscription? _sub;
|
||||
Uri? _latestUri;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -74,8 +74,8 @@ class HomeState extends State<Home> {
|
||||
appBar: MiniNavigationBar(),
|
||||
drawer: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? MobileNavigationDrawer() : null,
|
||||
body: DoubleBackToCloseAppWrapper(
|
||||
child: ScreenTypeLayout(
|
||||
mobile: SingleChildScrollView(
|
||||
child: ScreenTypeLayout.builder(
|
||||
mobile: (context) => SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
@@ -86,7 +86,7 @@ class HomeState extends State<Home> {
|
||||
],
|
||||
),
|
||||
),
|
||||
tablet: SingleChildScrollView(
|
||||
tablet: (context) => SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
@@ -98,8 +98,8 @@ class HomeState extends State<Home> {
|
||||
],
|
||||
),
|
||||
),
|
||||
desktop: Scrollbar(
|
||||
isAlwaysShown: true,
|
||||
desktop: (context) => Scrollbar(
|
||||
thumbVisibility: true,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -115,10 +115,10 @@ class HomeState extends State<Home> {
|
||||
),
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: ScreenTypeLayout(
|
||||
mobile: MobileBottomNav(currentIndex: 0,),
|
||||
tablet: BottomNav(),
|
||||
desktop: BottomNav(),
|
||||
bottomNavigationBar: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileBottomNav(currentIndex: 0,),
|
||||
tablet: (context) => BottomNav(),
|
||||
desktop: (context) => BottomNav(),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -136,7 +136,7 @@ class HomeState extends State<Home> {
|
||||
_loadData();
|
||||
eventBus.on<OpenDrawer>().listen((event) {
|
||||
if (mounted) {
|
||||
_scaffoldKey.currentState.openDrawer();
|
||||
_scaffoldKey.currentState?.openDrawer();
|
||||
}
|
||||
});
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||
@@ -163,7 +163,9 @@ class HomeState extends State<Home> {
|
||||
if (!mounted) return;
|
||||
_latestUri = Uri.base;
|
||||
print('uri base $_latestUri');
|
||||
eventBus.fire(OnGotDeepLinkUri(_latestUri));
|
||||
if (_latestUri != null) {
|
||||
eventBus.fire(OnGotDeepLinkUri(_latestUri!));
|
||||
}
|
||||
} else {
|
||||
// _sub = getUriLinksStream().listen((Uri uri) {
|
||||
// print('_sub should get uri $uri');
|
||||
|
||||
@@ -16,7 +16,7 @@ import '../widgets/mobile/MobileBottomNav.dart';
|
||||
import '../widgets/mobile/mobile_igoshow_learn_more.dart';
|
||||
|
||||
class IGoShowLearnMore extends StatefulWidget {
|
||||
const IGoShowLearnMore({Key key}) : super(key: key);
|
||||
const IGoShowLearnMore({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -26,7 +26,7 @@ class IGoShowLearnMore extends StatefulWidget {
|
||||
|
||||
class IGoShowLearnMoreState extends State<IGoShowLearnMore> {
|
||||
final _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
Map<String, dynamic> data;
|
||||
Map<String, dynamic>? data;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -55,15 +55,15 @@ class IGoShowLearnMoreState extends State<IGoShowLearnMore> {
|
||||
breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT,
|
||||
),
|
||||
drawer: null,
|
||||
body: ScreenTypeLayout(
|
||||
mobile: MobileiGoShowLearnMore(data),
|
||||
tablet: DesktopiGoShowLearnMore(data),
|
||||
desktop: DesktopiGoShowLearnMore(data),
|
||||
body: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileiGoShowLearnMore(data!),
|
||||
tablet: (context) => DesktopiGoShowLearnMore(data!),
|
||||
desktop: (context) => DesktopiGoShowLearnMore(data!),
|
||||
),
|
||||
bottomNavigationBar: ScreenTypeLayout(
|
||||
mobile: MobileBottomNav(currentIndex: 0,),
|
||||
tablet: BottomNav(),
|
||||
desktop: BottomNav(),
|
||||
bottomNavigationBar: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileBottomNav(currentIndex: 0,),
|
||||
tablet: (context) => BottomNav(),
|
||||
desktop: (context) => BottomNav(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -14,9 +14,7 @@ import '../widgets/mobile/MobileBottomNav.dart';
|
||||
import '../widgets/mobile/mobile_login.dart';
|
||||
|
||||
class Login extends StatefulWidget {
|
||||
final Key key;
|
||||
|
||||
const Login({this.key}) : super(key: key);
|
||||
const Login({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -50,15 +48,15 @@ class LoginState extends State<Login> {
|
||||
breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT,
|
||||
),
|
||||
drawer: null,
|
||||
body: ScreenTypeLayout(
|
||||
mobile: MobileLogin(),
|
||||
tablet: DesktopLogin(),
|
||||
desktop: DesktopLogin(),
|
||||
body: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileLogin(),
|
||||
tablet: (context) => DesktopLogin(),
|
||||
desktop: (context) => DesktopLogin(),
|
||||
),
|
||||
bottomNavigationBar: ScreenTypeLayout(
|
||||
mobile: MobileBottomNav(currentIndex: 0,),
|
||||
tablet: BottomNav(),
|
||||
desktop: BottomNav(),
|
||||
bottomNavigationBar: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileBottomNav(currentIndex: 0,),
|
||||
tablet: (context) => BottomNav(),
|
||||
desktop: (context) => BottomNav(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -15,9 +15,7 @@ import '../widgets/mobile/MobileBottomNav.dart';
|
||||
import '../widgets/mobile/mobile_me.dart';
|
||||
|
||||
class Me extends StatefulWidget {
|
||||
final Key key;
|
||||
|
||||
const Me({this.key}) : super(key: key);
|
||||
const Me({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -52,16 +50,16 @@ class MeState extends State<Me> {
|
||||
),
|
||||
drawer: null,
|
||||
body: DoubleBackToCloseAppWrapper(
|
||||
child: ScreenTypeLayout(
|
||||
mobile: MobileMe(),
|
||||
tablet: DesktopMe(),
|
||||
desktop: DesktopMe(),
|
||||
child: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileMe(),
|
||||
tablet: (context) => DesktopMe(),
|
||||
desktop: (context) => DesktopMe(),
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: ScreenTypeLayout(
|
||||
mobile: MobileBottomNav(currentIndex: 3,),
|
||||
tablet: BottomNav(),
|
||||
desktop: BottomNav(),
|
||||
bottomNavigationBar: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileBottomNav(currentIndex: 3,),
|
||||
tablet: (context) => BottomNav(),
|
||||
desktop: (context) => BottomNav(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -16,7 +16,7 @@ import '../widgets/mobile/MobileBottomNav.dart';
|
||||
import '../widgets/mobile/mobile_minipos_learn_more.dart';
|
||||
|
||||
class MiniPosLearnMore extends StatefulWidget {
|
||||
const MiniPosLearnMore({Key key}) : super(key: key);
|
||||
const MiniPosLearnMore({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -26,7 +26,7 @@ class MiniPosLearnMore extends StatefulWidget {
|
||||
|
||||
class MiniPosLearnMoreState extends State<MiniPosLearnMore> {
|
||||
final _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
Map<String, dynamic> data;
|
||||
Map<String, dynamic>? data;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -42,35 +42,36 @@ class MiniPosLearnMoreState extends State<MiniPosLearnMore> {
|
||||
);
|
||||
}
|
||||
|
||||
return WillPopScope(
|
||||
child: ResponsiveBuilder(
|
||||
builder: (context, sizingInformation) =>
|
||||
Scaffold(
|
||||
key: _scaffoldKey,
|
||||
appBar: MiniNavigationBar(
|
||||
title: S.of(context).minipos,
|
||||
back: true,
|
||||
breadCrumbs: [
|
||||
BreadCrumb(S.of(context).minipos, null),
|
||||
],
|
||||
breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT,
|
||||
),
|
||||
drawer: null,
|
||||
body: ScreenTypeLayout(
|
||||
mobile: MobileMiniPosLearnMore(data),
|
||||
tablet: DesktopMiniPosLearnMore(data),
|
||||
desktop: DesktopMiniPosLearnMore(data),
|
||||
),
|
||||
bottomNavigationBar: ScreenTypeLayout(
|
||||
mobile: MobileBottomNav(currentIndex: 0,),
|
||||
tablet: BottomNav(),
|
||||
desktop: BottomNav(),
|
||||
),
|
||||
return ResponsiveBuilder(
|
||||
builder: (context, sizingInformation) => PopScope(
|
||||
canPop: true,
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (didPop) return;
|
||||
// 可以在这里处理返回逻辑
|
||||
},
|
||||
child: Scaffold(
|
||||
key: _scaffoldKey,
|
||||
appBar: MiniNavigationBar(
|
||||
title: S.of(context).minipos,
|
||||
back: true,
|
||||
breadCrumbs: [
|
||||
BreadCrumb(S.of(context).minipos, null),
|
||||
],
|
||||
breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT,
|
||||
),
|
||||
drawer: null,
|
||||
body: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileMiniPosLearnMore(data!),
|
||||
tablet: (context) => DesktopMiniPosLearnMore(data!),
|
||||
desktop: (context) => DesktopMiniPosLearnMore(data!),
|
||||
),
|
||||
bottomNavigationBar: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileBottomNav(currentIndex: 0),
|
||||
tablet: (context) => BottomNav(),
|
||||
desktop: (context) => BottomNav(),
|
||||
),
|
||||
),
|
||||
),
|
||||
onWillPop: () async {
|
||||
return true;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,20 +8,19 @@ import '../widgets/desktop/desktop_my_addresses.dart';
|
||||
import '../widgets/mobile/mobile_my_addresses.dart';
|
||||
|
||||
class MyAddresses extends StatelessWidget {
|
||||
final Key key;
|
||||
final int businessId;
|
||||
|
||||
const MyAddresses({this.key, int businessId}) :
|
||||
const MyAddresses({Key? key, int? businessId}) :
|
||||
businessId = businessId ?? Constants.BUSINESS_ID;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ResponsiveBuilder(
|
||||
builder: (context, sizingInformation) =>
|
||||
ScreenTypeLayout(
|
||||
mobile: MobileMyAddresses(businessId: businessId,),
|
||||
tablet: DesktopMyAddresses(businessId: businessId,),
|
||||
desktop: DesktopMyAddresses(businessId: businessId,),
|
||||
ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileMyAddresses(businessId: businessId,),
|
||||
tablet: (context) => DesktopMyAddresses(businessId: businessId,),
|
||||
desktop: (context) => DesktopMyAddresses(businessId: businessId,),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@ class MyCards extends StatelessWidget {
|
||||
|
||||
return ResponsiveBuilder(
|
||||
builder: (context, sizingInformation) =>
|
||||
ScreenTypeLayout(
|
||||
mobile: MobileMyCards(),
|
||||
tablet: DesktopMyCards(),
|
||||
desktop: DesktopMyCards(),
|
||||
ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileMyCards(),
|
||||
tablet: (context) => DesktopMyCards(),
|
||||
desktop: (context) => DesktopMyCards(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,20 +8,19 @@ import '../widgets/desktop/desktop_my_support.dart';
|
||||
import '../widgets/mobile/mobile_my_support.dart';
|
||||
|
||||
class MySupport extends StatelessWidget {
|
||||
final Key key;
|
||||
final int businessId;
|
||||
|
||||
const MySupport({this.key, int businessId}) :
|
||||
const MySupport({Key? key, int? businessId}) :
|
||||
businessId = businessId ?? Constants.BUSINESS_ID;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ResponsiveBuilder(
|
||||
builder: (context, sizingInformation) =>
|
||||
ScreenTypeLayout(
|
||||
mobile: MobileMySupport(businessId: businessId,),
|
||||
tablet: DesktopMySupport(businessId: businessId,),
|
||||
desktop: DesktopMySupport(businessId: businessId,),
|
||||
ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileMySupport(businessId: businessId,),
|
||||
tablet: (context) => DesktopMySupport(businessId: businessId,),
|
||||
desktop: (context) => DesktopMySupport(businessId: businessId,),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,25 +7,24 @@ import '../widgets/desktop/desktop_new_address.dart';
|
||||
import '../widgets/mobile/mobile_new_address.dart';
|
||||
|
||||
class NewAddress extends StatelessWidget {
|
||||
final Key key;
|
||||
final LocatedAddress locatedAddress;
|
||||
final int businessId;
|
||||
const NewAddress({this.key, this.locatedAddress, this.businessId}) : super(key: key);
|
||||
final LocatedAddress? locatedAddress;
|
||||
final int? businessId;
|
||||
const NewAddress({Key? key, this.locatedAddress, this.businessId}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ResponsiveBuilder(
|
||||
builder: (context, sizingInformation) =>
|
||||
ScreenTypeLayout(
|
||||
mobile: MobileNewAddress(
|
||||
ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileNewAddress(
|
||||
locatedAddress: locatedAddress,
|
||||
businessId: businessId,
|
||||
),
|
||||
tablet: DesktopNewAddress(
|
||||
tablet: (context) => DesktopNewAddress(
|
||||
locatedAddress: locatedAddress,
|
||||
businessId: businessId,
|
||||
),
|
||||
desktop: DesktopNewAddress(
|
||||
desktop: (context) => DesktopNewAddress(
|
||||
locatedAddress: locatedAddress,
|
||||
businessId: businessId,
|
||||
),
|
||||
|
||||
@@ -10,7 +10,7 @@ import '../widgets/mobile/mobile_new_comment.dart';
|
||||
class NewComment extends StatelessWidget {
|
||||
final int orderId;
|
||||
|
||||
const NewComment(this.orderId, {Key key}) :
|
||||
const NewComment(this.orderId, {Key? key}) :
|
||||
super(key: key);
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ class NewComment extends StatelessWidget {
|
||||
|
||||
return ResponsiveBuilder(
|
||||
builder: (context, sizingInformation) =>
|
||||
ScreenTypeLayout(
|
||||
mobile: MobileNewComment(orderId,),
|
||||
tablet: DesktopNewComment(orderId,),
|
||||
desktop: DesktopNewComment(orderId,),
|
||||
ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileNewComment(orderId,),
|
||||
tablet: (context) => DesktopNewComment(orderId,),
|
||||
desktop: (context) => DesktopNewComment(orderId,),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,10 +14,9 @@ import '../widgets/mobile/MobileBottomNav.dart';
|
||||
import '../widgets/mobile/mobile_new_ticket.dart';
|
||||
|
||||
class NewTicket extends StatefulWidget {
|
||||
final Key key;
|
||||
final int businessId;
|
||||
final int? businessId;
|
||||
|
||||
const NewTicket({this.key, int businessId}) :
|
||||
const NewTicket({Key? key, int? businessId}) :
|
||||
businessId = businessId ?? Constants.BUSINESS_ID;
|
||||
|
||||
@override
|
||||
@@ -52,15 +51,15 @@ class NewTicketState extends State<NewTicket> {
|
||||
breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT,
|
||||
),
|
||||
drawer: null,
|
||||
body: ScreenTypeLayout(
|
||||
mobile: MobileNewTicket(businessId: widget.businessId,),
|
||||
tablet: DesktopNewTicket(businessId: widget.businessId,),
|
||||
desktop: DesktopNewTicket(businessId: widget.businessId,),
|
||||
body: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileNewTicket(businessId: widget.businessId!,),
|
||||
tablet: (context) => DesktopNewTicket(businessId: widget.businessId!,),
|
||||
desktop: (context) => DesktopNewTicket(businessId: widget.businessId!,),
|
||||
),
|
||||
bottomNavigationBar: ScreenTypeLayout(
|
||||
mobile: MobileBottomNav(currentIndex: 0,),
|
||||
tablet: BottomNav(),
|
||||
desktop: BottomNav(),
|
||||
bottomNavigationBar: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileBottomNav(currentIndex: 0,),
|
||||
tablet: (context) => BottomNav(),
|
||||
desktop: (context) => BottomNav(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -12,7 +12,7 @@ import '../widgets/mobile/MobileBottomNav.dart';
|
||||
import '../widgets/mobile/mobile_new_user.dart';
|
||||
|
||||
class NewUser extends StatelessWidget {
|
||||
const NewUser({Key key}) : super(key: key);
|
||||
const NewUser({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -28,15 +28,15 @@ class NewUser extends StatelessWidget {
|
||||
breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT,
|
||||
),
|
||||
drawer: null,
|
||||
body: ScreenTypeLayout(
|
||||
mobile: MobileNewUser(),
|
||||
tablet: DesktopNewUser(),
|
||||
desktop: DesktopNewUser(),
|
||||
body: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileNewUser(),
|
||||
tablet: (context) => DesktopNewUser(),
|
||||
desktop: (context) => DesktopNewUser(),
|
||||
),
|
||||
bottomNavigationBar: ScreenTypeLayout(
|
||||
mobile: MobileBottomNav(currentIndex: 0,),
|
||||
tablet: BottomNav(),
|
||||
desktop: BottomNav(),
|
||||
bottomNavigationBar: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileBottomNav(currentIndex: 0,),
|
||||
tablet: (context) => BottomNav(),
|
||||
desktop: (context) => BottomNav(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -11,7 +11,7 @@ class OrderDetail extends StatelessWidget {
|
||||
final int orderId;
|
||||
final bool fromOrders;
|
||||
|
||||
const OrderDetail(this.orderId, {this.fromOrders = false, Key key}) :
|
||||
const OrderDetail(this.orderId, {this.fromOrders = false, Key? key}) :
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
@@ -20,10 +20,10 @@ class OrderDetail extends StatelessWidget {
|
||||
|
||||
return ResponsiveBuilder(
|
||||
builder: (context, sizingInformation) =>
|
||||
ScreenTypeLayout(
|
||||
mobile: MobileOrderDetail(orderId, fromOrders: fromOrders,),
|
||||
tablet: DesktopOrderDetail(orderId, fromOrders: fromOrders,),
|
||||
desktop: DesktopOrderDetail(orderId, fromOrders: fromOrders,),
|
||||
ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileOrderDetail(orderId, fromOrders: fromOrders,),
|
||||
tablet: (context) => DesktopOrderDetail(orderId, fromOrders: fromOrders,),
|
||||
desktop: (context) => DesktopOrderDetail(orderId, fromOrders: fromOrders,),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import '../widgets/mobile/mobile_pay_now.dart';
|
||||
class PayNow extends StatelessWidget {
|
||||
final int orderId;
|
||||
|
||||
const PayNow(this.orderId, {Key key}) :
|
||||
const PayNow(this.orderId, {Key? key}) :
|
||||
super(key: key);
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ class PayNow extends StatelessWidget {
|
||||
|
||||
return ResponsiveBuilder(
|
||||
builder: (context, sizingInformation) =>
|
||||
ScreenTypeLayout(
|
||||
mobile: MobilePayNow(orderId,),
|
||||
tablet: DesktopPayNow(orderId,),
|
||||
desktop: DesktopPayNow(orderId,),
|
||||
ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobilePayNow(orderId,),
|
||||
tablet: (context) => DesktopPayNow(orderId,),
|
||||
desktop: (context) => DesktopPayNow(orderId,),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@ import '../utils/utils.dart';
|
||||
|
||||
class PlainPage extends StatefulWidget {
|
||||
final int businessId;
|
||||
final String slug;
|
||||
final String? slug;
|
||||
|
||||
const PlainPage(this.slug, {this.businessId, Key key}) :
|
||||
const PlainPage(this.slug, {required this.businessId, Key? key}) :
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
@@ -23,7 +23,7 @@ class PlainPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class PlainPageState extends State<PlainPage> {
|
||||
Blog blog;
|
||||
Blog? blog;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -43,10 +43,10 @@ class PlainPageState extends State<PlainPage> {
|
||||
|
||||
return ResponsiveBuilder(
|
||||
builder: (context, sizingInformation) =>
|
||||
ScreenTypeLayout(
|
||||
mobile: MobilePlainPage(blog),
|
||||
tablet: DesktopPlainPage(blog),
|
||||
desktop: DesktopPlainPage(blog),
|
||||
ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobilePlainPage(blog!),
|
||||
tablet: (context) => DesktopPlainPage(blog!),
|
||||
desktop: (context) => DesktopPlainPage(blog!),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class ProductDetailPage extends StatelessWidget {
|
||||
final Business business;
|
||||
final Product product;
|
||||
|
||||
const ProductDetailPage({this.business, this.product, Key key}) :
|
||||
const ProductDetailPage({required this.business, required this.product, Key? key}) :
|
||||
super(key: key);
|
||||
|
||||
|
||||
@@ -23,10 +23,10 @@ class ProductDetailPage extends StatelessWidget {
|
||||
|
||||
return ResponsiveBuilder(
|
||||
builder: (context, sizingInformation) =>
|
||||
ScreenTypeLayout(
|
||||
mobile: MobileProductDetailPage(business: business, product: product,),
|
||||
tablet: DesktopProductDetailPage(business: business, product: product,),
|
||||
desktop: DesktopProductDetailPage(business: business, product: product,),
|
||||
ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileProductDetailPage(business: business, product: product,),
|
||||
tablet: (context) => DesktopProductDetailPage(business: business, product: product,),
|
||||
desktop: (context) => DesktopProductDetailPage(business: business, product: product,),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,16 +9,16 @@ import '../widgets/mobile/product_search.dart' as mobile;
|
||||
class ProductSearch extends StatelessWidget {
|
||||
final Business business;
|
||||
|
||||
const ProductSearch(this.business, {Key key}) : super(key: key);
|
||||
const ProductSearch(this.business, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ResponsiveBuilder(
|
||||
builder: (context, sizingInformation) =>
|
||||
ScreenTypeLayout(
|
||||
mobile: mobile.ProductSearch(business),
|
||||
tablet: desktop.ProductSearch(business),
|
||||
desktop: desktop.ProductSearch(business),
|
||||
ScreenTypeLayout.builder(
|
||||
mobile: (context) => mobile.ProductSearch(business),
|
||||
tablet: (context) => desktop.ProductSearch(business),
|
||||
desktop: (context) => desktop.ProductSearch(business),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import '../widgets/mobile/mobile_renew_license.dart';
|
||||
|
||||
class RenewLicense extends StatefulWidget {
|
||||
|
||||
const RenewLicense({Key key}) :
|
||||
const RenewLicense({Key? key}) :
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
@@ -28,10 +28,10 @@ class RenewLicenseState extends State<RenewLicense> {
|
||||
|
||||
return ResponsiveBuilder(
|
||||
builder: (context, sizingInformation) =>
|
||||
ScreenTypeLayout(
|
||||
mobile: MobileRenewLicense(Constants.BUSINESS_ID),
|
||||
tablet: DesktopRenewLicense(Constants.BUSINESS_ID),
|
||||
desktop: DesktopRenewLicense(Constants.BUSINESS_ID),
|
||||
ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileRenewLicense(Constants.BUSINESS_ID),
|
||||
tablet: (context) => DesktopRenewLicense(Constants.BUSINESS_ID),
|
||||
desktop: (context) => DesktopRenewLicense(Constants.BUSINESS_ID),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import '../widgets/mobile/mobile_renew_license.dart';
|
||||
class RenewMiniOffice extends StatefulWidget {
|
||||
final int gid;
|
||||
|
||||
const RenewMiniOffice(this.gid, {Key key}) :
|
||||
const RenewMiniOffice(this.gid, {Key? key}) :
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
@@ -25,7 +25,7 @@ class RenewMiniOffice extends StatefulWidget {
|
||||
}
|
||||
|
||||
class RenewMiniOfficeState extends State<RenewMiniOffice> {
|
||||
Map<String, dynamic> data;
|
||||
Map<String, dynamic>? data;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -45,10 +45,10 @@ class RenewMiniOfficeState extends State<RenewMiniOffice> {
|
||||
|
||||
return ResponsiveBuilder(
|
||||
builder: (context, sizingInformation) =>
|
||||
ScreenTypeLayout(
|
||||
mobile: MobileRenewMiniOffice(data),
|
||||
tablet: DesktopRenewMiniOffice(data),
|
||||
desktop: DesktopRenewMiniOffice(data),
|
||||
ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileRenewMiniOffice(data!),
|
||||
tablet: (context) => DesktopRenewMiniOffice(data!),
|
||||
desktop: (context) => DesktopRenewMiniOffice(data!),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import '../widgets/mobile/mobile_reset_password.dart';
|
||||
class ResetPassword extends StatelessWidget {
|
||||
final String mobile;
|
||||
final String code;
|
||||
const ResetPassword(this.mobile, {Key key, this.code}) : super(key: key);
|
||||
const ResetPassword(this.mobile, {Key? key, required this.code}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -30,15 +30,15 @@ class ResetPassword extends StatelessWidget {
|
||||
breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT,
|
||||
),
|
||||
drawer: null,
|
||||
body: ScreenTypeLayout(
|
||||
mobile: MobileResetPassword(mobile, code: code,),
|
||||
tablet: DesktopResetPassword(mobile, code: code,),
|
||||
desktop: DesktopResetPassword(mobile, code: code,),
|
||||
body: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileResetPassword(mobile, code: code,),
|
||||
tablet: (context) => DesktopResetPassword(mobile, code: code,),
|
||||
desktop: (context) => DesktopResetPassword(mobile, code: code,),
|
||||
),
|
||||
bottomNavigationBar: ScreenTypeLayout(
|
||||
mobile: MobileBottomNav(currentIndex: 0,),
|
||||
tablet: BottomNav(),
|
||||
desktop: BottomNav(),
|
||||
bottomNavigationBar: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileBottomNav(currentIndex: 0,),
|
||||
tablet: (context) => BottomNav(),
|
||||
desktop: (context) => BottomNav(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -5,18 +5,17 @@ import '../widgets/mobile/mobile_search_place.dart';
|
||||
import 'package:responsive_builder/responsive_builder.dart';
|
||||
|
||||
class SearchPlace extends StatelessWidget {
|
||||
final Key key;
|
||||
final int businessId;
|
||||
const SearchPlace(this.businessId, {this.key}) : super(key: key);
|
||||
const SearchPlace(this.businessId, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ResponsiveBuilder(
|
||||
builder: (context, sizingInformation) =>
|
||||
ScreenTypeLayout(
|
||||
mobile: MobileSearchPlace(businessId),
|
||||
tablet: DesktopSearchPlace(businessId),
|
||||
desktop: DesktopSearchPlace(businessId),
|
||||
ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileSearchPlace(businessId),
|
||||
tablet: (context) => DesktopSearchPlace(businessId),
|
||||
desktop: (context) => DesktopSearchPlace(businessId),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import '../widgets/mobile/mobile_set_password.dart';
|
||||
class SetPassword extends StatelessWidget {
|
||||
final String mobile;
|
||||
final String code;
|
||||
const SetPassword(this.mobile, {Key key, this.code}) : super(key: key);
|
||||
const SetPassword(this.mobile, {Key? key, required this.code}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -30,15 +30,15 @@ class SetPassword extends StatelessWidget {
|
||||
breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT,
|
||||
),
|
||||
drawer: null,
|
||||
body: ScreenTypeLayout(
|
||||
mobile: MobileSetPassword(mobile, code: code,),
|
||||
tablet: DesktopSetPassword(mobile, code: code,),
|
||||
desktop: DesktopSetPassword(mobile, code: code,),
|
||||
body: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileSetPassword(mobile, code: code,),
|
||||
tablet: (context) => DesktopSetPassword(mobile, code: code,),
|
||||
desktop: (context) => DesktopSetPassword(mobile, code: code,),
|
||||
),
|
||||
bottomNavigationBar: ScreenTypeLayout(
|
||||
mobile: MobileBottomNav(currentIndex: 0,),
|
||||
tablet: BottomNav(),
|
||||
desktop: BottomNav(),
|
||||
bottomNavigationBar: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileBottomNav(currentIndex: 0,),
|
||||
tablet: (context) => BottomNav(),
|
||||
desktop: (context) => BottomNav(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -8,9 +8,9 @@ import '../widgets/desktop/shop.dart' as desktop;
|
||||
import '../widgets/mobile/shop.dart' as mobile;
|
||||
|
||||
class Shop extends StatefulWidget {
|
||||
final int businessId;
|
||||
final int? businessId;
|
||||
|
||||
const Shop({this.businessId, Key key}) : super(key: key);
|
||||
const Shop({this.businessId, Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => ShopState();
|
||||
@@ -20,17 +20,17 @@ class ShopState extends State<Shop> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
int _businessId =
|
||||
widget.businessId == null ? Utils.getBusinessId() : widget.businessId;
|
||||
widget.businessId == null ? Utils.getBusinessId() : widget.businessId!;
|
||||
|
||||
return ResponsiveBuilder(
|
||||
builder: (context, sizingInformation) => ScreenTypeLayout(
|
||||
mobile: mobile.Shop(
|
||||
builder: (context, sizingInformation) => ScreenTypeLayout.builder(
|
||||
mobile: (context) => mobile.Shop(
|
||||
businessId: _businessId,
|
||||
),
|
||||
tablet: desktop.Shop(
|
||||
tablet: (context) => desktop.Shop(
|
||||
businessId: _businessId,
|
||||
),
|
||||
desktop: desktop.Shop(
|
||||
desktop: (context) => desktop.Shop(
|
||||
businessId: _businessId,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -15,7 +15,7 @@ import '../widgets/mobile/mobile_store_product_search.dart';
|
||||
class StoreProductSearch extends StatelessWidget {
|
||||
final Business business;
|
||||
|
||||
const StoreProductSearch(this.business, {Key key}) : super(key: key);
|
||||
const StoreProductSearch(this.business, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -31,15 +31,15 @@ class StoreProductSearch extends StatelessWidget {
|
||||
breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT,
|
||||
),
|
||||
drawer: null,
|
||||
body: ScreenTypeLayout(
|
||||
mobile: MobileStoreProductSearch(business,),
|
||||
tablet: DesktopStoreProductSearch(business),
|
||||
desktop: DesktopStoreProductSearch(business),
|
||||
body: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileStoreProductSearch(business,),
|
||||
tablet: (context) => DesktopStoreProductSearch(business),
|
||||
desktop: (context) => DesktopStoreProductSearch(business),
|
||||
),
|
||||
bottomNavigationBar: ScreenTypeLayout(
|
||||
mobile: MobileBottomNav(currentIndex: 1,),
|
||||
tablet: BottomNav(),
|
||||
desktop: BottomNav(),
|
||||
bottomNavigationBar: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileBottomNav(currentIndex: 1,),
|
||||
tablet: (context) => BottomNav(),
|
||||
desktop: (context) => BottomNav(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -13,7 +13,7 @@ import '../widgets/mobile/mobile_stripe_pay_web.dart';
|
||||
class StripePayWeb extends StatelessWidget {
|
||||
final Order order;
|
||||
final PaymentPlatform paymentPlatform;
|
||||
final StripePaymentMethod stripePaymentMethod;
|
||||
final StripePaymentMethod? stripePaymentMethod;
|
||||
|
||||
const StripePayWeb(this.order, this.paymentPlatform, {this.stripePaymentMethod});
|
||||
|
||||
@@ -23,10 +23,10 @@ class StripePayWeb extends StatelessWidget {
|
||||
|
||||
return ResponsiveBuilder(
|
||||
builder: (context, sizingInformation) =>
|
||||
ScreenTypeLayout(
|
||||
mobile: MobileStripePayWeb(order, paymentPlatform, stripePaymentMethod: stripePaymentMethod,),
|
||||
tablet: DesktopStripePayWeb(order, paymentPlatform, stripePaymentMethod: stripePaymentMethod,),
|
||||
desktop: DesktopStripePayWeb(order, paymentPlatform, stripePaymentMethod: stripePaymentMethod,),
|
||||
ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileStripePayWeb(order, paymentPlatform, stripePaymentMethod: stripePaymentMethod,),
|
||||
tablet: (context) => DesktopStripePayWeb(order, paymentPlatform, stripePaymentMethod: stripePaymentMethod,),
|
||||
desktop: (context) => DesktopStripePayWeb(order, paymentPlatform, stripePaymentMethod: stripePaymentMethod,),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import '../widgets/mobile/MobileBottomNav.dart';
|
||||
import '../widgets/mobile/mobile_user_profile.dart';
|
||||
|
||||
class UserProfile extends StatelessWidget {
|
||||
const UserProfile({Key key}) : super(key: key);
|
||||
const UserProfile({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -29,15 +29,15 @@ class UserProfile extends StatelessWidget {
|
||||
breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT,
|
||||
),
|
||||
drawer: null,
|
||||
body: ScreenTypeLayout(
|
||||
mobile: MobileUserProfile(),
|
||||
tablet: DesktopUserProfile(),
|
||||
desktop: DesktopUserProfile(),
|
||||
body: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileUserProfile(),
|
||||
tablet: (context) => DesktopUserProfile(),
|
||||
desktop: (context) => DesktopUserProfile(),
|
||||
),
|
||||
bottomNavigationBar: ScreenTypeLayout(
|
||||
mobile: MobileBottomNav(currentIndex: 0,),
|
||||
tablet: BottomNav(),
|
||||
desktop: BottomNav(),
|
||||
bottomNavigationBar: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileBottomNav(currentIndex: 0,),
|
||||
tablet: (context) => BottomNav(),
|
||||
desktop: (context) => BottomNav(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -14,10 +14,9 @@ import '../widgets/mobile/MobileBottomNav.dart';
|
||||
import '../widgets/mobile/mobile_view_blog.dart';
|
||||
|
||||
class ViewBlog extends StatefulWidget {
|
||||
final Key key;
|
||||
final int bid;
|
||||
|
||||
const ViewBlog(this.bid, {this.key}) : super(key: key);
|
||||
const ViewBlog(this.bid, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -51,15 +50,15 @@ class ViewBlogState extends State<ViewBlog> {
|
||||
breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT,
|
||||
),
|
||||
drawer: null,
|
||||
body: ScreenTypeLayout(
|
||||
mobile: MobileViewBlog(widget.bid),
|
||||
tablet: DesktopViewBlog(widget.bid),
|
||||
desktop: DesktopViewBlog(widget.bid),
|
||||
body: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileViewBlog(widget.bid),
|
||||
tablet: (context) => DesktopViewBlog(widget.bid),
|
||||
desktop: (context) => DesktopViewBlog(widget.bid),
|
||||
),
|
||||
bottomNavigationBar: ScreenTypeLayout(
|
||||
mobile: MobileBottomNav(currentIndex: 0,),
|
||||
tablet: BottomNav(),
|
||||
desktop: BottomNav(),
|
||||
bottomNavigationBar: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileBottomNav(currentIndex: 0,),
|
||||
tablet: (context) => BottomNav(),
|
||||
desktop: (context) => BottomNav(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -14,10 +14,9 @@ import '../widgets/mobile/MobileBottomNav.dart';
|
||||
import '../widgets/mobile/mobile_view_ticket.dart';
|
||||
|
||||
class ViewTicket extends StatefulWidget {
|
||||
final Key key;
|
||||
final int ticketId;
|
||||
|
||||
const ViewTicket(this.ticketId, {this.key}) : super(key: key);
|
||||
const ViewTicket(this.ticketId, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -51,15 +50,15 @@ class ViewTicketState extends State<ViewTicket> {
|
||||
breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT,
|
||||
),
|
||||
drawer: null,
|
||||
body: ScreenTypeLayout(
|
||||
mobile: MobileViewTicket(widget.ticketId),
|
||||
tablet: DesktopViewTicket(widget.ticketId),
|
||||
desktop: DesktopViewTicket(widget.ticketId),
|
||||
body: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileViewTicket(widget.ticketId),
|
||||
tablet: (context) => DesktopViewTicket(widget.ticketId),
|
||||
desktop: (context) => DesktopViewTicket(widget.ticketId),
|
||||
),
|
||||
bottomNavigationBar: ScreenTypeLayout(
|
||||
mobile: MobileBottomNav(currentIndex: 0,),
|
||||
tablet: BottomNav(),
|
||||
desktop: BottomNav(),
|
||||
bottomNavigationBar: ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileBottomNav(currentIndex: 0,),
|
||||
tablet: (context) => BottomNav(),
|
||||
desktop: (context) => BottomNav(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
116
lib/routes.dart
116
lib/routes.dart
@@ -44,169 +44,169 @@ class Routes {
|
||||
|
||||
static void configure() {
|
||||
router.define('/', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return Home(title: Constants.APP_TITLE,);
|
||||
}),
|
||||
transitionType: TransitionType.fadeIn
|
||||
);
|
||||
router.define('/download', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return Download();
|
||||
}),
|
||||
transitionType: TransitionType.inFromRight
|
||||
);
|
||||
router.define('/minipos-learn-more', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return MiniPosLearnMore();
|
||||
}),
|
||||
transitionType: TransitionType.inFromRight
|
||||
);
|
||||
router.define('/igoshow-learn-more', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return IGoShowLearnMore();
|
||||
}),
|
||||
transitionType: TransitionType.inFromRight
|
||||
);
|
||||
router.define('/login', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return Login();
|
||||
}),
|
||||
transitionType: TransitionType.inFromRight
|
||||
);
|
||||
router.define('/me', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return Me();
|
||||
}),
|
||||
transitionType: TransitionType.inFromRight
|
||||
);
|
||||
router.define('/change-password', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return ChangePassword();
|
||||
}),
|
||||
transitionType: TransitionType.inFromRight
|
||||
);
|
||||
router.define('/user-profile', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return UserProfile();
|
||||
}),
|
||||
transitionType: TransitionType.inFromRight
|
||||
);
|
||||
router.define('/new-user', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return NewUser();
|
||||
}),
|
||||
transitionType: TransitionType.inFromRight
|
||||
);
|
||||
router.define('/set-password/:mobile/:code', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
return SetPassword(params['mobile'][0], code: params['code'][0]);
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return SetPassword(params['mobile']![0], code: params['code']![0]);
|
||||
}
|
||||
));
|
||||
router.define('/forgot-password', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return ForgotPassword();
|
||||
}
|
||||
));
|
||||
router.define('/reset-password/:mobile/:code', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
return ResetPassword(params['mobile'][0], code: params['code'][0]);
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return ResetPassword(params['mobile']![0], code: params['code']![0]);
|
||||
}
|
||||
));
|
||||
router.define('/change-mobile-email/:ismobile', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
if (params['ismobile'][0] == '1') {
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
if (params['ismobile']![0] == '1') {
|
||||
return ChangeMobileOrEmail(true);
|
||||
}
|
||||
return ChangeMobileOrEmail(false);
|
||||
}
|
||||
));
|
||||
router.define('/my-addresses/:business_id', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
return MyAddresses(businessId: int.parse(params['business_id'][0]),);
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return MyAddresses(businessId: int.parse(params['business_id']![0]),);
|
||||
}
|
||||
));
|
||||
router.define('/my-support/:business_id', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
return MySupport(businessId: int.parse(params['business_id'][0]),);
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return MySupport(businessId: int.parse(params['business_id']![0]),);
|
||||
}
|
||||
));
|
||||
router.define('/new-ticket/:business_id', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
return NewTicket(businessId: int.parse(params['business_id'][0]),);
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return NewTicket(businessId: int.parse(params['business_id']![0]),);
|
||||
}
|
||||
));
|
||||
router.define('/search-place/:business_id', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
return SearchPlace(int.parse(params['business_id'][0]));
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return SearchPlace(int.parse(params['business_id']![0]));
|
||||
}
|
||||
));
|
||||
router.define('/view-ticket/:ticket_id', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
return ViewTicket(int.parse(params['ticket_id'][0]),);
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return ViewTicket(int.parse(params['ticket_id']![0]),);
|
||||
}
|
||||
));
|
||||
router.define('/blog/:business_id', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
return Blog(businessId: int.parse(params['business_id'][0]),);
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return Blog(businessId: int.parse(params['business_id']![0]),);
|
||||
}
|
||||
));
|
||||
router.define('/view-blog/:bid', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
return ViewBlog(int.parse(params['bid'][0]),);
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return ViewBlog(int.parse(params['bid']![0]),);
|
||||
}
|
||||
));
|
||||
router.define('/shop/:business_id', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
return Shop(businessId: int.parse(params['business_id'][0]),);
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return Shop(businessId: int.parse(params['business_id']![0]),);
|
||||
}
|
||||
));
|
||||
router.define('/shop', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return Shop();
|
||||
}
|
||||
));
|
||||
// router.define('/ocr-scan', handler: new Handler(
|
||||
// handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
// handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
// return OCRScan();
|
||||
// }
|
||||
// ));
|
||||
router.define('/checkout/:id', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
return Checkout(int.parse(params['id'][0]));
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return Checkout(int.parse(params['id']![0]));
|
||||
}),
|
||||
);
|
||||
router.define('/paynow/:orderId', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
return PayNow(int.parse(params['orderId'][0]));
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return PayNow(int.parse(params['orderId']![0]));
|
||||
}),
|
||||
);
|
||||
router.define('/orders', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return Orders();
|
||||
}
|
||||
));
|
||||
router.define('/my-cards', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return MyCards();
|
||||
}
|
||||
));
|
||||
router.define('/orderdetail/:orderId', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
return OrderDetail(int.parse(params['orderId'][0]));
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return OrderDetail(int.parse(params['orderId']![0]));
|
||||
}),
|
||||
);
|
||||
router.define('/new-comment/:orderId', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
return NewComment(int.parse(params['orderId'][0]));
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return NewComment(int.parse(params['orderId']![0]));
|
||||
}),
|
||||
);
|
||||
router.define('/coupons/:contactId', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
return Coupons(int.parse(params['contactId'][0]));
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return Coupons(int.parse(params['contactId']![0]));
|
||||
}),
|
||||
);
|
||||
router.define('/service-policy', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return PlainPage(
|
||||
'service-policy',
|
||||
// businessId: Constants.BUSINESS_ID,
|
||||
@@ -215,7 +215,7 @@ class Routes {
|
||||
}),
|
||||
);
|
||||
router.define('/return-policy', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return PlainPage(
|
||||
'return-policy',
|
||||
// businessId: Constants.BUSINESS_ID,
|
||||
@@ -224,7 +224,7 @@ class Routes {
|
||||
}),
|
||||
);
|
||||
router.define('/privacy-policy', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return PlainPage(
|
||||
'privacy-policy',
|
||||
// businessId: Constants.BUSINESS_ID,
|
||||
@@ -233,7 +233,7 @@ class Routes {
|
||||
}),
|
||||
);
|
||||
router.define('/end-user-license-agreement', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return PlainPage(
|
||||
'end-user-license-agreement',
|
||||
// businessId: Constants.BUSINESS_ID,
|
||||
@@ -242,7 +242,7 @@ class Routes {
|
||||
}),
|
||||
);
|
||||
router.define('/about-us', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return PlainPage(
|
||||
'about-us',
|
||||
// businessId: Constants.BUSINESS_ID,
|
||||
@@ -251,29 +251,29 @@ class Routes {
|
||||
}),
|
||||
);
|
||||
router.define('/contact-us', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return ContactUs(
|
||||
businessId: Constants.BUSINESS_ID,
|
||||
);
|
||||
}),
|
||||
);
|
||||
router.define('/renew-license', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return RenewLicense();
|
||||
}
|
||||
));
|
||||
router.define('/renew-minioffice/:gid', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
return RenewMiniOffice(int.parse(params['gid'][0]));
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return RenewMiniOffice(int.parse(params['gid']![0]));
|
||||
}
|
||||
));
|
||||
router.define('/buy-service/:gid/:servicename', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
return BuyService(int.parse(params['gid'][0]), params['servicename'][0]);
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return BuyService(int.parse(params['gid']![0]), params['servicename']![0]);
|
||||
}
|
||||
));
|
||||
router.define('/contact-stores', handler: new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
|
||||
return CreateOnlineStore1();
|
||||
}
|
||||
));
|
||||
|
||||
@@ -10,17 +10,17 @@ class UpdateContext {
|
||||
}
|
||||
|
||||
class UpdateLocale {
|
||||
final Locale locale;
|
||||
final Locale? locale;
|
||||
UpdateLocale(this.locale);
|
||||
}
|
||||
|
||||
class UpdateCurrentUser {
|
||||
final User user;
|
||||
final User? user;
|
||||
UpdateCurrentUser(this.user);
|
||||
}
|
||||
|
||||
class UpdateRedirectRoute {
|
||||
final String route;
|
||||
final String? route;
|
||||
UpdateRedirectRoute(this.route);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@ import 'package:redux/redux.dart';
|
||||
|
||||
import '../actions.dart';
|
||||
|
||||
final cartInfoReducer = combineReducers<List<CartInfo>>([
|
||||
TypedReducer<List<CartInfo>, UpdateCartInfo>(_updateCartInfo)
|
||||
final cartInfoReducer = combineReducers<List<CartInfo>?>([
|
||||
TypedReducer<List<CartInfo>?, UpdateCartInfo>(_updateCartInfo)
|
||||
]);
|
||||
|
||||
List<CartInfo> _updateCartInfo(List<CartInfo> cartInfos, action) {
|
||||
List<CartInfo> _updateCartInfo(List<CartInfo>? cartInfos, action) {
|
||||
return action.cartInfos;
|
||||
}
|
||||
@@ -3,10 +3,10 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_wisetronic/store/actions.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
|
||||
final contextReducer = combineReducers<BuildContext>([
|
||||
TypedReducer<BuildContext, UpdateContext>(_updateContext)
|
||||
final contextReducer = combineReducers<BuildContext?>([
|
||||
TypedReducer<BuildContext?, UpdateContext>(_updateContext)
|
||||
]);
|
||||
|
||||
BuildContext _updateContext(BuildContext context, action) {
|
||||
BuildContext _updateContext(BuildContext? context, action) {
|
||||
return action.context;
|
||||
}
|
||||
@@ -2,10 +2,10 @@ import 'package:redux/redux.dart';
|
||||
|
||||
import '../actions.dart';
|
||||
|
||||
final deviceIdReducer = combineReducers<String>([
|
||||
TypedReducer<String, UpdateDeviceId>(_updateDeviceId)
|
||||
final deviceIdReducer = combineReducers<String?>([
|
||||
TypedReducer<String?, UpdateDeviceId>(_updateDeviceId)
|
||||
]);
|
||||
|
||||
String _updateDeviceId(String deviceId, action) {
|
||||
String _updateDeviceId(String? deviceId, action) {
|
||||
return action.deviceId;
|
||||
}
|
||||
@@ -2,10 +2,10 @@ import 'package:redux/redux.dart';
|
||||
|
||||
import '../actions.dart';
|
||||
|
||||
final fcmtokenReducer = combineReducers<String>([
|
||||
TypedReducer<String, UpdateFcmToken>(_updateFcmToken)
|
||||
final fcmtokenReducer = combineReducers<String?>([
|
||||
TypedReducer<String?, UpdateFcmToken>(_updateFcmToken)
|
||||
]);
|
||||
|
||||
String _updateFcmToken(String token, action) {
|
||||
String _updateFcmToken(String? token, action) {
|
||||
return action.token;
|
||||
}
|
||||
@@ -2,10 +2,10 @@ import 'package:redux/redux.dart';
|
||||
|
||||
import '../actions.dart';
|
||||
|
||||
final lastVisitReducer = combineReducers<List<int>>([
|
||||
TypedReducer<List<int>, UpdateLastVisit>(_updateLastVisit)
|
||||
final lastVisitReducer = combineReducers<List<int>?>([
|
||||
TypedReducer<List<int>?, UpdateLastVisit>(_updateLastVisit)
|
||||
]);
|
||||
|
||||
List<int> _updateLastVisit(List<int> lastVisit, action) {
|
||||
List<int> _updateLastVisit(List<int>? lastVisit, action) {
|
||||
return action.lastVisit;
|
||||
}
|
||||
@@ -2,10 +2,10 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_wisetronic/store/actions.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
|
||||
final localeReducer = combineReducers<Locale>([
|
||||
TypedReducer<Locale, UpdateLocale>(_updateLocale)
|
||||
final localeReducer = combineReducers<Locale?>([
|
||||
TypedReducer<Locale?, UpdateLocale>(_updateLocale)
|
||||
]);
|
||||
|
||||
Locale _updateLocale(Locale locale, action) {
|
||||
Locale _updateLocale(Locale? locale, action) {
|
||||
return action.locale;
|
||||
}
|
||||
@@ -3,10 +3,10 @@ import 'package:redux/redux.dart';
|
||||
import '../../models/located_address.dart';
|
||||
import '../actions.dart';
|
||||
|
||||
final locatedAddressReducer = combineReducers<LocatedAddress>([
|
||||
TypedReducer<LocatedAddress, UpdateLocatedAddress>(_updateLocatedAddress)
|
||||
final locatedAddressReducer = combineReducers<LocatedAddress?>([
|
||||
TypedReducer<LocatedAddress?, UpdateLocatedAddress>(_updateLocatedAddress)
|
||||
]);
|
||||
|
||||
LocatedAddress _updateLocatedAddress(LocatedAddress locatedAddress, action) {
|
||||
LocatedAddress _updateLocatedAddress(LocatedAddress? locatedAddress, action) {
|
||||
return action.locatedAddress;
|
||||
}
|
||||
@@ -2,10 +2,10 @@
|
||||
import 'package:redux/redux.dart';
|
||||
import '../actions.dart';
|
||||
|
||||
final redirectRouteReducer = combineReducers<String>([
|
||||
TypedReducer<String, UpdateRedirectRoute>(_updateRedirectRoute)
|
||||
final redirectRouteReducer = combineReducers<String?>([
|
||||
TypedReducer<String?, UpdateRedirectRoute>(_updateRedirectRoute)
|
||||
]);
|
||||
|
||||
String _updateRedirectRoute(String route, action) {
|
||||
String? _updateRedirectRoute(String? route, action) {
|
||||
return action.route;
|
||||
}
|
||||
@@ -2,10 +2,10 @@ import 'package:redux/redux.dart';
|
||||
|
||||
import '../actions.dart';
|
||||
|
||||
final tableNumberReducer = combineReducers<String>([
|
||||
TypedReducer<String, UpdateTableNumber>(_updateTableNumber)
|
||||
final tableNumberReducer = combineReducers<String?>([
|
||||
TypedReducer<String?, UpdateTableNumber>(_updateTableNumber)
|
||||
]);
|
||||
|
||||
String _updateTableNumber(String tableNumber, action) {
|
||||
String _updateTableNumber(String? tableNumber, action) {
|
||||
return action.tableNumber;
|
||||
}
|
||||
@@ -4,10 +4,10 @@ import 'package:flutter_wisetronic/models/user.dart';
|
||||
|
||||
import '../actions.dart';
|
||||
|
||||
final userReducer = combineReducers<User>([
|
||||
TypedReducer<User, UpdateCurrentUser>(_updateCurrentUser)
|
||||
final userReducer = combineReducers<User?>([
|
||||
TypedReducer<User?, UpdateCurrentUser>(_updateCurrentUser)
|
||||
]);
|
||||
|
||||
User _updateCurrentUser(User user, action) {
|
||||
User? _updateCurrentUser(User? user, action) {
|
||||
return action.user;
|
||||
}
|
||||
@@ -6,16 +6,16 @@ import '../../models/user.dart';
|
||||
|
||||
@immutable
|
||||
class AppState {
|
||||
final BuildContext context;
|
||||
final Locale locale;
|
||||
final User user;
|
||||
final String redirectRoute;
|
||||
final List<CartInfo> cartInfos;
|
||||
final LocatedAddress locatedAddress;
|
||||
final String fcmToken;
|
||||
final List<int> lastVisit;
|
||||
final String deviceId;
|
||||
final String tableNumber;
|
||||
final BuildContext? context;
|
||||
final Locale? locale;
|
||||
final User? user;
|
||||
final String? redirectRoute;
|
||||
final List<CartInfo>? cartInfos;
|
||||
final LocatedAddress? locatedAddress;
|
||||
final String? fcmToken;
|
||||
final List<int>? lastVisit;
|
||||
final String? deviceId;
|
||||
final String? tableNumber;
|
||||
|
||||
AppState({this.context, this.locale, this.user, this.redirectRoute,
|
||||
this.cartInfos, this.locatedAddress, this.fcmToken, this.lastVisit,
|
||||
@@ -24,8 +24,8 @@ class AppState {
|
||||
factory AppState.init() => AppState();
|
||||
|
||||
AppState copyWith({
|
||||
BuildContext context,
|
||||
Locale locale}) {
|
||||
BuildContext? context,
|
||||
Locale? locale}) {
|
||||
return AppState(
|
||||
context: context ?? this.context,
|
||||
locale: locale ?? this.locale,
|
||||
|
||||
@@ -21,9 +21,9 @@ class DoubleBackToCloseApp extends StatefulWidget {
|
||||
/// Creates a widget that allows the user to close the app by double tapping
|
||||
/// the back-button.
|
||||
const DoubleBackToCloseApp({
|
||||
Key key,
|
||||
@required this.snackBar,
|
||||
@required this.child,
|
||||
Key? key,
|
||||
required this.snackBar,
|
||||
required this.child,
|
||||
}) : assert(snackBar != null),
|
||||
assert(child != null),
|
||||
super(key: key);
|
||||
@@ -34,7 +34,7 @@ class DoubleBackToCloseApp extends StatefulWidget {
|
||||
|
||||
class _DoubleBackToCloseAppState extends State<DoubleBackToCloseApp> {
|
||||
/// The last time the user tapped Android's back-button.
|
||||
DateTime _lastTimeBackButtonWasTapped;
|
||||
DateTime? _lastTimeBackButtonWasTapped;
|
||||
|
||||
/// Returns whether the current platform is Android.
|
||||
bool get _isAndroid => Theme.of(context).platform == TargetPlatform.android;
|
||||
@@ -50,7 +50,7 @@ class _DoubleBackToCloseAppState extends State<DoubleBackToCloseApp> {
|
||||
bool get _isSnackBarVisible =>
|
||||
(_lastTimeBackButtonWasTapped != null) &&
|
||||
(widget.snackBar.duration >
|
||||
DateTime.now().difference(_lastTimeBackButtonWasTapped));
|
||||
DateTime.now().difference(_lastTimeBackButtonWasTapped!));
|
||||
|
||||
/// Returns whether the next back navigation of this route will be handled
|
||||
/// internally.
|
||||
@@ -59,7 +59,7 @@ class _DoubleBackToCloseAppState extends State<DoubleBackToCloseApp> {
|
||||
/// local-history of the current route, in order to handle pop. This is done
|
||||
/// by [Drawer], for example, so it can close on pop.
|
||||
bool get _willHandlePopInternally =>
|
||||
ModalRoute.of(context).willHandlePopInternally;
|
||||
ModalRoute.of(context)!.willHandlePopInternally;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class IFrameWeb extends StatefulWidget {
|
||||
final String width;
|
||||
final String height;
|
||||
final String src;
|
||||
final String? width;
|
||||
final String? height;
|
||||
final String? src;
|
||||
|
||||
const IFrameWeb({this.width, this.height, this.src});
|
||||
|
||||
|
||||
@@ -7,14 +7,12 @@ import 'package:crypto/crypto.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import '../store/store.dart';
|
||||
import 'utils.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:universal_io/io.dart';
|
||||
|
||||
import '../constants.dart';
|
||||
|
||||
typedef void PostCallback(Response response);
|
||||
|
||||
String generateSignature(String string, {String key}) {
|
||||
String generateSignature(String string, {String? key}) {
|
||||
if (key == null) {
|
||||
key = Constants.API_SECRET;
|
||||
}
|
||||
@@ -37,17 +35,17 @@ class HttpUtil {
|
||||
'Http-Contact-Authorization': '',
|
||||
'Http-Device-Type': Utils.getOs(checkWeb: true),
|
||||
'Http-Api-Branch': 'flutter',
|
||||
'Http-Language-Code': store.state.locale.languageCode,
|
||||
'Http-Country-Code': store.state.locale.countryCode,
|
||||
'Http-Language-Code': (store == null || store.state == null || store.state.locale == null) ? 'en' : store.state.locale!.languageCode,
|
||||
'Http-Country-Code': (store == null || store.state == null || store.state.locale == null) ? 'US' : store.state.locale!.countryCode!,
|
||||
};
|
||||
|
||||
static Future<dynamic> httpGet(String url,
|
||||
{
|
||||
Map<String, dynamic> queryParameters,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
int businessId = 0,
|
||||
Function(int, int) receiveProgress,
|
||||
Function(int, int)? receiveProgress,
|
||||
bool returnError = false,
|
||||
Map<String, String> additionalHeaders,
|
||||
Map<String, String>? additionalHeaders,
|
||||
}) async {
|
||||
Map<String, dynamic> localHeaders = json.decode(json.encode(headers));
|
||||
if (additionalHeaders != null) {
|
||||
@@ -59,8 +57,7 @@ class HttpUtil {
|
||||
}
|
||||
|
||||
localHeaders['Http-Business-Id'] = businessId == 0 ? '${Constants.BUSINESS_ID}' : businessId.toString();
|
||||
Box box = await Utils.getBox();
|
||||
localHeaders['Http-Contact-Authorization'] = box.get(Constants.KEY_ACCESS_TOKEN, defaultValue: '');
|
||||
localHeaders['Http-Contact-Authorization'] = Utils.prefs?.getString(Constants.KEY_ACCESS_TOKEN) ?? '';
|
||||
localHeaders['Http-App-Key'] = platformName;
|
||||
localHeaders['Http-Device-Type'] = platformName;
|
||||
String requestUrl = Constants.BASE_API_URL + url;
|
||||
@@ -69,7 +66,9 @@ class HttpUtil {
|
||||
requestUrl = url;
|
||||
}
|
||||
|
||||
Utils.jsonPrettyPrint(queryParameters);
|
||||
if (queryParameters != null) {
|
||||
Utils.jsonPrettyPrint(queryParameters!);
|
||||
}
|
||||
|
||||
Dio dio = Dio();
|
||||
try {
|
||||
@@ -84,9 +83,9 @@ class HttpUtil {
|
||||
// print('response data: ${response.data}');
|
||||
// Utils.jsonPrettyPrint(response.data);
|
||||
|
||||
int statusCode = response.statusCode;
|
||||
int statusCode = response.statusCode!;
|
||||
return response.data;
|
||||
} on DioError catch(e) {
|
||||
} on DioException catch(e) {
|
||||
print('HttpGet failed, request: $requestUrl, headers: $localHeaders, error ${e.response}');
|
||||
if (returnError) {
|
||||
return e;
|
||||
@@ -95,16 +94,16 @@ class HttpUtil {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<dynamic> httpPost(String url, PostCallback callback,
|
||||
static Future<dynamic> httpPost(String url, PostCallback? callback,
|
||||
{
|
||||
Map<String, dynamic> queryParameters,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
int businessId = 0,
|
||||
bool isFormData = false,
|
||||
Map<String, String> additionalHeaders,
|
||||
Map<String, dynamic> body,
|
||||
FormData formData,
|
||||
Function(int, int) sendProgress,
|
||||
Function(int, int) receiveProgress,
|
||||
Map<String, String>? additionalHeaders,
|
||||
Map<String, dynamic>? body,
|
||||
FormData? formData,
|
||||
Function(int, int)? sendProgress,
|
||||
Function(int, int)? receiveProgress,
|
||||
bool returnError = false,
|
||||
}) async {
|
||||
|
||||
@@ -116,8 +115,7 @@ class HttpUtil {
|
||||
localHeaders['Http-Signature'] = generateSignature(url);
|
||||
}
|
||||
localHeaders['Http-Business-Id'] = businessId == 0 ? '${Constants.BUSINESS_ID}' : businessId.toString();
|
||||
Box box = await Utils.getBox();
|
||||
localHeaders['Http-Contact-Authorization'] = box.get(Constants.KEY_ACCESS_TOKEN, defaultValue: '');
|
||||
localHeaders['Http-Contact-Authorization'] = Utils.prefs?.getString(Constants.KEY_ACCESS_TOKEN) ?? '';
|
||||
localHeaders['Http-App-Key'] = platformName;
|
||||
localHeaders['Http-Device-Type'] = platformName;
|
||||
|
||||
@@ -138,7 +136,7 @@ class HttpUtil {
|
||||
Response response = await dio.post(
|
||||
requestUrl,
|
||||
queryParameters: queryParameters == null ? {} : queryParameters,
|
||||
data: isFormData ? ((formData != null)?formData:FormData.fromMap(body)) : json.encode(body),
|
||||
data: isFormData ? ((formData != null)?formData:FormData.fromMap(body!)) : json.encode(body),
|
||||
options: Options(
|
||||
headers: localHeaders,
|
||||
contentType: isFormData ? Headers.formUrlEncodedContentType : Headers.jsonContentType,
|
||||
@@ -149,17 +147,17 @@ class HttpUtil {
|
||||
|
||||
// Utils.jsonPrettyPrint(response.data);
|
||||
|
||||
int statusCode = response.statusCode;
|
||||
int statusCode = response.statusCode!;
|
||||
if (callback != null) {
|
||||
callback(response);
|
||||
}
|
||||
return response.data;
|
||||
} on DioError catch(e, stacktrace) {
|
||||
} on DioException catch(e, stacktrace) {
|
||||
if (e.response != null) {
|
||||
try {
|
||||
Utils.jsonPrettyPrint(e.response.data);
|
||||
Utils.jsonPrettyPrint(e.response?.data);
|
||||
} catch (err) {
|
||||
print(e.response.data);
|
||||
print(e.response?.data);
|
||||
}
|
||||
}
|
||||
if (returnError) {
|
||||
@@ -169,14 +167,14 @@ class HttpUtil {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<dynamic> httpPut(String url, PostCallback callback,
|
||||
static Future<dynamic> httpPut(String url, PostCallback? callback,
|
||||
{
|
||||
Map<String, dynamic> queryParameters,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
int businessId = 0,
|
||||
Map<String, String> additionalHeaders,
|
||||
Map<String, dynamic> body,
|
||||
Function(int, int) sendProgress,
|
||||
Function(int, int) receiveProgress,
|
||||
Map<String, String>? additionalHeaders,
|
||||
Map<String, dynamic>? body,
|
||||
Function(int, int)? sendProgress,
|
||||
Function(int, int)? receiveProgress,
|
||||
bool returnError = false,
|
||||
}) async {
|
||||
|
||||
@@ -190,8 +188,7 @@ class HttpUtil {
|
||||
}
|
||||
|
||||
localHeaders['Http-Business-Id'] = businessId == 0 ? '${Constants.BUSINESS_ID}' : businessId.toString();
|
||||
Box box = await Utils.getBox();
|
||||
localHeaders['Http-Contact-Authorization'] = box.get(Constants.KEY_ACCESS_TOKEN, defaultValue: '');
|
||||
localHeaders['Http-Contact-Authorization'] = Utils.prefs?.getString(Constants.KEY_ACCESS_TOKEN) ?? '';
|
||||
localHeaders['Http-App-Key'] = platformName;
|
||||
localHeaders['Http-Device-Type'] = platformName;
|
||||
|
||||
@@ -218,14 +215,14 @@ class HttpUtil {
|
||||
|
||||
// Utils.jsonPrettyPrint(response.data);
|
||||
|
||||
int statusCode = response.statusCode;
|
||||
int statusCode = response.statusCode!;
|
||||
if (callback != null) {
|
||||
callback(response);
|
||||
}
|
||||
return response.data;
|
||||
} on DioError catch(e) {
|
||||
} on DioException catch(e) {
|
||||
if (e.response != null) {
|
||||
Utils.jsonPrettyPrint(e.response.data);
|
||||
Utils.jsonPrettyPrint(e.response!.data);
|
||||
}
|
||||
if (returnError) {
|
||||
return e;
|
||||
@@ -234,14 +231,14 @@ class HttpUtil {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<dynamic> httpPatch(String url, PostCallback callback,
|
||||
static Future<dynamic> httpPatch(String url, PostCallback? callback,
|
||||
{
|
||||
Map<String, dynamic> queryParameters,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
int businessId = 0,
|
||||
Map<String, String> additionalHeaders,
|
||||
Map<String, dynamic> body,
|
||||
Function(int, int) sendProgress,
|
||||
Function(int, int) receiveProgress,
|
||||
Map<String, String>? additionalHeaders,
|
||||
Map<String, dynamic>? body,
|
||||
Function(int, int)? sendProgress,
|
||||
Function(int, int)? receiveProgress,
|
||||
bool returnError = false,
|
||||
}) async {
|
||||
|
||||
@@ -255,8 +252,7 @@ class HttpUtil {
|
||||
}
|
||||
|
||||
localHeaders['Http-Business-Id'] = businessId == 0 ? '${Constants.BUSINESS_ID}' : businessId.toString();
|
||||
Box box = await Utils.getBox();
|
||||
localHeaders['Http-Contact-Authorization'] = box.get(Constants.KEY_ACCESS_TOKEN, defaultValue: '');
|
||||
localHeaders['Http-Contact-Authorization'] = Utils.prefs?.getString(Constants.KEY_ACCESS_TOKEN) ?? '';
|
||||
localHeaders['Http-App-Key'] = platformName;
|
||||
localHeaders['Http-Device-Type'] = platformName;
|
||||
|
||||
@@ -268,7 +264,9 @@ class HttpUtil {
|
||||
requestUrl = url;
|
||||
}
|
||||
|
||||
Utils.jsonPrettyPrint(body);
|
||||
if (body != null) {
|
||||
Utils.jsonPrettyPrint(body!);
|
||||
}
|
||||
|
||||
Dio dio = Dio();
|
||||
try {
|
||||
@@ -285,14 +283,14 @@ class HttpUtil {
|
||||
|
||||
// Utils.jsonPrettyPrint(response.data);
|
||||
|
||||
int statusCode = response.statusCode;
|
||||
int statusCode = response.statusCode!;
|
||||
if (callback != null) {
|
||||
callback(response);
|
||||
}
|
||||
return response.data;
|
||||
} on DioError catch(e) {
|
||||
} on DioException catch(e) {
|
||||
if (e.response != null) {
|
||||
Utils.jsonPrettyPrint(e.response.data);
|
||||
Utils.jsonPrettyPrint(e.response!.data);
|
||||
}
|
||||
if (returnError) {
|
||||
return e;
|
||||
@@ -301,12 +299,12 @@ class HttpUtil {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<dynamic> httpDelete(String url, PostCallback callback,
|
||||
static Future<dynamic> httpDelete(String url, PostCallback? callback,
|
||||
{
|
||||
Map<String, dynamic> queryParameters,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
int businessId = 0,
|
||||
Map<String, String> additionalHeaders,
|
||||
Map<String, dynamic> body,
|
||||
Map<String, String>? additionalHeaders,
|
||||
Map<String, dynamic>? body,
|
||||
bool returnError = false,
|
||||
}) async {
|
||||
|
||||
@@ -320,8 +318,7 @@ class HttpUtil {
|
||||
}
|
||||
|
||||
localHeaders['Http-Business-Id'] = businessId == 0 ? '${Constants.BUSINESS_ID}' : businessId.toString();
|
||||
Box box = await Utils.getBox();
|
||||
localHeaders['Http-Contact-Authorization'] = box.get(Constants.KEY_ACCESS_TOKEN, defaultValue: '');
|
||||
localHeaders['Http-Contact-Authorization'] = Utils.prefs?.getString(Constants.KEY_ACCESS_TOKEN) ?? '';
|
||||
localHeaders['Http-App-Key'] = platformName;
|
||||
localHeaders['Http-Device-Type'] = platformName;
|
||||
|
||||
@@ -333,7 +330,9 @@ class HttpUtil {
|
||||
requestUrl = url;
|
||||
}
|
||||
|
||||
Utils.jsonPrettyPrint(body);
|
||||
if (body != null) {
|
||||
Utils.jsonPrettyPrint(body);
|
||||
}
|
||||
|
||||
Dio dio = Dio();
|
||||
try {
|
||||
@@ -348,14 +347,14 @@ class HttpUtil {
|
||||
|
||||
// Utils.jsonPrettyPrint(response.data);
|
||||
|
||||
int statusCode = response.statusCode;
|
||||
int statusCode = response.statusCode!;
|
||||
if (callback != null) {
|
||||
callback(response);
|
||||
}
|
||||
return response.data;
|
||||
} on DioError catch(e) {
|
||||
} on DioException catch(e) {
|
||||
if (e.response != null) {
|
||||
Utils.jsonPrettyPrint(e.response.data);
|
||||
Utils.jsonPrettyPrint(e.response!.data);
|
||||
}
|
||||
if(returnError) {
|
||||
return e;
|
||||
|
||||
@@ -14,7 +14,7 @@ class ShopScrollController extends ScrollController {
|
||||
this.coordinator, {
|
||||
double initialScrollOffset = 0.0,
|
||||
this.keepScrollOffset = true,
|
||||
this.debugLabel,
|
||||
required this.debugLabel,
|
||||
}) : assert(initialScrollOffset != null),
|
||||
assert(keepScrollOffset != null),
|
||||
_initialScrollOffset = initialScrollOffset;
|
||||
@@ -61,7 +61,7 @@ class ShopScrollController extends ScrollController {
|
||||
'ScrollController not attached to any scroll views.');
|
||||
assert(_positions.length == 1,
|
||||
'ScrollController attached to multiple scroll views.');
|
||||
return _positions.single;
|
||||
return _positions.single as ShopScrollPosition;
|
||||
}
|
||||
|
||||
/// 可滚动小部件的当前滚动偏移量
|
||||
@@ -83,12 +83,12 @@ class ShopScrollController extends ScrollController {
|
||||
/// 持续时间不能为零。 要在没有动画的情况下跳至特定值,请使用[jumpTo]。
|
||||
Future<void> animateTo(
|
||||
double offset, {
|
||||
@required Duration duration,
|
||||
@required Curve curve,
|
||||
required Duration duration,
|
||||
required Curve curve,
|
||||
}) {
|
||||
assert(_positions.isNotEmpty,
|
||||
'ScrollController not attached to any scroll views.');
|
||||
final List<Future<void>> animations = List<Future<void>>(_positions.length);
|
||||
final List<Future<void>> animations = List<Future<void>>.filled(_positions.length, Future<void>.value());
|
||||
for (int i = 0; i < _positions.length; i += 1)
|
||||
animations[i] =
|
||||
_positions[i].animateTo(offset, duration: duration, curve: curve);
|
||||
@@ -149,7 +149,7 @@ class ShopScrollController extends ScrollController {
|
||||
/// 则它将是前一个实例。 当环境已更改并且[Scrollable]需要重新创建[ScrollPosition]
|
||||
/// 对象时,将使用此方法。 第一次创建[ScrollPosition]时为null。
|
||||
ScrollPosition createScrollPosition(ScrollPhysics physics,
|
||||
ScrollContext context, ScrollPosition oldPosition) {
|
||||
ScrollContext context, ScrollPosition? oldPosition) {
|
||||
return ShopScrollPosition(
|
||||
coordinator: coordinator,
|
||||
physics: physics,
|
||||
|
||||
@@ -12,15 +12,15 @@ class ShopScrollCoordinator {
|
||||
/// 页面主 CustomScrollView 控制
|
||||
final String pageLabel = "page";
|
||||
|
||||
ShopScrollController _pageScrollController;
|
||||
double Function() pinnedHeaderSliverHeightBuilder;
|
||||
ShopScrollController? _pageScrollController;
|
||||
double Function()? pinnedHeaderSliverHeightBuilder;
|
||||
|
||||
ShopScrollPosition get _pageScrollPosition => _pageScrollController.position;
|
||||
ShopScrollPosition get _pageScrollPosition => _pageScrollController!.position;
|
||||
|
||||
ScrollDragController scrollDragController;
|
||||
ScrollDragController? scrollDragController;
|
||||
|
||||
/// 主页面滑动部件默认位置
|
||||
double _pageInitialOffset;
|
||||
double? _pageInitialOffset;
|
||||
|
||||
/// 获取主页面滑动控制器
|
||||
ShopScrollController pageScrollController([double initialOffset = 0.0]) {
|
||||
@@ -28,27 +28,27 @@ class ShopScrollCoordinator {
|
||||
_pageInitialOffset = initialOffset;
|
||||
_pageScrollController = ShopScrollController(this,
|
||||
debugLabel: pageLabel, initialScrollOffset: initialOffset);
|
||||
return _pageScrollController;
|
||||
return _pageScrollController!;
|
||||
}
|
||||
|
||||
/// 创建并获取一个子滑动控制器
|
||||
ShopScrollController newChildScrollController([String debugLabel]) =>
|
||||
ShopScrollController(this, debugLabel: debugLabel);
|
||||
ShopScrollController newChildScrollController([String? debugLabel]) =>
|
||||
ShopScrollController(this, debugLabel: debugLabel ?? '');
|
||||
|
||||
/// 子部件滑动数据协调
|
||||
/// [userScrollDirection]用户滑动方向
|
||||
/// [position]被滑动的子部件的位置信息
|
||||
void applyUserOffset(double delta,
|
||||
[ScrollDirection userScrollDirection, ShopScrollPosition position]) {
|
||||
[ScrollDirection? userScrollDirection, ShopScrollPosition? position]) {
|
||||
if (userScrollDirection == ScrollDirection.reverse) {
|
||||
updateUserScrollDirection(_pageScrollPosition, userScrollDirection);
|
||||
updateUserScrollDirection(_pageScrollPosition, userScrollDirection!);
|
||||
final innerDelta = _pageScrollPosition.applyClampedDragUpdate(delta);
|
||||
if (innerDelta != 0.0) {
|
||||
updateUserScrollDirection(position, userScrollDirection);
|
||||
updateUserScrollDirection(position!, userScrollDirection);
|
||||
position.applyFullDragUpdate(innerDelta);
|
||||
}
|
||||
} else {
|
||||
updateUserScrollDirection(position, userScrollDirection);
|
||||
updateUserScrollDirection(position!, userScrollDirection!);
|
||||
final outerDelta = position.applyClampedDragUpdate(delta);
|
||||
if (outerDelta != 0.0) {
|
||||
updateUserScrollDirection(_pageScrollPosition, userScrollDirection);
|
||||
@@ -60,7 +60,7 @@ class ShopScrollCoordinator {
|
||||
bool applyContentDimensions(double minScrollExtent, double maxScrollExtent,
|
||||
ShopScrollPosition position) {
|
||||
if (pinnedHeaderSliverHeightBuilder != null) {
|
||||
maxScrollExtent = maxScrollExtent - pinnedHeaderSliverHeightBuilder();
|
||||
maxScrollExtent = maxScrollExtent - pinnedHeaderSliverHeightBuilder!();
|
||||
maxScrollExtent = math.max(0.0, maxScrollExtent);
|
||||
}
|
||||
return position.applyContentDimensions(
|
||||
@@ -77,9 +77,9 @@ class ShopScrollCoordinator {
|
||||
/// 当手指离开屏幕
|
||||
void onPointerUp(PointerUpEvent event) {
|
||||
final double _pagePixels = _pageScrollPosition.pixels;
|
||||
if (0.0 < _pagePixels && _pagePixels < _pageInitialOffset) {
|
||||
if (0.0 < _pagePixels && _pagePixels < _pageInitialOffset!) {
|
||||
if (pageExpand == PageExpandState.NotExpand &&
|
||||
_pageInitialOffset - _pagePixels > _scrollRedundancy) {
|
||||
_pageInitialOffset! - _pagePixels > _scrollRedundancy) {
|
||||
_pageScrollPosition
|
||||
.animateTo(0.0,
|
||||
duration: const Duration(milliseconds: 400), curve: Curves.ease)
|
||||
@@ -87,7 +87,7 @@ class ShopScrollCoordinator {
|
||||
} else {
|
||||
pageExpand = PageExpandState.Expanding;
|
||||
_pageScrollPosition
|
||||
.animateTo(_pageInitialOffset,
|
||||
.animateTo(_pageInitialOffset!,
|
||||
duration: const Duration(milliseconds: 400), curve: Curves.ease)
|
||||
.then((value) => pageExpand = PageExpandState.NotExpand);
|
||||
}
|
||||
|
||||
@@ -11,17 +11,17 @@ import 'shop_scroll_coordinator.dart';
|
||||
class ShopScrollPosition extends ScrollPosition
|
||||
implements ScrollActivityDelegate {
|
||||
final ShopScrollCoordinator coordinator; // 协调器
|
||||
ScrollDragController _currentDrag;
|
||||
ScrollDragController? _currentDrag;
|
||||
double _heldPreviousVelocity = 0.0;
|
||||
|
||||
ShopScrollPosition(
|
||||
{@required ScrollPhysics physics,
|
||||
@required ScrollContext context,
|
||||
{required ScrollPhysics physics,
|
||||
required ScrollContext context,
|
||||
double initialPixels = 0.0,
|
||||
bool keepScrollOffset = true,
|
||||
ScrollPosition oldPosition,
|
||||
String debugLabel,
|
||||
@required this.coordinator})
|
||||
ScrollPosition? oldPosition,
|
||||
String? debugLabel,
|
||||
required this.coordinator})
|
||||
: super(
|
||||
physics: physics,
|
||||
context: context,
|
||||
@@ -40,7 +40,7 @@ class ShopScrollPosition extends ScrollPosition
|
||||
|
||||
@override
|
||||
double setPixels(double newPixels) {
|
||||
assert(activity.isScrolling);
|
||||
assert(activity!.isScrolling);
|
||||
return super.setPixels(newPixels);
|
||||
}
|
||||
|
||||
@@ -51,13 +51,13 @@ class ShopScrollPosition extends ScrollPosition
|
||||
goIdle();
|
||||
return;
|
||||
}
|
||||
activity.updateDelegate(this);
|
||||
activity!.updateDelegate(this);
|
||||
final ShopScrollPosition typedOther = other as ShopScrollPosition;
|
||||
_userScrollDirection = typedOther._userScrollDirection;
|
||||
assert(_currentDrag == null);
|
||||
if (typedOther._currentDrag != null) {
|
||||
_currentDrag = typedOther._currentDrag;
|
||||
_currentDrag.updateDelegate(this);
|
||||
_currentDrag?.updateDelegate(this);
|
||||
typedOther._currentDrag = null;
|
||||
}
|
||||
}
|
||||
@@ -131,14 +131,14 @@ class ShopScrollPosition extends ScrollPosition
|
||||
}
|
||||
|
||||
@override
|
||||
void beginActivity(ScrollActivity newActivity) {
|
||||
void beginActivity(ScrollActivity? newActivity) {
|
||||
_heldPreviousVelocity = 0.0;
|
||||
if (newActivity == null) return;
|
||||
assert(newActivity.delegate == this);
|
||||
super.beginActivity(newActivity);
|
||||
_currentDrag?.dispose();
|
||||
_currentDrag = null;
|
||||
if (!activity.isScrolling) updateUserScrollDirection(ScrollDirection.idle);
|
||||
if (!activity!.isScrolling) updateUserScrollDirection(ScrollDirection.idle);
|
||||
}
|
||||
|
||||
/// 将[用户滚动方向]设置为给定值。
|
||||
@@ -154,7 +154,7 @@ class ShopScrollPosition extends ScrollPosition
|
||||
|
||||
@override
|
||||
ScrollHoldController hold(VoidCallback holdCancelCallback) {
|
||||
final double previousVelocity = activity.velocity;
|
||||
final double previousVelocity = activity!.velocity;
|
||||
final HoldScrollActivity holdActivity =
|
||||
HoldScrollActivity(delegate: this, onHoldCanceled: holdCancelCallback);
|
||||
beginActivity(holdActivity);
|
||||
@@ -195,10 +195,10 @@ class ShopScrollPosition extends ScrollPosition
|
||||
if (coordinator.pageExpand == PageExpandState.Expanding) return;
|
||||
}
|
||||
assert(pixels != null);
|
||||
final Simulation simulation =
|
||||
final Simulation? simulation =
|
||||
physics.createBallisticSimulation(this, velocity);
|
||||
if (simulation != null) {
|
||||
beginActivity(BallisticScrollActivity(this, simulation, context.vsync));
|
||||
beginActivity(BallisticScrollActivity(this, simulation, context.vsync, true));
|
||||
} else {
|
||||
goIdle();
|
||||
}
|
||||
@@ -220,8 +220,8 @@ class ShopScrollPosition extends ScrollPosition
|
||||
@override
|
||||
Future<void> animateTo(
|
||||
double to, {
|
||||
@required Duration duration,
|
||||
@required Curve curve,
|
||||
required Duration duration,
|
||||
required Curve curve,
|
||||
}) {
|
||||
if (nearEqual(to, pixels, physics.tolerance.distance)) {
|
||||
// 跳过动画,直接移到我们已经靠近的位置。
|
||||
|
||||
@@ -6,15 +6,11 @@ import 'dart:ui' as ui;
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
// import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:path/path.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:stripe_payment/stripe_payment.dart';
|
||||
|
||||
import '../constants.dart';
|
||||
@@ -42,174 +38,17 @@ class Util {
|
||||
}
|
||||
Util._internal();
|
||||
|
||||
// final FirebaseMessaging firebaseMessaging = FirebaseMessaging();
|
||||
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
|
||||
static bool notificationTapped = false;
|
||||
|
||||
init() {
|
||||
// initLocalNotification();
|
||||
// initFirebaseMessaging();
|
||||
|
||||
// ePmqRwRUTmKuFNfbHA-6zq:APA91bEFEQx1YgJqfx0V0VYo86uRDGjG6SP1SPCAZW4OvQ7gMOeKWDQ47bfuEM00YavtKq7ZGpsWfFL7B3ypm00ZA6crjJJLK_-j_H8bS_dnQbLFwyRcW67IXCs5sRkro71bRZv7L1WM
|
||||
|
||||
// eventBus.on<SubscribeToTopic>().listen((event) {
|
||||
// if (firebaseMessaging != null) {
|
||||
// firebaseMessaging.subscribeToTopic(event.topic);
|
||||
// }
|
||||
// });
|
||||
// eventBus.on<UnSubscribeToTopic>().listen((event) {
|
||||
// if (firebaseMessaging != null) {
|
||||
// firebaseMessaging.unsubscribeFromTopic(event.topic);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
initLocalNotification() async {
|
||||
var initializationSettingsAndroid = new AndroidInitializationSettings('ic_launcher');
|
||||
var initializationSettingsIOS = new IOSInitializationSettings(
|
||||
onDidReceiveLocalNotification: onDidReceiveLocalNotification);
|
||||
var initializationSettings = new InitializationSettings(
|
||||
android: initializationSettingsAndroid,
|
||||
iOS: initializationSettingsIOS,
|
||||
);
|
||||
await flutterLocalNotificationsPlugin.initialize(initializationSettings,
|
||||
onSelectNotification: onSelectNotification);
|
||||
}
|
||||
|
||||
Future onSelectNotification(String payload, {bool replace=false}) async {
|
||||
print('payload: $payload');
|
||||
if (payload != null && payload.isNotEmpty) {
|
||||
Routes.router.navigateTo(store.state.context, payload, replace: replace);
|
||||
}
|
||||
}
|
||||
|
||||
// initFirebaseMessaging() {
|
||||
// if (Platform.isIOS) {
|
||||
// iosPermission();
|
||||
// }
|
||||
// firebaseMessaging.getToken().then((token) {
|
||||
// print('FCM token: $token');
|
||||
// store.dispatch(UpdateFcmToken(token));
|
||||
// });
|
||||
// firebaseMessaging.configure(
|
||||
// onMessage: (Map<String, dynamic> message) {
|
||||
// print('FCM onMessage: $message');
|
||||
// // eventBus.fire(OnFcmReceived(message));
|
||||
// showNotificationWithDefaultSound(message);
|
||||
// return;
|
||||
// },
|
||||
// onBackgroundMessage: Platform.isIOS ? null : backgroundMessageHandler,
|
||||
// onResume: (Map<String, dynamic> message) {
|
||||
// print('FCM onResume: $message');
|
||||
// if (Platform.isAndroid) {
|
||||
// if (message != null && message['data'] != null && message['data']['route'] != null) {
|
||||
// notificationTapped = true;
|
||||
// onSelectNotification(message['data']['route']);
|
||||
// }
|
||||
// } else {
|
||||
// if (message != null && message['route'] != null) {
|
||||
// notificationTapped = true;
|
||||
// onSelectNotification(message['route']);
|
||||
// }
|
||||
// }
|
||||
// return;
|
||||
// },
|
||||
// onLaunch: (Map<String, dynamic> message) {
|
||||
// print('FCM onLaunch: $message');
|
||||
// if (Platform.isAndroid) {
|
||||
// if (message != null && message['data'] != null && message['data']['route'] != null) {
|
||||
// notificationTapped = true;
|
||||
// onSelectNotification(message['data']['route'], replace: true);
|
||||
// }
|
||||
// } else {
|
||||
// if (message != null && message['route'] != null) {
|
||||
// notificationTapped = true;
|
||||
// onSelectNotification(message['route'], replace: true);
|
||||
// }
|
||||
// }
|
||||
// return;
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
|
||||
Future onDidReceiveLocalNotification(int id, String title, String body, String payload) async {
|
||||
showDialog(
|
||||
context: store.state.context,
|
||||
builder: (BuildContext context) => CupertinoAlertDialog(
|
||||
title: Text(title),
|
||||
content: Text(body),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
isDefaultAction: true,
|
||||
child: Text(S.of(context).ok),
|
||||
onPressed: () async {
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
if (payload != null && payload.isNotEmpty) {
|
||||
Routes.router.navigateTo(context, payload);
|
||||
}
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future showNotificationWithDefaultSound(Map<String, dynamic> message) async {
|
||||
var androidPlatformChannelSpecifics = new AndroidNotificationDetails(
|
||||
'channelId',
|
||||
'channelName',
|
||||
'channelDescription',
|
||||
importance: Importance.max,
|
||||
priority: Priority.high,
|
||||
);
|
||||
var iOSPlatformChannelSpecifics = new IOSNotificationDetails(presentSound: true, badgeNumber: 1);
|
||||
var platformChannelSpecifics = new NotificationDetails(
|
||||
android: androidPlatformChannelSpecifics,
|
||||
iOS: iOSPlatformChannelSpecifics,
|
||||
);
|
||||
await flutterLocalNotificationsPlugin.show(
|
||||
0,
|
||||
Platform.isAndroid ? message['notification']['title'] : message['title'],
|
||||
Platform.isAndroid ? message['notification']['body'] : message['body'],
|
||||
platformChannelSpecifics,
|
||||
payload: Platform.isAndroid ? message['data']['route'] : message['route'],
|
||||
);
|
||||
}
|
||||
|
||||
// iosPermission() {
|
||||
// firebaseMessaging.requestNotificationPermissions(
|
||||
// const IosNotificationSettings(
|
||||
// sound: true,
|
||||
// badge: true,
|
||||
// alert: true,
|
||||
// )
|
||||
// );
|
||||
// firebaseMessaging.onIosSettingsRegistered.listen((IosNotificationSettings settings) {
|
||||
// print('IOS settings registered: $settings');
|
||||
// });
|
||||
// }
|
||||
|
||||
static Future<dynamic> backgroundMessageHandler(Map<String, dynamic> message) {
|
||||
print('FCM background message handler: $message');
|
||||
return Future<void>.value();
|
||||
}
|
||||
|
||||
static Future<Box> getBox() async {
|
||||
final dir = await getApplicationDocumentsDirectory();
|
||||
Hive.init(dir.path);
|
||||
Box box = await Hive.openBox('app_data');
|
||||
return box;
|
||||
}
|
||||
|
||||
static Widget showImage(String imageUrl, {double width, double height,
|
||||
BoxFit fit, Widget Function(BuildContext, String, dynamic) errorWidget}) {
|
||||
if (imageUrl != null && imageUrl.isNotEmpty && imageUrl.startsWith('https:')) {
|
||||
static Widget showImage(String imageUrl, {double? width, double? height,
|
||||
BoxFit? fit, Widget Function(BuildContext, String, dynamic)? errorWidget}) {
|
||||
if (imageUrl.isNotEmpty && imageUrl.startsWith('https:')) {
|
||||
return CachedNetworkImage(
|
||||
imageUrl: imageUrl,
|
||||
width: width,
|
||||
height: width,
|
||||
fit: fit,
|
||||
placeholder: (context, url) => Utils.imageLoadingIndicator(width: width, height: height),
|
||||
placeholder: (context, url) => Utils.imageLoadingIndicator(width: width ?? 30, height: height ?? 30),
|
||||
errorWidget: errorWidget != null ? errorWidget : (context, url, error) {
|
||||
return Image.asset(
|
||||
'assets/images/not_found.png',
|
||||
@@ -219,13 +58,13 @@ class Util {
|
||||
);
|
||||
},
|
||||
);
|
||||
} else if (imageUrl != null && imageUrl.isNotEmpty) {
|
||||
} else if (imageUrl.isNotEmpty) {
|
||||
return Image.file(
|
||||
File(imageUrl),
|
||||
width: width,
|
||||
height: height,
|
||||
fit: fit,
|
||||
errorBuilder: (BuildContext context, Object object, StackTrace stackTrace) {
|
||||
errorBuilder: (BuildContext context, Object object, StackTrace? stackTrace) {
|
||||
return Image.asset(
|
||||
'assets/images/not_found.png',
|
||||
width: width,
|
||||
@@ -319,14 +158,14 @@ class Util {
|
||||
final picker = ImagePicker();
|
||||
var image = await picker.pickImage(source: ImageSource.gallery);
|
||||
Navigator.of(context).pop();
|
||||
uploadPicture(context, File(image.path), user, commentId: commentId, orderId: orderId);
|
||||
uploadPicture(context, File(image!.path), user, commentId: commentId, orderId: orderId);
|
||||
}
|
||||
|
||||
void getPictureFromCamera(BuildContext context, User user, {int commentId = -1, int orderId = 0}) async {
|
||||
final picker = ImagePicker();
|
||||
var image = await picker.pickImage(source: ImageSource.camera);
|
||||
Navigator.of(context).pop();
|
||||
uploadPicture(context, File(image.path), user, commentId: commentId, orderId: orderId);
|
||||
uploadPicture(context, File(image!.path), user, commentId: commentId, orderId: orderId);
|
||||
}
|
||||
|
||||
void uploadPicture(BuildContext context, File image, User user, {int commentId = -1, int orderId = 0}) async {
|
||||
@@ -456,18 +295,18 @@ class Util {
|
||||
ImagePicker picker = ImagePicker();
|
||||
var image = await picker.pickImage(source: ImageSource.gallery);
|
||||
Navigator.of(context).pop();
|
||||
onGotFile(imageId, image.path);
|
||||
onGotFile(imageId, image!.path);
|
||||
}
|
||||
|
||||
void getPictureFromCamera2(BuildContext context, int imageId, OnGotFile onGotFile) async {
|
||||
ImagePicker picker = ImagePicker();
|
||||
var image = await picker.pickImage(source: ImageSource.camera);
|
||||
Navigator.of(context).pop();
|
||||
onGotFile(imageId, image.path);
|
||||
onGotFile(imageId, image!.path);
|
||||
}
|
||||
|
||||
Future<void> createTicket(BuildContext context, String msg, List<Map<String, dynamic>> images,
|
||||
OnSuccess onSuccess, OnError onError, {int id}) {
|
||||
OnSuccess onSuccess, OnError onError, {int? id}) async {
|
||||
var formData = FormData();
|
||||
formData.fields.add(MapEntry("msg", msg));
|
||||
formData.fields.add(MapEntry('id', id == null ? '0' : id.toString()));
|
||||
@@ -562,7 +401,7 @@ class Util {
|
||||
PaymentPlatform paymentPlatform, {
|
||||
bool googlePay=false,
|
||||
bool applePay=false,
|
||||
StripePaymentMethod stripePaymentMethod,
|
||||
StripePaymentMethod? stripePaymentMethod,
|
||||
}) {
|
||||
switch(paymentPlatform.code) {
|
||||
case Constants.PAYMENT_METHOD_CODE_SQUARE:
|
||||
@@ -587,7 +426,7 @@ class Util {
|
||||
StripePayment.setOptions(
|
||||
StripeOptions(publishableKey: paymentPlatform.publishableKey,
|
||||
merchantId: paymentPlatform.merchantId,
|
||||
androidPayMode: paymentPlatform.publishableKey.contains('_test_')
|
||||
androidPayMode: paymentPlatform.publishableKey!.contains('_test_')
|
||||
? 'test'
|
||||
: 'production'
|
||||
)
|
||||
@@ -595,14 +434,14 @@ class Util {
|
||||
StripePayment.paymentRequestWithNativePay(
|
||||
androidPayOptions: AndroidPayPaymentRequest(
|
||||
totalPrice: order.totalPrice.toStringAsFixed(2),
|
||||
currencyCode: order.businessInfo.currency,
|
||||
currencyCode: order.businessInfo!.currency,
|
||||
),
|
||||
applePayOptions: ApplePayPaymentOptions(
|
||||
currencyCode: order.businessInfo.currency,
|
||||
countryCode: order.businessInfo.address.country,
|
||||
currencyCode: order.businessInfo!.currency,
|
||||
countryCode: order.businessInfo!.address.country,
|
||||
items: [
|
||||
ApplePayItem(
|
||||
label: order.businessInfo.name,
|
||||
label: order.businessInfo!.name,
|
||||
amount: order.totalPrice.toStringAsFixed(2),
|
||||
),
|
||||
],
|
||||
@@ -633,7 +472,7 @@ class Util {
|
||||
),
|
||||
);
|
||||
if (paymentMethod != null) {
|
||||
Utils.stripePaymentIntent(order, null, paymentMethod.id, paymentMethod.type, (response) {
|
||||
Utils.stripePaymentIntent(order, null, paymentMethod.id!, paymentMethod.type!, (response) {
|
||||
if (response.data['status'] == Constants.STRIPE_STATUS_REQUIRES_CONFIRMATION) {
|
||||
StripePayment.confirmPaymentIntent(
|
||||
PaymentIntent(
|
||||
@@ -643,8 +482,8 @@ class Util {
|
||||
).then((paymentIntentResult) {
|
||||
if (paymentIntentResult.status == Constants.STRIPE_STATUS_SUCCEDED) {
|
||||
Utils.stripeChargedSuccess(order,
|
||||
paymentMethod.id,
|
||||
paymentIntentResult.paymentIntentId,
|
||||
paymentMethod.id!,
|
||||
paymentIntentResult.paymentIntentId!,
|
||||
(response) {
|
||||
StripePayment.completeNativePayRequest().then((_) {
|
||||
eventBus.fire(OnOrderUpdated());
|
||||
@@ -680,10 +519,10 @@ class Util {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Uint8List> getBytesFromAsset(String path, int width) async {
|
||||
static Future<Uint8List?> getBytesFromAsset(String path, int width) async {
|
||||
ByteData data = await rootBundle.load(path);
|
||||
ui.Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List(), targetWidth: width);
|
||||
ui.FrameInfo fi = await codec.getNextFrame();
|
||||
return (await fi.image.toByteData(format: ui.ImageByteFormat.png)).buffer.asUint8List();
|
||||
return (await fi.image.toByteData(format: ui.ImageByteFormat.png))?.buffer.asUint8List();
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,6 @@ import 'dart:typed_data';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:hive_flutter/hive_flutter.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../constants.dart';
|
||||
@@ -36,27 +34,21 @@ class Util {
|
||||
|
||||
}
|
||||
|
||||
static Future<Box> getBox() async {
|
||||
Hive.initFlutter();
|
||||
Box box = await Hive.openBox('wisetronic_app_data');
|
||||
return box;
|
||||
}
|
||||
|
||||
static Widget showImage(String imageUrl, {double width, double height,
|
||||
BoxFit fit, Widget Function(BuildContext, String, dynamic) errorWidget}) {
|
||||
static Widget showImage(String imageUrl, {double? width, double? height,
|
||||
BoxFit? fit, Widget Function(BuildContext, String?, dynamic)? errorWidget}) {
|
||||
return Image.network(imageUrl,
|
||||
fit: fit,
|
||||
width: width,
|
||||
height: height,
|
||||
cacheWidth: width != null ? width.round() : null,
|
||||
cacheHeight: height != null ? height.round() : null,
|
||||
loadingBuilder: (BuildContext context, Widget child, ImageChunkEvent loadingProgress) {
|
||||
loadingBuilder: (BuildContext context, Widget child, ImageChunkEvent? loadingProgress) {
|
||||
if (loadingProgress == null) return child;
|
||||
return Center(
|
||||
child: Utils.imageLoadingIndicator(),
|
||||
);
|
||||
},
|
||||
errorBuilder: (BuildContext context, Object object, StackTrace stackTrace) {
|
||||
errorBuilder: (BuildContext context, Object object, StackTrace? stackTrace) {
|
||||
print('StackTrace: $stackTrace');
|
||||
if (errorWidget != null) {
|
||||
return errorWidget(context, null, null);
|
||||
@@ -106,16 +98,16 @@ class Util {
|
||||
}
|
||||
|
||||
void startFilePicker(BuildContext context, User user, {int commentId = -1, int orderId = 0}) async {
|
||||
InputElement uploadInput = FileUploadInputElement();
|
||||
InputElement uploadInput = FileUploadInputElement() as InputElement;
|
||||
uploadInput.click();
|
||||
uploadInput.onChange.listen((e) {
|
||||
final files = uploadInput.files;
|
||||
if (files.length >= 1) {
|
||||
if (files!.length >= 1) {
|
||||
final File file = files[0];
|
||||
final FileReader reader = new FileReader();
|
||||
|
||||
reader.onLoadEnd.listen((e) {
|
||||
uploadPicture(context, reader.result, file.name, user, commentId: commentId, orderId: orderId);
|
||||
uploadPicture(context, reader.result as Uint8List, file.name, user, commentId: commentId, orderId: orderId);
|
||||
});
|
||||
reader.onError.listen((e) {
|
||||
Fluttertoast.showToast(
|
||||
@@ -210,11 +202,11 @@ class Util {
|
||||
|
||||
void startFilePicker2(BuildContext context, int imageId, OnGotFile onGotFile) async {
|
||||
final _image = await WebImagePicker().pickImage();
|
||||
onGotFile(imageId, _image.dataScheme);
|
||||
onGotFile(imageId, _image!.dataScheme);
|
||||
}
|
||||
|
||||
void createTicket(BuildContext context, String msg, List<Map<String, dynamic>> images,
|
||||
OnSuccess onSuccess, OnError onError, {int id}) {
|
||||
OnSuccess onSuccess, OnError onError, {int? id}) {
|
||||
var formData = FormData();
|
||||
formData.fields.add(MapEntry("msg", msg));
|
||||
formData.fields.add(MapEntry('id', id == null ? '0' : id.toString()));
|
||||
@@ -252,7 +244,7 @@ class Util {
|
||||
PaymentPlatform paymentPlatform, {
|
||||
bool googlePay=false,
|
||||
bool applePay=false,
|
||||
StripePaymentMethod stripePaymentMethod,
|
||||
StripePaymentMethod? stripePaymentMethod,
|
||||
}) {
|
||||
switch(paymentPlatform.code) {
|
||||
case Constants.PAYMENT_METHOD_CODE_SQUARE:
|
||||
@@ -293,36 +285,36 @@ class Util {
|
||||
}
|
||||
|
||||
class ImageInfo {
|
||||
String name;
|
||||
String data;
|
||||
String dataScheme;
|
||||
String path;
|
||||
String name = '';
|
||||
String data = '';
|
||||
String dataScheme = '';
|
||||
String path = '';
|
||||
}
|
||||
|
||||
class WebImagePicker {
|
||||
Future<ImageInfo> pickImage() async {
|
||||
Future<ImageInfo?> pickImage() async {
|
||||
print('pickImage');
|
||||
final ImageInfo data = ImageInfo();
|
||||
final FileUploadInputElement input = FileUploadInputElement();
|
||||
document.body.children.add(input);
|
||||
document.body!.children.add(input);
|
||||
input..accept = 'image/*';
|
||||
input.click();
|
||||
await input.onChange.first;
|
||||
if (input.files.isEmpty) return null;
|
||||
if (input.files!.isEmpty) return null;
|
||||
final reader = FileReader();
|
||||
reader.readAsDataUrl(input.files[0]);
|
||||
reader.readAsDataUrl(input.files![0]);
|
||||
await reader.onLoad.first;
|
||||
final encoded = reader.result as String;
|
||||
// remove data:image/*;base64 preambule
|
||||
final stripped =
|
||||
encoded.replaceFirst(RegExp(r'data:image/[^;]+;base64,'), '');
|
||||
//final imageBase64 = base64.decode(stripped);
|
||||
final imageName = input.files?.first?.name;
|
||||
final imagePath = input.files?.first?.relativePath;
|
||||
data.name = imageName;
|
||||
final imageName = input.files?.first.name;
|
||||
final imagePath = input.files?.first.relativePath;
|
||||
data.name = imageName!;
|
||||
data.data = stripped;
|
||||
data.dataScheme = encoded;
|
||||
data.path = imagePath;
|
||||
data.path = imagePath!;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:flutter_wisetronic/models/product.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:universal_io/io.dart';
|
||||
@@ -28,6 +27,7 @@ import '../store/actions.dart';
|
||||
import '../store/store.dart';
|
||||
import 'http_util.dart';
|
||||
import 'util_web.dart' if (dart.library.io) 'util_io.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
typedef void OnSuccess(Response response);
|
||||
typedef void OnError(dynamic error);
|
||||
@@ -37,16 +37,25 @@ typedef void OnOk();
|
||||
typedef void OnLoadImageError();
|
||||
|
||||
class Utils {
|
||||
static StreamSubscription onProductWillAddToCartSubscription;
|
||||
static StreamSubscription onProductWillRemoveFromCartSubscription;
|
||||
static final Utils _utils = Utils._internal();
|
||||
static SharedPreferences? prefs;
|
||||
|
||||
static StreamSubscription? onProductWillAddToCartSubscription;
|
||||
static StreamSubscription? onProductWillRemoveFromCartSubscription;
|
||||
|
||||
factory Utils() {
|
||||
return _utils;
|
||||
}
|
||||
Utils._internal();
|
||||
|
||||
init() async {
|
||||
prefs = await SharedPreferences.getInstance();
|
||||
onProductWillAddToCartSubscription =
|
||||
eventBus.on<OnProductWillAddToCart>().listen((event) {
|
||||
CartInfo cartInfo =
|
||||
CartInfo? cartInfo =
|
||||
getCartInfoByBusiness(store.state.cartInfos, event.business);
|
||||
|
||||
if (cartInfo == null || cartInfo.productList.length == 0) {
|
||||
if (cartInfo == null || cartInfo.productList!.length == 0) {
|
||||
cartInfo = CartInfo();
|
||||
cartInfo.id = 0;
|
||||
cartInfo.amountPaid = 0.0;
|
||||
@@ -57,7 +66,7 @@ class Utils {
|
||||
id: 0,
|
||||
price: event.price,
|
||||
product: event.product,
|
||||
name: event.product.name,
|
||||
name: event.product.name!,
|
||||
description: event.description,
|
||||
quantity: 1.0);
|
||||
cartInfo.productList = [lineItem];
|
||||
@@ -67,15 +76,15 @@ class Utils {
|
||||
eventBus.fire(new OnCartInfoUpdated());
|
||||
print('#1');
|
||||
} else {
|
||||
if (event.product.productAttributes.length > 0) {
|
||||
if (event.product.productAttributes!.length > 0) {
|
||||
CartLineItem lineItem = newCartLineItem(
|
||||
id: 0,
|
||||
price: event.price,
|
||||
product: event.product,
|
||||
name: event.product.name,
|
||||
name: event.product.name!,
|
||||
description: event.description,
|
||||
quantity: 1.0);
|
||||
cartInfo.productList.add(lineItem);
|
||||
cartInfo.productList!.add(lineItem);
|
||||
addSubproductToCard(cartInfo, lineItem);
|
||||
store.dispatch(new UpdateCartInfo(addCartInfoToCartInfoList(
|
||||
store.state.cartInfos, cartInfo)));
|
||||
@@ -83,8 +92,8 @@ class Utils {
|
||||
eventBus.fire(new OnCartInfoUpdated());
|
||||
} else {
|
||||
int found = -1;
|
||||
for (var i = 0; i < cartInfo.productList.length; i++) {
|
||||
if (event.product.id == cartInfo.productList[i].product.id) {
|
||||
for (var i = 0; i < cartInfo.productList!.length; i++) {
|
||||
if (event.product.id == cartInfo.productList![i].product!.id) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
@@ -94,18 +103,18 @@ class Utils {
|
||||
id: 0,
|
||||
price: event.price,
|
||||
product: event.product,
|
||||
name: event.product.name,
|
||||
name: event.product.name!,
|
||||
description: event.description,
|
||||
quantity: 1.0);
|
||||
cartInfo.productList.add(lineItem);
|
||||
cartInfo.productList!.add(lineItem);
|
||||
addSubproductToCard(cartInfo, lineItem);
|
||||
store.dispatch(new UpdateCartInfo(addCartInfoToCartInfoList(
|
||||
store.state.cartInfos, cartInfo)));
|
||||
print('#3');
|
||||
eventBus.fire(new OnCartInfoUpdated());
|
||||
} else {
|
||||
if (cartInfo.productList[found].quantity + 1.0 >
|
||||
event.product.leftNum) {
|
||||
if (cartInfo.productList![found].quantity! + 1.0 >
|
||||
event.product.leftNum!) {
|
||||
// Fluttertoast.showToast(
|
||||
// msg: S.of(context).product_insufficient,
|
||||
// toastLength: Toast.LENGTH_SHORT,
|
||||
@@ -113,8 +122,8 @@ class Utils {
|
||||
// backgroundColor: Colors.red,
|
||||
// textColor: Colors.white);
|
||||
} else {
|
||||
cartInfo.productList[found].quantity += 1;
|
||||
addSubproductQty(cartInfo, cartInfo.productList[found]);
|
||||
cartInfo.productList![found].quantity = cartInfo.productList![found].quantity! + 1;
|
||||
addSubproductQty(cartInfo, cartInfo.productList![found]);
|
||||
store.dispatch(new UpdateCartInfo(
|
||||
addCartInfoToCartInfoList(
|
||||
store.state.cartInfos, cartInfo)));
|
||||
@@ -127,41 +136,41 @@ class Utils {
|
||||
});
|
||||
onProductWillRemoveFromCartSubscription =
|
||||
eventBus.on<OnProductWillRemoveFromCart>().listen((event) {
|
||||
CartInfo cartInfo =
|
||||
CartInfo? cartInfo =
|
||||
getCartInfoByBusiness(store.state.cartInfos, event.business);
|
||||
if (cartInfo != null) {
|
||||
if (cartInfo.productList.length > 0) {
|
||||
if (cartInfo.productList!.length > 0) {
|
||||
if (event.productListIndex != -1) {
|
||||
if (cartInfo.productList[event.productListIndex].quantity <= 1) {
|
||||
String uuid = cartInfo.productList[event.productListIndex].uuid;
|
||||
cartInfo.productList.removeAt(event.productListIndex);
|
||||
if (cartInfo.productList![event.productListIndex].quantity! <= 1) {
|
||||
String uuid = cartInfo.productList![event.productListIndex].uuid!;
|
||||
cartInfo.productList!.removeAt(event.productListIndex);
|
||||
removeSubproduct(cartInfo, uuid);
|
||||
} else {
|
||||
cartInfo.productList[event.productListIndex].quantity -= 1;
|
||||
addSubproductQty(cartInfo, cartInfo.productList[event.productListIndex], remove: true);
|
||||
cartInfo.productList![event.productListIndex].quantity = cartInfo.productList![event.productListIndex].quantity! - 1;
|
||||
addSubproductQty(cartInfo, cartInfo.productList![event.productListIndex], remove: true);
|
||||
}
|
||||
} else {
|
||||
int productListIndex = -1;
|
||||
for (var i = 0; i < cartInfo.productList.length; i++) {
|
||||
if (cartInfo.productList[i].product.id == event.product.id) {
|
||||
for (var i = 0; i < cartInfo.productList!.length; i++) {
|
||||
if (cartInfo.productList![i].product!.id == event.product.id) {
|
||||
productListIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (productListIndex != -1) {
|
||||
if (cartInfo.productList[productListIndex].quantity <= 1) {
|
||||
String uuid = cartInfo.productList[productListIndex].uuid;
|
||||
cartInfo.productList.removeAt(productListIndex);
|
||||
if (cartInfo.productList![productListIndex].quantity! <= 1) {
|
||||
String uuid = cartInfo.productList![productListIndex].uuid!;
|
||||
cartInfo.productList!.removeAt(productListIndex);
|
||||
removeSubproduct(cartInfo, uuid);
|
||||
} else {
|
||||
cartInfo.productList[productListIndex].quantity -= 1;
|
||||
addSubproductQty(cartInfo, cartInfo.productList[productListIndex], remove: true);
|
||||
cartInfo.productList![productListIndex].quantity = cartInfo.productList![productListIndex].quantity! - 1;
|
||||
addSubproductQty(cartInfo, cartInfo.productList![productListIndex], remove: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cartInfo.productList.length <= 0) {
|
||||
if (cartInfo.productList!.length <= 0) {
|
||||
store.dispatch(UpdateCartInfo(removeCartInfoFromCartInfoList(
|
||||
store.state.cartInfos, cartInfo)));
|
||||
} else {
|
||||
@@ -211,7 +220,7 @@ class Utils {
|
||||
return false;
|
||||
}
|
||||
|
||||
static Map<String, dynamic> stringToJson(String string) {
|
||||
static Map<String, dynamic>? stringToJson(String? string) {
|
||||
if (string == null || string.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
@@ -244,10 +253,6 @@ class Utils {
|
||||
return platformName;
|
||||
}
|
||||
|
||||
static Future<Box> getBox() async {
|
||||
return Util.getBox();
|
||||
}
|
||||
|
||||
static Widget imageLoadingIndicator(
|
||||
{double width = 30.0, double height = 30.0}) {
|
||||
return SizedBox(
|
||||
@@ -365,7 +370,7 @@ class Utils {
|
||||
);
|
||||
}
|
||||
|
||||
static showLoadingDialog(BuildContext context, {String message}) {
|
||||
static showLoadingDialog(BuildContext context, {String? message}) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
@@ -468,46 +473,45 @@ class Utils {
|
||||
}
|
||||
|
||||
static void getCurrentUser() {
|
||||
getBox().then((box) {
|
||||
int userId = box.get(Constants.KEY_USER_ID, defaultValue: 0);
|
||||
String accessToken =
|
||||
box.get(Constants.KEY_ACCESS_TOKEN, defaultValue: '');
|
||||
if (userId == 0 || accessToken.isEmpty) {
|
||||
eventBus.fire(new OnGetCurrentUserFailed(Error()));
|
||||
} else {
|
||||
HttpUtil.httpGet(
|
||||
'v1/users/$userId',
|
||||
queryParameters: {},
|
||||
businessId: Constants.BUSINESS_ID,
|
||||
).then((value) {
|
||||
User user = User.fromJson(value);
|
||||
store.dispatch(UpdateCurrentUser(user));
|
||||
eventBus.fire(OnCurrentUserUpdated());
|
||||
}).catchError((err) {
|
||||
eventBus.fire(new OnGetCurrentUserFailed(err));
|
||||
});
|
||||
}
|
||||
}).catchError((err) {
|
||||
eventBus.fire(new OnGetCurrentUserFailed(err));
|
||||
});
|
||||
if (store.state.user != null) {
|
||||
eventBus.fire(OnCurrentUserUpdated());
|
||||
return;
|
||||
}
|
||||
int? userId = prefs?.getInt(Constants.KEY_USER_ID) ?? 0;
|
||||
String? accessToken = prefs?.getString(Constants.KEY_ACCESS_TOKEN) ?? '';
|
||||
if (userId == 0 || accessToken.isEmpty) {
|
||||
eventBus.fire(new OnGetCurrentUserFailed(Error()));
|
||||
} else {
|
||||
HttpUtil.httpGet(
|
||||
'v1/users/$userId',
|
||||
queryParameters: {},
|
||||
businessId: Constants.BUSINESS_ID,
|
||||
).then((value) {
|
||||
User user = User.fromJson(value);
|
||||
store.dispatch(UpdateCurrentUser(user));
|
||||
eventBus.fire(OnCurrentUserUpdated());
|
||||
}).catchError((err) {
|
||||
eventBus.fire(new OnGetCurrentUserFailed(err));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static void showMessageDialog(BuildContext context, dynamic error,
|
||||
{String title, List<Widget> actions, OnOk onOk}) {
|
||||
{String? title, List<Widget>? actions, OnOk? onOk}) {
|
||||
String message = '';
|
||||
print('error $error');
|
||||
if (error is DioError && error.response != null) {
|
||||
if (error.response.data['message'] != null) {
|
||||
message = error.response.data['message'];
|
||||
} else if (error.response.data['error'] != null) {
|
||||
if (error.response.data['error'] is String) {
|
||||
message = error.response.data['error'];
|
||||
} else if (error.response.data['error']['errmsg'] != null) {
|
||||
message = error.response.data['error']['errmsg'];
|
||||
} else if (error.response.data['error']['message'] != null) {
|
||||
message = error.response.data['error']['message'];
|
||||
if (error is DioException && error.response != null) {
|
||||
if (error.response!.data['message'] != null) {
|
||||
message = error.response!.data['message'];
|
||||
} else if (error.response!.data['error'] != null) {
|
||||
if (error.response!.data['error'] is String) {
|
||||
message = error.response!.data['error'];
|
||||
} else if (error.response!.data['error']['errmsg'] != null) {
|
||||
message = error.response!.data['error']['errmsg'];
|
||||
} else if (error.response!.data['error']['message'] != null) {
|
||||
message = error.response!.data['error']['message'];
|
||||
} else {
|
||||
message = error.response.data.toString();
|
||||
message = error.response!.data.toString();
|
||||
}
|
||||
}
|
||||
} else if (error is String) {
|
||||
@@ -540,20 +544,15 @@ class Utils {
|
||||
}
|
||||
|
||||
static Future<List<int>> getLastVisit() async {
|
||||
Box box = await getBox();
|
||||
List<dynamic> lastVisit =
|
||||
json.decode(box.get(Constants.KEY_LAST_VISIT, defaultValue: '[]'));
|
||||
json.decode(prefs?.getString(Constants.KEY_LAST_VISIT) ?? '[]');
|
||||
List<int> lv = lastVisit.map((e) => e as int).toList();
|
||||
store.dispatch(UpdateLastVisit(lv));
|
||||
return lv;
|
||||
}
|
||||
|
||||
static void saveLastVisit(List<int> lastVisit) {
|
||||
getBox().then((box) {
|
||||
box.put(Constants.KEY_LAST_VISIT, lastVisit.toString());
|
||||
}).catchError((error) {
|
||||
print('Error occurred: $error');
|
||||
});
|
||||
prefs?.setString(Constants.KEY_LAST_VISIT, lastVisit.toString());
|
||||
}
|
||||
|
||||
static String utcDatetimeStringToLocalDatetimeString(
|
||||
@@ -656,26 +655,26 @@ class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
static CartInfo getCartInfoByBusiness(
|
||||
List<CartInfo> cartInfos, Business business) {
|
||||
static CartInfo? getCartInfoByBusiness(
|
||||
List<CartInfo>? cartInfos, Business business) {
|
||||
if (cartInfos == null || cartInfos.length <= 0) {
|
||||
return null;
|
||||
}
|
||||
for (var i = 0; i < cartInfos.length; i++) {
|
||||
if (cartInfos[i].businessInfo.id == business.id) {
|
||||
if (cartInfos[i].businessInfo!.id == business.id) {
|
||||
return cartInfos[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static CartInfo getCartInfoByBusinessId(
|
||||
List<CartInfo> cartInfos, int businessId) {
|
||||
static CartInfo? getCartInfoByBusinessId(
|
||||
List<CartInfo>? cartInfos, int businessId) {
|
||||
if (cartInfos == null || cartInfos.length <= 0) {
|
||||
return null;
|
||||
}
|
||||
for (var i = 0; i < cartInfos.length; i++) {
|
||||
if (cartInfos[i].businessInfo.id == businessId) {
|
||||
if (cartInfos[i].businessInfo!.id == businessId) {
|
||||
return cartInfos[i];
|
||||
}
|
||||
}
|
||||
@@ -683,13 +682,13 @@ class Utils {
|
||||
}
|
||||
|
||||
static List<CartInfo> addCartInfoToCartInfoList(
|
||||
List<CartInfo> cartInfos, CartInfo cartInfo) {
|
||||
List<CartInfo>? cartInfos, CartInfo cartInfo) {
|
||||
if (cartInfos == null || cartInfos.length <= 0) {
|
||||
cartInfos = [cartInfo];
|
||||
} else {
|
||||
bool found = false;
|
||||
for (var i = 0; i < cartInfos.length; i++) {
|
||||
if (cartInfos[i].businessInfo.id == cartInfo.businessInfo.id) {
|
||||
if (cartInfos[i].businessInfo!.id == cartInfo.businessInfo!.id) {
|
||||
cartInfos[i] = cartInfo;
|
||||
found = true;
|
||||
break;
|
||||
@@ -699,22 +698,19 @@ class Utils {
|
||||
cartInfos.add(cartInfo);
|
||||
}
|
||||
}
|
||||
Utils.getBox().then((box) {
|
||||
box.put(Constants.KEY_CARTINFOS, cartInfos.toString());
|
||||
}).catchError((error) {
|
||||
print('Error occurred: $error');
|
||||
});
|
||||
prefs?.setString(Constants.KEY_CARTINFOS, cartInfos.toString());
|
||||
return cartInfos;
|
||||
}
|
||||
|
||||
static List<CartInfo> removeCartInfoFromCartInfoList(
|
||||
List<CartInfo> cartInfos, CartInfo cartInfo) {
|
||||
List<CartInfo>? cartInfos, CartInfo? cartInfo) {
|
||||
if (cartInfos == null || cartInfos.length <= 0 || cartInfo == null) {
|
||||
prefs?.setString(Constants.KEY_CARTINFOS, cartInfos.toString());
|
||||
return [];
|
||||
}
|
||||
int removeIndex = -1;
|
||||
for (var i = 0; i < cartInfos.length; i++) {
|
||||
if (cartInfo.businessInfo.id == cartInfos[i].businessInfo.id) {
|
||||
if (cartInfo.businessInfo!.id == cartInfos[i].businessInfo!.id) {
|
||||
removeIndex = i;
|
||||
break;
|
||||
}
|
||||
@@ -722,17 +718,13 @@ class Utils {
|
||||
if (removeIndex != -1) {
|
||||
cartInfos.removeAt(removeIndex);
|
||||
}
|
||||
getBox().then((box) {
|
||||
box.put(Constants.KEY_CARTINFOS, cartInfos.toString());
|
||||
}).catchError((error) {
|
||||
print('Error occurred: $error');
|
||||
});
|
||||
prefs?.setString(Constants.KEY_CARTINFOS, cartInfos.toString());
|
||||
return cartInfos;
|
||||
}
|
||||
|
||||
static void clearCart(BuildContext context, CartInfo cartInfo,
|
||||
{OnComplete onComplete}) {
|
||||
if (cartInfo != null && cartInfo.productList.length > 0) {
|
||||
{OnComplete? onComplete}) {
|
||||
if (cartInfo != null && cartInfo.productList!.length > 0) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
@@ -766,7 +758,7 @@ class Utils {
|
||||
}
|
||||
|
||||
static void requireLogin(BuildContext context,
|
||||
{String returnUrl, bool replace = true, int delayMilliseconds = 400}) {
|
||||
{String? returnUrl, bool replace = true, int delayMilliseconds = 400}) {
|
||||
Future.delayed(Duration(milliseconds: delayMilliseconds), () {
|
||||
if (returnUrl != null) {
|
||||
store.dispatch(UpdateRedirectRoute(returnUrl));
|
||||
@@ -775,9 +767,9 @@ class Utils {
|
||||
});
|
||||
}
|
||||
|
||||
static String getFirstNumberFromString(String numString) {
|
||||
static String? getFirstNumberFromString(String numString) {
|
||||
final intInStr = RegExp(r'\d+');
|
||||
return intInStr.firstMatch(numString).group(0);
|
||||
return intInStr.firstMatch(numString)?.group(0);
|
||||
}
|
||||
|
||||
static void loadProducts(int businessId, int categoryId, int page, bool more,
|
||||
@@ -845,7 +837,7 @@ class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
static String getWeekDayName(BuildContext context, int timestamp, bool shortName) {
|
||||
static String? getWeekDayName(BuildContext context, int timestamp, bool shortName) {
|
||||
DateTime date = DateTime.fromMillisecondsSinceEpoch(timestamp * 1000);
|
||||
switch(date.weekday) {
|
||||
case 1:
|
||||
@@ -854,61 +846,54 @@ class Utils {
|
||||
} else {
|
||||
return S.of(context).monday;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (shortName) {
|
||||
return S.of(context).tue;
|
||||
} else {
|
||||
return S.of(context).tuesday;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (shortName) {
|
||||
return S.of(context).wed;
|
||||
} else {
|
||||
return S.of(context).wednesday;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (shortName) {
|
||||
return S.of(context).thu;
|
||||
} else {
|
||||
return S.of(context).thursday;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if (shortName) {
|
||||
return S.of(context).fri;
|
||||
} else {
|
||||
return S.of(context).friday;
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
if (shortName) {
|
||||
return S.of(context).sat;
|
||||
} else {
|
||||
return S.of(context).saturday;
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
if (shortName) {
|
||||
return S.of(context).sun;
|
||||
} else {
|
||||
return S.of(context).sunday;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void stripePaymentIntent(Order order, String customerId, String paymentMethodId, String cardType,
|
||||
static void stripePaymentIntent(Order order, String? customerId, String paymentMethodId, String cardType,
|
||||
OnSuccess onSuccess, OnError onError,
|
||||
{
|
||||
String cardBrand,
|
||||
String cardCountry,
|
||||
int cardExpMonth,
|
||||
int cardExpYear,
|
||||
String cardFunding,
|
||||
String cardLast4,
|
||||
String? cardBrand,
|
||||
String? cardCountry,
|
||||
int? cardExpMonth,
|
||||
int? cardExpYear,
|
||||
String? cardFunding,
|
||||
String? cardLast4,
|
||||
}) {
|
||||
|
||||
HttpUtil.httpPost('v1/stripe-payment-intent',
|
||||
@@ -919,12 +904,12 @@ class Utils {
|
||||
'customer_id': customerId == null ? '' : customerId,
|
||||
'payment_method_id': paymentMethodId,
|
||||
'payment_method_type': cardType,
|
||||
'card_brand': cardBrand,
|
||||
'card_country': cardCountry,
|
||||
'card_exp_month': cardExpMonth,
|
||||
'card_exp_year': cardExpYear,
|
||||
'card_funding': cardFunding,
|
||||
'card_last4': cardLast4,
|
||||
'card_brand': cardBrand ?? '',
|
||||
'card_country': cardCountry ?? '',
|
||||
'card_exp_month': cardExpMonth ?? 0,
|
||||
'card_exp_year': cardExpYear ?? 0,
|
||||
'card_funding': cardFunding ?? '',
|
||||
'card_last4': cardLast4 ?? '',
|
||||
},
|
||||
isFormData: true,
|
||||
).catchError(onError);
|
||||
@@ -945,8 +930,8 @@ class Utils {
|
||||
|
||||
static int getProductLineInOrder(CartInfo cartInfo) {
|
||||
int qty = 0;
|
||||
for (CartLineItem lineItem in cartInfo.productList) {
|
||||
if (lineItem.product.id != null) {
|
||||
for (CartLineItem lineItem in cartInfo.productList!) {
|
||||
if (lineItem.product?.id != null) {
|
||||
qty += 1;
|
||||
}
|
||||
}
|
||||
@@ -954,10 +939,10 @@ class Utils {
|
||||
}
|
||||
|
||||
static void orderAgain(BuildContext context, CartInfo cartInfo) {
|
||||
cartInfo.productList.removeWhere((element) => element.product == null || element.product.id == null);
|
||||
cartInfo.productList!.removeWhere((element) => element.product == null || element.product!.id == null);
|
||||
store.dispatch(UpdateCartInfo(Utils.addCartInfoToCartInfoList(store.state.cartInfos, cartInfo)));
|
||||
eventBus.fire(new OnCartInfoUpdated());
|
||||
Routes.router.navigateTo(context, '/checkout/${cartInfo.businessInfo.id}');
|
||||
Routes.router.navigateTo(context, '/checkout/${cartInfo.businessInfo!.id}');
|
||||
}
|
||||
|
||||
static String getOrderStatus(BuildContext context, int statusCode) {
|
||||
@@ -978,42 +963,42 @@ class Utils {
|
||||
}
|
||||
|
||||
static CartLineItem newCartLineItem(
|
||||
{int id,
|
||||
double price,
|
||||
Product product,
|
||||
String name,
|
||||
String description,
|
||||
double quantity,
|
||||
String parentUuid,
|
||||
{int? id,
|
||||
double? price,
|
||||
Product? product,
|
||||
String? name,
|
||||
String? description,
|
||||
double? quantity,
|
||||
String? parentUuid,
|
||||
}) {
|
||||
CartLineItem lineItem = CartLineItem();
|
||||
lineItem.unitPrice = price;
|
||||
lineItem.product = product;
|
||||
lineItem.name = product.name;
|
||||
lineItem.name = product?.name ?? '';
|
||||
lineItem.description = description;
|
||||
lineItem.quantity = quantity;
|
||||
lineItem.parentUuid = parentUuid;
|
||||
lineItem.parentUuid = parentUuid ?? '';
|
||||
return lineItem;
|
||||
}
|
||||
|
||||
static void addSubproductToCard(CartInfo cartInfo, CartLineItem lineItem) {
|
||||
if (lineItem.product.subproducts.length > 0) {
|
||||
for (int j = 0; j < lineItem.product.subproducts.length; j++) {
|
||||
cartInfo.productList.add(
|
||||
if (lineItem.product!.subproducts!.length > 0) {
|
||||
for (int j = 0; j < lineItem.product!.subproducts!.length; j++) {
|
||||
cartInfo.productList!.add(
|
||||
newCartLineItem(
|
||||
id: 0,
|
||||
price: 0.0,
|
||||
product: Product(
|
||||
lineItem.product.subproducts[j].product.id,
|
||||
lineItem.product.businessId,
|
||||
lineItem.product.subproducts[j].product.name,
|
||||
lineItem.product.subproducts[j].product.price,
|
||||
lineItem.product.subproducts[j].product.description,
|
||||
lineItem.product.subproducts[j].product.image,
|
||||
lineItem.product.subproducts[j].product.productAttributes
|
||||
lineItem.product!.subproducts![j].product.id,
|
||||
lineItem.product!.businessId!,
|
||||
lineItem.product!.subproducts![j].product.name,
|
||||
lineItem.product!.subproducts![j].product.price,
|
||||
lineItem.product!.subproducts![j].product.description,
|
||||
lineItem.product!.subproducts![j].product.image,
|
||||
lineItem.product!.subproducts![j].product.productAttributes
|
||||
),
|
||||
name: lineItem.product.subproducts[j].product.name,
|
||||
description: lineItem.product.subproducts[j].product.description,
|
||||
name: lineItem.product!.subproducts![j].product.name,
|
||||
description: lineItem.product!.subproducts![j].product.description,
|
||||
quantity: 1.0,
|
||||
parentUuid: lineItem.uuid
|
||||
)
|
||||
@@ -1024,16 +1009,16 @@ class Utils {
|
||||
|
||||
static void addSubproductQty(CartInfo cartInfo, CartLineItem lineItem,
|
||||
{bool remove = false}) {
|
||||
if (lineItem.product.subproducts.length > 0) {
|
||||
for (var i = 0; i < cartInfo.productList.length; i++) {
|
||||
CartLineItem lineItem1 = cartInfo.productList[i];
|
||||
if (lineItem.product!.subproducts!.length > 0) {
|
||||
for (var i = 0; i < cartInfo.productList!.length; i++) {
|
||||
CartLineItem lineItem1 = cartInfo.productList![i];
|
||||
if (lineItem1.parentUuid == lineItem.uuid) {
|
||||
for (var j = 0; j < lineItem.product.subproducts.length; j++) {
|
||||
if (lineItem.product.subproducts[j].product.id == lineItem1.product.id) {
|
||||
for (var j = 0; j < lineItem.product!.subproducts!.length; j++) {
|
||||
if (lineItem.product!.subproducts![j].product.id == lineItem1.product!.id) {
|
||||
if (remove) {
|
||||
lineItem1.quantity -= lineItem.product.subproducts[j].quantity;
|
||||
lineItem1.quantity = lineItem1.quantity! - lineItem.product!.subproducts![j].quantity;
|
||||
} else {
|
||||
lineItem1.quantity += lineItem.product.subproducts[j].quantity;
|
||||
lineItem1.quantity = lineItem1.quantity! + lineItem.product!.subproducts![j].quantity;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1044,7 +1029,7 @@ class Utils {
|
||||
}
|
||||
|
||||
static void removeSubproduct(CartInfo cartInfo, String uuid) {
|
||||
cartInfo.productList.removeWhere((element) => element.parentUuid == uuid);
|
||||
cartInfo.productList!.removeWhere((element) => element.parentUuid == uuid);
|
||||
}
|
||||
|
||||
static void openEmail(String email) async {
|
||||
@@ -1069,7 +1054,7 @@ class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
static Widget buildLine(String name, dynamic value, {double nameSize, double valueSize}) {
|
||||
static Widget buildLine(String name, dynamic value, {double? nameSize, double? valueSize}) {
|
||||
Row row = Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -1119,7 +1104,7 @@ class Utils {
|
||||
}
|
||||
|
||||
class RuntimeError extends Error {
|
||||
final int code;
|
||||
final int? code;
|
||||
final String message;
|
||||
RuntimeError(this.message, {this.code});
|
||||
String toString() => "Runtime Error: $message";
|
||||
|
||||
@@ -13,9 +13,9 @@ import '../../widgets/general/breadcrumbs.dart';
|
||||
import '../../widgets/general/navigationbar.dart';
|
||||
|
||||
class DesktopBuyService extends StatefulWidget {
|
||||
final Map<String, dynamic> data;
|
||||
final Map<String, dynamic>? data;
|
||||
|
||||
const DesktopBuyService(this.data, {Key key})
|
||||
const DesktopBuyService(this.data, {Key? key})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
|
||||
@@ -5,7 +5,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:flutter_wisetronic/widgets/general/breadcrumbs.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:gender_selection/gender_selection.dart';
|
||||
import 'package:gender_picker/gender_picker.dart';
|
||||
import 'package:gender_picker/source/enums.dart';
|
||||
|
||||
import '../../constants.dart';
|
||||
import '../../events/eventbus.dart';
|
||||
@@ -20,10 +21,9 @@ import '../../utils/utils.dart';
|
||||
import '../../widgets/general/navigationbar.dart';
|
||||
|
||||
class DesktopEditAddress extends StatefulWidget {
|
||||
final Key key;
|
||||
final Address address;
|
||||
final Address? address;
|
||||
final int businessId;
|
||||
const DesktopEditAddress(this.address, {this.key, int businessId}) :
|
||||
const DesktopEditAddress(this.address, {Key? key, int? businessId}) :
|
||||
businessId = businessId ?? Constants.BUSINESS_ID;
|
||||
|
||||
@override
|
||||
@@ -45,12 +45,12 @@ class DesktopEditAddressState extends State<DesktopEditAddress> {
|
||||
final emailController = TextEditingController();
|
||||
final faxController = TextEditingController();
|
||||
|
||||
String country;
|
||||
Gender _selectedGender;
|
||||
String? country;
|
||||
Gender? _selectedGender;
|
||||
|
||||
String _selectedProvince;
|
||||
String? _selectedProvince;
|
||||
|
||||
bool showLoading;
|
||||
bool showLoading = false;
|
||||
|
||||
double sideSpace = 0;
|
||||
double mainSpace = 1200;
|
||||
@@ -105,8 +105,8 @@ class DesktopEditAddressState extends State<DesktopEditAddress> {
|
||||
.of(context)
|
||||
.contact_name,
|
||||
),
|
||||
validator: (String value) {
|
||||
if (value
|
||||
validator: (String? value) {
|
||||
if (value == null || value
|
||||
.trim()
|
||||
.isEmpty) {
|
||||
return S
|
||||
@@ -117,27 +117,25 @@ class DesktopEditAddressState extends State<DesktopEditAddress> {
|
||||
},
|
||||
),
|
||||
),
|
||||
GenderSelection(
|
||||
maleText: S
|
||||
.of(context)
|
||||
.mr,
|
||||
femaleText: S
|
||||
.of(context)
|
||||
.ms,
|
||||
selectedGenderIconBackgroundColor: Colors.indigo,
|
||||
checkIconAlignment: Alignment.bottomRight,
|
||||
selectedGenderCheckIcon: Icons.check,
|
||||
onChanged: (Gender gender) {
|
||||
GenderPickerWithImage(
|
||||
onChanged: (Gender? gender) {
|
||||
_selectedGender = gender;
|
||||
},
|
||||
equallyAligned: true,
|
||||
animationDuration: Duration(milliseconds: 400),
|
||||
isCircular: true,
|
||||
isSelectedGenderIconCircular: true,
|
||||
opacityOfGradient: 0.6,
|
||||
padding: const EdgeInsets.all(3.0),
|
||||
size: 50,
|
||||
maleText: S.of(context).mr,
|
||||
femaleText: S.of(context).ms,
|
||||
selectedGender: _selectedGender,
|
||||
showOtherGender: false,
|
||||
verticalAlignedText: false,
|
||||
selectedGenderTextStyle: TextStyle(
|
||||
color: Color(0xFF8b32a8), fontWeight: FontWeight.bold),
|
||||
unSelectedGenderTextStyle: TextStyle(
|
||||
color: Colors.white, fontWeight: FontWeight.normal),
|
||||
equallyAligned: true,
|
||||
animationDuration: Duration(milliseconds: 200),
|
||||
isCircular: true,
|
||||
opacityOfGradient: 0.5,
|
||||
padding: const EdgeInsets.all(3),
|
||||
size: 50,
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(
|
||||
@@ -160,8 +158,8 @@ class DesktopEditAddressState extends State<DesktopEditAddress> {
|
||||
.of(context)
|
||||
.mobile_phone_number,
|
||||
),
|
||||
validator: (String value) {
|
||||
if (value
|
||||
validator: (String? value) {
|
||||
if (value == null || value
|
||||
.trim()
|
||||
.isEmpty) {
|
||||
return S
|
||||
@@ -192,8 +190,8 @@ class DesktopEditAddressState extends State<DesktopEditAddress> {
|
||||
.of(context)
|
||||
.street_line_1,
|
||||
),
|
||||
validator: (String value) {
|
||||
if (value
|
||||
validator: (String? value) {
|
||||
if (value == null || value
|
||||
.trim()
|
||||
.isEmpty) {
|
||||
return S
|
||||
@@ -246,8 +244,8 @@ class DesktopEditAddressState extends State<DesktopEditAddress> {
|
||||
.of(context)
|
||||
.city,
|
||||
),
|
||||
validator: (String value) {
|
||||
if (value
|
||||
validator: (String? value) {
|
||||
if (value == null || value
|
||||
.trim()
|
||||
.isEmpty) {
|
||||
return S
|
||||
@@ -316,8 +314,8 @@ class DesktopEditAddressState extends State<DesktopEditAddress> {
|
||||
.of(context)
|
||||
.postal_code,
|
||||
),
|
||||
validator: (String value) {
|
||||
if (value
|
||||
validator: (String? value) {
|
||||
if (value == null || value
|
||||
.trim()
|
||||
.isEmpty) {
|
||||
return S
|
||||
@@ -361,8 +359,8 @@ class DesktopEditAddressState extends State<DesktopEditAddress> {
|
||||
.of(context)
|
||||
.email,
|
||||
),
|
||||
validator: (String value) {
|
||||
if (value.isNotEmpty && !EmailValidator.validate(value)) {
|
||||
validator: (String? value) {
|
||||
if (value != null && value.isNotEmpty && !EmailValidator.validate(value)) {
|
||||
return S
|
||||
.of(context)
|
||||
.email_is_not_valid;
|
||||
@@ -496,29 +494,29 @@ class DesktopEditAddressState extends State<DesktopEditAddress> {
|
||||
super.initState();
|
||||
setState(() {
|
||||
showLoading = false;
|
||||
_selectedProvince = widget.address.state;
|
||||
cityController.text = widget.address.city;
|
||||
postalCodeController.text = widget.address.zip;
|
||||
streetLine1Controller.text = widget.address.addressLine1;
|
||||
streetLine2Controller.text = widget.address.addressLine2;
|
||||
_selectedGender = widget.address.gender == 1 ? Gender.Male : Gender.Female;
|
||||
country = widget.address.country;
|
||||
contactNameController.text = widget.address.contactName;
|
||||
phoneController.text = widget.address.phone;
|
||||
emailController.text = widget.address.email;
|
||||
faxController.text = widget.address.fax;
|
||||
_selectedProvince = widget.address?.state;
|
||||
cityController.text = widget.address?.city ?? '';
|
||||
postalCodeController.text = widget.address?.zip ?? '';
|
||||
streetLine1Controller.text = widget.address?.addressLine1 ?? '';
|
||||
streetLine2Controller.text = widget.address?.addressLine2 ?? '';
|
||||
_selectedGender = widget.address?.gender == 1 ? Gender.Male : Gender.Female;
|
||||
country = widget.address?.country;
|
||||
contactNameController.text = widget.address?.contactName ?? '';
|
||||
phoneController.text = widget.address?.phone ?? '';
|
||||
emailController.text = widget.address?.email ?? '';
|
||||
faxController.text = widget.address?.fax ?? '';
|
||||
});
|
||||
}
|
||||
|
||||
void _saveEditAddress() {
|
||||
final FormState form = _formKey.currentState;
|
||||
if (form.validate()) {
|
||||
final FormState? form = _formKey.currentState;
|
||||
if (form != null && form.validate()) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
showLoading = true;
|
||||
});
|
||||
}
|
||||
HttpUtil.httpPatch('v1/addresses/${widget.address.id}', (response) {
|
||||
HttpUtil.httpPatch('v1/addresses/${widget.address?.id}', (response) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
showLoading = false;
|
||||
@@ -532,7 +530,7 @@ class DesktopEditAddressState extends State<DesktopEditAddress> {
|
||||
}
|
||||
},
|
||||
body: {
|
||||
'id': widget.address.id,
|
||||
'id': widget.address?.id,
|
||||
'name': contactNameController.text.trim(),
|
||||
'address_line1': streetLine1Controller.text.trim(),
|
||||
'address_line2': streetLine2Controller.text.trim(),
|
||||
@@ -562,7 +560,7 @@ class DesktopEditAddressState extends State<DesktopEditAddress> {
|
||||
showLoading = true;
|
||||
});
|
||||
}
|
||||
HttpUtil.httpDelete('v1/addresses/${widget.address.id}', (response) {
|
||||
HttpUtil.httpDelete('v1/addresses/${widget.address?.id}', (response) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
showLoading = false;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_wisetronic/generated/l10n.dart';
|
||||
|
||||
class DesktopIndexMainContent1 extends StatefulWidget {
|
||||
final String message;
|
||||
const DesktopIndexMainContent1(this.message, {Key key}) : super(key: key);
|
||||
final String? message;
|
||||
const DesktopIndexMainContent1(this.message, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -37,7 +36,7 @@ class DesktopIndexMainContent1State extends State<DesktopIndexMainContent1> {
|
||||
padding: EdgeInsets.symmetric(vertical: 30.0, horizontal: 30.0),
|
||||
child: Container(
|
||||
child: Text(
|
||||
widget.message,
|
||||
widget.message ?? '',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
|
||||
@@ -5,8 +5,8 @@ import '../../widgets/general/text_link.dart';
|
||||
import '../../utils/util_web.dart' if (dart.library.io) '../../utils/util_io.dart';
|
||||
|
||||
class DesktopIndexMainContent2 extends StatefulWidget {
|
||||
final Map<String, dynamic> content;
|
||||
const DesktopIndexMainContent2(this.content, {Key key}) : super(key: key);
|
||||
final Map<String, dynamic>? content;
|
||||
const DesktopIndexMainContent2(this.content, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -54,7 +54,7 @@ class DesktopIndexMainContent2State extends State<DesktopIndexMainContent2> {
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0),
|
||||
child: Text(
|
||||
'${widget.content['minipos']}',
|
||||
'${widget.content?['minipos']}',
|
||||
style: TextStyle(
|
||||
fontSize: 20.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -66,7 +66,7 @@ class DesktopIndexMainContent2State extends State<DesktopIndexMainContent2> {
|
||||
width: mainSpace / 2 - 100.0,
|
||||
padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0),
|
||||
child: Text(
|
||||
'${widget.content['point_of_sale_system_solution']}',
|
||||
'${widget.content?['point_of_sale_system_solution']}',
|
||||
style: TextStyle(
|
||||
fontSize: 15.0,
|
||||
color: Colors.grey,
|
||||
@@ -80,7 +80,7 @@ class DesktopIndexMainContent2State extends State<DesktopIndexMainContent2> {
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Util.showImage(
|
||||
'https:${widget.content['minipos_image']['image']}',
|
||||
'https:${widget.content?['minipos_image']['image']}',
|
||||
fit: BoxFit.fitWidth
|
||||
),
|
||||
),
|
||||
@@ -101,7 +101,7 @@ class DesktopIndexMainContent2State extends State<DesktopIndexMainContent2> {
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0),
|
||||
child: Text(
|
||||
'${widget.content['igoshow']}',
|
||||
'${widget.content?['igoshow']}',
|
||||
style: TextStyle(
|
||||
fontSize: 20.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -113,7 +113,7 @@ class DesktopIndexMainContent2State extends State<DesktopIndexMainContent2> {
|
||||
width: mainSpace / 2 - 100.0,
|
||||
padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0),
|
||||
child: Text(
|
||||
'${widget.content['igoshow_solution']}',
|
||||
'${widget.content?['igoshow_solution']}',
|
||||
style: TextStyle(
|
||||
fontSize: 15.0,
|
||||
color: Colors.grey,
|
||||
@@ -127,7 +127,7 @@ class DesktopIndexMainContent2State extends State<DesktopIndexMainContent2> {
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Util.showImage(
|
||||
'https:${widget.content['igoshow_image']['image']}',
|
||||
'https:${widget.content?['igoshow_image']['image']}',
|
||||
fit: BoxFit.fitWidth
|
||||
),
|
||||
),
|
||||
@@ -149,7 +149,7 @@ class DesktopIndexMainContent2State extends State<DesktopIndexMainContent2> {
|
||||
Column col = Column(
|
||||
children: [],
|
||||
);
|
||||
for (int i = 0; i < (widget.content['minipos_features'] as List).length; i++) {
|
||||
for (int i = 0; i < (widget.content?['minipos_features'] as List).length; i++) {
|
||||
col.children.add(Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -166,7 +166,7 @@ class DesktopIndexMainContent2State extends State<DesktopIndexMainContent2> {
|
||||
width: width - 40.0,
|
||||
padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0),
|
||||
child: Text(
|
||||
'${(widget.content['minipos_features'] as List)[i]}',
|
||||
'${(widget.content?['minipos_features'] as List)[i]}',
|
||||
style: TextStyle(
|
||||
color: Colors.black54,
|
||||
),
|
||||
@@ -195,7 +195,7 @@ class DesktopIndexMainContent2State extends State<DesktopIndexMainContent2> {
|
||||
Column col = Column(
|
||||
children: [],
|
||||
);
|
||||
for (int i = 0; i < (widget.content['igoshow_features'] as List).length; i++) {
|
||||
for (int i = 0; i < (widget.content?['igoshow_features'] as List).length; i++) {
|
||||
col.children.add(Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -212,7 +212,7 @@ class DesktopIndexMainContent2State extends State<DesktopIndexMainContent2> {
|
||||
width: width - 40.0,
|
||||
padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0),
|
||||
child: Text(
|
||||
'${(widget.content['igoshow_features'] as List)[i]}',
|
||||
'${(widget.content?['igoshow_features'] as List)[i]}',
|
||||
style: TextStyle(
|
||||
color: Colors.black54,
|
||||
),
|
||||
|
||||
@@ -6,8 +6,8 @@ import 'package:flutter_wisetronic/widgets/general/text_link.dart';
|
||||
import '../../constants.dart';
|
||||
|
||||
class DesktopIndexMainContent3 extends StatefulWidget {
|
||||
final Map<String, dynamic> content;
|
||||
const DesktopIndexMainContent3(this.content, {Key key}) : super(key: key);
|
||||
final Map<String, dynamic>? content;
|
||||
const DesktopIndexMainContent3(this.content, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
|
||||
@@ -14,12 +14,12 @@ import '../../widgets/general/breadcrumbs.dart';
|
||||
import '../../widgets/general/navigationbar.dart';
|
||||
|
||||
class DesktopNavigationBar extends StatefulWidget {
|
||||
final bool hasBack;
|
||||
final List<BreadCrumb> breadCrumbs;
|
||||
final Widget shoppingCart;
|
||||
final OnBackPress onBackPress;
|
||||
final bool? hasBack;
|
||||
final List<BreadCrumb>? breadCrumbs;
|
||||
final Widget? shoppingCart;
|
||||
final OnBackPress? onBackPress;
|
||||
|
||||
const DesktopNavigationBar({Key key, this.hasBack, this.breadCrumbs,
|
||||
const DesktopNavigationBar({Key? key, this.hasBack, this.breadCrumbs,
|
||||
this.shoppingCart, this.onBackPress}) : super(key: key);
|
||||
|
||||
@override
|
||||
@@ -30,13 +30,13 @@ class DesktopNavigationBar extends StatefulWidget {
|
||||
}
|
||||
|
||||
class DesktopNavigationBarState extends State<DesktopNavigationBar> {
|
||||
User _user;
|
||||
User? _user;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget sc = SizedBox.shrink();
|
||||
if (widget.shoppingCart != null) {
|
||||
sc = widget.shoppingCart;
|
||||
sc = widget.shoppingCart!;
|
||||
}
|
||||
Widget breadCrumbBar = SizedBox.shrink();
|
||||
if (widget.breadCrumbs != null && widget.breadCrumbs.length > 0) {
|
||||
@@ -51,8 +51,8 @@ class DesktopNavigationBarState extends State<DesktopNavigationBar> {
|
||||
Expanded(
|
||||
child: BreadCrumbs(
|
||||
widget.hasBack ?? false,
|
||||
onBackPress: widget.onBackPress,
|
||||
breadCrumbs: widget.breadCrumbs,
|
||||
onBackPress: widget.onBackPress!,
|
||||
breadCrumbs: widget.breadCrumbs!,
|
||||
),
|
||||
),
|
||||
sc,
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
import 'package:email_validator/email_validator.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_wisetronic/widgets/general/breadcrumbs.dart';
|
||||
import 'package:gender_selection/gender_selection.dart';
|
||||
import 'package:gender_picker/gender_picker.dart';
|
||||
import 'package:gender_picker/source/enums.dart';
|
||||
|
||||
import '../../constants.dart';
|
||||
import '../../generated/l10n.dart';
|
||||
@@ -14,10 +15,9 @@ import '../../utils/http_util.dart';
|
||||
import '../../widgets/general/navigationbar.dart';
|
||||
|
||||
class DesktopNewAddress extends StatefulWidget {
|
||||
final Key key;
|
||||
final LocatedAddress locatedAddress;
|
||||
final int businessId;
|
||||
const DesktopNewAddress({this.key, this.locatedAddress, this.businessId}) : super(key: key);
|
||||
final LocatedAddress? locatedAddress;
|
||||
final int? businessId;
|
||||
const DesktopNewAddress({Key? key, this.locatedAddress, this.businessId}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -39,9 +39,9 @@ class DesktopNewAddressState extends State<DesktopNewAddress> {
|
||||
final faxController = TextEditingController();
|
||||
|
||||
String country = 'CA';
|
||||
Gender _selectedGender;
|
||||
Gender? _selectedGender;
|
||||
|
||||
String _selectedProvince;
|
||||
String? _selectedProvince;
|
||||
|
||||
double sideSpace = 0;
|
||||
double mainSpace = 1200;
|
||||
@@ -97,31 +97,33 @@ class DesktopNewAddressState extends State<DesktopNewAddress> {
|
||||
),
|
||||
labelText: S.of(context).contact_name,
|
||||
),
|
||||
validator: (String value) {
|
||||
if (value.trim().isEmpty) {
|
||||
validator: (String? value) {
|
||||
if (value == null || value.trim().isEmpty) {
|
||||
return S.of(context).contact_name_is_required;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
),
|
||||
GenderSelection(
|
||||
maleText: S.of(context).mr,
|
||||
femaleText: S.of(context).ms,
|
||||
selectedGenderIconBackgroundColor: Colors.indigo,
|
||||
checkIconAlignment: Alignment.bottomRight,
|
||||
selectedGenderCheckIcon: Icons.check,
|
||||
onChanged: (Gender gender) {
|
||||
GenderPickerWithImage(
|
||||
onChanged: (Gender? gender) {
|
||||
_selectedGender = gender;
|
||||
},
|
||||
equallyAligned: true,
|
||||
animationDuration: Duration(milliseconds: 400),
|
||||
isCircular: true,
|
||||
isSelectedGenderIconCircular: true,
|
||||
opacityOfGradient: 0.6,
|
||||
padding: const EdgeInsets.all(3.0),
|
||||
size: 50,
|
||||
maleText: S.of(context).mr,
|
||||
femaleText: S.of(context).ms,
|
||||
selectedGender: _selectedGender,
|
||||
showOtherGender: false,
|
||||
verticalAlignedText: false,
|
||||
selectedGenderTextStyle: TextStyle(
|
||||
color: Color(0xFF8b32a8), fontWeight: FontWeight.bold),
|
||||
unSelectedGenderTextStyle: TextStyle(
|
||||
color: Colors.white, fontWeight: FontWeight.normal),
|
||||
equallyAligned: true,
|
||||
animationDuration: Duration(milliseconds: 200),
|
||||
isCircular: true,
|
||||
opacityOfGradient: 0.5,
|
||||
padding: const EdgeInsets.all(3),
|
||||
size: 50,
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 16.0, right: 16.0, top: 16.0, bottom: 0.0),
|
||||
@@ -141,8 +143,8 @@ class DesktopNewAddressState extends State<DesktopNewAddress> {
|
||||
),
|
||||
labelText: S.of(context).mobile_phone_number,
|
||||
),
|
||||
validator: (String value) {
|
||||
if (value.trim().isEmpty) {
|
||||
validator: (String? value) {
|
||||
if (value == null || value.trim().isEmpty) {
|
||||
return S.of(context).mobile_phone_number_is_required;
|
||||
}
|
||||
return null;
|
||||
@@ -166,8 +168,8 @@ class DesktopNewAddressState extends State<DesktopNewAddress> {
|
||||
),
|
||||
labelText: S.of(context).street_line_1,
|
||||
),
|
||||
validator: (String value) {
|
||||
if (value.trim().isEmpty) {
|
||||
validator: (String? value) {
|
||||
if (value == null || value.trim().isEmpty) {
|
||||
return S.of(context).street_line_1_is_required;
|
||||
}
|
||||
return null;
|
||||
@@ -210,8 +212,8 @@ class DesktopNewAddressState extends State<DesktopNewAddress> {
|
||||
),
|
||||
labelText: S.of(context).city,
|
||||
),
|
||||
validator: (String value) {
|
||||
if (value.trim().isEmpty) {
|
||||
validator: (String? value) {
|
||||
if (value == null || value.trim().isEmpty) {
|
||||
return S.of(context).city_is_required;
|
||||
}
|
||||
return null;
|
||||
@@ -256,8 +258,8 @@ class DesktopNewAddressState extends State<DesktopNewAddress> {
|
||||
),
|
||||
labelText: S.of(context).postal_code,
|
||||
),
|
||||
validator: (String value) {
|
||||
if (value.trim().isEmpty) {
|
||||
validator: (String? value) {
|
||||
if (value == null || value.trim().isEmpty) {
|
||||
return S.of(context).postal_code_is_required;
|
||||
}
|
||||
return null;
|
||||
@@ -291,8 +293,8 @@ class DesktopNewAddressState extends State<DesktopNewAddress> {
|
||||
),
|
||||
labelText: S.of(context).email,
|
||||
),
|
||||
validator: (String value) {
|
||||
if (value.isNotEmpty && !EmailValidator.validate(value)) {
|
||||
validator: (String? value) {
|
||||
if (value == null || value.isNotEmpty && !EmailValidator.validate(value)) {
|
||||
return S.of(context).email_is_not_valid;
|
||||
}
|
||||
return null;
|
||||
@@ -377,15 +379,15 @@ class DesktopNewAddressState extends State<DesktopNewAddress> {
|
||||
super.initState();
|
||||
setState(() {
|
||||
if (widget.locatedAddress != null) {
|
||||
if (provinces.contains(widget.locatedAddress.province)) {
|
||||
_selectedProvince = widget.locatedAddress.province;
|
||||
if (provinces.contains(widget.locatedAddress?.province)) {
|
||||
_selectedProvince = widget.locatedAddress?.province;
|
||||
}
|
||||
cityController.text = widget.locatedAddress.city;
|
||||
postalCodeController.text = widget.locatedAddress.postalCode;
|
||||
streetLine1Controller.text = (widget.locatedAddress.streetNumber != null
|
||||
&& widget.locatedAddress.streetNumber.isNotEmpty
|
||||
? widget.locatedAddress.streetNumber + ' ' : '')
|
||||
+ widget.locatedAddress.streetName;
|
||||
cityController.text = widget.locatedAddress?.city ?? '';
|
||||
postalCodeController.text = widget.locatedAddress?.postalCode ?? '';
|
||||
streetLine1Controller.text = (widget.locatedAddress?.streetNumber != null
|
||||
&& widget.locatedAddress!.streetNumber.isNotEmpty
|
||||
? widget.locatedAddress!.streetNumber + ' ' : '')
|
||||
+ widget.locatedAddress!.streetName;
|
||||
} else {
|
||||
_selectedProvince = 'Ontario';
|
||||
}
|
||||
@@ -395,11 +397,11 @@ class DesktopNewAddressState extends State<DesktopNewAddress> {
|
||||
}
|
||||
|
||||
void _saveNewAddress() {
|
||||
final FormState form = _formKey.currentState;
|
||||
if (form.validate()) {
|
||||
final FormState? form = _formKey.currentState;
|
||||
if (form != null && form.validate()) {
|
||||
|
||||
HttpUtil.httpPost('v1/addresses', (response) {
|
||||
if (widget.businessId > 0) {
|
||||
if (widget.businessId != null && widget.businessId! > 0) {
|
||||
Routes.router.navigateTo(context, '/checkout/${widget.businessId}', replace: true);
|
||||
} else {
|
||||
Routes.router.navigateTo(context, '/my-addresses/${widget.businessId}', replace: true);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stripe_sdk/stripe_sdk.dart';
|
||||
import 'package:stripe_sdk/stripe_sdk_ui.dart';
|
||||
import '../../vendor/stripe_sdk/lib/stripe_sdk_ui.dart';
|
||||
import '../../utils/mini_stripe_api.dart';
|
||||
|
||||
import '../../constants.dart';
|
||||
import '../../events/eventbus.dart';
|
||||
@@ -20,11 +20,10 @@ import '../../widgets/general/navigationbar.dart';
|
||||
|
||||
|
||||
class DesktopStripePayWeb extends StatefulWidget {
|
||||
final Key key;
|
||||
final Order order;
|
||||
final PaymentPlatform paymentPlatform;
|
||||
final StripePaymentMethod stripePaymentMethod;
|
||||
const DesktopStripePayWeb(this.order, this.paymentPlatform, {this.key, this.stripePaymentMethod});
|
||||
final StripePaymentMethod? stripePaymentMethod;
|
||||
const DesktopStripePayWeb(this.order, this.paymentPlatform, {Key? key, this.stripePaymentMethod});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -39,9 +38,9 @@ class DesktopStripePayWebState extends State<DesktopStripePayWeb> {
|
||||
final formKey = GlobalKey<FormState>();
|
||||
final card = StripeCard();
|
||||
|
||||
CardForm form;
|
||||
CardForm? form;
|
||||
|
||||
bool isSubmitting;
|
||||
bool isSubmitting = false;
|
||||
|
||||
double sideSpace = 0;
|
||||
double mainSpace = 1200;
|
||||
@@ -69,23 +68,37 @@ class DesktopStripePayWebState extends State<DesktopStripePayWeb> {
|
||||
form = CardForm(card: card, formKey: formKey, displayPostalCode: false,);
|
||||
body = ListView(
|
||||
children: <Widget>[
|
||||
form,
|
||||
form!,
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 20.0, bottom: 20.0, right: 16.0),
|
||||
alignment: Alignment.centerRight,
|
||||
child: ElevatedButton(
|
||||
child: ElevatedButton.icon(
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: Theme.of(context).primaryColor,
|
||||
backgroundColor: Colors.green,
|
||||
foregroundColor: Colors.white,
|
||||
padding:
|
||||
EdgeInsets.only(left: 32, right: 32, top: 20, bottom: 20),
|
||||
elevation: 2.0,
|
||||
shape: new RoundedRectangleBorder(
|
||||
borderRadius: new BorderRadius.circular(10.0),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
S.of(context).submit,
|
||||
icon: Icon(
|
||||
Icons.check,
|
||||
size: 32.0,
|
||||
color: Colors.yellow,
|
||||
),
|
||||
label: Text(
|
||||
S.of(context).pay,
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
if (formKey.currentState.validate()) {
|
||||
formKey.currentState.save();
|
||||
if (formKey.currentState != null && formKey.currentState!.validate()) {
|
||||
formKey.currentState!.save();
|
||||
_paymentRequestWithCard(context);
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
@@ -131,7 +144,7 @@ class DesktopStripePayWebState extends State<DesktopStripePayWeb> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
isSubmitting = false;
|
||||
StripeApi.init(widget.paymentPlatform.publishableKey);
|
||||
MiniStripeApi.init(widget.paymentPlatform.publishableKey!);
|
||||
}
|
||||
|
||||
SnackBar messageSnackBar(BuildContext context, String message) {
|
||||
@@ -160,12 +173,12 @@ class DesktopStripePayWebState extends State<DesktopStripePayWeb> {
|
||||
}
|
||||
|
||||
_paymentWithPaymentMethod(BuildContext context) async {
|
||||
Utils.stripePaymentIntent(widget.order, widget.stripePaymentMethod.customerId,
|
||||
widget.stripePaymentMethod.paymentMethodId,
|
||||
widget.stripePaymentMethod.paymentMethodType, (response) async {
|
||||
Utils.stripePaymentIntent(widget.order, widget.stripePaymentMethod?.customerId,
|
||||
widget.stripePaymentMethod!.paymentMethodId,
|
||||
widget.stripePaymentMethod!.paymentMethodType, (response) async {
|
||||
|
||||
if (response.data['status'] == Constants.STRIPE_STATUS_REQUIRES_CONFIRMATION) {
|
||||
await StripeApi.instance.confirmPaymentIntent(
|
||||
await MiniStripeApi.instance.confirmPaymentIntent(
|
||||
response.data[Constants.STRIPE_CLIENT_SECRET],
|
||||
data: {
|
||||
'payment_method': response.data['payment_method'],
|
||||
@@ -173,7 +186,7 @@ class DesktopStripePayWebState extends State<DesktopStripePayWeb> {
|
||||
).then((result2) {
|
||||
if (result2['status'] == Constants.STRIPE_STATUS_SUCCEDED) {
|
||||
Utils.stripeChargedSuccess(widget.order,
|
||||
widget.stripePaymentMethod.paymentMethodId,
|
||||
widget.stripePaymentMethod!.paymentMethodId,
|
||||
result2['id'], (response) {
|
||||
if (isSubmitting) {
|
||||
Navigator.of(context).pop();
|
||||
@@ -198,11 +211,11 @@ class DesktopStripePayWebState extends State<DesktopStripePayWeb> {
|
||||
_paymentRequestWithCard(BuildContext context) async {
|
||||
isSubmitting = true;
|
||||
Utils.showSubmitDialog(context);
|
||||
await StripeApi.instance.createPaymentMethodFromCard(card)
|
||||
await MiniStripeApi.instance.createPaymentMethodFromCard(card)
|
||||
.then((result) {
|
||||
Utils.stripePaymentIntent(widget.order, null, result['id'], result['type'], (response) async {
|
||||
if (response.data['status'] == Constants.STRIPE_STATUS_REQUIRES_CONFIRMATION) {
|
||||
await StripeApi.instance.confirmPaymentIntent(
|
||||
await MiniStripeApi.instance.confirmPaymentIntent(
|
||||
response.data[Constants.STRIPE_CLIENT_SECRET],
|
||||
data: {
|
||||
'payment_method': response.data['payment_method'],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
import 'package:badges/badges.dart';
|
||||
import 'package:badges/badges.dart' as badges;
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
@@ -17,16 +17,16 @@ import '../../store/store.dart';
|
||||
import '../../utils/utils.dart';
|
||||
|
||||
class AddRemoveButton extends StatefulWidget {
|
||||
final Product product;
|
||||
final Product? product;
|
||||
final Business business;
|
||||
final bool addOnly;
|
||||
final int cartLineItemIndex;
|
||||
final bool addToBasket;
|
||||
final bool onHovor;
|
||||
final bool? addOnly;
|
||||
final int? cartLineItemIndex;
|
||||
final bool? addToBasket;
|
||||
final bool? onHovor;
|
||||
|
||||
AddRemoveButton({
|
||||
this.product,
|
||||
this.business,
|
||||
required this.business,
|
||||
this.addOnly = false,
|
||||
this.cartLineItemIndex = -1,
|
||||
this.addToBasket = false,
|
||||
@@ -40,7 +40,7 @@ class AddRemoveButton extends StatefulWidget {
|
||||
}
|
||||
|
||||
class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
int _qty;
|
||||
int? _qty;
|
||||
var zeroColor = const Color(0xFFEFEFEF);
|
||||
var qtyColor = const Color(0xFFFF6666);
|
||||
var zeroFontColor = const Color(0xFF888888);
|
||||
@@ -48,7 +48,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
|
||||
var d = 1;
|
||||
|
||||
CartInfo cartInfo;
|
||||
CartInfo? cartInfo;
|
||||
|
||||
GlobalKey startKey = GlobalKey();
|
||||
|
||||
@@ -59,14 +59,14 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.product.leftNum == null) {
|
||||
if (widget.product?.leftNum == null) {
|
||||
_qty = 0;
|
||||
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business);
|
||||
if (cartInfo != null) {
|
||||
for (var i = 0; i < cartInfo.productList.length; i++) {
|
||||
if (cartInfo.productList[i].product.id == widget.product.id
|
||||
&& cartInfo.productList[i].unitPrice == 0.0) {
|
||||
_qty = cartInfo.productList[i].quantity.round();
|
||||
for (var i = 0; i < cartInfo!.productList!.length; i++) {
|
||||
if (cartInfo!.productList?[i].product?.id == widget.product?.id
|
||||
&& cartInfo!.productList?[i].unitPrice == 0.0) {
|
||||
_qty = cartInfo!.productList?[i].quantity?.round();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
),
|
||||
);
|
||||
}
|
||||
if (widget.product.leftNum <= 0) {
|
||||
if (widget.product!.leftNum! <= 0) {
|
||||
return Container(
|
||||
padding: EdgeInsets.only(top: 0.0, bottom: 10.0, left: 8.0, right: 8.0),
|
||||
child: Text(
|
||||
@@ -100,19 +100,19 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
),
|
||||
);
|
||||
}
|
||||
if (widget.addToBasket) {
|
||||
if (widget.addToBasket!) {
|
||||
_qty = 0;
|
||||
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business);
|
||||
if (cartInfo != null) {
|
||||
for (var i = 0; i < cartInfo.productList.length; i++) {
|
||||
if (cartInfo.productList[i].product.id == widget.product.id) {
|
||||
_qty = cartInfo.productList[i].quantity.round();
|
||||
for (var i = 0; i < cartInfo!.productList!.length; i++) {
|
||||
if (cartInfo!.productList?[i].product?.id == widget.product?.id) {
|
||||
_qty = cartInfo!.productList?[i].quantity?.round();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_qty > 0) {
|
||||
return Badge(
|
||||
if (_qty! > 0) {
|
||||
return badges.Badge(
|
||||
badgeContent: Text(
|
||||
'$_qty',
|
||||
style: TextStyle(
|
||||
@@ -120,14 +120,17 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
fontSize: 17.0,
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.all(10),
|
||||
position: BadgePosition.topEnd(top: -15, end: -10),
|
||||
badgeColor: Colors.lightBlueAccent,
|
||||
badgeStyle: badges.BadgeStyle(
|
||||
padding: EdgeInsets.all(10),
|
||||
badgeColor: Colors.lightBlueAccent,
|
||||
),
|
||||
position: badges.BadgePosition.topEnd(top: -15, end: -10),
|
||||
child: ElevatedButton.icon(
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: Colors.redAccent,
|
||||
onPrimary: Colors.white,
|
||||
padding: EdgeInsets.only(left: 32, right: 32, top: 20, bottom: 20),
|
||||
backgroundColor: Colors.redAccent,
|
||||
foregroundColor: Colors.white,
|
||||
padding:
|
||||
EdgeInsets.only(left: 32, right: 32, top: 20, bottom: 20),
|
||||
elevation: 2.0,
|
||||
shape: new RoundedRectangleBorder(
|
||||
borderRadius: new BorderRadius.circular(10.0),
|
||||
@@ -154,7 +157,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
} else {
|
||||
return ElevatedButton.icon(
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: Colors.redAccent,
|
||||
backgroundColor: Colors.redAccent,
|
||||
padding: EdgeInsets.only(left: 32, right: 32, top: 20, bottom: 20),
|
||||
elevation: 2.0,
|
||||
shape: new RoundedRectangleBorder(
|
||||
@@ -179,7 +182,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
},
|
||||
);
|
||||
}
|
||||
} else if (widget.addOnly) {
|
||||
} else if (widget.addOnly!) {
|
||||
return Container(
|
||||
key: startKey,
|
||||
padding: EdgeInsets.all(0.0),
|
||||
@@ -197,15 +200,15 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
_qty = 0;
|
||||
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business);
|
||||
if (cartInfo != null) {
|
||||
for (var i = 0; i < cartInfo.productList.length; i++) {
|
||||
if (cartInfo.productList[i].product.id == widget.product.id) {
|
||||
_qty = cartInfo.productList[i].quantity.round();
|
||||
for (var i = 0; i < cartInfo!.productList!.length; i++) {
|
||||
if (cartInfo!.productList?[i].product?.id == widget.product?.id) {
|
||||
_qty = cartInfo!.productList?[i].quantity?.round();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (widget.product.productAttributes != null &&
|
||||
widget.product.productAttributes.length > 0 && widget.cartLineItemIndex == -1) {
|
||||
if (widget.product!.productAttributes != null &&
|
||||
widget.product!.productAttributes!.length > 0 && widget.cartLineItemIndex == -1) {
|
||||
return new Row(
|
||||
key: startKey,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
@@ -219,13 +222,13 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
style: new TextStyle(
|
||||
fontSize: 13.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _qty > 0 ? qtyFontColor : zeroFontColor
|
||||
color: _qty! > 0 ? qtyFontColor : zeroFontColor
|
||||
),
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.all(5.0).copyWith(left: 10.0, right: 10.0),
|
||||
decoration: BoxDecoration(
|
||||
color: _qty > 0 ? qtyColor : zeroColor,
|
||||
color: _qty! > 0 ? qtyColor : zeroColor,
|
||||
shape: BoxShape.rectangle,
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(10.0),
|
||||
@@ -242,7 +245,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
],
|
||||
);
|
||||
} else {
|
||||
if (!widget.onHovor && _qty == 0) {
|
||||
if (!widget.onHovor! && _qty == 0) {
|
||||
return SizedBox.shrink();
|
||||
}
|
||||
return new Row(
|
||||
@@ -258,13 +261,13 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
style: new TextStyle(
|
||||
fontSize: 13.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _qty > 0 ? qtyFontColor : zeroFontColor
|
||||
color: _qty! > 0 ? qtyFontColor : zeroFontColor
|
||||
),
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.all(5.0).copyWith(left: 10.0, right: 10.0),
|
||||
decoration: BoxDecoration(
|
||||
color: _qty > 0 ? qtyColor : zeroColor,
|
||||
color: _qty! > 0 ? qtyColor : zeroColor,
|
||||
shape: BoxShape.rectangle,
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(10.0),
|
||||
@@ -299,7 +302,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
if (_qty > 0) {
|
||||
if (_qty! > 0) {
|
||||
_removeFromCart(context);
|
||||
}
|
||||
},
|
||||
@@ -312,7 +315,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
|
||||
void _addToCart(BuildContext context) {
|
||||
if (widget.cartLineItemIndex != -1) {
|
||||
if (cartInfo.productList[widget.cartLineItemIndex].quantity + 1.0 > widget.product.leftNum) {
|
||||
if (cartInfo!.productList![widget.cartLineItemIndex!].quantity! + 1.0 > widget.product!.leftNum!) {
|
||||
Fluttertoast.showToast(
|
||||
msg: S.of(context).product_insufficient,
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
@@ -321,23 +324,23 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
textColor: Colors.white
|
||||
);
|
||||
} else {
|
||||
cartInfo.productList[widget.cartLineItemIndex].quantity += 1.0;
|
||||
Utils.addSubproductQty(cartInfo, cartInfo.productList[widget.cartLineItemIndex]);
|
||||
cartInfo!.productList![widget.cartLineItemIndex!].quantity = cartInfo!.productList![widget.cartLineItemIndex!].quantity! + 1.0;
|
||||
Utils.addSubproductQty(cartInfo!, cartInfo!.productList![widget.cartLineItemIndex!]);
|
||||
store.dispatch(UpdateCartInfo(
|
||||
Utils.addCartInfoToCartInfoList(store.state.cartInfos, cartInfo)));
|
||||
Utils.addCartInfoToCartInfoList(store.state.cartInfos, cartInfo!)));
|
||||
eventBus.fire(new OnCartInfoUpdated());
|
||||
}
|
||||
} else {
|
||||
if (widget.product.productAttributes.length > 0) {
|
||||
if (widget.product!.productAttributes!.length > 0) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) =>
|
||||
new AttributeSelection(
|
||||
product: widget.product, business: widget.business, startKey: startKey,)),
|
||||
product: widget.product!, business: widget.business, startKey: startKey,)),
|
||||
);
|
||||
} else {
|
||||
eventBus.fire(new OnProductWillAddToCart(widget.product, {},
|
||||
widget.product.price, widget.product.description,
|
||||
eventBus.fire(new OnProductWillAddToCart(widget.product!, {},
|
||||
widget.product!.price!, widget.product!.description!,
|
||||
widget.business, buttonKey: startKey));
|
||||
}
|
||||
}
|
||||
@@ -345,7 +348,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
|
||||
void _removeFromCart(BuildContext context) {
|
||||
if (widget.cartLineItemIndex != -1) {
|
||||
if (cartInfo.productList[widget.cartLineItemIndex].quantity <= 1) {
|
||||
if (cartInfo!.productList![widget.cartLineItemIndex!].quantity! <= 1) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
@@ -375,23 +378,23 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
}
|
||||
} else {
|
||||
eventBus.fire(new OnProductWillRemoveFromCart(
|
||||
widget.product, -1, widget.business));
|
||||
widget.product!, -1, widget.business));
|
||||
}
|
||||
}
|
||||
|
||||
void _removeCartLineItem() {
|
||||
if (cartInfo.productList[widget.cartLineItemIndex].quantity <= 1) {
|
||||
String uuid = cartInfo.productList[widget.cartLineItemIndex].uuid;
|
||||
cartInfo.productList.removeAt(widget.cartLineItemIndex);
|
||||
Utils.removeSubproduct(cartInfo, uuid);
|
||||
if (cartInfo!.productList![widget.cartLineItemIndex!].quantity! <= 1) {
|
||||
String uuid = cartInfo!.productList![widget.cartLineItemIndex!].uuid!;
|
||||
cartInfo!.productList?.removeAt(widget.cartLineItemIndex!);
|
||||
Utils.removeSubproduct(cartInfo!, uuid);
|
||||
} else {
|
||||
cartInfo.productList[widget.cartLineItemIndex].quantity -= 1;
|
||||
Utils.addSubproductQty(cartInfo, cartInfo.productList[widget.cartLineItemIndex], remove: true);
|
||||
cartInfo!.productList![widget.cartLineItemIndex!].quantity = cartInfo!.productList![widget.cartLineItemIndex!].quantity! - 1;
|
||||
Utils.addSubproductQty(cartInfo!, cartInfo!.productList![widget.cartLineItemIndex!], remove: true);
|
||||
}
|
||||
if (cartInfo.productList.length <= 0) {
|
||||
if (cartInfo!.productList!.length <= 0) {
|
||||
store.dispatch(new UpdateCartInfo(Utils.removeCartInfoFromCartInfoList(store.state.cartInfos, cartInfo)));
|
||||
} else {
|
||||
store.dispatch(new UpdateCartInfo(Utils.addCartInfoToCartInfoList(store.state.cartInfos, cartInfo)));
|
||||
store.dispatch(new UpdateCartInfo(Utils.addCartInfoToCartInfoList(store.state.cartInfos, cartInfo!)));
|
||||
}
|
||||
eventBus.fire(new OnCartInfoUpdated());
|
||||
}
|
||||
|
||||
@@ -5,23 +5,23 @@ import 'popup_animation_widget.dart';
|
||||
|
||||
class AnimationPointManager {
|
||||
List<AnimatedWidget> list = [];
|
||||
static AnimationController controller1;
|
||||
static AnimationController controller2;
|
||||
static AnimationController? controller1;
|
||||
static AnimationController? controller2;
|
||||
|
||||
Future<void> addParabolicAniamtion({
|
||||
@required TickerProvider vsync,
|
||||
@required GlobalKey stackKey,
|
||||
@required GlobalKey startKey,
|
||||
@required GlobalKey endKey,
|
||||
@required Duration duration,
|
||||
@required AnimationStatusListener statusListener,
|
||||
required TickerProvider vsync,
|
||||
required GlobalKey stackKey,
|
||||
required GlobalKey startKey,
|
||||
required GlobalKey endKey,
|
||||
required Duration duration,
|
||||
required AnimationStatusListener statusListener,
|
||||
Color color = Colors.red,
|
||||
double size = 20,
|
||||
Offset startAdjustOffset = Offset.zero,
|
||||
Offset endAdjustOffset = Offset.zero,
|
||||
}) async {
|
||||
controller1 = createController(vsync, duration);
|
||||
Animation animation = createAnimation(controller1);
|
||||
Animation<double> animation = createAnimation(controller1);
|
||||
|
||||
AnimatedWidget animatedWidget = ParabolicAnimationWidget(
|
||||
animation: animation,
|
||||
@@ -37,9 +37,9 @@ class AnimationPointManager {
|
||||
statusListener(AnimationStatus.dismissed);
|
||||
|
||||
try {
|
||||
await controller1.forward().orCancel;
|
||||
await controller1?.forward().orCancel;
|
||||
list.remove(animatedWidget);
|
||||
controller1.dispose();
|
||||
controller1?.dispose();
|
||||
print('Controller1 disposed');
|
||||
} on TickerCanceled {
|
||||
print("Ticker Canceled");
|
||||
@@ -51,31 +51,31 @@ class AnimationPointManager {
|
||||
}
|
||||
|
||||
Future<void> addPopupAniamtion({
|
||||
@required TickerProvider vsync,
|
||||
@required GlobalKey stackKey,
|
||||
@required GlobalKey startKey,
|
||||
@required Widget child,
|
||||
Duration duration,
|
||||
required TickerProvider vsync,
|
||||
required GlobalKey stackKey,
|
||||
required GlobalKey startKey,
|
||||
required Widget child,
|
||||
required Duration duration,
|
||||
Offset popupOffset = Offset.zero,
|
||||
AnimationStatusListener statusListener,
|
||||
AnimationStatusListener? statusListener,
|
||||
}) async {
|
||||
controller2 = createController(vsync, duration);
|
||||
|
||||
AnimatedWidget animatedWidget = PopupAnimationWidget(
|
||||
animation: controller2.view,
|
||||
animation: controller2!.view,
|
||||
stackKey: stackKey,
|
||||
startKey: startKey,
|
||||
child: child,
|
||||
popupOffset: popupOffset,
|
||||
);
|
||||
list.add(animatedWidget);
|
||||
statusListener(AnimationStatus.dismissed);
|
||||
if (statusListener != null) statusListener(AnimationStatus.dismissed);
|
||||
|
||||
try {
|
||||
await controller2.forward().orCancel;
|
||||
await controller2.reverse().orCancel;
|
||||
await controller2?.forward().orCancel;
|
||||
await controller2?.reverse().orCancel;
|
||||
list.remove(animatedWidget);
|
||||
controller2.dispose();
|
||||
controller2?.dispose();
|
||||
print('Controller2 disposed');
|
||||
} on TickerCanceled {
|
||||
print("Ticker Canceled");
|
||||
@@ -83,7 +83,7 @@ class AnimationPointManager {
|
||||
print('Error: $error');
|
||||
}
|
||||
|
||||
statusListener(AnimationStatus.completed);
|
||||
if (statusListener != null) statusListener(AnimationStatus.completed);
|
||||
}
|
||||
|
||||
static AnimationController createController(
|
||||
|
||||
@@ -14,7 +14,7 @@ import 'rules.dart';
|
||||
import 'options_base.dart';
|
||||
|
||||
class CheckOptions extends OptionsBase {
|
||||
CheckOptions({@required Product product, @required int index, @required Map<String, dynamic> selections})
|
||||
CheckOptions({required Product product, required int index, required Map<String, dynamic> selections})
|
||||
: super(product: product, index: index, selections: selections);
|
||||
|
||||
@override
|
||||
@@ -50,14 +50,14 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Text(
|
||||
S.of(context).check_option_select_token(product.productAttributes[this.index].name),
|
||||
S.of(context).check_option_select_token(product!.productAttributes![this.index!].name),
|
||||
style: new TextStyle(
|
||||
fontSize: 12.5,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
new Text(
|
||||
product.productAttributes[this.index].required ? S.of(context).check_option_is_required : S.of(context).check_option_is_optional,
|
||||
product!.productAttributes![this.index!].required ? S.of(context).check_option_is_required : S.of(context).check_option_is_optional,
|
||||
style: new TextStyle(
|
||||
fontSize: 10.0,
|
||||
color: new Color(0xFF999999)
|
||||
@@ -95,25 +95,25 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
|
||||
'adjust_amount': adjustAmount
|
||||
};
|
||||
var cloneSelections = json.decode(json.encode(selections));
|
||||
int idx = Utils.selectionsContains(cloneSelections, product.productAttributes[index].name, name);
|
||||
int idx = Utils.selectionsContains(cloneSelections, product!.productAttributes![index!].name, name);
|
||||
if (idx != -1) {
|
||||
(cloneSelections[product.productAttributes[index].name.toUpperCase()] as List).removeAt(idx);
|
||||
} else if (cloneSelections.containsKey(product.productAttributes[index].name.toUpperCase())) {
|
||||
(cloneSelections[product.productAttributes[index].name.toUpperCase()] as List).add(opt);
|
||||
(cloneSelections[product!.productAttributes![index!].name.toUpperCase()] as List).removeAt(idx);
|
||||
} else if (cloneSelections.containsKey(product!.productAttributes![index!].name.toUpperCase())) {
|
||||
(cloneSelections[product!.productAttributes![index!].name.toUpperCase()] as List).add(opt);
|
||||
} else {
|
||||
cloneSelections[product.productAttributes[index].name.toUpperCase()] = [opt];
|
||||
cloneSelections[product!.productAttributes![index!].name.toUpperCase()] = [opt];
|
||||
}
|
||||
|
||||
if (idx != -1 && (cloneSelections[product.productAttributes[index].name.toUpperCase()] as List).length == 0) {
|
||||
cloneSelections.remove(product.productAttributes[index].name.toUpperCase());
|
||||
if (idx != -1 && (cloneSelections[product!.productAttributes![index!].name.toUpperCase()] as List).length == 0) {
|
||||
cloneSelections.remove(product!.productAttributes![index!].name.toUpperCase());
|
||||
}
|
||||
|
||||
setOptionsStateDisabled(product.productAttributes[index].name, false);
|
||||
setOptionsStateDisabled(product!.productAttributes![index!].name, false);
|
||||
|
||||
setState(() {
|
||||
selections = cloneSelections;
|
||||
});
|
||||
eventBus.fire(new OnAttributeSelectionsChanged(selections));
|
||||
eventBus.fire(new OnAttributeSelectionsChanged(selections!));
|
||||
}
|
||||
|
||||
Widget _getOptionWidget() {
|
||||
@@ -121,20 +121,20 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
|
||||
children: <Widget>[],
|
||||
);
|
||||
|
||||
List<ProductOption> productOptions = product.productAttributes[index].productOptions;
|
||||
List<ProductOption> productOptions = product!.productAttributes![index!].productOptions;
|
||||
|
||||
if (!optionsState.containsKey(product.productAttributes[index].name)) {
|
||||
if (!optionsState.containsKey(product!.productAttributes![index!].name)) {
|
||||
List<Map<String, dynamic>> optionState = [];
|
||||
for (var i = 0; i < productOptions.length; i++) {
|
||||
optionState.add({'name': product.productAttributes[index].productOptions[i].name, 'disabled': false, 'check': false});
|
||||
optionState.add({'name': product!.productAttributes![index!].productOptions[i].name, 'disabled': false, 'check': false});
|
||||
}
|
||||
optionsState[product.productAttributes[index].name] = optionState;
|
||||
optionsState[product!.productAttributes![index!].name] = optionState;
|
||||
}
|
||||
|
||||
if (selections.containsKey(product.productAttributes[index].name.toUpperCase())) {
|
||||
if (selections!.containsKey(product!.productAttributes![index!].name.toUpperCase())) {
|
||||
|
||||
Map<String, dynamic> attrExtraJson = Utils.stringToJson(
|
||||
product.productAttributes[index].extra);
|
||||
Map<String, dynamic>? attrExtraJson = Utils.stringToJson(
|
||||
product!.productAttributes![index!].extra);
|
||||
if (attrExtraJson != null) {
|
||||
var selectLimitIfFieldEqualsTo = Rule.getRule(
|
||||
attrExtraJson, Rule.RULE_SELECT_LIMIT_IF_FIELD_EQUALS_TO);
|
||||
@@ -147,15 +147,15 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
|
||||
int limitQty = selectLimitIfFieldEqualsTo1[Rule
|
||||
.RULE_KEY_FORCE_LIMITED];
|
||||
thisLimitQty = limitQty;
|
||||
if ((selections[product.productAttributes[index].name
|
||||
if ((selections![product!.productAttributes![index!].name
|
||||
.toUpperCase()] as List).length >= limitQty) {
|
||||
disableOptionIfNotSelected();
|
||||
}
|
||||
} else if (Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY]).length > 0) {
|
||||
if (selectLimitIfFieldEqualsTo1.containsKey(Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY])[0])) {
|
||||
int limitQty = selectLimitIfFieldEqualsTo1[Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY])[0]];
|
||||
} else if (Utils.getSelectedAttributeValue(selections!, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY]).length > 0) {
|
||||
if (selectLimitIfFieldEqualsTo1.containsKey(Utils.getSelectedAttributeValue(selections!, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY])[0])) {
|
||||
int limitQty = selectLimitIfFieldEqualsTo1[Utils.getSelectedAttributeValue(selections!, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY])[0]];
|
||||
thisLimitQty = limitQty;
|
||||
if ((selections[product.productAttributes[index].name
|
||||
if ((selections![product!.productAttributes![index!].name
|
||||
.toUpperCase()] as List).length >= limitQty) {
|
||||
disableOptionIfNotSelected();
|
||||
}
|
||||
@@ -168,15 +168,15 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
|
||||
int limitQty = selectLimitIfFieldEqualsTo[Rule
|
||||
.RULE_KEY_FORCE_LIMITED];
|
||||
thisLimitQty = limitQty;
|
||||
if ((selections[product.productAttributes[index].name
|
||||
if ((selections![product!.productAttributes![index!].name
|
||||
.toUpperCase()] as List).length >= limitQty) {
|
||||
disableOptionIfNotSelected();
|
||||
}
|
||||
} else if (Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY]).length > 0) {
|
||||
if (selectLimitIfFieldEqualsTo.containsKey(Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY])[0])) {
|
||||
int limitQty = selectLimitIfFieldEqualsTo[Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY])[0]];
|
||||
} else if (Utils.getSelectedAttributeValue(selections!, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY]).length > 0) {
|
||||
if (selectLimitIfFieldEqualsTo.containsKey(Utils.getSelectedAttributeValue(selections!, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY])[0])) {
|
||||
int limitQty = selectLimitIfFieldEqualsTo[Utils.getSelectedAttributeValue(selections!, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY])[0]];
|
||||
thisLimitQty = limitQty;
|
||||
if ((selections[product.productAttributes[index].name
|
||||
if ((selections![product!.productAttributes![index!].name
|
||||
.toUpperCase()] as List).length >= limitQty) {
|
||||
disableOptionIfNotSelected();
|
||||
}
|
||||
@@ -187,7 +187,7 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
|
||||
}
|
||||
|
||||
for (var i = 0; i < productOptions.length; i++) {
|
||||
Map<String, dynamic> extraJson = Utils.stringToJson(
|
||||
Map<String, dynamic>? extraJson = Utils.stringToJson(
|
||||
productOptions[i].extra);
|
||||
if (extraJson != null) {
|
||||
Map<String, dynamic> exclusiveRule = Rule.getRule(
|
||||
@@ -195,12 +195,12 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
|
||||
Map<String, dynamic> multiItemRule = Rule.getRule(extraJson, Rule.RULE_ACTUAL_QTY_IS);
|
||||
if (exclusiveRule != null) {
|
||||
if (thisLimitQty > 0 && !_checkOptionIsCheck(productOptions[i].name)) {
|
||||
optionsState[product.productAttributes[index].name][i]['disabled'] = true;
|
||||
optionsState[product!.productAttributes![index!].name][i]['disabled'] = true;
|
||||
} else {
|
||||
if (_checkOptionIsCheck(productOptions[i].name)) {
|
||||
setOptionsStateDisabled(
|
||||
product.productAttributes[index].name, true);
|
||||
optionsState[product.productAttributes[index]
|
||||
product!.productAttributes![index!].name, true);
|
||||
optionsState[product!.productAttributes![index!]
|
||||
.name][i]['disabled'] = false;
|
||||
break;
|
||||
}
|
||||
@@ -208,12 +208,12 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
|
||||
}
|
||||
if (multiItemRule != null) {
|
||||
if (_checkOptionIsCheck(productOptions[i].name)) {
|
||||
if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes[index].name.toUpperCase()] as List).length) {
|
||||
if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections![product!.productAttributes![index!].name.toUpperCase()] as List).length) {
|
||||
disableOptionIfNotSelected();
|
||||
}
|
||||
} else {
|
||||
if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes[index].name.toUpperCase()] as List).length) {
|
||||
optionsState[product.productAttributes[index]
|
||||
if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections![product!.productAttributes![index!].name.toUpperCase()] as List).length) {
|
||||
optionsState[product!.productAttributes![index!]
|
||||
.name][i]['disabled'] = true;
|
||||
}
|
||||
}
|
||||
@@ -222,26 +222,26 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> optionState = optionsState[product.productAttributes[index].name];
|
||||
List<Map<String, dynamic>> optionState = optionsState[product!.productAttributes![index!].name];
|
||||
for (var i = 0; i < optionState.length; i++) {
|
||||
Widget optionWidget = _getOptionCheck(
|
||||
product.productAttributes[index].productOptions[i], optionState[i]['disabled'], i);
|
||||
product!.productAttributes![index!].productOptions[i], optionState[i]['disabled'], i);
|
||||
row.children.add(optionWidget);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
void disableOptionIfNotSelected() {
|
||||
setOptionsStateDisabled(product.productAttributes[index].name, true);
|
||||
for (var i = 0; i < optionsState[product.productAttributes[index].name].length; i++) {
|
||||
if (Utils.selectionsContains(selections, product.productAttributes[index].name, optionsState[product.productAttributes[index].name][i]['name']) != -1) {
|
||||
optionsState[product.productAttributes[index].name][i]['disabled'] = false;
|
||||
setOptionsStateDisabled(product!.productAttributes![index!].name, true);
|
||||
for (var i = 0; i < optionsState[product!.productAttributes![index!].name].length; i++) {
|
||||
if (Utils.selectionsContains(selections!, product!.productAttributes![index!].name, optionsState[product!.productAttributes![index!].name][i]['name']) != -1) {
|
||||
optionsState[product!.productAttributes![index!].name][i]['disabled'] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool _checkOptionIsCheck(String name) {
|
||||
if (Utils.selectionsContains(selections, product.productAttributes[index].name, name) != -1) {
|
||||
if (Utils.selectionsContains(selections!, product!.productAttributes![index!].name, name) != -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -251,7 +251,7 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
|
||||
bool disabled = optDisabled;
|
||||
bool check = _checkOptionIsCheck(productOption.name);
|
||||
|
||||
Map<String, dynamic> extraJson = Utils.stringToJson(productOption.extra);
|
||||
Map<String, dynamic>? extraJson = Utils.stringToJson(productOption.extra);
|
||||
// Utils.jsonPrettyPrint(extraJson);
|
||||
|
||||
double extraAdjustAmount = 0.0;
|
||||
@@ -262,13 +262,13 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
|
||||
if (sizeBaseAdjustment is List) {
|
||||
for (var i = 0; i < (sizeBaseAdjustment as List).length; i++) {
|
||||
Map<String, dynamic> sizeBaseAdjustment1 = sizeBaseAdjustment[i];
|
||||
List<String> attValues = Utils.getSelectedAttributeValue(selections, sizeBaseAdjustment1[Rule.RULE_KEY_FIELD_KEY]);
|
||||
List<String> attValues = Utils.getSelectedAttributeValue(selections!, sizeBaseAdjustment1[Rule.RULE_KEY_FIELD_KEY]);
|
||||
if (attValues.length > 0 && sizeBaseAdjustment1.containsKey(attValues[0])) {
|
||||
extraAdjustAmount += sizeBaseAdjustment1[attValues[0]];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<String> attValues = Utils.getSelectedAttributeValue(selections, sizeBaseAdjustment[Rule.RULE_KEY_FIELD_KEY]);
|
||||
List<String> attValues = Utils.getSelectedAttributeValue(selections!, sizeBaseAdjustment[Rule.RULE_KEY_FIELD_KEY]);
|
||||
if (attValues.length > 0 && sizeBaseAdjustment.containsKey(attValues[0])) {
|
||||
extraAdjustAmount += sizeBaseAdjustment[attValues[0]];
|
||||
}
|
||||
@@ -282,7 +282,7 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
|
||||
for (var i = 0; i < (disabledRule as List).length; i++) {
|
||||
Map<String, dynamic> disabledRule1 = disabledRule[i];
|
||||
List<String> attValues = Utils.getSelectedAttributeValue(
|
||||
selections, disabledRule1[Rule.RULE_KEY_FIELD_KEY]);
|
||||
selections!, disabledRule1[Rule.RULE_KEY_FIELD_KEY]);
|
||||
if (attValues.length > 0 &&
|
||||
disabledRule1.containsKey(attValues[0])) {
|
||||
disabled = true;
|
||||
@@ -301,7 +301,7 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
|
||||
}
|
||||
} else {
|
||||
List<String> attValues = Utils.getSelectedAttributeValue(
|
||||
selections, disabledRule[Rule.RULE_KEY_FIELD_KEY]);
|
||||
selections!, disabledRule[Rule.RULE_KEY_FIELD_KEY]);
|
||||
if (attValues.length > 0) {
|
||||
for (String s in attValues) {
|
||||
if (disabledRule.containsKey(s) && disabledRule[s]) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_wisetronic/models/product.dart';
|
||||
import '../../../models/product.dart';
|
||||
|
||||
typedef void OnOptionTapped(String name, int quantity, double adjustAmount);
|
||||
|
||||
@@ -9,16 +9,16 @@ abstract class OptionsBase extends StatefulWidget {
|
||||
final Product product;
|
||||
final int index;
|
||||
final Map<String, dynamic> selections;
|
||||
OptionsBase({@required Product product, @required int index, @required Map<String, dynamic> selections})
|
||||
OptionsBase({required Product product, required int index, required Map<String, dynamic> selections})
|
||||
: product = product,
|
||||
index = index,
|
||||
selections = selections;
|
||||
}
|
||||
|
||||
abstract class OptionsBaseState<Base extends OptionsBase> extends State<Base> {
|
||||
Product product;
|
||||
Map<String, dynamic> selections;
|
||||
int index;
|
||||
Product? product;
|
||||
Map<String, dynamic>? selections;
|
||||
int? index;
|
||||
|
||||
final Color disabledBackgroundColor = new Color(0xFFBCBCBC);
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import 'options_base.dart';
|
||||
import 'rules.dart';
|
||||
|
||||
class QtyOptions extends OptionsBase {
|
||||
QtyOptions({@required Product product, @required int index, @required Map<String, dynamic> selections})
|
||||
QtyOptions({required Product product, required int index, required Map<String, dynamic> selections})
|
||||
: super(product: product, index: index, selections: selections);
|
||||
|
||||
@override
|
||||
@@ -41,14 +41,14 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Text(
|
||||
S.of(context).check_option_select_token(product.productAttributes[this.index].name),
|
||||
S.of(context).check_option_select_token(product!.productAttributes![this.index!].name),
|
||||
style: new TextStyle(
|
||||
fontSize: 12.5,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
new Text(
|
||||
product.productAttributes[this.index].required ? S.of(context).check_option_is_required : S.of(context).check_option_is_optional,
|
||||
product!.productAttributes![this.index!].required ? S.of(context).check_option_is_required : S.of(context).check_option_is_optional,
|
||||
style: new TextStyle(
|
||||
fontSize: 10.0,
|
||||
color: new Color(0xFF999999)
|
||||
@@ -86,38 +86,38 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
'adjust_amount': adjustAmount
|
||||
};
|
||||
var cloneSelections = json.decode(json.encode(selections));
|
||||
int idx = Utils.selectionsContains(cloneSelections, product.productAttributes[index].name, name);
|
||||
int idx = Utils.selectionsContains(cloneSelections, product!.productAttributes![index!].name, name);
|
||||
if (idx != -1) {
|
||||
if (quantity == 1) {
|
||||
cloneSelections[product.productAttributes[index].name.toUpperCase()][idx]['quantity'] += 1;
|
||||
optionsState[product.productAttributes[index].name][optIndex]['quantity'] = cloneSelections[product.productAttributes[index].name.toUpperCase()][idx]['quantity'];
|
||||
cloneSelections[product!.productAttributes![index!].name.toUpperCase()][idx]['quantity'] += 1;
|
||||
optionsState[product!.productAttributes![index!].name][optIndex]['quantity'] = cloneSelections[product!.productAttributes![index!].name.toUpperCase()][idx]['quantity'];
|
||||
} else {
|
||||
if (cloneSelections[product.productAttributes[index].name.toUpperCase()][idx]['quantity'] - 1 > 0) {
|
||||
cloneSelections[product.productAttributes[index].name.toUpperCase()][idx]['quantity'] -= 1;
|
||||
optionsState[product.productAttributes[index].name][optIndex]['quantity'] = cloneSelections[product.productAttributes[index].name.toUpperCase()][idx]['quantity'];
|
||||
if (cloneSelections[product!.productAttributes![index!].name.toUpperCase()][idx]['quantity'] - 1 > 0) {
|
||||
cloneSelections[product!.productAttributes![index!].name.toUpperCase()][idx]['quantity'] -= 1;
|
||||
optionsState[product!.productAttributes![index!].name][optIndex]['quantity'] = cloneSelections[product!.productAttributes![index!].name.toUpperCase()][idx]['quantity'];
|
||||
} else {
|
||||
(cloneSelections[product.productAttributes[index].name.toUpperCase()] as List).removeAt(idx);
|
||||
optionsState[product.productAttributes[index].name][optIndex]['quantity'] = 0;
|
||||
(cloneSelections[product!.productAttributes![index!].name.toUpperCase()] as List).removeAt(idx);
|
||||
optionsState[product!.productAttributes![index!].name][optIndex]['quantity'] = 0;
|
||||
}
|
||||
}
|
||||
} else if (cloneSelections.containsKey(product.productAttributes[index].name.toUpperCase())) {
|
||||
(cloneSelections[product.productAttributes[index].name.toUpperCase()] as List).add(opt);
|
||||
optionsState[product.productAttributes[index].name][optIndex]['quantity'] = 1;
|
||||
} else if (cloneSelections.containsKey(product!.productAttributes![index!].name.toUpperCase())) {
|
||||
(cloneSelections[product!.productAttributes![index!].name.toUpperCase()] as List).add(opt);
|
||||
optionsState[product!.productAttributes![index!].name][optIndex]['quantity'] = 1;
|
||||
} else {
|
||||
cloneSelections[product.productAttributes[index].name.toUpperCase()] = [opt];
|
||||
optionsState[product.productAttributes[index].name][optIndex]['quantity'] = 1;
|
||||
cloneSelections[product!.productAttributes![index!].name.toUpperCase()] = [opt];
|
||||
optionsState[product!.productAttributes![index!].name][optIndex]['quantity'] = 1;
|
||||
}
|
||||
|
||||
if (idx != -1 && (cloneSelections[product.productAttributes[index].name.toUpperCase()] as List).length == 0) {
|
||||
cloneSelections.remove(product.productAttributes[index].name.toUpperCase());
|
||||
if (idx != -1 && (cloneSelections[product!.productAttributes![index!].name.toUpperCase()] as List).length == 0) {
|
||||
cloneSelections.remove(product!.productAttributes![index!].name.toUpperCase());
|
||||
}
|
||||
|
||||
setOptionsStateDisabled(product.productAttributes[index].name, false);
|
||||
setOptionsStateDisabled(product!.productAttributes![index!].name, false);
|
||||
|
||||
setState(() {
|
||||
selections = cloneSelections;
|
||||
});
|
||||
eventBus.fire(new OnAttributeSelectionsChanged(selections));
|
||||
eventBus.fire(new OnAttributeSelectionsChanged(selections!));
|
||||
}
|
||||
|
||||
Widget _getOptionWidget() {
|
||||
@@ -125,24 +125,24 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
children: <Widget>[],
|
||||
);
|
||||
|
||||
List<ProductOption> productOptions = product.productAttributes[index].productOptions;
|
||||
List<ProductOption> productOptions = product!.productAttributes![index!].productOptions;
|
||||
|
||||
if (!optionsState.containsKey(product.productAttributes[index].name)) {
|
||||
if (!optionsState.containsKey(product!.productAttributes![index!].name)) {
|
||||
List<Map<String, dynamic>> optionState = [];
|
||||
for (var i = 0; i < productOptions.length; i++) {
|
||||
int qty = 0;
|
||||
int idx = Utils.selectionsContains(selections, product.productAttributes[index].name, productOptions[i].name);
|
||||
int idx = Utils.selectionsContains(selections!, product!.productAttributes![index!].name, productOptions[i].name);
|
||||
if (idx != -1) {
|
||||
qty = selections[product.productAttributes[index].name.toUpperCase()][idx]['quantity'];
|
||||
qty = selections![product!.productAttributes![index!].name.toUpperCase()][idx]['quantity'];
|
||||
}
|
||||
optionState.add({'name': product.productAttributes[index].productOptions[i].name, 'disabled': false, 'quantity': qty, 'check': false});
|
||||
optionState.add({'name': product!.productAttributes![index!].productOptions[i].name, 'disabled': false, 'quantity': qty, 'check': false});
|
||||
}
|
||||
optionsState[product.productAttributes[index].name] = optionState;
|
||||
optionsState[product!.productAttributes![index!].name] = optionState;
|
||||
}
|
||||
|
||||
if (selections.containsKey(product.productAttributes[index].name.toUpperCase())) {
|
||||
Map<String, dynamic> attrExtraJson = Utils.stringToJson(
|
||||
product.productAttributes[index].extra);
|
||||
if (selections!.containsKey(product!.productAttributes![index!].name.toUpperCase())) {
|
||||
Map<String, dynamic>? attrExtraJson = Utils.stringToJson(
|
||||
product!.productAttributes![index!].extra);
|
||||
if (attrExtraJson != null) {
|
||||
var selectLimitIfFieldEqualsTo = Rule.getRule(
|
||||
attrExtraJson, Rule.RULE_SELECT_LIMIT_IF_FIELD_EQUALS_TO);
|
||||
@@ -155,15 +155,15 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
int limitQty = selectLimitIfFieldEqualsTo1[Rule
|
||||
.RULE_KEY_FORCE_LIMITED];
|
||||
thisLimitQty = limitQty;
|
||||
if ((selections[product.productAttributes[index].name
|
||||
if ((selections![product!.productAttributes![index!].name
|
||||
.toUpperCase()] as List).length >= limitQty) {
|
||||
disableOptionIfNotSelected();
|
||||
}
|
||||
} else if (Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY]).length > 0) {
|
||||
if (selectLimitIfFieldEqualsTo1.containsKey(Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY])[0])) {
|
||||
int limitQty = selectLimitIfFieldEqualsTo1[Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY])[0]];
|
||||
} else if (Utils.getSelectedAttributeValue(selections!, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY]).length > 0) {
|
||||
if (selectLimitIfFieldEqualsTo1.containsKey(Utils.getSelectedAttributeValue(selections!, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY])[0])) {
|
||||
int limitQty = selectLimitIfFieldEqualsTo1[Utils.getSelectedAttributeValue(selections!, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY])[0]];
|
||||
thisLimitQty = limitQty;
|
||||
if ((selections[product.productAttributes[index].name
|
||||
if ((selections![product!.productAttributes![index!].name
|
||||
.toUpperCase()] as List).length >= limitQty) {
|
||||
disableOptionIfNotSelected();
|
||||
}
|
||||
@@ -176,15 +176,15 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
int limitQty = selectLimitIfFieldEqualsTo[Rule
|
||||
.RULE_KEY_FORCE_LIMITED];
|
||||
thisLimitQty = limitQty;
|
||||
if ((selections[product.productAttributes[index].name
|
||||
if ((selections![product!.productAttributes![index!].name
|
||||
.toUpperCase()] as List).length >= limitQty) {
|
||||
disableOptionIfNotSelected();
|
||||
}
|
||||
} else if (Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY]).length > 0) {
|
||||
if (selectLimitIfFieldEqualsTo.containsKey(Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY])[0])) {
|
||||
int limitQty = selectLimitIfFieldEqualsTo[Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY])[0]];
|
||||
} else if (Utils.getSelectedAttributeValue(selections!, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY]).length > 0) {
|
||||
if (selectLimitIfFieldEqualsTo.containsKey(Utils.getSelectedAttributeValue(selections!, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY])[0])) {
|
||||
int limitQty = selectLimitIfFieldEqualsTo[Utils.getSelectedAttributeValue(selections!, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY])[0]];
|
||||
thisLimitQty = limitQty;
|
||||
if ((selections[product.productAttributes[index].name
|
||||
if ((selections![product!.productAttributes![index!].name
|
||||
.toUpperCase()] as List).length >= limitQty) {
|
||||
disableOptionIfNotSelected();
|
||||
}
|
||||
@@ -195,7 +195,7 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
}
|
||||
|
||||
for (var i = 0; i < productOptions.length; i++) {
|
||||
Map<String, dynamic> extraJson = Utils.stringToJson(
|
||||
Map<String, dynamic>? extraJson = Utils.stringToJson(
|
||||
productOptions[i].extra);
|
||||
if (extraJson != null) {
|
||||
Map<String, dynamic> exclusiveRule = Rule.getRule(
|
||||
@@ -203,12 +203,12 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
Map<String, dynamic> multiItemRule = Rule.getRule(extraJson, Rule.RULE_ACTUAL_QTY_IS);
|
||||
if (exclusiveRule != null) {
|
||||
if (thisLimitQty > 0 && !_checkOptionIsCheck(productOptions[i].name)) {
|
||||
optionsState[product.productAttributes[index].name][i]['disabled'] = true;
|
||||
optionsState[product!.productAttributes![index!].name][i]['disabled'] = true;
|
||||
} else {
|
||||
if (_checkOptionIsCheck(productOptions[i].name)) {
|
||||
setOptionsStateDisabled(
|
||||
product.productAttributes[index].name, true);
|
||||
optionsState[product.productAttributes[index]
|
||||
product!.productAttributes![index!].name, true);
|
||||
optionsState[product!.productAttributes![index!]
|
||||
.name][i]['disabled'] = false;
|
||||
break;
|
||||
}
|
||||
@@ -216,12 +216,12 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
}
|
||||
if (multiItemRule != null) {
|
||||
if (_checkOptionIsCheck(productOptions[i].name)) {
|
||||
if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes[index].name.toUpperCase()] as List).length) {
|
||||
if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections![product!.productAttributes![index!].name.toUpperCase()] as List).length) {
|
||||
disableOptionIfNotSelected();
|
||||
}
|
||||
} else {
|
||||
if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes[index].name.toUpperCase()] as List).length) {
|
||||
optionsState[product.productAttributes[index]
|
||||
if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections![product!.productAttributes![index!].name.toUpperCase()] as List).length) {
|
||||
optionsState[product!.productAttributes![index!]
|
||||
.name][i]['disabled'] = true;
|
||||
}
|
||||
}
|
||||
@@ -230,26 +230,26 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> optionState = optionsState[product.productAttributes[index].name];
|
||||
List<Map<String, dynamic>> optionState = optionsState[product!.productAttributes![index!].name];
|
||||
for (var i = 0; i < optionState.length; i++) {
|
||||
Widget optionWidget = _getOptionQty(
|
||||
product.productAttributes[index].productOptions[i], optionState[i]['disabled'], optionState[i]['quantity'], i);
|
||||
product!.productAttributes![index!].productOptions[i], optionState[i]['disabled'], optionState[i]['quantity'], i);
|
||||
row.children.add(optionWidget);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
void disableOptionIfNotSelected() {
|
||||
setOptionsStateDisabled(product.productAttributes[index].name, true);
|
||||
for (var i = 0; i < optionsState[product.productAttributes[index].name].length; i++) {
|
||||
if (Utils.selectionsContains(selections, product.productAttributes[index].name, optionsState[product.productAttributes[index].name][i]['name']) != -1) {
|
||||
optionsState[product.productAttributes[index].name][i]['disabled'] = false;
|
||||
setOptionsStateDisabled(product!.productAttributes![index!].name, true);
|
||||
for (var i = 0; i < optionsState[product!.productAttributes![index!].name].length; i++) {
|
||||
if (Utils.selectionsContains(selections!, product!.productAttributes![index!].name, optionsState[product!.productAttributes![index!].name][i]['name']) != -1) {
|
||||
optionsState[product!.productAttributes![index!].name][i]['disabled'] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool _checkOptionIsCheck(String name) {
|
||||
if (Utils.selectionsContains(selections, product.productAttributes[index].name, name) != -1) {
|
||||
if (Utils.selectionsContains(selections!, product!.productAttributes![index!].name, name) != -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -259,7 +259,7 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
bool disabled = optDisabled;
|
||||
bool check = _checkOptionIsCheck(productOption.name);
|
||||
|
||||
Map<String, dynamic> extraJson = Utils.stringToJson(productOption.extra);
|
||||
Map<String, dynamic>? extraJson = Utils.stringToJson(productOption.extra);
|
||||
// Utils.jsonPrettyPrint(extraJson);
|
||||
|
||||
double extraAdjustAmount = 0.0;
|
||||
@@ -270,13 +270,13 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
if (sizeBaseAdjustment is List) {
|
||||
for (var i = 0; i < (sizeBaseAdjustment as List).length; i++) {
|
||||
Map<String, dynamic> sizeBaseAdjustment1 = sizeBaseAdjustment[i];
|
||||
List<String> attValues = Utils.getSelectedAttributeValue(selections, sizeBaseAdjustment1[Rule.RULE_KEY_FIELD_KEY]);
|
||||
List<String> attValues = Utils.getSelectedAttributeValue(selections!, sizeBaseAdjustment1[Rule.RULE_KEY_FIELD_KEY]);
|
||||
if (attValues.length > 0 && sizeBaseAdjustment1.containsKey(attValues[0])) {
|
||||
extraAdjustAmount += sizeBaseAdjustment1[attValues[0]];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<String> attValues = Utils.getSelectedAttributeValue(selections, sizeBaseAdjustment[Rule.RULE_KEY_FIELD_KEY]);
|
||||
List<String> attValues = Utils.getSelectedAttributeValue(selections!, sizeBaseAdjustment[Rule.RULE_KEY_FIELD_KEY]);
|
||||
if (attValues.length > 0 && sizeBaseAdjustment.containsKey(attValues[0])) {
|
||||
extraAdjustAmount += sizeBaseAdjustment[attValues[0]];
|
||||
}
|
||||
@@ -290,7 +290,7 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
for (var i = 0; i < (disabledRule as List).length; i++) {
|
||||
Map<String, dynamic> disabledRule1 = disabledRule[i];
|
||||
List<String> attValues = Utils.getSelectedAttributeValue(
|
||||
selections, disabledRule1[Rule.RULE_KEY_FIELD_KEY]);
|
||||
selections!, disabledRule1[Rule.RULE_KEY_FIELD_KEY]);
|
||||
if (attValues.length > 0 &&
|
||||
disabledRule1.containsKey(attValues[0])) {
|
||||
disabled = true;
|
||||
@@ -309,7 +309,7 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
}
|
||||
} else {
|
||||
List<String> attValues = Utils.getSelectedAttributeValue(
|
||||
selections, disabledRule[Rule.RULE_KEY_FIELD_KEY]);
|
||||
selections!, disabledRule[Rule.RULE_KEY_FIELD_KEY]);
|
||||
if (attValues.length > 0) {
|
||||
for (String s in attValues) {
|
||||
if (disabledRule.containsKey(s) && disabledRule[s]) {
|
||||
|
||||
@@ -14,7 +14,7 @@ import 'options_base.dart';
|
||||
import 'rules.dart';
|
||||
|
||||
class RadioOptions extends OptionsBase {
|
||||
RadioOptions({@required Product product, @required int index, @required Map<String, dynamic> selections})
|
||||
RadioOptions({required Product product, required int index, required Map<String, dynamic> selections})
|
||||
: super(product: product, index: index, selections: selections);
|
||||
|
||||
@override
|
||||
@@ -40,14 +40,14 @@ class RadioOptionsState extends OptionsBaseState<RadioOptions> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Text(
|
||||
S.of(context).radio_option_select_token(product.productAttributes[this.index].name),
|
||||
S.of(context).radio_option_select_token(product!.productAttributes![this.index!].name),
|
||||
style: new TextStyle(
|
||||
fontSize: 12.5,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
new Text(
|
||||
product.productAttributes[this.index].required ? S.of(context).radio_option_is_required : S.of(context).radio_option_is_optional,
|
||||
product!.productAttributes![this.index!].required ? S.of(context).radio_option_is_required : S.of(context).radio_option_is_optional,
|
||||
style: new TextStyle(
|
||||
fontSize: 10.0,
|
||||
color: new Color(0xFF999999)
|
||||
@@ -85,24 +85,24 @@ class RadioOptionsState extends OptionsBaseState<RadioOptions> {
|
||||
'adjust_amount': adjustAmount
|
||||
};
|
||||
var cloneSelections = json.decode(json.encode(selections));
|
||||
if (product.productAttributes[index].required) {
|
||||
cloneSelections[product.productAttributes[index].name.toUpperCase()] = [opt];
|
||||
if (product!.productAttributes![index!].required) {
|
||||
cloneSelections[product!.productAttributes![index!].name.toUpperCase()] = [opt];
|
||||
} else {
|
||||
if (cloneSelections.containsKey(product.productAttributes[index].name.toUpperCase())
|
||||
&& Utils.equalsIgnoreCase(cloneSelections[product.productAttributes[index].name.toUpperCase()][0]['name'], name)) {
|
||||
cloneSelections.remove(product.productAttributes[index].name.toUpperCase());
|
||||
if (cloneSelections.containsKey(product!.productAttributes![index!].name.toUpperCase())
|
||||
&& Utils.equalsIgnoreCase(cloneSelections[product!.productAttributes![index!].name.toUpperCase()][0]['name'], name)) {
|
||||
cloneSelections.remove(product!.productAttributes![index!].name.toUpperCase());
|
||||
} else {
|
||||
cloneSelections[product.productAttributes[index].name.toUpperCase()] = [opt];
|
||||
cloneSelections[product!.productAttributes![index!].name.toUpperCase()] = [opt];
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> extraJson = Utils.stringToJson(productOption.extra);
|
||||
Map<String, dynamic>? extraJson = Utils.stringToJson(productOption.extra);
|
||||
if (extraJson != null) {
|
||||
Map<String, dynamic> exclusiveRule = Rule.getRule(
|
||||
extraJson, Rule.RULE_EXCLUSIVE_SELECTION);
|
||||
if (exclusiveRule != null) {
|
||||
if (_checkOptionIsCheck(productOption.name)) {
|
||||
setOptionsStateDisabled(product.productAttributes[index].name, false);
|
||||
setOptionsStateDisabled(product!.productAttributes![index!].name, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -110,7 +110,7 @@ class RadioOptionsState extends OptionsBaseState<RadioOptions> {
|
||||
setState(() {
|
||||
selections = cloneSelections;
|
||||
});
|
||||
eventBus.fire(new OnAttributeSelectionsChanged(selections));
|
||||
eventBus.fire(new OnAttributeSelectionsChanged(selections!));
|
||||
}
|
||||
|
||||
Widget _getOptionWidget() {
|
||||
@@ -118,42 +118,42 @@ class RadioOptionsState extends OptionsBaseState<RadioOptions> {
|
||||
children: <Widget>[],
|
||||
);
|
||||
|
||||
List<ProductOption> productOptions = product.productAttributes[index].productOptions;
|
||||
List<ProductOption> productOptions = product!.productAttributes![index!].productOptions;
|
||||
|
||||
if (!optionsState.containsKey(product.productAttributes[index].name)) {
|
||||
if (!optionsState.containsKey(product!.productAttributes![index!].name)) {
|
||||
List<Map<String, dynamic>> optionState = [];
|
||||
for (var i = 0; i < productOptions.length; i++) {
|
||||
optionState.add({'name': product.productAttributes[index].productOptions[i].name, 'disabled': false, 'check': false});
|
||||
optionState.add({'name': product!.productAttributes![index!].productOptions[i].name, 'disabled': false, 'check': false});
|
||||
}
|
||||
optionsState[product.productAttributes[index].name] = optionState;
|
||||
optionsState[product!.productAttributes![index!].name] = optionState;
|
||||
}
|
||||
|
||||
for (var i = 0; i < productOptions.length; i++) {
|
||||
Map<String, dynamic> extraJson = Utils.stringToJson(productOptions[i].extra);
|
||||
Map<String, dynamic>? extraJson = Utils.stringToJson(productOptions[i].extra);
|
||||
if (extraJson != null) {
|
||||
Map<String, dynamic> exclusiveRule = Rule.getRule(
|
||||
extraJson, Rule.RULE_EXCLUSIVE_SELECTION);
|
||||
if (exclusiveRule != null) {
|
||||
if (_checkOptionIsCheck(productOptions[i].name)) {
|
||||
setOptionsStateDisabled(product.productAttributes[index].name, true);
|
||||
optionsState[product.productAttributes[index].name][i]['disabled'] = false;
|
||||
setOptionsStateDisabled(product!.productAttributes![index!].name, true);
|
||||
optionsState[product!.productAttributes![index!].name][i]['disabled'] = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> optionState = optionsState[product.productAttributes[index].name];
|
||||
List<Map<String, dynamic>> optionState = optionsState[product!.productAttributes![index!].name];
|
||||
for (var i = 0; i < optionState.length; i++) {
|
||||
Widget optionWidget = _getOptionRadio(
|
||||
product.productAttributes[index].productOptions[i], optionState[i]['disabled'], i);
|
||||
product!.productAttributes![index!].productOptions[i], optionState[i]['disabled'], i);
|
||||
row.children.add(optionWidget);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
bool _checkOptionIsCheck(String name) {
|
||||
if (Utils.selectionsContains(selections, product.productAttributes[index].name, name) != -1) {
|
||||
if (Utils.selectionsContains(selections!, product!.productAttributes![index!].name, name) != -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -163,7 +163,7 @@ class RadioOptionsState extends OptionsBaseState<RadioOptions> {
|
||||
bool disabled = optDisabled;
|
||||
bool check = _checkOptionIsCheck(productOption.name);
|
||||
|
||||
Map<String, dynamic> extraJson = Utils.stringToJson(productOption.extra);
|
||||
Map<String, dynamic>? extraJson = Utils.stringToJson(productOption.extra);
|
||||
// Utils.jsonPrettyPrint(extraJson);
|
||||
|
||||
double extraAdjustAmount = 0.0;
|
||||
@@ -174,13 +174,13 @@ class RadioOptionsState extends OptionsBaseState<RadioOptions> {
|
||||
if (sizeBaseAdjustment is List) {
|
||||
for (var i = 0; i < (sizeBaseAdjustment as List).length; i++) {
|
||||
Map<String, dynamic> sizeBaseAdjustment1 = sizeBaseAdjustment[i];
|
||||
List<String> attValues = Utils.getSelectedAttributeValue(selections, sizeBaseAdjustment1[Rule.RULE_KEY_FIELD_KEY]);
|
||||
List<String> attValues = Utils.getSelectedAttributeValue(selections!, sizeBaseAdjustment1[Rule.RULE_KEY_FIELD_KEY]);
|
||||
if (attValues.length > 0 && sizeBaseAdjustment1.containsKey(attValues[0])) {
|
||||
extraAdjustAmount += sizeBaseAdjustment1[attValues[0]];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<String> attValues = Utils.getSelectedAttributeValue(selections, sizeBaseAdjustment[Rule.RULE_KEY_FIELD_KEY]);
|
||||
List<String> attValues = Utils.getSelectedAttributeValue(selections!, sizeBaseAdjustment[Rule.RULE_KEY_FIELD_KEY]);
|
||||
if (attValues.length > 0 && sizeBaseAdjustment.containsKey(attValues[0])) {
|
||||
extraAdjustAmount += sizeBaseAdjustment[attValues[0]];
|
||||
}
|
||||
@@ -194,7 +194,7 @@ class RadioOptionsState extends OptionsBaseState<RadioOptions> {
|
||||
for (var i = 0; i < (disabledRule as List).length; i++) {
|
||||
Map<String, dynamic> disabledRule1 = disabledRule[i];
|
||||
List<String> attValues = Utils.getSelectedAttributeValue(
|
||||
selections, disabledRule1[Rule.RULE_KEY_FIELD_KEY]);
|
||||
selections!, disabledRule1[Rule.RULE_KEY_FIELD_KEY]);
|
||||
if (attValues.length > 0 &&
|
||||
disabledRule1.containsKey(attValues[0])) {
|
||||
disabled = true;
|
||||
@@ -213,7 +213,7 @@ class RadioOptionsState extends OptionsBaseState<RadioOptions> {
|
||||
}
|
||||
} else {
|
||||
List<String> attValues = Utils.getSelectedAttributeValue(
|
||||
selections, disabledRule[Rule.RULE_KEY_FIELD_KEY]);
|
||||
selections!, disabledRule[Rule.RULE_KEY_FIELD_KEY]);
|
||||
if (attValues.length > 0) {
|
||||
for (String s in attValues) {
|
||||
if (disabledRule.containsKey(s) && disabledRule[s]) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class BottomNav extends StatefulWidget {
|
||||
const BottomNav({Key key}) : super(key: key);
|
||||
const BottomNav({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
|
||||
@@ -7,10 +7,10 @@ import '../../routes.dart';
|
||||
import 'navigationbar.dart';
|
||||
|
||||
class BreadCrumbs extends StatelessWidget {
|
||||
final List<BreadCrumb> breadCrumbs;
|
||||
final List<BreadCrumb>? breadCrumbs;
|
||||
final bool hasBack;
|
||||
final OnBackPress onBackPress;
|
||||
const BreadCrumbs(this.hasBack, {this.breadCrumbs, Key key, this.onBackPress}) : super(key: key);
|
||||
final OnBackPress? onBackPress;
|
||||
const BreadCrumbs(this.hasBack, {this.breadCrumbs, Key? key, this.onBackPress}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -49,17 +49,17 @@ class BreadCrumbs extends StatelessWidget {
|
||||
));
|
||||
}
|
||||
if (breadCrumbs != null) {
|
||||
for (int i = 0; i < breadCrumbs.length; i++) {
|
||||
BreadCrumb breadCrumb = breadCrumbs[i];
|
||||
for (int i = 0; i < breadCrumbs!.length; i++) {
|
||||
BreadCrumb breadCrumb = breadCrumbs![i];
|
||||
if (breadCrumb.text == null && breadCrumb.item != null) {
|
||||
if (breadCrumb.onTap == null) {
|
||||
widgets.add(breadCrumb.item);
|
||||
widgets.add(breadCrumb.item!);
|
||||
} else {
|
||||
widgets.add(MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: GestureDetector(
|
||||
child: breadCrumb.item,
|
||||
onTap: breadCrumb.onTap,
|
||||
child: breadCrumb.item!,
|
||||
onTap: breadCrumb.onTap as GestureTapCallback?,
|
||||
),
|
||||
));
|
||||
}
|
||||
@@ -94,7 +94,7 @@ class BreadCrumbs extends StatelessWidget {
|
||||
color: Colors.blueAccent,
|
||||
),
|
||||
Text(
|
||||
breadCrumb.text,
|
||||
breadCrumb.text ?? '',
|
||||
style: TextStyle(
|
||||
color: Colors.blueAccent,
|
||||
fontSize: 14.0,
|
||||
@@ -103,7 +103,7 @@ class BreadCrumbs extends StatelessWidget {
|
||||
],
|
||||
) :
|
||||
Text(
|
||||
breadCrumb.text,
|
||||
breadCrumb.text ?? '',
|
||||
style: TextStyle(
|
||||
color: Colors.blueAccent,
|
||||
fontSize: 14.0,
|
||||
@@ -113,7 +113,7 @@ class BreadCrumbs extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
onTap: () {
|
||||
Routes.router.navigateTo(context, breadCrumb.route);
|
||||
Routes.router.navigateTo(context, breadCrumb.route ?? '');
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -145,7 +145,7 @@ class BreadCrumbs extends StatelessWidget {
|
||||
color: Colors.lightBlueAccent,
|
||||
),
|
||||
Text(
|
||||
breadCrumb.text,
|
||||
breadCrumb.text ?? '',
|
||||
style: TextStyle(
|
||||
color: Colors.black54,
|
||||
fontSize: 14.0,
|
||||
@@ -155,7 +155,7 @@ class BreadCrumbs extends StatelessWidget {
|
||||
],
|
||||
) :
|
||||
Text(
|
||||
breadCrumb.text,
|
||||
breadCrumb.text ?? '',
|
||||
style: TextStyle(
|
||||
color: Colors.black54,
|
||||
fontSize: 14.0,
|
||||
@@ -184,11 +184,11 @@ class BreadCrumbs extends StatelessWidget {
|
||||
}
|
||||
|
||||
class BreadCrumb {
|
||||
final String text;
|
||||
final String route;
|
||||
final IconData icon;
|
||||
final Widget item;
|
||||
final Function onTap;
|
||||
final String? text;
|
||||
final String? route;
|
||||
final IconData? icon;
|
||||
final Widget? item;
|
||||
final Function? onTap;
|
||||
|
||||
BreadCrumb(this.text, this.route, {this.icon, this.item, this.onTap});
|
||||
}
|
||||
@@ -6,8 +6,8 @@ import 'style.dart';
|
||||
class Carousel extends StatefulWidget {
|
||||
Carousel({
|
||||
double height = 200.0,
|
||||
List<Widget> pages,
|
||||
bool autoPlay,
|
||||
List<Widget>? pages,
|
||||
bool autoPlay = false,
|
||||
Duration duration = const Duration(seconds: 2),
|
||||
Duration animationDuration = const Duration(milliseconds: 1000),
|
||||
})
|
||||
@@ -17,11 +17,11 @@ class Carousel extends StatefulWidget {
|
||||
duration = duration,
|
||||
animationDuration = animationDuration;
|
||||
|
||||
final double height;
|
||||
final List<Widget> pages;
|
||||
final bool autoPlay;
|
||||
final Duration duration;
|
||||
final Duration animationDuration;
|
||||
final double? height;
|
||||
final List<Widget>? pages;
|
||||
final bool? autoPlay;
|
||||
final Duration? duration;
|
||||
final Duration? animationDuration;
|
||||
|
||||
@override
|
||||
createState() => new CarouselState();
|
||||
@@ -30,7 +30,7 @@ class Carousel extends StatefulWidget {
|
||||
class CarouselState extends State<Carousel> {
|
||||
final _pageController = new PageController();
|
||||
|
||||
Timer _timer;
|
||||
Timer? _timer;
|
||||
int _currentPage = 0;
|
||||
bool reverse = false;
|
||||
GlobalKey<IndicatorState> _indicatorStateKey = new GlobalKey();
|
||||
@@ -38,13 +38,13 @@ class CarouselState extends State<Carousel> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.autoPlay) {
|
||||
_timer = new Timer.periodic(widget.duration, (timer) {
|
||||
if (widget.autoPlay!) {
|
||||
_timer = new Timer.periodic(widget.duration!, (timer) {
|
||||
_pageController.animateToPage(_currentPage,
|
||||
duration: widget.animationDuration, curve: Curves.linear);
|
||||
duration: widget.animationDuration!, curve: Curves.linear);
|
||||
if (!reverse) {
|
||||
_currentPage += 1;
|
||||
if (_currentPage == widget.pages.length) {
|
||||
if (_currentPage == widget.pages?.length) {
|
||||
_currentPage -= 1;
|
||||
reverse = true;
|
||||
}
|
||||
@@ -61,9 +61,9 @@ class CarouselState extends State<Carousel> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_pageController?.dispose();
|
||||
_pageController.dispose();
|
||||
if (_timer != null) {
|
||||
_timer.cancel();
|
||||
_timer!.cancel();
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
@@ -77,10 +77,10 @@ class CarouselState extends State<Carousel> {
|
||||
color: Style.backgroundColor,
|
||||
child: new PageView(
|
||||
controller: _pageController,
|
||||
children: widget.pages,
|
||||
children: widget.pages!,
|
||||
onPageChanged: (index) {
|
||||
_currentPage = index;
|
||||
_indicatorStateKey.currentState.changeIndex(index);
|
||||
_indicatorStateKey.currentState?.changeIndex(index);
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -91,7 +91,7 @@ class CarouselState extends State<Carousel> {
|
||||
child: new Align(
|
||||
child: new Indicator(
|
||||
key: _indicatorStateKey,
|
||||
count: widget.pages.length,
|
||||
count: widget.pages!.length,
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
),
|
||||
@@ -102,11 +102,11 @@ class CarouselState extends State<Carousel> {
|
||||
}
|
||||
|
||||
class Indicator extends StatefulWidget {
|
||||
Indicator({Key key, int count})
|
||||
Indicator({Key? key, int? count})
|
||||
: count = count,
|
||||
super(key: key);
|
||||
|
||||
final int count;
|
||||
final int? count;
|
||||
|
||||
@override
|
||||
createState() => new IndicatorState();
|
||||
@@ -124,7 +124,7 @@ class IndicatorState extends State<Indicator> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var indicators = <Widget>[];
|
||||
for (var i = 0; i < widget.count; ++i) {
|
||||
for (var i = 0; i < widget.count!; ++i) {
|
||||
indicators.add(new Container(
|
||||
width: 5.0,
|
||||
height: 5.0,
|
||||
@@ -135,7 +135,7 @@ class IndicatorState extends State<Indicator> {
|
||||
));
|
||||
}
|
||||
return new SizedBox(
|
||||
width: widget.count * 15.0,
|
||||
width: widget.count! * 15.0,
|
||||
height: 30.0,
|
||||
child: new Row(
|
||||
children: indicators,
|
||||
|
||||
@@ -4,9 +4,9 @@ import '../../generated/l10n.dart';
|
||||
import '../../utils/double_back_to_close_app.dart';
|
||||
|
||||
class DoubleBackToCloseAppWrapper extends StatelessWidget {
|
||||
final Widget child;
|
||||
final Widget? child;
|
||||
|
||||
const DoubleBackToCloseAppWrapper({Key key, this.child}) : super(key: key);
|
||||
const DoubleBackToCloseAppWrapper({Key? key, this.child}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -20,7 +20,7 @@ class DoubleBackToCloseAppWrapper extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
child: child,
|
||||
child: child!,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,8 @@ import '../../utils/utils.dart';
|
||||
|
||||
class DownloadItem extends StatefulWidget {
|
||||
final dynamic desc;
|
||||
final double width;
|
||||
const DownloadItem(this.desc, {Key key, this.width}) : super(key: key);
|
||||
final double? width;
|
||||
const DownloadItem(this.desc, {Key? key, this.width}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -52,7 +52,7 @@ class DownloadItemState extends State<DownloadItem> {
|
||||
margin: EdgeInsets.only(right: 16.0),
|
||||
),
|
||||
Container(
|
||||
width: widget.width != null ? widget.width - iconWidth - buttonWidth - 60 : MediaQuery.of(context).size.width - iconWidth - buttonWidth - 60,
|
||||
width: widget.width != null ? widget.width! - iconWidth - buttonWidth - 60 : MediaQuery.of(context).size.width - iconWidth - buttonWidth - 60,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -186,9 +186,9 @@ class DownloadItemState extends State<DownloadItem> {
|
||||
}
|
||||
|
||||
Widget getDownloadButton() {
|
||||
String downloadUrl;
|
||||
String os = Utils.getOs();
|
||||
String selectedOs;
|
||||
String? downloadUrl;
|
||||
String? os = Utils.getOs();
|
||||
String? selectedOs;
|
||||
List<String> supportedOss = [];
|
||||
for (int i = 0; i < (widget.desc['urls'] as List).length; i++) {
|
||||
supportedOss.add((widget.desc['urls'] as List)[i]['os']);
|
||||
@@ -244,7 +244,7 @@ class DownloadItemState extends State<DownloadItem> {
|
||||
} else if (downloadUrl != null && downloadUrl.isNotEmpty) {
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: Theme.of(context).primaryColor,
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
padding: EdgeInsets.all(8)
|
||||
),
|
||||
child: Row(
|
||||
@@ -255,7 +255,7 @@ class DownloadItemState extends State<DownloadItem> {
|
||||
padding: EdgeInsets.only(right: 0.0, left: 6.0, top: 6.0, bottom: 6.0),
|
||||
child: Icon(
|
||||
IconData(
|
||||
Utils.getOsFontHex(selectedOs),
|
||||
Utils.getOsFontHex(selectedOs!),
|
||||
fontFamily: 'wisetronic',
|
||||
fontPackage: null
|
||||
),
|
||||
|
||||
@@ -7,14 +7,14 @@ import 'package:responsive_builder/responsive_builder.dart';
|
||||
|
||||
class IndexCarousel extends StatelessWidget {
|
||||
final List<Gallery> galleries;
|
||||
const IndexCarousel(this.galleries, {Key key}) : super(key: key);
|
||||
const IndexCarousel(this.galleries, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ScreenTypeLayout(
|
||||
mobile: MobileIndexCarousel(galleries),
|
||||
tablet: DesktopIndexCarousel(galleries),
|
||||
desktop: DesktopIndexCarousel(galleries),
|
||||
return ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileIndexCarousel(galleries),
|
||||
tablet: (context) => DesktopIndexCarousel(galleries),
|
||||
desktop: (context) => DesktopIndexCarousel(galleries),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,14 +6,14 @@ import 'package:responsive_builder/responsive_builder.dart';
|
||||
|
||||
class IndexMainContent1 extends StatelessWidget {
|
||||
final String message;
|
||||
const IndexMainContent1(this.message, {Key key}) : super(key: key);
|
||||
const IndexMainContent1(this.message, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ScreenTypeLayout(
|
||||
mobile: MobileIndexMainContent1(message),
|
||||
tablet: DesktopIndexMainContent1(message),
|
||||
desktop: DesktopIndexMainContent1(message),
|
||||
return ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileIndexMainContent1(message),
|
||||
tablet: (context) => DesktopIndexMainContent1(message),
|
||||
desktop: (context) => DesktopIndexMainContent1(message),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,14 +6,14 @@ import 'package:responsive_builder/responsive_builder.dart';
|
||||
|
||||
class IndexMainContent2 extends StatelessWidget {
|
||||
final Map<String, dynamic> content;
|
||||
const IndexMainContent2(this.content, {Key key}) : super(key: key);
|
||||
const IndexMainContent2(this.content, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ScreenTypeLayout(
|
||||
mobile: MobileIndexMainContent2(content),
|
||||
tablet: DesktopIndexMainContent2(content),
|
||||
desktop: DesktopIndexMainContent2(content),
|
||||
return ScreenTypeLayout.builder(
|
||||
mobile: (context) => MobileIndexMainContent2(content),
|
||||
tablet: (context) => DesktopIndexMainContent2(content),
|
||||
desktop: (context) => DesktopIndexMainContent2(content),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user