CMC Marge

merge-update-with-lab-changes
Mirza.Shafique 5 years ago
parent a67c5afcfb
commit d1bc46f451

@ -1,10 +1,12 @@
import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart';
import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/add_new_address_Request_Model.dart'; import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/add_new_address_Request_Model.dart';
import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/cmc_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/cmc_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/home_health_care_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/home_health_care_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart';
@ -22,9 +24,7 @@ class CMCLocationPage extends StatefulWidget {
final double longitude; final double longitude;
final dynamic model; final dynamic model;
const CMCLocationPage( const CMCLocationPage({Key key, this.onPick, this.latitude, this.longitude, this.model}) : super(key: key);
{Key key, this.onPick, this.latitude, this.longitude, this.model})
: super(key: key);
@override @override
_CMCLocationPageState createState() => _CMCLocationPageState(); _CMCLocationPageState createState() => _CMCLocationPageState();
@ -39,7 +39,7 @@ class _CMCLocationPageState extends State<CMCLocationPage> {
void initState() { void initState() {
latitude = widget.latitude; latitude = widget.latitude;
longitude = widget.longitude; longitude = widget.longitude;
if(latitude == 0.0 && longitude == 0.0) { if (latitude == 0.0 && longitude == 0.0) {
showCurrentLocation = true; showCurrentLocation = true;
} }
super.initState(); super.initState();
@ -54,6 +54,14 @@ class _CMCLocationPageState extends State<CMCLocationPage> {
isShowDecPage: false, isShowDecPage: false,
isShowAppBar: true, isShowAppBar: true,
baseViewModel: model, baseViewModel: model,
showNewAppBar: true,
showNewAppBarTitle: true,
backgroundColor: CustomColors.appBackgroudGreyColor,
description: TranslationBase.of(context).infoCMC,
imagesInfo: [
ImagesInfo(imageAr: 'https://hmgwebservices.com/Images/MobileApp/CMC/ar/0.png', imageEn: 'https://hmgwebservices.com/Images/MobileApp/CMC/en/0.png'),
],
appBarTitle: TranslationBase.of(context).addNewAddress,
body: PlacePicker( body: PlacePicker(
apiKey: GOOGLE_API_KEY, apiKey: GOOGLE_API_KEY,
enableMyLocationButton: true, enableMyLocationButton: true,
@ -66,10 +74,8 @@ class _CMCLocationPageState extends State<CMCLocationPage> {
onPlacePicked: (PickResult result) { onPlacePicked: (PickResult result) {
print(result.adrAddress); print(result.adrAddress);
}, },
selectedPlaceWidgetBuilder: selectedPlaceWidgetBuilder: (_, selectedPlace, state, isSearchBarFocused) {
(_, selectedPlace, state, isSearchBarFocused) { print("state: $state, isSearchBarFocused: $isSearchBarFocused");
print(
"state: $state, isSearchBarFocused: $isSearchBarFocused");
return isSearchBarFocused return isSearchBarFocused
? Container() ? Container()
: FloatingCard( : FloatingCard(
@ -85,67 +91,45 @@ class _CMCLocationPageState extends State<CMCLocationPage> {
child: Column( child: Column(
children: [ children: [
SecondaryButton( SecondaryButton(
color: Colors.grey[800], color: CustomColors.accentColor,
textColor: Colors.white, textColor: Colors.white,
onTap: () async { onTap: () async {
print(selectedPlace); print(selectedPlace);
AddNewAddressRequestModel AddNewAddressRequestModel addNewAddressRequestModel = new AddNewAddressRequestModel(
addNewAddressRequestModel =
new AddNewAddressRequestModel(
customer: Customer(addresses: [ customer: Customer(addresses: [
Addresses( Addresses(
address1: selectedPlace address1: selectedPlace.formattedAddress,
.formattedAddress, address2: selectedPlace.formattedAddress,
address2: selectedPlace
.formattedAddress,
customerAttributes: "", customerAttributes: "",
city: "", city: "",
createdOnUtc: "", createdOnUtc: "",
id: 0, id: 0,
latLong: latLong: "$latitude,$longitude",
"$latitude,$longitude",
email: "") email: "")
]), ]),
); );
selectedPlace.addressComponents selectedPlace.addressComponents.forEach((e) {
.forEach((e) {
if (e.types.contains("country")) { if (e.types.contains("country")) {
addNewAddressRequestModel addNewAddressRequestModel.customer.addresses[0].country = e.longName;
.customer
.addresses[0]
.country = e.longName;
} }
if (e.types if (e.types.contains("postal_code")) {
.contains("postal_code")) { addNewAddressRequestModel.customer.addresses[0].zipPostalCode = e.longName;
addNewAddressRequestModel
.customer
.addresses[0]
.zipPostalCode = e.longName;
} }
if (e.types.contains("locality")) { if (e.types.contains("locality")) {
addNewAddressRequestModel addNewAddressRequestModel.customer.addresses[0].city = e.longName;
.customer
.addresses[0]
.city = e.longName;
} }
}); });
await model.addAddressInfo( await model.addAddressInfo(addNewAddressRequestModel: addNewAddressRequestModel);
addNewAddressRequestModel: if (model.state == ViewState.ErrorLocal) {
addNewAddressRequestModel);
if (model.state ==
ViewState.ErrorLocal) {
Utils.showErrorToast(model.error); Utils.showErrorToast(model.error);
} else { } else {
AppToast.showSuccessToast( AppToast.showSuccessToast(message: "Address Added Successfully");
message:
"Address Added Successfully");
} }
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
label: TranslationBase.of(context) label: TranslationBase.of(context).addNewAddress,
.addNewAddress,
), ),
], ],
), ),

@ -105,7 +105,6 @@ class _NewCMCPageState extends State<NewCMCPage> with TickerProviderStateMixin {
return Scaffold( return Scaffold(
body: SafeArea( body: SafeArea(
child: SingleChildScrollView(
child: Container( child: Container(
child: widget.model.cmcAllOrderDetail.length != 0 child: widget.model.cmcAllOrderDetail.length != 0
? Column( ? Column(
@ -221,7 +220,6 @@ class _NewCMCPageState extends State<NewCMCPage> with TickerProviderStateMixin {
), ),
), ),
), ),
),
); );
} }
} }

Loading…
Cancel
Save