You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
227 lines
9.4 KiB
Dart
227 lines
9.4 KiB
Dart
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
|
import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart';
|
|
import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart';
|
|
import 'package:diplomaticquarterapp/core/model/pharmacies/payment-checkout-data.dart';
|
|
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart';
|
|
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/order_model_view_model.dart';
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
|
|
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
|
|
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
|
import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart';
|
|
import 'package:diplomaticquarterapp/pages/pharmacies/screens/payment-method-select-page.dart';
|
|
import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderPreviewItem.dart';
|
|
import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart';
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
|
import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart';
|
|
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
|
import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart';
|
|
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
class SelectAddressWidget extends StatefulWidget {
|
|
final OrderPreviewViewModel model;
|
|
final List<Addresses> addresses;
|
|
|
|
SelectAddressWidget(this.model, this.addresses);
|
|
|
|
@override
|
|
_SelectAddressWidgetState createState() => _SelectAddressWidgetState();
|
|
}
|
|
|
|
class _SelectAddressWidgetState extends State<SelectAddressWidget> {
|
|
Addresses address;
|
|
|
|
_navigateToAddressPage() {
|
|
Navigator.push(context, FadePage(page: PharmacyAddressesPage()))
|
|
.then((result) {
|
|
if (result != null) {
|
|
address = result;
|
|
widget.model.paymentCheckoutData.address = address;
|
|
widget.model.getInformationsByAddress();
|
|
}
|
|
|
|
/* setState(() {
|
|
if (result != null) {
|
|
address = result;
|
|
widget.model.paymentCheckoutData.address = address;
|
|
widget.model.getInformationsByAddress();
|
|
}
|
|
})*/
|
|
});
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
if (widget.model.paymentCheckoutData.address != null) {
|
|
address = widget.model.paymentCheckoutData.address;
|
|
}
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
OrderPreviewViewModel model = Provider.of(context);
|
|
return Container(
|
|
color: Colors.white,
|
|
child: address == null
|
|
? InkWell(
|
|
onTap: () => {_navigateToAddressPage()},
|
|
child: Container(
|
|
margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12),
|
|
child: Row(
|
|
children: [
|
|
Image.asset(
|
|
"assets/images/pharmacy_module/ic_shipping_address.png",
|
|
width: 30.0,
|
|
height: 30.0,
|
|
fit: BoxFit.scaleDown,
|
|
),
|
|
Expanded(
|
|
child: Container(
|
|
padding:
|
|
EdgeInsets.symmetric(vertical: 0, horizontal: 6),
|
|
child: Texts(
|
|
TranslationBase.of(context).selectAddress,
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.bold,
|
|
color: Color(0xff0000ff),
|
|
),
|
|
),
|
|
),
|
|
Icon(
|
|
Icons.arrow_forward_ios,
|
|
size: 20,
|
|
color: Colors.grey.shade400,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
)
|
|
: Container(
|
|
child: Container(
|
|
margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Image.asset(
|
|
"assets/images/pharmacy_module/ic_shipping_mark.png",
|
|
width: 30.0,
|
|
height: 30.0,
|
|
fit: BoxFit.scaleDown,
|
|
),
|
|
Expanded(
|
|
child: Container(
|
|
padding: EdgeInsets.symmetric(
|
|
vertical: 0, horizontal: 6),
|
|
child: Texts(
|
|
TranslationBase.of(context).shippingAddress,
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
),
|
|
InkWell(
|
|
onTap: () => {_navigateToAddressPage()},
|
|
child: Texts(
|
|
TranslationBase.of(context).changeAddress,
|
|
fontSize: 12,
|
|
fontWeight: FontWeight.normal,
|
|
color: Color(0xff0000ff),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
|
child: Texts(
|
|
"${address.firstName} ${address.lastName}",
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
|
child: Texts(
|
|
"${address.address1} ${address.address2} ${address.address2},, ${address.city}, ${address.country} ${address.zipPostalCode}",
|
|
fontSize: 12,
|
|
fontWeight: FontWeight.normal,
|
|
color: Colors.grey.shade500,
|
|
),
|
|
),
|
|
Row(
|
|
children: [
|
|
Container(
|
|
margin: const EdgeInsets.only(right: 8),
|
|
child: Icon(
|
|
Icons.phone,
|
|
size: 20,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
Texts(
|
|
"${address.phoneNumber}",
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.grey,
|
|
),
|
|
],
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.symmetric(vertical: 8),
|
|
child: SizedBox(
|
|
height: 2,
|
|
width: double.infinity,
|
|
child: Container(
|
|
color: Color(0xffefefef),
|
|
),
|
|
),
|
|
),
|
|
Row(
|
|
children: [
|
|
Image.asset(
|
|
"assets/images/pharmacy_module/ic_shipping_truck.png",
|
|
width: 30.0,
|
|
height: 30.0,
|
|
fit: BoxFit.scaleDown,
|
|
),
|
|
Container(
|
|
padding:
|
|
EdgeInsets.symmetric(vertical: 0, horizontal: 6),
|
|
child: Texts(
|
|
"${TranslationBase.of(context).shipBy}",
|
|
fontSize: 12,
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
Container(
|
|
child: Image.asset(
|
|
model.paymentCheckoutData.shippingOption == null
|
|
? ""
|
|
: model.paymentCheckoutData.shippingOption
|
|
.shippingRateComputationMethodSystemName ==
|
|
"Shipping.FixedOrByWeight"
|
|
? "assets/images/pharmacy_module/payment/hmg_shipping_logo.png"
|
|
: "assets/images/pharmacy_module/payment/aramex_shipping_logo.png",
|
|
fit: BoxFit.contain,
|
|
),
|
|
margin: EdgeInsets.symmetric(horizontal: 8),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
), // ic_shipping_mark.png
|
|
);
|
|
}
|
|
}
|