first commit
This commit is contained in:
96
lib/home.dart
Normal file
96
lib/home.dart
Normal file
@ -0,0 +1,96 @@
|
||||
// import 'dart:async';
|
||||
//
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter/services.dart';
|
||||
// import 'package:flutter_map/flutter_map.dart';
|
||||
// import 'package:flutter_map_marker_cluster/flutter_map_marker_cluster.dart';
|
||||
// import 'package:geolocator/geolocator.dart';
|
||||
// import 'package:latlong/latlong.dart';
|
||||
// import 'package:map_controller/map_controller.dart';
|
||||
//
|
||||
// class Home extends StatefulWidget {
|
||||
// const Home({Key? key}) : super(key: key);
|
||||
//
|
||||
//
|
||||
// @override
|
||||
// _HomeState createState() => _HomeState();
|
||||
// }
|
||||
//
|
||||
// class _HomeState extends State<Home> {
|
||||
//
|
||||
// MapController? mapController;
|
||||
// StatefulMapController? statefulMapController;
|
||||
// StreamSubscription<StatefulMapControllerStateChange>? sub;
|
||||
// final PopupController _popupController = PopupController();
|
||||
//
|
||||
// Future<void> showCurrentPosition() async {
|
||||
// LocationPermission permission = await Geolocator.checkPermission();
|
||||
// if(permission != LocationPermission.whileInUse || permission != LocationPermission.always ){
|
||||
// permission = await Geolocator.requestPermission();
|
||||
// }
|
||||
// Position position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
|
||||
// mapController?.move(LatLng(position.latitude, position.longitude), 14);
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// mapController = MapController();
|
||||
// statefulMapController = StatefulMapController(mapController: mapController);
|
||||
// statefulMapController!.onReady.then((_) => loadData());
|
||||
// sub = statefulMapController!.changeFeed.listen((change) => setState(() {}));
|
||||
// super.initState();
|
||||
// }
|
||||
//
|
||||
// void loadData() async {
|
||||
// print("Loading geojson data");
|
||||
// final data = await rootBundle.loadString('assets/3.geojson');
|
||||
// await statefulMapController?.fromGeoJson(data,
|
||||
// markerIcon: Icon(Icons.note), verbose: true);
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Scaffold(
|
||||
// appBar: AppBar(
|
||||
// title: Text("Rogaining"),
|
||||
// actions: [
|
||||
// IconButton(
|
||||
// icon: const Icon(Icons.map),
|
||||
// onPressed: () => {
|
||||
// showCurrentPosition()
|
||||
// },
|
||||
// )
|
||||
//
|
||||
// ],
|
||||
//
|
||||
// // center: LatLng(7.25221960625, 80.7931815538),
|
||||
// // zoom: 7.0,
|
||||
//
|
||||
// ),
|
||||
// body: FlutterMap(
|
||||
// mapController: mapController,
|
||||
// options: MapOptions(
|
||||
// onLongPress: (latlong) {
|
||||
//
|
||||
// },
|
||||
// center: LatLng(37.523437479105006, 139.9073099236486),
|
||||
// zoom: 6,
|
||||
// maxZoom: 20,
|
||||
// onTap: (latlong){} // Hide popup when the map is tapped.
|
||||
// ),
|
||||
// children: [
|
||||
// TileLayerWidget(
|
||||
// options: TileLayerOptions(
|
||||
// urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
// subdomains: ['a', 'b', 'c'],
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// layers: [
|
||||
// MarkerLayerOptions(markers: statefulMapController!.markers),
|
||||
// ],
|
||||
// ),
|
||||
//
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
46
lib/main.dart
Normal file
46
lib/main.dart
Normal file
@ -0,0 +1,46 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get_core/src/get_main.dart';
|
||||
import 'package:get/get_instance/src/extension_instance.dart';
|
||||
import 'package:get/get_navigation/src/extension_navigation.dart';
|
||||
import 'package:get/get_navigation/src/root/get_material_app.dart';
|
||||
import 'package:get/get_navigation/src/routes/transitions_type.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:rogaining_jp/routes/app_pages.dart';
|
||||
import 'package:rogaining_jp/utils/string_values.dart';
|
||||
import 'package:rogaining_jp/utils/util_controller.dart';
|
||||
|
||||
import 'Pages/home/home_binding.dart';
|
||||
|
||||
void main() {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
// This widget is the root of your application.
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
UtilController utilController = Get.put(UtilController());
|
||||
return GetMaterialApp(
|
||||
translations: StringValues(),
|
||||
locale: const Locale('en', 'US'),
|
||||
fallbackLocale: const Locale('en', 'US'),
|
||||
title: 'SENRIS',
|
||||
theme: ThemeData(
|
||||
primarySwatch: Colors.blue,
|
||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||
textTheme: GoogleFonts.muliTextTheme(),
|
||||
),
|
||||
debugShowCheckedModeBanner: false,
|
||||
defaultTransition: Transition.cupertino,
|
||||
opaqueRoute: Get.isOpaqueRouteDefault,
|
||||
popGesture: Get.isPopGestureEnable,
|
||||
transitionDuration: Duration(milliseconds: 230),
|
||||
initialBinding: HomeBinding(),
|
||||
initialRoute: AppPages.INITIAL,
|
||||
getPages: AppPages.routes,
|
||||
);
|
||||
}
|
||||
}
|
||||
77
lib/models/check_points.dart
Normal file
77
lib/models/check_points.dart
Normal file
@ -0,0 +1,77 @@
|
||||
|
||||
import 'dart:ffi';
|
||||
|
||||
enum Entity {
|
||||
gathering,
|
||||
siteSeen,
|
||||
boating,
|
||||
diving
|
||||
}
|
||||
|
||||
class CheckPoint{
|
||||
int? id;
|
||||
double? lat;
|
||||
double? long;
|
||||
Entity? entitty;
|
||||
String? image1;
|
||||
String? image2;
|
||||
String? image3;
|
||||
String? image4;
|
||||
String? title;
|
||||
|
||||
|
||||
CheckPoint.fromId(int id) {
|
||||
// TODO: implement
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
CheckPoint({this.id, this.lat, this.long, this.entitty, this.image1, this.image2, this.image3, this.image4, this.title});
|
||||
|
||||
factory CheckPoint.fromMap(Map<String, dynamic> json) => CheckPoint(
|
||||
id: json['id'],
|
||||
lat: json['lat'],
|
||||
long: json['long'],
|
||||
entitty: json['entity'],
|
||||
image1: json['image1'],
|
||||
image2: json['image2'],
|
||||
image3: json['image3'],
|
||||
image4: json['image4'],
|
||||
title: json['note'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'id': id,
|
||||
'lat': lat,
|
||||
'long': long,
|
||||
'entity': entitty,
|
||||
'image1': image1,
|
||||
'image2': image2,
|
||||
'image3': image3,
|
||||
'image4': image4,
|
||||
'note': title,
|
||||
};
|
||||
}
|
||||
|
||||
Map<String, dynamic> toFeatureMap() {
|
||||
return {
|
||||
"type": "Feature",
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
long,
|
||||
lat
|
||||
]
|
||||
},
|
||||
"properties": {
|
||||
'entity': entitty.toString(),
|
||||
'image1': image1,
|
||||
'image2': image2,
|
||||
'image3': image3,
|
||||
'image4': image4,
|
||||
'note': title,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
27
lib/models/rog_event_model.dart
Normal file
27
lib/models/rog_event_model.dart
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
|
||||
class RogEvent{
|
||||
int? id;
|
||||
String? title;
|
||||
String? venue;
|
||||
DateTime? at_date;
|
||||
List<LatLng>? latlngs;
|
||||
|
||||
RogEvent({this.id, this.title, this.venue, this.at_date, this.latlngs});
|
||||
|
||||
RogEvent.fromId(int id){
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
Future<void> fromgeoJson(String geojson) async {
|
||||
final geo = GeoJson();
|
||||
return await geo.parse(geojson, verbose: true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
13
lib/pages/home/home_binding.dart
Normal file
13
lib/pages/home/home_binding.dart
Normal file
@ -0,0 +1,13 @@
|
||||
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:rogaining_jp/pages/home/home_controller.dart';
|
||||
import 'package:rogaining_jp/pages/travel/travel_controller.dart';
|
||||
|
||||
class HomeBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.put<HomeController>(HomeController());
|
||||
Get.put<TravelController>(TravelController());
|
||||
}
|
||||
}
|
||||
55
lib/pages/home/home_controller.dart
Normal file
55
lib/pages/home/home_controller.dart
Normal file
@ -0,0 +1,55 @@
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:rogaining_jp/models/check_points.dart';
|
||||
import 'package:rogaining_jp/services/checkpoint_service.dart';
|
||||
import 'package:rogaining_jp/services/rog_event_service.dart';
|
||||
import 'package:rogaining_jp/services/rog_route_service.dart';
|
||||
|
||||
|
||||
class HomeController extends GetxController {
|
||||
|
||||
List<CheckPoint> checkpoints = <CheckPoint>[].obs;
|
||||
List<GeoJsonFeature?> RogEvents = <GeoJsonFeature>[].obs;
|
||||
List<GeoJsonFeature?> RogRoutes = <GeoJsonFeature>[].obs;
|
||||
|
||||
|
||||
CheckPoint getIncidentForLatLong(double lat, double long){
|
||||
for(CheckPoint i in checkpoints){
|
||||
if(i.lat == lat && i.long == long){
|
||||
return i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return CheckPoint.fromId(1);
|
||||
}
|
||||
|
||||
|
||||
void addCheckPoint(CheckPoint checkPoint){
|
||||
this.checkpoints.add(checkPoint);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
checkpoints.addAll(CheckpointService.getDistricts());
|
||||
RogEventService.loadRogEvents().then((value){
|
||||
RogEvents.addAll(value);
|
||||
});
|
||||
RogRouteService.loadRogRoutes().then((value){
|
||||
RogRoutes.addAll(value);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
221
lib/pages/home/home_page.dart
Normal file
221
lib/pages/home/home_page.dart
Normal file
@ -0,0 +1,221 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:flutter_map_location_marker/flutter_map_location_marker.dart';
|
||||
import 'package:flutter_map_marker_cluster/flutter_map_marker_cluster.dart';
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:get/get_core/src/get_main.dart';
|
||||
import 'package:get/get_instance/src/extension_instance.dart';
|
||||
import 'package:get/get_state_manager/src/rx_flutter/rx_obx_widget.dart';
|
||||
import 'package:get/get_state_manager/src/simple/get_view.dart';
|
||||
import 'package:get/get_utils/src/extensions/internacionalization.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:rogaining_jp/models/check_points.dart';
|
||||
import 'package:rogaining_jp/pages/home/home_controller.dart';
|
||||
import 'package:rogaining_jp/services/rog_event_service.dart';
|
||||
import 'package:rogaining_jp/utils/util_controller.dart';
|
||||
import 'package:rogaining_jp/widgets/marker_popup_widget.dart';
|
||||
|
||||
class HomePage extends GetView<HomeController> {
|
||||
|
||||
final HomeController homeController = Get.find<HomeController>();
|
||||
|
||||
final MapController mapController = MapController();
|
||||
|
||||
|
||||
//var markers = <Marker>[].obs;
|
||||
|
||||
Future<void> showCurrentPosition() async {
|
||||
LocationPermission permission = await Geolocator.checkPermission();
|
||||
if(permission != LocationPermission.whileInUse || permission != LocationPermission.always ){
|
||||
permission = await Geolocator.requestPermission();
|
||||
}
|
||||
Position position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
|
||||
mapController.move(LatLng(position.latitude, position.longitude), 14);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final PopupController _popupController = PopupController();
|
||||
final UtilController ctrl = Get.find<UtilController>();
|
||||
|
||||
//print("length is " + homeController.RogRoutes[0]!.properties!["name"]);
|
||||
|
||||
|
||||
return Scaffold(
|
||||
drawer: 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(
|
||||
// Important: Remove any padding from the ListView.
|
||||
padding: EdgeInsets.zero,
|
||||
children: [
|
||||
const DrawerHeader(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.blue,
|
||||
),
|
||||
child: Text('Drawer Header'),
|
||||
),
|
||||
ListTile(
|
||||
title: const Text('Item 1'),
|
||||
onTap: () {
|
||||
// Update the state of the app.
|
||||
// ...
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: const Text('Item 2'),
|
||||
onTap: () {
|
||||
// Update the state of the app.
|
||||
// ...
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
appBar: AppBar(
|
||||
title: Text("app_title".tr),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.map),
|
||||
onPressed: () => {print("action")},
|
||||
)
|
||||
|
||||
],
|
||||
|
||||
// center: LatLng(7.25221960625, 80.7931815538),
|
||||
// zoom: 7.0,
|
||||
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Obx(() =>
|
||||
Stack(
|
||||
children: [
|
||||
FlutterMap(
|
||||
mapController: mapController,
|
||||
options: MapOptions(
|
||||
onLongPress: (TapPosition, latlong) {
|
||||
CheckPoint i = CheckPoint(
|
||||
entitty: Entity.siteSeen,
|
||||
lat: latlong.latitude,
|
||||
long: latlong.longitude,
|
||||
title: ""
|
||||
);
|
||||
homeController.addCheckPoint(i);
|
||||
},
|
||||
center: LatLng(36.02496227461018, 139.4499871456401),
|
||||
zoom: 7,
|
||||
maxZoom: 20,
|
||||
plugins: [
|
||||
MarkerClusterPlugin(),
|
||||
],
|
||||
onTap: (_, __) => _popupController
|
||||
.hideAllPopups(), // Hide popup when the map is tapped.
|
||||
),
|
||||
children: [
|
||||
TileLayerWidget(
|
||||
options: TileLayerOptions(
|
||||
urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
subdomains: ['a', 'b', 'c'],
|
||||
),
|
||||
),
|
||||
PolylineLayerWidget(
|
||||
options: PolylineLayerOptions(
|
||||
polylines: homeController.RogRoutes.map((e){
|
||||
return Polyline(
|
||||
points: (e!.geometry as GeoJsonMultiLine).lines.first.geoSerie!.toLatLng(),
|
||||
strokeWidth: 3.0,
|
||||
color: Colors.black
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
LocationMarkerLayerWidget(),
|
||||
MarkerClusterLayerWidget(
|
||||
options: MarkerClusterLayerOptions(
|
||||
spiderfyCircleRadius: 80,
|
||||
spiderfySpiralDistanceMultiplier: 2,
|
||||
circleSpiralSwitchover: 12,
|
||||
maxClusterRadius: 20,
|
||||
rotate: true,
|
||||
size: Size(40, 40),
|
||||
anchor: AnchorPos.align(AnchorAlign.center),
|
||||
fitBoundsOptions: const FitBoundsOptions(
|
||||
padding: EdgeInsets.all(50),
|
||||
maxZoom: 15,
|
||||
),
|
||||
markers: homeController.RogEvents.map((e) {
|
||||
return Marker(
|
||||
anchorPos: AnchorPos.align(AnchorAlign.center),
|
||||
height: 30.0,
|
||||
width: 30.0,
|
||||
point: LatLng((e!.geometry as GeoJsonMultiPoint).geoSerie!.geoPoints.first.latitude, (e!.geometry as GeoJsonMultiPoint).geoSerie!.geoPoints.first.longitude),
|
||||
builder: (ctx) => Icon(Icons.pin_drop),
|
||||
);
|
||||
}).toList(),
|
||||
popupOptions: PopupOptions(
|
||||
popupSnap: PopupSnap.markerTop,
|
||||
popupController: _popupController,
|
||||
popupBuilder: (_, marker) => Container(
|
||||
width: 350,
|
||||
height: 300,
|
||||
color: Colors.white,
|
||||
child: GestureDetector(
|
||||
onTap: () => debugPrint('Popup tap!'),
|
||||
child: MarkerPopupWidget(homeController.getIncidentForLatLong(marker.point.latitude, marker.point.longitude), homeController),
|
||||
),
|
||||
)),
|
||||
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: 50.0,
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade100,
|
||||
borderRadius: BorderRadius.circular(10.0)
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
const Expanded(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Text("...")
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.my_location_outlined,),
|
||||
onPressed: () => {
|
||||
showCurrentPosition()
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
9
lib/pages/travel/travel_binding.dart
Normal file
9
lib/pages/travel/travel_binding.dart
Normal file
@ -0,0 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class TravelBinding extends Bindings {
|
||||
|
||||
@override
|
||||
void dependencies() {
|
||||
}
|
||||
}
|
||||
5
lib/pages/travel/travel_controller.dart
Normal file
5
lib/pages/travel/travel_controller.dart
Normal file
@ -0,0 +1,5 @@
|
||||
import 'package:get/get_state_manager/src/simple/get_controllers.dart';
|
||||
|
||||
class TravelController extends GetxController {
|
||||
|
||||
}
|
||||
10
lib/pages/travel/travel_page.dart
Normal file
10
lib/pages/travel/travel_page.dart
Normal file
@ -0,0 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class TravelPage extends StatelessWidget {
|
||||
const TravelPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
26
lib/routes/app_pages.dart
Normal file
26
lib/routes/app_pages.dart
Normal file
@ -0,0 +1,26 @@
|
||||
import 'package:get/get_navigation/src/routes/get_route.dart';
|
||||
import 'package:rogaining_jp/Pages/home/home_binding.dart';
|
||||
import 'package:rogaining_jp/Pages/travel/travel_binding.dart';
|
||||
import 'package:rogaining_jp/Pages/travel/travel_page.dart';
|
||||
import 'package:rogaining_jp/pages/home/home_page.dart';
|
||||
|
||||
|
||||
part 'app_routes.dart';
|
||||
|
||||
class AppPages {
|
||||
static const INITIAL = Routes.HOME;
|
||||
static const TRAVEL = Routes.TRAVEL;
|
||||
|
||||
static final routes = [
|
||||
GetPage(
|
||||
name: Routes.HOME,
|
||||
page: () => HomePage(),
|
||||
binding: HomeBinding(),
|
||||
),
|
||||
GetPage(
|
||||
name: Routes.TRAVEL,
|
||||
page: () => TravelPage(),
|
||||
binding: TravelBinding(),
|
||||
),
|
||||
];
|
||||
}
|
||||
7
lib/routes/app_routes.dart
Normal file
7
lib/routes/app_routes.dart
Normal file
@ -0,0 +1,7 @@
|
||||
part of 'app_pages.dart';
|
||||
|
||||
abstract class Routes {
|
||||
// Main Menu Route
|
||||
static const HOME = '/';
|
||||
static const TRAVEL = '/travel';
|
||||
}
|
||||
82
lib/services/checkpoint_service.dart
Normal file
82
lib/services/checkpoint_service.dart
Normal file
@ -0,0 +1,82 @@
|
||||
import 'package:get/get_rx/src/rx_types/rx_types.dart';
|
||||
import 'package:rogaining_jp/models/check_points.dart';
|
||||
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class CheckpointService {
|
||||
|
||||
static Future<CheckPoint> syncIncident(CheckPoint incident) async {
|
||||
print(jsonEncode(incident.toFeatureMap()));
|
||||
String url = 'http://front.lk:8100/api/v1/incidents/';
|
||||
final response = await http.post(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
body: jsonEncode(incident.toFeatureMap()),
|
||||
);
|
||||
|
||||
if (response.statusCode == 201) {
|
||||
return CheckPoint.fromMap(jsonDecode(response.body));
|
||||
} else {
|
||||
throw Exception('Failed to create album.');
|
||||
}
|
||||
}
|
||||
|
||||
static List<CheckPoint> getDistricts() {
|
||||
return <CheckPoint>[
|
||||
CheckPoint(
|
||||
id:1,
|
||||
lat: 35.3411516,
|
||||
long: 137.1275938,
|
||||
title: "日本、〒507-0028 岐阜県多治見市弁天町1丁目47−1"
|
||||
),
|
||||
CheckPoint(
|
||||
id:2,
|
||||
lat: 35.3681674,
|
||||
long: 137.2014657,
|
||||
title: "岐阜県土岐市泉町河合849−1 はま寿司 土岐店",
|
||||
),
|
||||
CheckPoint(
|
||||
id:3,
|
||||
lat: 35.357564,
|
||||
long: 137.2430125,
|
||||
title: "岐阜県瑞浪市南小田町1丁目141 マクドナルド 19号瑞浪店",
|
||||
),
|
||||
CheckPoint(
|
||||
id:4,
|
||||
lat: 35.3238775,
|
||||
long: 137.2028726,
|
||||
title: "岐阜県土岐市下石町1937−3 蕎麦 秋新",
|
||||
),
|
||||
CheckPoint(
|
||||
id:5,
|
||||
lat: 35.2993208,
|
||||
long: 137.1594189,
|
||||
title: "岐阜県多治見市笠原町2082−5 多治見市モザイクタイルミュージアム",
|
||||
),
|
||||
CheckPoint(
|
||||
id:6,
|
||||
lat: 35.2999321,
|
||||
long: 137.1268954,
|
||||
title: "岐阜県多治見市市之倉町4丁目6−30−1 市之倉さかづき美術館",
|
||||
),
|
||||
CheckPoint(
|
||||
id:7,
|
||||
lat: 35.3180639,
|
||||
long: 137.13031620000001,
|
||||
title: "岐阜県多治見市大畑町2丁目150 感謝と挑戦のTYK体育館(多治見市総合体育館)",
|
||||
),
|
||||
CheckPoint(
|
||||
id:7,
|
||||
lat: 35.3411375,
|
||||
long: 137.1276928,
|
||||
title: "岐阜県多治見市大畑町2丁目150 感謝と挑戦のTYK体育館(多治見市総合体育館)",
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
48
lib/services/rog_event_service.dart
Normal file
48
lib/services/rog_event_service.dart
Normal file
@ -0,0 +1,48 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:rogaining_jp/models/check_points.dart';
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:rogaining_jp/models/rog_event_model.dart';
|
||||
import 'package:rogaining_jp/widgets/marker_popup_widget.dart';
|
||||
|
||||
class RogEventService {
|
||||
|
||||
static Future<List<GeoJsonFeature?>> loadRogEvents() async {
|
||||
|
||||
List<GeoJsonFeature?> pts = <GeoJsonFeature>[];
|
||||
|
||||
final geo = GeoJson();
|
||||
|
||||
geo.processedFeatures.listen((GeoJsonFeature feature) {
|
||||
//GeoJsonMultiPoint g = feature.geometry;
|
||||
//print(g.geoSerie!.geoPoints.first.longitude);
|
||||
//print(<GeoJsonMultiPoint>feature.geometry);
|
||||
pts.add(feature);
|
||||
});
|
||||
|
||||
geo.endSignal.listen((_) => geo.dispose());
|
||||
|
||||
String url = 'http://localhost:8100/api/v1/rog/';
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
String objs = response.body;
|
||||
print(objs);
|
||||
await geo.parse(response.body, verbose: false);
|
||||
return pts;
|
||||
} else {
|
||||
throw Exception('Failed to create album.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
45
lib/services/rog_route_service.dart
Normal file
45
lib/services/rog_route_service.dart
Normal file
@ -0,0 +1,45 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:rogaining_jp/models/check_points.dart';
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:rogaining_jp/models/rog_event_model.dart';
|
||||
import 'package:rogaining_jp/widgets/marker_popup_widget.dart';
|
||||
|
||||
class RogRouteService {
|
||||
|
||||
static Future<List<GeoJsonFeature?>> loadRogRoutes() async {
|
||||
|
||||
List<GeoJsonFeature?> routes = <GeoJsonFeature>[];
|
||||
|
||||
final geo = GeoJson();
|
||||
|
||||
geo.processedFeatures.listen((GeoJsonFeature feature) {
|
||||
routes.add(feature);
|
||||
});
|
||||
|
||||
geo.endSignal.listen((_) => geo.dispose());
|
||||
|
||||
String url = 'http://localhost:8100/api/v1/eventroute/';
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
String objs = response.body;
|
||||
print(objs);
|
||||
await geo.parse(response.body, verbose: false);
|
||||
return routes;
|
||||
} else {
|
||||
throw Exception('Failed to create album.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
14
lib/utils/string_values.dart
Normal file
14
lib/utils/string_values.dart
Normal file
@ -0,0 +1,14 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class StringValues extends Translations{
|
||||
@override
|
||||
// TODO: implement keys
|
||||
Map<String, Map<String, String>> get keys => {
|
||||
'en_US': {
|
||||
'app_title': 'Rogaining JP'
|
||||
},
|
||||
'ja_JP': {
|
||||
'app_title': 'ロゲイニング'
|
||||
}
|
||||
};
|
||||
}
|
||||
9
lib/utils/util_controller.dart
Normal file
9
lib/utils/util_controller.dart
Normal file
@ -0,0 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class UtilController extends GetxController{
|
||||
void changeLanguage(var lang, var cnty){
|
||||
var locale = Locale(lang, cnty);
|
||||
Get.updateLocale(locale);
|
||||
}
|
||||
}
|
||||
124
lib/widgets/marker_popup_widget.dart
Normal file
124
lib/widgets/marker_popup_widget.dart
Normal file
@ -0,0 +1,124 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:get/get_core/src/get_main.dart';
|
||||
import 'package:get/get_instance/src/extension_instance.dart';
|
||||
import 'package:get/get_navigation/src/extension_navigation.dart';
|
||||
import 'package:get/get_state_manager/src/rx_flutter/rx_obx_widget.dart';
|
||||
import 'package:rogaining_jp/models/check_points.dart';
|
||||
import 'package:rogaining_jp/pages/home/home_controller.dart';
|
||||
|
||||
|
||||
class MarkerPopupWidget extends StatelessWidget {
|
||||
CheckPoint checkpoint;
|
||||
HomeController homeController;
|
||||
|
||||
String dropdownValue = 'One';
|
||||
|
||||
MarkerPopupWidget(this.checkpoint, this.homeController);
|
||||
|
||||
TextEditingController detailController = TextEditingController();
|
||||
|
||||
|
||||
void onIncidentSubmit(){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final TextEditingController _latitudeController = TextEditingController(text: checkpoint.lat.toString());
|
||||
final TextEditingController _longitudeController = TextEditingController(text: checkpoint.long.toString());;
|
||||
final TextEditingController _noteController = TextEditingController(text: checkpoint.title);
|
||||
|
||||
return SingleChildScrollView(
|
||||
child: Container(
|
||||
alignment: Alignment.topLeft,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(20.0),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 35.0,
|
||||
alignment: Alignment.center,
|
||||
color: Colors.black12,
|
||||
child: const Text("Rogaining", style: TextStyle(
|
||||
fontSize: 18.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text("Title", style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
SizedBox(width: 10.0,),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _noteController,
|
||||
decoration: InputDecoration(
|
||||
hintText: "Title",
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text("Event", style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
SizedBox(width: 10.0,),
|
||||
Expanded(
|
||||
child: ListTile(
|
||||
title: const Text(
|
||||
"Select event"
|
||||
),
|
||||
trailing: Icon(Icons.arrow_forward_ios),
|
||||
onTap: (){},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text("Images", style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
SizedBox(width: 10.0,),
|
||||
Expanded(
|
||||
child: ListTile(
|
||||
title: const Text(
|
||||
"Select Photos"
|
||||
),
|
||||
trailing: Icon(Icons.arrow_forward_ios),
|
||||
onTap: (){},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed:(){},
|
||||
icon: Icon(Icons.favorite_outlined, color: Colors.blue,)
|
||||
),
|
||||
IconButton(
|
||||
onPressed:(){},
|
||||
icon: Icon(Icons.note, color: Colors.blue,)
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user