initial rod app
This commit is contained in:
0
lib/pages/drawer/drawer_binding.dart
Normal file
0
lib/pages/drawer/drawer_binding.dart
Normal file
20
lib/pages/drawer/drawer_controller.dart
Normal file
20
lib/pages/drawer/drawer_controller.dart
Normal file
@ -0,0 +1,20 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class LayerDrawerController extends GetxController {
|
||||
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
30
lib/pages/drawer/drawer_page.dart
Normal file
30
lib/pages/drawer/drawer_page.dart
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class DrawerPage extends StatelessWidget {
|
||||
const DrawerPage({ Key? key }) : super(key: key);
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Drawer(
|
||||
// Add a ListView to the drawer. This ensures the user can scroll
|
||||
// through the options in the drawer if there isn't enough vertical
|
||||
// space to fit everything.
|
||||
child: ListView.builder(
|
||||
itemCount: 10,
|
||||
itemBuilder: (context, i){
|
||||
return Obx(() =>
|
||||
CheckboxListTile(
|
||||
value: true,
|
||||
title: Text("Title"),
|
||||
onChanged: (val){
|
||||
}
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
12
lib/pages/home/home_binding.dart
Normal file
12
lib/pages/home/home_binding.dart
Normal file
@ -0,0 +1,12 @@
|
||||
import 'package:get/get_core/src/get_main.dart';
|
||||
import 'package:get/get_instance/src/bindings_interface.dart';
|
||||
import 'package:get/get_instance/src/extension_instance.dart';
|
||||
import 'package:rogapp/pages/home/home_controller.dart';
|
||||
|
||||
|
||||
class HomeBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.put<HomeController>(HomeController());
|
||||
}
|
||||
}
|
||||
31
lib/pages/home/home_controller.dart
Normal file
31
lib/pages/home/home_controller.dart
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rogapp/services/location_service.dart';
|
||||
|
||||
class HomeController extends GetxController {
|
||||
|
||||
List<GeoJsonFeatureCollection> locations = <GeoJsonFeatureCollection>[].obs;
|
||||
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
LocationService.loadLocations().then((value){
|
||||
locations.add(value!);
|
||||
});
|
||||
}
|
||||
|
||||
GeoJsonFeature? getFeatureForLatLong(double lat, double long){
|
||||
if(locations.length > 0){
|
||||
for(GeoJsonFeature i in locations[0].collection){
|
||||
GeoJsonMultiPoint p = i.geometry as GeoJsonMultiPoint;
|
||||
if(p.geoSerie!.geoPoints[0].latitude == lat && p.geoSerie!.geoPoints[0].longitude == long){
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
103
lib/pages/home/home_page.dart
Normal file
103
lib/pages/home/home_page.dart
Normal file
@ -0,0 +1,103 @@
|
||||
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rogapp/pages/drawer/drawer_page.dart';
|
||||
import 'package:rogapp/pages/home/home_controller.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
import 'package:rogapp/services/location_line_service.dart';
|
||||
import 'package:rogapp/services/location_polygon_service.dart';
|
||||
import 'package:rogapp/services/location_service.dart';
|
||||
import 'package:rogapp/widgets/bottom_sheet_widget.dart';
|
||||
|
||||
class HomePage extends GetView<HomeController> {
|
||||
|
||||
final HomeController homeController = Get.find<HomeController>();
|
||||
|
||||
Image getImage(int index){
|
||||
if(homeController.locations[0].collection[index].properties!["photos"] == null || homeController.locations[0].collection[index].properties!["photos"] == ""){
|
||||
return Image(image: AssetImage('assets/images/empty_image.png'));
|
||||
}
|
||||
else{
|
||||
return Image(image: NetworkImage(homeController.locations[0].collection[index].properties!["photos"]));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
drawer: DrawerPage(),
|
||||
appBar: AppBar(
|
||||
title: Text("app_title".tr),
|
||||
centerTitle: true,
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.map),
|
||||
onPressed: (){
|
||||
//print(homeController.locations.length);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
floatingActionButton: new FloatingActionButton(
|
||||
onPressed: (){
|
||||
Get.toNamed(AppPages.MAP);
|
||||
},
|
||||
tooltip: 'Increment',
|
||||
child: new Icon(Icons.document_scanner),
|
||||
elevation: 4.0,
|
||||
),
|
||||
bottomNavigationBar: BottomAppBar(
|
||||
child: new Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Expanded(child: IconButton(icon: Icon(Icons.camera_enhance), onPressed: (){},),),
|
||||
Expanded(child: IconButton(icon: Icon(Icons.arrow_back_ios), onPressed: (){}),),
|
||||
Expanded(child: new Text('')),
|
||||
Expanded(child: IconButton(icon: Icon(Icons.arrow_forward_ios), onPressed: (){}),),
|
||||
Expanded(child: IconButton(icon: Icon(Icons.travel_explore), onPressed: (){}),),
|
||||
],
|
||||
),
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||
body:Column(
|
||||
children: [
|
||||
Container(
|
||||
height: 50.0,
|
||||
color: Colors.amber,
|
||||
),
|
||||
Expanded(
|
||||
child: Obx(() =>
|
||||
homeController.locations.length > 0 ?
|
||||
ListView.builder(
|
||||
itemCount: homeController.locations[0].collection.length,
|
||||
shrinkWrap: true,
|
||||
itemBuilder: (_, index){
|
||||
return Card(
|
||||
child: ListTile(
|
||||
onTap: (){
|
||||
GeoJsonFeature gf = homeController.locations[0].collection[index];
|
||||
|
||||
|
||||
showModalBottomSheet(
|
||||
isScrollControlled: true,
|
||||
context: context,
|
||||
builder: (context) => BottomSheetWidget(pt: gf),
|
||||
);
|
||||
},
|
||||
leading: getImage(index),
|
||||
title: Text(homeController.locations[0].collection[index].properties!['location_name']),
|
||||
subtitle: Text(homeController.locations[0].collection[index].properties!['category']),
|
||||
),
|
||||
);
|
||||
},
|
||||
) : Container(width: 0, height: 0,),
|
||||
)
|
||||
)
|
||||
],
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
0
lib/pages/map/map_controller.dart
Normal file
0
lib/pages/map/map_controller.dart
Normal file
136
lib/pages/map/map_page.dart
Normal file
136
lib/pages/map/map_page.dart
Normal file
@ -0,0 +1,136 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/plugin_api.dart';
|
||||
import 'package:flutter_map_location_marker/flutter_map_location_marker.dart';
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get/get_state_manager/get_state_manager.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:rogapp/pages/drawer/drawer_page.dart';
|
||||
import 'package:rogapp/pages/home/home_controller.dart';
|
||||
import 'package:flutter_map_marker_cluster/flutter_map_marker_cluster.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
import 'package:rogapp/widgets/base_layer_widget.dart';
|
||||
import 'package:rogapp/widgets/bottom_sheet_widget.dart';
|
||||
|
||||
|
||||
class MapPage extends StatelessWidget {
|
||||
MapPage({ Key? key }) : super(key: key);
|
||||
|
||||
final HomeController homeController = Get.find<HomeController>();
|
||||
|
||||
final MapController mapController = MapController();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final PopupController _popupController = PopupController();
|
||||
|
||||
|
||||
return Scaffold(
|
||||
drawer: DrawerPage(),
|
||||
appBar: AppBar(
|
||||
title: Text("app_title".tr),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.map),
|
||||
onPressed: () => {print("action")},
|
||||
)
|
||||
|
||||
],
|
||||
),
|
||||
bottomNavigationBar: BottomAppBar(
|
||||
child: new Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Expanded(child: IconButton(icon: Icon(Icons.camera_enhance), onPressed: (){},),),
|
||||
Expanded(child: IconButton(icon: Icon(Icons.arrow_back_ios), onPressed: (){}),),
|
||||
Expanded(child: new Text('')),
|
||||
Expanded(child: IconButton(icon: Icon(Icons.arrow_forward_ios), onPressed: (){}),),
|
||||
Expanded(child: IconButton(icon: Icon(Icons.travel_explore), onPressed: (){}),),
|
||||
],
|
||||
),
|
||||
),
|
||||
floatingActionButton: new FloatingActionButton(
|
||||
onPressed: (){
|
||||
Get.toNamed(AppPages.INITIAL);
|
||||
},
|
||||
tooltip: 'Increment',
|
||||
child: new Icon(Icons.document_scanner),
|
||||
elevation: 4.0,
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||
body: SafeArea(
|
||||
child: Obx(() =>
|
||||
Stack(
|
||||
children: [
|
||||
FlutterMap(
|
||||
mapController: mapController,
|
||||
options: MapOptions(
|
||||
center: LatLng(37.15319600454702, 139.58765950528198),
|
||||
zoom: 6,
|
||||
maxZoom: 20,
|
||||
plugins: [
|
||||
MarkerClusterPlugin(),
|
||||
],
|
||||
onTap: (_, __) =>
|
||||
_popupController
|
||||
.hideAllPopups(), // Hide popup when the map is tapped.
|
||||
),
|
||||
children: [
|
||||
BaseLayer(),
|
||||
LocationMarkerLayerWidget(),
|
||||
homeController.locations.length > 0 ?
|
||||
MarkerClusterLayerWidget(
|
||||
options: MarkerClusterLayerOptions(
|
||||
spiderfyCircleRadius: 80,
|
||||
spiderfySpiralDistanceMultiplier: 2,
|
||||
circleSpiralSwitchover: 12,
|
||||
maxClusterRadius: 20,
|
||||
rotate: true,
|
||||
onMarkerTap: (marker) => showModalBottomSheet(
|
||||
isScrollControlled: true,
|
||||
context: context,
|
||||
builder: (context) => BottomSheetWidget(pt: homeController.getFeatureForLatLong(marker.point.latitude, marker.point.longitude),),
|
||||
),
|
||||
size: Size(40, 40),
|
||||
anchor: AnchorPos.align(AnchorAlign.center),
|
||||
fitBoundsOptions: const FitBoundsOptions(
|
||||
padding: EdgeInsets.all(50),
|
||||
maxZoom: 15,
|
||||
),
|
||||
markers:homeController.locations[0].collection.map((i) {
|
||||
GeoJsonMultiPoint p = i.geometry as GeoJsonMultiPoint;
|
||||
return Marker(
|
||||
anchorPos: AnchorPos.align(AnchorAlign.center),
|
||||
height: 70.0,
|
||||
width: 70.0,
|
||||
point: LatLng(p.geoSerie!.geoPoints[0].latitude, p.geoSerie!.geoPoints[0].longitude),
|
||||
builder: (ctx) => Icon(Icons.pin_drop),
|
||||
);
|
||||
}).toList(),
|
||||
builder: (context, markers) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(20.0),
|
||||
color: Colors.blue),
|
||||
child: Center(
|
||||
child: Text(
|
||||
markers.length.toString(),
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
): Container(height:0,width: 0),
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user