Untitled
unknown
plain_text
2 years ago
27 kB
5
Indexable
import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:get/get.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart' as gmap; import 'package:latlong2/latlong.dart'; import 'package:metooltip/metooltip.dart'; import 'package:the_citizen_app/src/config/app_theme.dart'; import 'package:the_citizen_app/src/config/base.dart'; import 'package:the_citizen_app/src/helpers/k_log.dart'; import 'package:the_citizen_app/src/helpers/k_text.dart'; class HomeScreenOsmMap extends StatelessWidget with Base { @override Widget build(BuildContext context) { mapC.getShouts(); return Scaffold( body: OrientationBuilder( builder: (BuildContext context, Orientation orientation) { return Obx( () => Column( children: [ Expanded( child: Stack( children: [ Obx( () => mapC.isGmap.value ? gmap.GoogleMap( // controller: gMapC.kMapController, myLocationEnabled: true, trafficEnabled: true, buildingsEnabled: true, mapToolbarEnabled: true, zoomGesturesEnabled: true, tiltGesturesEnabled: true, myLocationButtonEnabled: true, rotateGesturesEnabled: true, // indoorViewEnabled: true, mapType: shoutC.isSatelite.value ? gmap.MapType.satellite : gmap.MapType.normal, initialCameraPosition: gmap.CameraPosition( target: locationTraceC.gmapMarker.isEmpty ? gmap.LatLng( locationC.latLng.value.latitude, locationC.latLng.value.longitude) : locationTraceC .gmapMarker.first.position, zoom: 18, ), markers: mapC.gmapMarkers, // onCameraMoveStarted: , // onCameraMove: (position) => CameraPosition( // target: siteCompletionStatusC.allMarkers.first.position, // zoom: 18, // ), onMapCreated: (gmap.GoogleMapController controller) { locationTraceC.mapController = controller; }, // polylines: locationTraceC.gmapPolyline, ) : FlutterMap( mapController: mapC.mapCtl, options: MapOptions( center: mapC.latLong != null ? mapC.latLong : LatLng(locationC.latLng.value.latitude, locationC.latLng.value.longitude), zoom: 15.0, minZoom: 1.0, /* onPositionChanged: (MapPosition position, bool hasGesture) { context.read<HomeBloc>().add(ShowMapVewChange(centerLatLng: position.center)); },*/ ), children: [ TileLayer( urlTemplate: shoutC.isSatelite.value ? 'http://www.google.cn/maps/vt?lyrs=s@189&gl=cn&x={x}&y={y}&z={z}' : "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", //urlTemplate: "http://123.49.35.90:8088/tilesBD/{z}/{x}/{y}.png", subdomains: ['a', 'b', 'c'], ), CircleLayer(circles: [ CircleMarker( point: LatLng( locationC.latLng.value.latitude, locationC.latLng.value.longitude), radius: 10, borderStrokeWidth: 2, color: Colors.lightBlue, borderColor: Colors.blue) ]), MarkerLayer(markers: mapC.markers), ], ), ), Padding( padding: EdgeInsets.all(10.0), child: Column( children: [ // state.agencies.isNotEmpty ? /*genButton( () { context.read<HomeBloc>().add(GetAssignShoutForMe()); }, Icons.location_history, 'AssignShoutForMe', buttonColor: Colors.green, )*/ //buttonColor: state.isShowAssignShout ? Colors.green : AppColors.buttonColor) if (agencyC.selectedAgency!.agencyId!.isNotEmpty) Align( alignment: Alignment.centerRight, child: MeTooltip( margin: EdgeInsets.only(left: 222.0), triangleColor: Colors.white, message: "My Shouts", allOffset: 0, preferOri: PreferOrientation.left, textStyle: TextStyle( fontFamily: 'Manrope', fontSize: 10.0, color: AppTheme.textColor6, fontWeight: FontWeight.w400, decoration: TextDecoration.none, ), decoration: BoxDecoration( border: Border.all( color: Colors.white, ), color: Colors.white, borderRadius: BorderRadius.circular(5), ), // triangleColor: Colors.white, child: (genButton( () { kLog('value'); mapC.getShouts(); mapC.myShout.value = true; mapC.assignShout.value = false; // context.read<HomeBloc>().add(GetMyShout()); }, 'assets/icons/icon_my_shouts_map.png', //Icons.location_history, 'MyShout', buttonColor: mapC.myShout.value ? Colors.green : AppTheme.textColor31, )), ), ), if (agencyC.selectedAgency!.agencyId!.isNotEmpty) Align( alignment: Alignment.centerRight, child: MeTooltip( margin: EdgeInsets.only(left: 198.0), triangleColor: Colors.white, message: 'Assigned to Me', allOffset: 0, preferOri: PreferOrientation.left, textStyle: TextStyle( fontFamily: 'Manrope', fontSize: 10.0, color: AppTheme.textColor6, fontWeight: FontWeight.w400, decoration: TextDecoration.none, ), decoration: BoxDecoration( border: Border.all( color: Colors.white, ), color: Colors.white, borderRadius: BorderRadius.circular(5), ), // triangleColor: Colors.white, child: genButton( () { mapC.myShout.value = false; mapC.assignShout.value = true; mapC.getAssignShoutsForMe('PENDING'); // context.read<HomeBloc>().add(GetAssignShoutForMe()); }, 'assets/icons/icon_assigned_shouts_map.png', //Icons.location_history, 'AssignShoutForMe', buttonColor: mapC.assignShout.value ? AppTheme.textColor40 : AppTheme.borderColor, ), ), ), Align( alignment: Alignment.centerRight, child: MeTooltip( margin: EdgeInsets.only(left: 190.0), triangleColor: Colors.white, message: 'Current Location', allOffset: 0, preferOri: PreferOrientation.left, textStyle: TextStyle( fontFamily: 'Manrope', fontSize: 10.0, color: AppTheme.textColor6, fontWeight: FontWeight.w400, decoration: TextDecoration.none, ), decoration: BoxDecoration( border: Border.all( color: Colors.white, ), color: Colors.white, borderRadius: BorderRadius.circular(5), ), // triangleColor: Colors.white, child: genButton( () { mapC.mapCtl.move( LatLng(locationC.latLng.value.latitude, locationC.latLng.value.longitude), 15); // context.read<HomeBloc>().add( // ShowMapViewChange(centerLatLng: state.currentPositionLatLng), // ); // _mapCtl.move(state.currentPositionLatLng, 15); }, 'assets/icons/icon_my_location_map.png', //Icons.location_searching, "positionChange", // buttonColor: state.colorCurrentLocation == true ? Colors.blueGrey : textColor32, buttonColor: AppTheme.textColor32, ), ), ), Align( alignment: Alignment.centerRight, child: GestureDetector( onTap: () { mapC.isGmap.value = true; shoutC.isSatelite.value = false; }, child: Container( margin: EdgeInsets.symmetric(vertical: 5), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(100), border: Border.all( color: Colors.white, width: 2), boxShadow: [ BoxShadow( color: Colors.blueGrey, spreadRadius: 1, blurRadius: 2, ), ], ), child: CircleAvatar( // radius: 25, backgroundColor: mapC.isGmap.value ? Colors.green : Colors.grey.shade500, child: KText( text: 'G', bold: true, color: Colors.white, )), ), ), ), Align( alignment: Alignment.centerRight, child: GestureDetector( onTap: () { mapC.isGmap.value = false; shoutC.isSatelite.value = false; }, child: Container( margin: EdgeInsets.symmetric(vertical: 5), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(100), border: Border.all( color: Colors.white, width: 2), boxShadow: [ BoxShadow( color: Colors.blueGrey, spreadRadius: 1, blurRadius: 2, ), ], ), child: CircleAvatar( backgroundColor: !mapC.isGmap.value ? Colors.green : Colors.grey.shade500, child: KText( text: 'O', bold: true, color: Colors.white, )), ), ), ), Align( alignment: Alignment.centerRight, child: GestureDetector( onTap: () { mapC.isGmap.value = false; shoutC.isSatelite.value = true; }, child: Container( margin: EdgeInsetsDirectional.symmetric(vertical: 5), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(100), border: Border.all(color: Colors.white, width: 2), boxShadow: [ BoxShadow( color: Colors.blueGrey, spreadRadius: 1, blurRadius: 2, ), ], ), child: CircleAvatar( backgroundImage: AssetImage( 'assets/images/satellite.jpg', ), ), ), ), ), ], ), ), Padding( padding: EdgeInsets.only(left: 20.0, bottom: 10.0), child: Align( alignment: Alignment.bottomLeft, child: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end, children: [ MeTooltip( message: 'Assigned', allOffset: 5, triangleColor: Colors.white, preferOri: PreferOrientation.up, textStyle: TextStyle( fontFamily: 'Mangrove', fontSize: 10.0, color: AppTheme.textColor6, fontWeight: FontWeight.w400, decoration: TextDecoration.none, ), decoration: BoxDecoration( border: Border.all( color: Colors.white, ), color: Colors.white, borderRadius: BorderRadius.circular(5), ), // triangleColor: Colors.white, child: Container( width: 30, height: 15, decoration: BoxDecoration( borderRadius: BorderRadius.circular(5), color: AppTheme.textColor33, //remove color to make it transpatent border: Border.all( width: 1.0, style: BorderStyle.solid, color: AppTheme.textColor1, ), ), ), ), SizedBox( width: 11, ), MeTooltip( message: 'Started', allOffset: 5, triangleColor: Colors.white, preferOri: PreferOrientation.up, textStyle: TextStyle( fontFamily: 'Manrope', fontSize: 10.0, color: AppTheme.textColor6, fontWeight: FontWeight.w400, decoration: TextDecoration.none, ), decoration: BoxDecoration( border: Border.all( color: Colors.white, ), color: Colors.white, borderRadius: BorderRadius.circular(5), ), // triangleColor: Colors.white, child: Container( width: 30, height: 15, decoration: BoxDecoration( borderRadius: BorderRadius.circular(5), color: AppTheme.textColor10, //remove color to make it transpatent border: Border.all( width: 1.0, style: BorderStyle.solid, color: AppTheme.textColor1, ), ), ), ), SizedBox( width: 11, ), MeTooltip( triangleColor: Colors.white, message: 'My Shouts', allOffset: 5, preferOri: PreferOrientation.up, textStyle: TextStyle( fontFamily: 'Manrope', fontSize: 10.0, color: AppTheme.textColor6, fontWeight: FontWeight.w400, decoration: TextDecoration.none, ), decoration: BoxDecoration( border: Border.all( color: Colors.white, ), color: Colors.white, borderRadius: BorderRadius.circular(5), ), // triangleColor: Colors.white, child: Container( width: 30, height: 15, decoration: BoxDecoration( borderRadius: BorderRadius.circular(5), color: AppTheme.textColor17, //remove color to make it transpatent border: Border.all( width: 1.0, style: BorderStyle.solid, color: AppTheme.textColor1, ), ), ), ), ], ), ), ), ], ), ), ], ), ); }, ), ); } Widget genButton( Function() function, String icon, String heroTag, { Color? buttonColor, }) { return Padding( padding: EdgeInsets.symmetric(vertical: 5), child: Align( alignment: Alignment.bottomRight, child: Container( height: 46, width: 46, // decoration: BoxDecoration(shape: BoxShape.circle, border: Border.all(width: 2, color: Colors.white)), child: FloatingActionButton( shape: RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(50.0)), ), onPressed: function, // () { // kLog('value'); // mapC.getShouts(); // }, heroTag: heroTag, materialTapTargetSize: MaterialTapTargetSize.padded, backgroundColor: buttonColor ?? buttonColor, child: Image.asset( icon, width: 40, height: 40, fit: BoxFit.cover, ), ), ), ), ); } Widget genIconButton(Function function, Widget imageIcon, String heroTag, {Color? buttonColor}) { return Padding( padding: EdgeInsets.symmetric(vertical: 10), child: Align( alignment: Alignment.bottomRight, child: Column( children: [ SizedBox( height: 40, child: FloatingActionButton( onPressed: () {}, heroTag: heroTag, materialTapTargetSize: MaterialTapTargetSize.padded, // backgroundColor: buttonColor ?? AppTheme.buttonColor, child: imageIcon, ), ), ], ), ), ); } }
Editor is loading...