Merge branch 'design_issues' into 'development'
return CMC HHC See merge request Cloud_Solution/diplomatic-quarter!242merge-update-with-lab-changes
commit
80fdebc34d
@ -0,0 +1,148 @@
|
|||||||
|
import 'package:diplomaticquarterapp/config/config.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/enum/viewstate.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/home_health_care_view_model.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
||||||
|
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/utils.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||||
|
import 'package:google_maps_place_picker/google_maps_place_picker.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class CMCLocationPage extends StatefulWidget {
|
||||||
|
final Function(PickResult) onPick;
|
||||||
|
final double latitude;
|
||||||
|
final double longitude;
|
||||||
|
final dynamic model;
|
||||||
|
|
||||||
|
const CMCLocationPage({Key key, this.onPick, this.latitude, this.longitude, this.model})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_CMCLocationPageState createState() =>
|
||||||
|
_CMCLocationPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CMCLocationPageState
|
||||||
|
extends State<CMCLocationPage> {
|
||||||
|
double latitude = 0;
|
||||||
|
double longitude = 0;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
|
||||||
|
latitude = widget.latitude;
|
||||||
|
longitude = widget.longitude;
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
ProjectViewModel projectViewModel = Provider.of(context);
|
||||||
|
return BaseView<CMCViewModel>(
|
||||||
|
onModelReady: (model) {},
|
||||||
|
builder: (_, model, widget) => AppScaffold(
|
||||||
|
isShowDecPage: false,
|
||||||
|
isShowAppBar: true,
|
||||||
|
baseViewModel: model,
|
||||||
|
body: PlacePicker(
|
||||||
|
apiKey: GOOGLE_API_KEY,
|
||||||
|
enableMyLocationButton: true,
|
||||||
|
automaticallyImplyAppBarLeading: false,
|
||||||
|
autocompleteOnTrailingWhitespace: true,
|
||||||
|
selectInitialPosition: true,
|
||||||
|
autocompleteLanguage: projectViewModel.currentLanguage,
|
||||||
|
enableMapTypeButton: true,
|
||||||
|
searchForInitialValue: false,
|
||||||
|
onPlacePicked: (PickResult result) {
|
||||||
|
print(result.adrAddress);
|
||||||
|
|
||||||
|
},
|
||||||
|
selectedPlaceWidgetBuilder:
|
||||||
|
(_, selectedPlace, state, isSearchBarFocused) {
|
||||||
|
print("state: $state, isSearchBarFocused: $isSearchBarFocused");
|
||||||
|
return isSearchBarFocused
|
||||||
|
? Container()
|
||||||
|
: FloatingCard(
|
||||||
|
bottomPosition: 0.0,
|
||||||
|
leftPosition: 0.0,
|
||||||
|
rightPosition: 0.0,
|
||||||
|
width: 500,
|
||||||
|
borderRadius: BorderRadius.circular(12.0),
|
||||||
|
child: state == SearchingState.Searching
|
||||||
|
? Center(child: CircularProgressIndicator())
|
||||||
|
: Container(
|
||||||
|
margin: EdgeInsets.all(12),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
SecondaryButton(
|
||||||
|
color: Colors.grey[800],
|
||||||
|
textColor: Colors.white,
|
||||||
|
onTap: () async {
|
||||||
|
print(selectedPlace);
|
||||||
|
AddNewAddressRequestModel
|
||||||
|
addNewAddressRequestModel =
|
||||||
|
new AddNewAddressRequestModel(
|
||||||
|
customer: Customer(addresses: [
|
||||||
|
Addresses(
|
||||||
|
address1:
|
||||||
|
selectedPlace.formattedAddress,
|
||||||
|
address2: selectedPlace
|
||||||
|
.formattedAddress,
|
||||||
|
customerAttributes: "",
|
||||||
|
city: "",
|
||||||
|
createdOnUtc: "",
|
||||||
|
id: 0,
|
||||||
|
latLong: "$latitude,$longitude",
|
||||||
|
email: "")
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
|
||||||
|
selectedPlace.addressComponents.forEach((e) {
|
||||||
|
if (e.types.contains("country")) {
|
||||||
|
addNewAddressRequestModel.customer
|
||||||
|
.addresses[0].country = e.longName;
|
||||||
|
}
|
||||||
|
if (e.types.contains("postal_code")) {
|
||||||
|
addNewAddressRequestModel.customer
|
||||||
|
.addresses[0].zipPostalCode =
|
||||||
|
e.longName;
|
||||||
|
}
|
||||||
|
if (e.types.contains("locality")) {
|
||||||
|
addNewAddressRequestModel.customer
|
||||||
|
.addresses[0].city =
|
||||||
|
e.longName;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await model.addAddressInfo(
|
||||||
|
addNewAddressRequestModel: addNewAddressRequestModel);
|
||||||
|
if (model.state == ViewState.ErrorLocal) {
|
||||||
|
Utils.showErrorToast(model.error);
|
||||||
|
} else {
|
||||||
|
AppToast.showSuccessToast(
|
||||||
|
message: "Address Added Successfully");
|
||||||
|
}
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
label: TranslationBase.of(context).addNewAddress,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
initialPosition: LatLng(latitude, longitude),
|
||||||
|
useCurrentLocation: false,
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,146 @@
|
|||||||
|
import 'package:diplomaticquarterapp/config/config.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/add_new_address_Request_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/pages/base/base_view.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/utils.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||||
|
import 'package:google_maps_place_picker/google_maps_place_picker.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class LocationPage extends StatefulWidget {
|
||||||
|
final Function(PickResult) onPick;
|
||||||
|
final double latitude;
|
||||||
|
final double longitude;
|
||||||
|
final dynamic model;
|
||||||
|
|
||||||
|
const LocationPage({Key key, this.onPick, this.latitude, this.longitude, this.model})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_LocationPageState createState() =>
|
||||||
|
_LocationPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LocationPageState
|
||||||
|
extends State<LocationPage> {
|
||||||
|
double latitude = 0;
|
||||||
|
double longitude = 0;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
|
||||||
|
latitude = widget.latitude;
|
||||||
|
longitude = widget.longitude;
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
ProjectViewModel projectViewModel = Provider.of(context);
|
||||||
|
return BaseView<HomeHealthCareViewModel>(
|
||||||
|
onModelReady: (model) {},
|
||||||
|
builder: (_, model, widget) => AppScaffold(
|
||||||
|
isShowDecPage: false,
|
||||||
|
isShowAppBar: true,
|
||||||
|
baseViewModel: model,
|
||||||
|
body: PlacePicker(
|
||||||
|
apiKey: GOOGLE_API_KEY,
|
||||||
|
enableMyLocationButton: true,
|
||||||
|
automaticallyImplyAppBarLeading: false,
|
||||||
|
autocompleteOnTrailingWhitespace: true,
|
||||||
|
selectInitialPosition: true,
|
||||||
|
autocompleteLanguage: projectViewModel.currentLanguage,
|
||||||
|
enableMapTypeButton: true,
|
||||||
|
searchForInitialValue: false,
|
||||||
|
onPlacePicked: (PickResult result) {
|
||||||
|
print(result.adrAddress);
|
||||||
|
|
||||||
|
},
|
||||||
|
selectedPlaceWidgetBuilder:
|
||||||
|
(_, selectedPlace, state, isSearchBarFocused) {
|
||||||
|
print("state: $state, isSearchBarFocused: $isSearchBarFocused");
|
||||||
|
return isSearchBarFocused
|
||||||
|
? Container()
|
||||||
|
: FloatingCard(
|
||||||
|
bottomPosition: 0.0,
|
||||||
|
leftPosition: 0.0,
|
||||||
|
rightPosition: 0.0,
|
||||||
|
width: 500,
|
||||||
|
borderRadius: BorderRadius.circular(12.0),
|
||||||
|
child: state == SearchingState.Searching
|
||||||
|
? Center(child: CircularProgressIndicator())
|
||||||
|
: Container(
|
||||||
|
margin: EdgeInsets.all(12),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
SecondaryButton(
|
||||||
|
color: Colors.grey[800],
|
||||||
|
textColor: Colors.white,
|
||||||
|
onTap: () async {
|
||||||
|
AddNewAddressRequestModel
|
||||||
|
addNewAddressRequestModel =
|
||||||
|
new AddNewAddressRequestModel(
|
||||||
|
customer: Customer(addresses: [
|
||||||
|
Addresses(
|
||||||
|
address1:
|
||||||
|
selectedPlace.formattedAddress,
|
||||||
|
address2: selectedPlace
|
||||||
|
.formattedAddress,
|
||||||
|
customerAttributes: "",
|
||||||
|
city: "",
|
||||||
|
createdOnUtc: "",
|
||||||
|
id: 0,
|
||||||
|
latLong: "$latitude,$longitude",
|
||||||
|
email: "")
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
|
||||||
|
selectedPlace.addressComponents.forEach((e) {
|
||||||
|
if (e.types.contains("country")) {
|
||||||
|
addNewAddressRequestModel.customer
|
||||||
|
.addresses[0].country = e.longName;
|
||||||
|
}
|
||||||
|
if (e.types.contains("postal_code")) {
|
||||||
|
addNewAddressRequestModel.customer
|
||||||
|
.addresses[0].zipPostalCode =
|
||||||
|
e.longName;
|
||||||
|
}
|
||||||
|
if (e.types.contains("locality")) {
|
||||||
|
addNewAddressRequestModel.customer
|
||||||
|
.addresses[0].city =
|
||||||
|
e.longName;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await model.addAddressInfo(
|
||||||
|
addNewAddressRequestModel: addNewAddressRequestModel);
|
||||||
|
if (model.state == ViewState.ErrorLocal) {
|
||||||
|
Utils.showErrorToast(model.error);
|
||||||
|
} else {
|
||||||
|
AppToast.showSuccessToast(
|
||||||
|
message: "Address Added Successfully");
|
||||||
|
}
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
label: TranslationBase.of(context).addNewAddress,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
initialPosition: LatLng(latitude, longitude),
|
||||||
|
useCurrentLocation: false,
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,139 @@
|
|||||||
|
import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/customer_addresses_service.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
// ignore: must_be_immutable
|
||||||
|
class SelectLocationDialog extends StatefulWidget {
|
||||||
|
final List<AddressInfo> addresses;
|
||||||
|
final Function(AddressInfo) onValueSelected;
|
||||||
|
AddressInfo selectedAddress;
|
||||||
|
|
||||||
|
SelectLocationDialog(
|
||||||
|
{Key key, this.addresses, this.onValueSelected, this.selectedAddress});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_SelectLocationDialogState createState() => _SelectLocationDialogState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SelectLocationDialogState extends State<SelectLocationDialog> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
widget.selectedAddress = widget.selectedAddress ?? widget.addresses[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SimpleDialog(
|
||||||
|
title: Texts(TranslationBase.of(context).selectAddress),
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
height: 150,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Divider(),
|
||||||
|
...List.generate(
|
||||||
|
widget.addresses.length,
|
||||||
|
(index) => Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 2,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
setState(() {
|
||||||
|
widget.selectedAddress = widget.addresses[index];
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: ListTile(
|
||||||
|
title: Text(widget.addresses[index].address1),
|
||||||
|
leading: Radio(
|
||||||
|
value: widget.addresses[index],
|
||||||
|
groupValue: widget.selectedAddress,
|
||||||
|
activeColor: Colors.red[800],
|
||||||
|
onChanged: (value) {
|
||||||
|
setState(() {
|
||||||
|
widget.selectedAddress = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 5.0,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 5.0,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Container(
|
||||||
|
child: Center(
|
||||||
|
child: Texts(
|
||||||
|
TranslationBase.of(context).cancel.toUpperCase(),
|
||||||
|
color: Colors.red,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
width: 1,
|
||||||
|
height: 30,
|
||||||
|
color: Colors.grey[500],
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
widget.onValueSelected(widget.selectedAddress);
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Center(
|
||||||
|
child: Texts(
|
||||||
|
TranslationBase.of(context).ok,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue