CMC Marge

merge-requests/390/head
Mirza.Shafique 4 years ago
parent a67c5afcfb
commit d1bc46f451

@ -1,10 +1,12 @@
import 'package:diplomaticquarterapp/config/config.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/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/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart';
@ -22,9 +24,7 @@ class CMCLocationPage extends StatefulWidget {
final double longitude;
final dynamic model;
const CMCLocationPage(
{Key key, this.onPick, this.latitude, this.longitude, this.model})
: super(key: key);
const CMCLocationPage({Key key, this.onPick, this.latitude, this.longitude, this.model}) : super(key: key);
@override
_CMCLocationPageState createState() => _CMCLocationPageState();
@ -39,7 +39,7 @@ class _CMCLocationPageState extends State<CMCLocationPage> {
void initState() {
latitude = widget.latitude;
longitude = widget.longitude;
if(latitude == 0.0 && longitude == 0.0) {
if (latitude == 0.0 && longitude == 0.0) {
showCurrentLocation = true;
}
super.initState();
@ -54,6 +54,14 @@ class _CMCLocationPageState extends State<CMCLocationPage> {
isShowDecPage: false,
isShowAppBar: true,
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(
apiKey: GOOGLE_API_KEY,
enableMyLocationButton: true,
@ -66,10 +74,8 @@ class _CMCLocationPageState extends State<CMCLocationPage> {
onPlacePicked: (PickResult result) {
print(result.adrAddress);
},
selectedPlaceWidgetBuilder:
(_, selectedPlace, state, isSearchBarFocused) {
print(
"state: $state, isSearchBarFocused: $isSearchBarFocused");
selectedPlaceWidgetBuilder: (_, selectedPlace, state, isSearchBarFocused) {
print("state: $state, isSearchBarFocused: $isSearchBarFocused");
return isSearchBarFocused
? Container()
: FloatingCard(
@ -85,67 +91,45 @@ class _CMCLocationPageState extends State<CMCLocationPage> {
child: Column(
children: [
SecondaryButton(
color: Colors.grey[800],
color: CustomColors.accentColor,
textColor: Colors.white,
onTap: () async {
print(selectedPlace);
AddNewAddressRequestModel
addNewAddressRequestModel =
new AddNewAddressRequestModel(
AddNewAddressRequestModel addNewAddressRequestModel = new AddNewAddressRequestModel(
customer: Customer(addresses: [
Addresses(
address1: selectedPlace
.formattedAddress,
address2: selectedPlace
.formattedAddress,
address1: selectedPlace.formattedAddress,
address2: selectedPlace.formattedAddress,
customerAttributes: "",
city: "",
createdOnUtc: "",
id: 0,
latLong:
"$latitude,$longitude",
latLong: "$latitude,$longitude",
email: "")
]),
);
selectedPlace.addressComponents
.forEach((e) {
selectedPlace.addressComponents.forEach((e) {
if (e.types.contains("country")) {
addNewAddressRequestModel
.customer
.addresses[0]
.country = e.longName;
addNewAddressRequestModel.customer.addresses[0].country = e.longName;
}
if (e.types
.contains("postal_code")) {
addNewAddressRequestModel
.customer
.addresses[0]
.zipPostalCode = 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;
addNewAddressRequestModel.customer.addresses[0].city = e.longName;
}
});
await model.addAddressInfo(
addNewAddressRequestModel:
addNewAddressRequestModel);
if (model.state ==
ViewState.ErrorLocal) {
await model.addAddressInfo(addNewAddressRequestModel: addNewAddressRequestModel);
if (model.state == ViewState.ErrorLocal) {
Utils.showErrorToast(model.error);
} else {
AppToast.showSuccessToast(
message:
"Address Added Successfully");
AppToast.showSuccessToast(message: "Address Added Successfully");
}
Navigator.of(context).pop();
},
label: TranslationBase.of(context)
.addNewAddress,
label: TranslationBase.of(context).addNewAddress,
),
],
),

@ -105,121 +105,119 @@ class _NewCMCPageState extends State<NewCMCPage> with TickerProviderStateMixin {
return Scaffold(
body: SafeArea(
child: SingleChildScrollView(
child: Container(
child: widget.model.cmcAllOrderDetail.length != 0
? Column(
children: [
Container(
width: double.infinity,
padding: EdgeInsets.only(left: 12, right: 12, top: 12),
child: Card(
shape: cardRadius(12),
elevation: 2,
margin: EdgeInsets.zero,
color: Color(0xffcd9e1b),
clipBehavior: Clip.antiAlias,
child: Container(
// decoration: containerColorRadiusLeft(Colors.white, 12),
margin: EdgeInsets.only(left: projectViewModel.isArabic ? 0 : 8, right: projectViewModel.isArabic ? 8 : 0),
padding: EdgeInsets.all(12),
// color: Colors.white,
decoration: BoxDecoration(
shape: BoxShape.rectangle,
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: projectViewModel.isArabic ? Radius.zero : Radius.circular(12.0),
topRight: projectViewModel.isArabic ? Radius.circular(12.0) : Radius.zero,
bottomLeft: projectViewModel.isArabic ? Radius.zero : Radius.circular(12.0),
bottomRight: projectViewModel.isArabic ? Radius.circular(12.0) : Radius.zero,
),
child: Container(
child: widget.model.cmcAllOrderDetail.length != 0
? Column(
children: [
Container(
width: double.infinity,
padding: EdgeInsets.only(left: 12, right: 12, top: 12),
child: Card(
shape: cardRadius(12),
elevation: 2,
margin: EdgeInsets.zero,
color: Color(0xffcd9e1b),
clipBehavior: Clip.antiAlias,
child: Container(
// decoration: containerColorRadiusLeft(Colors.white, 12),
margin: EdgeInsets.only(left: projectViewModel.isArabic ? 0 : 8, right: projectViewModel.isArabic ? 8 : 0),
padding: EdgeInsets.all(12),
// color: Colors.white,
decoration: BoxDecoration(
shape: BoxShape.rectangle,
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: projectViewModel.isArabic ? Radius.zero : Radius.circular(12.0),
topRight: projectViewModel.isArabic ? Radius.circular(12.0) : Radius.zero,
bottomLeft: projectViewModel.isArabic ? Radius.zero : Radius.circular(12.0),
bottomRight: projectViewModel.isArabic ? Radius.circular(12.0) : Radius.zero,
),
// clipBehavior: Clip.antiAlias,
child: Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
TranslationBase.of(context).OrderStatus +
' ' +
(projectViewModel.isArabic ? widget.model.cmcAllOrderDetail[0].descriptionN : widget.model.cmcAllOrderDetail[0].description),
style: TextStyle(
fontSize: 12,
letterSpacing: -0.48,
color: Color(0xffcd9e1b),
fontWeight: FontWeight.w700,
),
),
mHeight(12),
Text(
TranslationBase.of(context).requestID + ' ' + widget.model.cmcAllOrderDetail[0].iD.toString(),
style: TextStyle(
fontSize: 16,
letterSpacing: -0.48,
fontWeight: FontWeight.w700,
),
),
// clipBehavior: Clip.antiAlias,
child: Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
TranslationBase.of(context).OrderStatus +
' ' +
(projectViewModel.isArabic ? widget.model.cmcAllOrderDetail[0].descriptionN : widget.model.cmcAllOrderDetail[0].description),
style: TextStyle(
fontSize: 12,
letterSpacing: -0.48,
color: Color(0xffcd9e1b),
fontWeight: FontWeight.w700,
),
Text(
TranslationBase.of(context).serviceName,
style: TextStyle(
fontSize: 12,
letterSpacing: -0.48,
fontWeight: FontWeight.w500,
),
),
mHeight(12),
Text(
TranslationBase.of(context).requestID + ' ' + widget.model.cmcAllOrderDetail[0].iD.toString(),
style: TextStyle(
fontSize: 16,
letterSpacing: -0.48,
fontWeight: FontWeight.w700,
),
Text(
!projectViewModel.isArabic ? widget.model.cmcAllOrderDetail[0].description.toString() : widget.model.cmcAllOrderDetail[0].descriptionN.toString(),
style: TextStyle(
fontSize: 12,
letterSpacing: -0.48,
fontWeight: FontWeight.w700,
),
),
Text(
TranslationBase.of(context).serviceName,
style: TextStyle(
fontSize: 12,
letterSpacing: -0.48,
fontWeight: FontWeight.w500,
),
],
),
),
Column(
children: [
),
Text(
DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(widget.model.cmcAllOrderDetail[0].createdOn)),
!projectViewModel.isArabic ? widget.model.cmcAllOrderDetail[0].description.toString() : widget.model.cmcAllOrderDetail[0].descriptionN.toString(),
style: TextStyle(
fontSize: 12,
letterSpacing: -0.48,
fontWeight: FontWeight.w700,
),
),
mHeight(8),
SecondaryButton(
onTap: () {
showConfirmMessage(widget.model, widget.model.cmcAllOrderDetail[0]);
},
label: TranslationBase.of(context).cancel,
color: Colors.red[900],
small: true,
)
],
),
],
),
),
Column(
children: [
Text(
DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(widget.model.cmcAllOrderDetail[0].createdOn)),
style: TextStyle(
fontSize: 12,
letterSpacing: -0.48,
fontWeight: FontWeight.w700,
),
),
mHeight(8),
SecondaryButton(
onTap: () {
showConfirmMessage(widget.model, widget.model.cmcAllOrderDetail[0]);
},
label: TranslationBase.of(context).cancel,
color: Colors.red[900],
small: true,
)
],
),
],
),
),
),
],
)
: Container(
color: Colors.red,
child: NewCMCStepOnePage(
changePageViewIndex: changePageViewIndex,
cMCInsertPresOrderRequestModel: cMCInsertPresOrderRequestModel,
model: widget.model,
latitude: _latitude,
longitude: _longitude,
),
],
)
: Container(
color: Colors.red,
child: NewCMCStepOnePage(
changePageViewIndex: changePageViewIndex,
cMCInsertPresOrderRequestModel: cMCInsertPresOrderRequestModel,
model: widget.model,
latitude: _latitude,
longitude: _longitude,
),
),
),
),
),
);

Loading…
Cancel
Save