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/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,121 +105,119 @@ 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( children: [
children: [ Container(
Container( width: double.infinity,
width: double.infinity, padding: EdgeInsets.only(left: 12, right: 12, top: 12),
padding: EdgeInsets.only(left: 12, right: 12, top: 12), child: Card(
child: Card( shape: cardRadius(12),
shape: cardRadius(12), elevation: 2,
elevation: 2, margin: EdgeInsets.zero,
margin: EdgeInsets.zero, color: Color(0xffcd9e1b),
color: Color(0xffcd9e1b), clipBehavior: Clip.antiAlias,
clipBehavior: Clip.antiAlias, child: Container(
child: Container( // decoration: containerColorRadiusLeft(Colors.white, 12),
// decoration: containerColorRadiusLeft(Colors.white, 12), margin: EdgeInsets.only(left: projectViewModel.isArabic ? 0 : 8, right: projectViewModel.isArabic ? 8 : 0),
margin: EdgeInsets.only(left: projectViewModel.isArabic ? 0 : 8, right: projectViewModel.isArabic ? 8 : 0), padding: EdgeInsets.all(12),
padding: EdgeInsets.all(12), // color: Colors.white,
// color: Colors.white, decoration: BoxDecoration(
decoration: BoxDecoration( shape: BoxShape.rectangle,
shape: BoxShape.rectangle, color: Colors.white,
color: Colors.white, borderRadius: BorderRadius.only(
borderRadius: BorderRadius.only( topLeft: projectViewModel.isArabic ? Radius.zero : Radius.circular(12.0),
topLeft: projectViewModel.isArabic ? Radius.zero : Radius.circular(12.0), topRight: projectViewModel.isArabic ? Radius.circular(12.0) : Radius.zero,
topRight: projectViewModel.isArabic ? Radius.circular(12.0) : Radius.zero, bottomLeft: projectViewModel.isArabic ? Radius.zero : Radius.circular(12.0),
bottomLeft: projectViewModel.isArabic ? Radius.zero : Radius.circular(12.0), bottomRight: projectViewModel.isArabic ? Radius.circular(12.0) : Radius.zero,
bottomRight: projectViewModel.isArabic ? Radius.circular(12.0) : Radius.zero,
),
), ),
// clipBehavior: Clip.antiAlias, ),
child: Row( // clipBehavior: Clip.antiAlias,
children: [ child: Row(
Expanded( children: [
child: Column( Expanded(
mainAxisAlignment: MainAxisAlignment.start, child: Column(
crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ crossAxisAlignment: CrossAxisAlignment.start,
Text( children: [
TranslationBase.of(context).OrderStatus + Text(
' ' + TranslationBase.of(context).OrderStatus +
(projectViewModel.isArabic ? widget.model.cmcAllOrderDetail[0].descriptionN : widget.model.cmcAllOrderDetail[0].description), ' ' +
style: TextStyle( (projectViewModel.isArabic ? widget.model.cmcAllOrderDetail[0].descriptionN : widget.model.cmcAllOrderDetail[0].description),
fontSize: 12, style: TextStyle(
letterSpacing: -0.48, fontSize: 12,
color: Color(0xffcd9e1b), letterSpacing: -0.48,
fontWeight: FontWeight.w700, 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,
),
), ),
Text( ),
TranslationBase.of(context).serviceName, mHeight(12),
style: TextStyle( Text(
fontSize: 12, TranslationBase.of(context).requestID + ' ' + widget.model.cmcAllOrderDetail[0].iD.toString(),
letterSpacing: -0.48, style: TextStyle(
fontWeight: FontWeight.w500, fontSize: 16,
), letterSpacing: -0.48,
fontWeight: FontWeight.w700,
), ),
Text( ),
!projectViewModel.isArabic ? widget.model.cmcAllOrderDetail[0].description.toString() : widget.model.cmcAllOrderDetail[0].descriptionN.toString(), Text(
style: TextStyle( TranslationBase.of(context).serviceName,
fontSize: 12, style: TextStyle(
letterSpacing: -0.48, fontSize: 12,
fontWeight: FontWeight.w700, letterSpacing: -0.48,
), fontWeight: FontWeight.w500,
), ),
], ),
),
),
Column(
children: [
Text( 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( style: TextStyle(
fontSize: 12, fontSize: 12,
letterSpacing: -0.48, letterSpacing: -0.48,
fontWeight: FontWeight.w700, 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