|
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/app_assets.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/app_export.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/utils.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/theme/colors.dart';
|
|
|
|
|
import 'package:huawei_map/huawei_map.dart' ;
|
|
|
|
|
|
|
|
|
|
class HMSMap extends StatefulWidget{
|
|
|
|
|
final CameraPosition currentLocation;
|
|
|
|
|
final Function(CameraPosition) onCameraMoved;
|
|
|
|
|
final VoidCallback onCameraIdle;
|
|
|
|
|
final MapType mapType;
|
|
|
|
|
final bool compassEnabled;
|
|
|
|
|
final bool myLocationEnabled;
|
|
|
|
|
final bool showCenterMarker;
|
|
|
|
|
final Completer<HuaweiMapController>? inputController;
|
|
|
|
|
|
|
|
|
|
HMSMap({super.key, required this.currentLocation ,required this.onCameraMoved,required this.onCameraIdle,
|
|
|
|
|
this.mapType = MapType.normal,this.compassEnabled = false,this.showCenterMarker = false,
|
|
|
|
|
this.myLocationEnabled = true, this.inputController});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<HMSMap> createState() => _HMSMapState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _HMSMapState extends State<HMSMap> {
|
|
|
|
|
Completer<HuaweiMapController>? controller;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
HuaweiMapInitializer.initializeMap();
|
|
|
|
|
controller = widget.inputController ?? Completer<HuaweiMapController>();
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
// @override
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) =>
|
|
|
|
|
Stack(
|
|
|
|
|
children: [
|
|
|
|
|
HuaweiMap(
|
|
|
|
|
mapType: widget.mapType,
|
|
|
|
|
zoomControlsEnabled: false,
|
|
|
|
|
myLocationEnabled: widget.myLocationEnabled,
|
|
|
|
|
myLocationButtonEnabled: false,
|
|
|
|
|
compassEnabled: widget.compassEnabled,
|
|
|
|
|
onCameraIdle:()=> widget.onCameraIdle(),
|
|
|
|
|
initialCameraPosition: widget.currentLocation,
|
|
|
|
|
onCameraMove: (value) => widget.onCameraMoved(value),
|
|
|
|
|
onMapCreated: (HuaweiMapController controller) {
|
|
|
|
|
this.controller?.complete(controller);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
Visibility(
|
|
|
|
|
visible: widget.showCenterMarker,
|
|
|
|
|
child: Align(
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
child: Icon(Icons.location_pin, size: 36.h, color: AppColors.primaryRedColor).paddingOnly(bottom: 24.h),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|