commit
c5a405d221
@ -0,0 +1,5 @@
|
||||
{
|
||||
"projects": {
|
||||
"default": "smartfit-9b86c"
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
"hosting": {
|
||||
"public": "build/web",
|
||||
"ignore": [
|
||||
"firebase.json",
|
||||
"**/.*",
|
||||
"**/node_modules/**"
|
||||
],
|
||||
"rewrites": [
|
||||
{
|
||||
"source": "**",
|
||||
"destination": "/index.html"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:smartfit_app_mobile/modele/user.dart';
|
||||
|
||||
class MapUtil {
|
||||
Set<Polyline> initPolines(BuildContext context, int largueur, Color couleur) {
|
||||
Set<Polyline> _polylines = {};
|
||||
_polylines.add(Polyline(
|
||||
polylineId: const PolylineId("Polyline"),
|
||||
color: couleur,
|
||||
points: context.watch<User>().listActivity[0].getPosition(),
|
||||
width: largueur));
|
||||
return _polylines;
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:smartfit_app_mobile/common/colo_extension.dart';
|
||||
import 'package:smartfit_app_mobile/modele/utile/maps/maps_utile.dart';
|
||||
|
||||
class MobileMyMaps extends StatefulWidget {
|
||||
const MobileMyMaps({super.key});
|
||||
|
||||
@override
|
||||
State<MobileMyMaps> createState() => _MobileMyMaps();
|
||||
}
|
||||
|
||||
class _MobileMyMaps extends State<MobileMyMaps> {
|
||||
final Completer<GoogleMapController> _googleMapController = Completer();
|
||||
CameraPosition? _cameraPosition;
|
||||
Set<Polyline> _polylines = {};
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_polylines = MapUtil().initPolines(context, 10, TColor.primaryColor1);
|
||||
_cameraPosition =
|
||||
CameraPosition(target: _polylines.first.points.first, zoom: 18);
|
||||
|
||||
return Scaffold(
|
||||
body: _getMap(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _getMap() {
|
||||
return Stack(
|
||||
children: [
|
||||
GoogleMap(
|
||||
initialCameraPosition: _cameraPosition!,
|
||||
mapType: MapType.normal,
|
||||
onMapCreated: (GoogleMapController controller) {
|
||||
if (!_googleMapController.isCompleted) {
|
||||
_googleMapController.complete(controller);
|
||||
}
|
||||
},
|
||||
polylines: _polylines,
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
@ -1,154 +1,29 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:location/location.dart';
|
||||
import 'package:smartfit_app_mobile/common/colo_extension.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:responsive_builder/responsive_builder.dart';
|
||||
import 'package:smartfit_app_mobile/modele/user.dart';
|
||||
import 'package:smartfit_app_mobile/view/map/mobile/mobile_my_map.dart';
|
||||
import 'package:smartfit_app_mobile/view/map/web/web_my_map.dart';
|
||||
import 'package:smartfit_app_mobile/view/profile/profile_view.dart';
|
||||
|
||||
class MyMap extends StatefulWidget {
|
||||
const MyMap({ Key? key }) : super(key: key);
|
||||
const MyMap({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<MyMap> createState() => _MyMapState();
|
||||
}
|
||||
|
||||
class _MyMapState extends State<MyMap> {
|
||||
|
||||
Completer<GoogleMapController> _googleMapController = Completer();
|
||||
CameraPosition? _cameraPosition;
|
||||
Location? _location;
|
||||
LocationData? _currentLocation;
|
||||
List<LatLng> _polylineCoordinates = [];
|
||||
Set<Polyline> _polylines = {};
|
||||
Set<Marker> _markers = {}; // Add a set to store markers
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_init();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
_init() async {
|
||||
_location = Location();
|
||||
_cameraPosition = CameraPosition(
|
||||
target: LatLng(0, 0), // this is just the example lat and lng for initializing
|
||||
zoom: 20
|
||||
);
|
||||
_initLocation();
|
||||
}
|
||||
|
||||
//function to listen when we move position
|
||||
_initLocation() {
|
||||
|
||||
_location?.getLocation().then((location) {
|
||||
_currentLocation = location;
|
||||
});
|
||||
|
||||
_location?.onLocationChanged.listen((newLocation) {
|
||||
setState(() {
|
||||
_currentLocation = newLocation;
|
||||
_polylineCoordinates.add(LatLng(
|
||||
_currentLocation?.latitude ?? 0,
|
||||
_currentLocation?.longitude ?? 0,
|
||||
));
|
||||
_updatePolyline();
|
||||
|
||||
});
|
||||
|
||||
moveToPosition(LatLng(_currentLocation?.latitude ?? 0,
|
||||
_currentLocation?.longitude ?? 0));
|
||||
});
|
||||
}
|
||||
|
||||
_updatePolyline() {
|
||||
setState(() {
|
||||
_polylines.clear();
|
||||
_polylines.add(Polyline(
|
||||
polylineId: PolylineId("polyline"),
|
||||
color: TColor.primaryColor1,
|
||||
points: _polylineCoordinates,
|
||||
width: 10,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
// Updated _updateMarker to use the custom marker
|
||||
_updateMarker(LatLng position) async {
|
||||
final markerId = MarkerId('marker');
|
||||
final marker = Marker(
|
||||
markerId: markerId,
|
||||
position: position
|
||||
);
|
||||
_markers.clear();
|
||||
_markers.add(marker);
|
||||
}
|
||||
|
||||
|
||||
moveToPosition(LatLng latLng) async {
|
||||
GoogleMapController mapController = await _googleMapController.future;
|
||||
mapController.animateCamera(
|
||||
CameraUpdate.newCameraPosition(
|
||||
CameraPosition(
|
||||
target: latLng,
|
||||
zoom: 15
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: _buildBody(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBody() {
|
||||
return _getMap();
|
||||
}
|
||||
|
||||
Widget _getMarker() {
|
||||
return Container(
|
||||
width: 25,
|
||||
height: 25,
|
||||
padding: EdgeInsets.all(2),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(100),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey,
|
||||
offset: Offset(0,3),
|
||||
spreadRadius: 4,
|
||||
blurRadius: 6
|
||||
)
|
||||
]
|
||||
),
|
||||
child: ClipOval(child: Image.asset("assets/img/u1.png")),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _getMap() {
|
||||
return Stack(
|
||||
children: [
|
||||
GoogleMap(
|
||||
initialCameraPosition: _cameraPosition!,
|
||||
mapType: MapType.normal,
|
||||
onMapCreated: (GoogleMapController controller) {
|
||||
if (!_googleMapController.isCompleted) {
|
||||
_googleMapController.complete(controller);
|
||||
}
|
||||
},
|
||||
polylines: _polylines,
|
||||
markers: _markers,
|
||||
),
|
||||
Positioned.fill(
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: _getMarker()
|
||||
return context.watch<User>().listActivity.isEmpty
|
||||
? ScreenTypeLayout.builder(
|
||||
mobile: (_) => const ProfileView(),
|
||||
desktop: (_) => const ProfileView(),
|
||||
)
|
||||
)
|
||||
],
|
||||
);
|
||||
: ScreenTypeLayout.builder(
|
||||
mobile: (_) => const MobileMyMaps(),
|
||||
desktop: (_) => const WebMyMaps(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,47 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:smartfit_app_mobile/common/colo_extension.dart';
|
||||
import 'package:smartfit_app_mobile/modele/utile/maps/maps_utile.dart';
|
||||
|
||||
class WebMyMaps extends StatefulWidget {
|
||||
const WebMyMaps({super.key});
|
||||
|
||||
@override
|
||||
State<WebMyMaps> createState() => _WebMyMaps();
|
||||
}
|
||||
|
||||
class _WebMyMaps extends State<WebMyMaps> {
|
||||
final Completer<GoogleMapController> _googleMapController = Completer();
|
||||
CameraPosition? _cameraPosition;
|
||||
Set<Polyline> _polylines = {};
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_polylines = MapUtil().initPolines(context, 10, TColor.primaryColor1);
|
||||
_cameraPosition =
|
||||
CameraPosition(target: _polylines.first.points.first, zoom: 18);
|
||||
|
||||
return Scaffold(
|
||||
body: _getMap(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _getMap() {
|
||||
return Stack(
|
||||
children: [
|
||||
GoogleMap(
|
||||
initialCameraPosition: _cameraPosition!,
|
||||
mapType: MapType.normal,
|
||||
onMapCreated: (GoogleMapController controller) {
|
||||
if (!_googleMapController.isCompleted) {
|
||||
_googleMapController.complete(controller);
|
||||
}
|
||||
},
|
||||
polylines: _polylines,
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:location/location.dart';
|
||||
import 'package:smartfit_app_mobile/common/colo_extension.dart';
|
||||
|
||||
class MobileMyMaps extends StatefulWidget {
|
||||
const MobileMyMaps({super.key});
|
||||
|
||||
@override
|
||||
State<MobileMyMaps> createState() => _MobileMyMaps();
|
||||
}
|
||||
|
||||
class _MobileMyMaps extends State<MobileMyMaps> {
|
||||
Completer<GoogleMapController> _googleMapController = Completer();
|
||||
CameraPosition? _cameraPosition;
|
||||
Location? _location;
|
||||
LocationData? _currentLocation;
|
||||
List<LatLng> _polylineCoordinates = [];
|
||||
Set<Polyline> _polylines = {};
|
||||
Set<Marker> _markers = {}; // Add a set to store markers
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_init();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
_init() async {
|
||||
_location = Location();
|
||||
_cameraPosition = const CameraPosition(
|
||||
target: LatLng(
|
||||
0, 0), // this is just the example lat and lng for initializing
|
||||
zoom: 20);
|
||||
_initLocation();
|
||||
}
|
||||
|
||||
//function to listen when we move position
|
||||
_initLocation() {
|
||||
_location?.getLocation().then((location) {
|
||||
_currentLocation = location;
|
||||
});
|
||||
|
||||
_location?.onLocationChanged.listen((newLocation) {
|
||||
setState(() {
|
||||
_currentLocation = newLocation;
|
||||
_polylineCoordinates.add(LatLng(
|
||||
_currentLocation?.latitude ?? 0,
|
||||
_currentLocation?.longitude ?? 0,
|
||||
));
|
||||
_updatePolyline();
|
||||
});
|
||||
|
||||
moveToPosition(LatLng(
|
||||
_currentLocation?.latitude ?? 0, _currentLocation?.longitude ?? 0));
|
||||
});
|
||||
}
|
||||
|
||||
_updatePolyline() {
|
||||
setState(() {
|
||||
_polylines.clear();
|
||||
_polylines.add(Polyline(
|
||||
polylineId: PolylineId("polyline"),
|
||||
color: TColor.primaryColor1,
|
||||
points: _polylineCoordinates,
|
||||
width: 10,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
// Updated _updateMarker to use the custom marker
|
||||
_updateMarker(LatLng position) async {
|
||||
final markerId = MarkerId('marker');
|
||||
final marker = Marker(markerId: markerId, position: position);
|
||||
_markers.clear();
|
||||
_markers.add(marker);
|
||||
}*/
|
||||
|
||||
moveToPosition(LatLng latLng) async {
|
||||
GoogleMapController mapController = await _googleMapController.future;
|
||||
mapController.animateCamera(CameraUpdate.newCameraPosition(
|
||||
CameraPosition(target: latLng, zoom: 15)));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: _getMap(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _getMarker() {
|
||||
return Container(
|
||||
width: 25,
|
||||
height: 25,
|
||||
padding: EdgeInsets.all(2),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(100),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey,
|
||||
offset: Offset(0, 3),
|
||||
spreadRadius: 4,
|
||||
blurRadius: 6)
|
||||
]),
|
||||
child: ClipOval(child: Image.asset("assets/img/u1.png")),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _getMap() {
|
||||
return Stack(
|
||||
children: [
|
||||
GoogleMap(
|
||||
initialCameraPosition: _cameraPosition!,
|
||||
mapType: MapType.normal,
|
||||
onMapCreated: (GoogleMapController controller) {
|
||||
if (!_googleMapController.isCompleted) {
|
||||
_googleMapController.complete(controller);
|
||||
}
|
||||
},
|
||||
polylines: _polylines,
|
||||
markers: _markers,
|
||||
),
|
||||
Positioned.fill(
|
||||
child: Align(alignment: Alignment.center, child: _getMarker()))
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue