|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import '../../../core/constants/translation_keys.dart';
|
|
|
|
|
import '../../../custom_widgets/custom_app_bar.dart';
|
|
|
|
|
import '../../../res/app_colors.dart';
|
|
|
|
|
import '../controllers/agent_location_controller.dart';
|
|
|
|
|
|
|
|
|
|
class AgentLocationView extends GetView<AgentLocationController> {
|
|
|
|
|
const AgentLocationView({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: DashBoardAppBar(
|
|
|
|
|
title: TranslationKeys.makeTranslation(TranslationKeys.textMapLocationTitle),
|
|
|
|
|
onBackButtonPressed: () {
|
|
|
|
|
Get.back();
|
|
|
|
|
},
|
|
|
|
|
actions: [
|
|
|
|
|
PopupMenuButton<MapType>(
|
|
|
|
|
color: AppColors.white,
|
|
|
|
|
icon: const Icon(
|
|
|
|
|
Icons.more_vert,
|
|
|
|
|
color: AppColors.white, // Set your desired color for the actions dots
|
|
|
|
|
),
|
|
|
|
|
onSelected: (selectedMapType) {
|
|
|
|
|
controller.changeMapType(selectedMapType);
|
|
|
|
|
},
|
|
|
|
|
itemBuilder: (BuildContext context) {
|
|
|
|
|
return [
|
|
|
|
|
PopupMenuItem<MapType>(
|
|
|
|
|
value: MapType.normal,
|
|
|
|
|
child: Text(
|
|
|
|
|
TranslationKeys.makeTranslation(TranslationKeys.textNormalMap),
|
|
|
|
|
style: Theme.of(context).textTheme.titleSmall,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
PopupMenuItem<MapType>(
|
|
|
|
|
value: MapType.satellite,
|
|
|
|
|
child: Text(
|
|
|
|
|
TranslationKeys.makeTranslation(TranslationKeys.textSatelliteMap),
|
|
|
|
|
style: Theme.of(context).textTheme.titleSmall,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
PopupMenuItem<MapType>(
|
|
|
|
|
value: MapType.hybrid,
|
|
|
|
|
child: Text(
|
|
|
|
|
TranslationKeys.makeTranslation(TranslationKeys.textHybridMap),
|
|
|
|
|
style: Theme.of(context).textTheme.titleSmall,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
body: Obx(() {
|
|
|
|
|
return GoogleMap(
|
|
|
|
|
mapType: controller.selectedMapType.value,
|
|
|
|
|
initialCameraPosition: const CameraPosition(
|
|
|
|
|
target: LatLng(37.7749, -122.4194),
|
|
|
|
|
zoom: 12.0,
|
|
|
|
|
),
|
|
|
|
|
markers: controller.markers.toSet(),
|
|
|
|
|
onMapCreated: (GoogleMapController controller) {
|
|
|
|
|
/// You can use the controller for further map customization
|
|
|
|
|
},
|
|
|
|
|
onTap: (LatLng latLng) {
|
|
|
|
|
/// Close any existing dialogs when tapping on the map
|
|
|
|
|
// Get.back();
|
|
|
|
|
|
|
|
|
|
/// Find the tapped marker based on its position
|
|
|
|
|
final tappedMarker = controller.markers.firstWhere(
|
|
|
|
|
(marker) => marker.position == latLng,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final tappedBranch = controller.getBranches(controller.mapType.first)[0];
|
|
|
|
|
Get.defaultDialog(
|
|
|
|
|
title: tappedBranch.name,
|
|
|
|
|
content: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text('${TranslationKeys.makeTranslation(TranslationKeys.textMapContactNumber)} ${tappedBranch.contactNumber}'),
|
|
|
|
|
Text('${TranslationKeys.makeTranslation(TranslationKeys.textMapContactNumber)} ${tappedBranch.contactNumber}'),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|