second step from location fixes
parent
7aa7af6de7
commit
ed56476d81
@ -0,0 +1,140 @@
|
|||||||
|
import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/EReferral/get_all_cities_response_model.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/home_health_care_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("sdsdsd"),
|
||||||
|
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,
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,108 @@
|
|||||||
|
import 'package:diplomaticquarterapp/config/config.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/patient_er_insert_pres_order_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/uitl/translations_delegate_base.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;
|
||||||
|
|
||||||
|
const LocationPage(
|
||||||
|
{Key key,
|
||||||
|
this.onPick,
|
||||||
|
this.latitude,
|
||||||
|
this.longitude,
|
||||||
|
})
|
||||||
|
: 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 AppScaffold(
|
||||||
|
isShowDecPage: false,
|
||||||
|
isShowAppBar: true,
|
||||||
|
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: () {
|
||||||
|
print(selectedPlace);
|
||||||
|
// setState(() {
|
||||||
|
// widget.patientERInsertPresOrderRequestModel
|
||||||
|
// .latitude =
|
||||||
|
// selectedPlace.geometry.location.lat;
|
||||||
|
// widget.patientERInsertPresOrderRequestModel
|
||||||
|
// .longitude =
|
||||||
|
// selectedPlace.geometry.location.lng;
|
||||||
|
// });
|
||||||
|
},
|
||||||
|
label: " Add New Address ",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
initialPosition: LatLng(latitude, longitude),
|
||||||
|
useCurrentLocation: false,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue