|
|
|
|
import 'package:diplomaticquarterapp/config/config.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/others/close_back.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 PickupLocationFromMap extends StatelessWidget {
|
|
|
|
|
final Function(PickResult) onPick;
|
|
|
|
|
final double latitude;
|
|
|
|
|
final double longitude;
|
|
|
|
|
final bool isWithAppBar;
|
|
|
|
|
final String buttonLabel;
|
|
|
|
|
final Color buttonColor;
|
|
|
|
|
|
|
|
|
|
const PickupLocationFromMap({Key key, this.onPick, this.latitude, this.longitude, this.isWithAppBar = true, this.buttonLabel, this.buttonColor}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
ProjectViewModel projectViewModel = Provider.of(context);
|
|
|
|
|
return AppScaffold(
|
|
|
|
|
isShowAppBar: true,
|
|
|
|
|
showNewAppBarTitle: true,
|
|
|
|
|
showNewAppBar: true,
|
|
|
|
|
appBarTitle: TranslationBase.of(context).selectLocation,
|
|
|
|
|
// appBar: isWithAppBar
|
|
|
|
|
// ? AppBar(
|
|
|
|
|
// elevation: 0,
|
|
|
|
|
// textTheme: TextTheme(
|
|
|
|
|
// headline6:
|
|
|
|
|
// TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
|
|
|
|
|
// ),
|
|
|
|
|
// title: Text('Location'),
|
|
|
|
|
// leading: CloseBack(),
|
|
|
|
|
// centerTitle: true,
|
|
|
|
|
// )
|
|
|
|
|
// : null,
|
|
|
|
|
body: PlacePicker(
|
|
|
|
|
apiKey: GOOGLE_API_KEY,
|
|
|
|
|
enableMyLocationButton: true,
|
|
|
|
|
automaticallyImplyAppBarLeading: false,
|
|
|
|
|
autocompleteLanguage: projectViewModel.currentLanguage,
|
|
|
|
|
enableMapTypeButton: true,
|
|
|
|
|
selectInitialPosition: true,
|
|
|
|
|
region: "SA",
|
|
|
|
|
onPlacePicked: (PickResult result) {
|
|
|
|
|
print(result.adrAddress);
|
|
|
|
|
onPick(result);
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
},
|
|
|
|
|
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: DefaultButton(
|
|
|
|
|
TranslationBase.of(context).next,
|
|
|
|
|
() {
|
|
|
|
|
onPick(selectedPlace);
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
initialPosition: LatLng(latitude, longitude),
|
|
|
|
|
useCurrentLocation: true,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|