final
This commit is contained in:
@@ -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'],
|
||||
|
||||
Reference in New Issue
Block a user