update for flutter_map

This commit is contained in:
Mohamed Nouffer
2022-12-13 18:19:16 +05:30
parent 244b7eb9ac
commit e9bf50fc14
51 changed files with 2701 additions and 4007 deletions

View File

@ -1,10 +0,0 @@
import 'package:get/get.dart';
import 'package:rogapp/pages/destination/destination_controller.dart';
import 'package:rogapp/pages/index/index_controller.dart';
class DestinationBinding extends Bindings {
@override
void dependencies() {
Get.put<DestinationController>(DestinationController());
}
}

View File

@ -1,306 +0,0 @@
import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:get/get.dart';
import 'package:latlong2/latlong.dart';
import 'package:rogapp/model/destination.dart';
import 'package:rogapp/model/location.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/routes/app_pages.dart';
import 'package:rogapp/services/destination_service.dart';
import 'package:rogapp/services/maxtrix_service.dart';
import 'package:rogapp/services/reacking_service.dart';
import 'package:rogapp/utils/database_helper.dart';
import 'dart:async';
import 'package:rogapp/widgets/bottom_sheet_widget.dart';
class DestinationController extends GetxController {
late LocationSettings locationSettings;
var destinationCount = 0.obs;
List<Location> destinations = <Location>[].obs;
List<Map<String, dynamic>> destination_index_data = <Map<String, dynamic>>[].obs;
List<Location> currentSelectedDestinations = <Location>[].obs;
bool checking_in = false;
List<bool> isSelected = [true].obs;
BuildContext? context;
List<String> gps = <String>["-- stating --"].obs;
List<String> locationPermission = <String>[" -- starting -- "].obs;
Map<String, dynamic> matrix = {};
final IndexController indexController = Get.find<IndexController>();
Future<Location?> getDEstinationForLatLong(double lat, double long)async {
String jjjj = '{"id":1,"type":"Feature","geometry":{"type":"MultiPoint","coordinates":[[136.731357,35.370094]]},"properties":{"location_id":915101,"location_name":"柳津","category":"買い物","zip":"〒501-6100","address":"柳津町字仙右城7696-1"}}';
for(final d in destinations){
if(lat == d.latitude && long == d.longitude){
return d;
}
}
}
checkForCheckin(double la, double ln){
for(final d in destinations){
if(!checking_in)
{
checking_in = true;
double lat = d.latitude!;
double lon = d.longitude!;
getDEstinationForLatLong(lat, lon).then((value){
var distance = Distance();
double dist = distance.as(LengthUnit.Meter, LatLng(lat, lon), LatLng(la, ln));
int rad = value!.checkin_radius! ?? 1000000;
bool auto_checkin = value.auto_checkin == 0 ? false : true;
indexController.currentDestinationFeature.add(value);
if(rad >= dist){
if(auto_checkin){
makeCheckin(value, true);
}
}
});
}
}
}
void makeCheckin(Location destination, bool action) async {
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ressssss ${action}@@@@@@@@@@@");
DatabaseHelper db = DatabaseHelper.instance;
int res = await db.updateAction(destination, action);
List<Location> ddd = await db.getDestinationByLatLon(destination.lat!, destination.lon!);
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ddddd ${ddd[0].checkedin} @@@@@@@@@@@");
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ressssss ${res}@@@@@@@@@@@");
PopulateDestinations();
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ after populating ${res} @@@@@@@@@@@");
print("---- database update resulr ------ res : ${res}-------");
}
@override
void onInit() async {
super.onInit();
checkPermission();
PopulateDestinations();
//print("------ in iniit");
if (defaultTargetPlatform == TargetPlatform.android) {
locationSettings = AndroidSettings(
accuracy: LocationAccuracy.bestForNavigation,
distanceFilter: 00,
forceLocationManager: true,
intervalDuration: const Duration(seconds: 1),
//(Optional) Set foreground notification config to keep the app alive
//when going to the background
foregroundNotificationConfig: const ForegroundNotificationConfig(
notificationText:
"Example app will continue to receive your location even when you aren't using it",
notificationTitle: "Running in Background",
enableWakeLock: true,
)
);
} else if (defaultTargetPlatform == TargetPlatform.iOS || defaultTargetPlatform == TargetPlatform.macOS) {
locationSettings = AppleSettings(
accuracy: LocationAccuracy.bestForNavigation,
activityType: ActivityType.fitness,
distanceFilter: 1,
pauseLocationUpdatesAutomatically: false,
// Only set to true if our app will be started up in the background.
showBackgroundLocationIndicator: true
);
} else {
locationSettings = LocationSettings(
accuracy: LocationAccuracy.high,
distanceFilter: 30,
);
}
try {
StreamSubscription<Position> positionStream = Geolocator.getPositionStream(locationSettings: locationSettings).listen(
(Position? position) {
if(isSelected[0]){
double czoom = indexController.rogMapController!.zoom;
indexController.rogMapController!.move(LatLng(position!.latitude, position!.longitude), czoom);
//String user_id = indexController.currentUser[0]["user"]["id"].toString();
//TrackingService.addTrack(user_id, position!.latitude, position.longitude).then((val){
//print("---- postion is ${position.latitude}, ${position.longitude}");
gps.clear();
gps.add("-- lat : ${position.latitude}, lon : ${position.longitude} --");
checkForCheckin(position!.latitude, position.longitude);
//});
}
//print(position == null ? 'Unknown' : 'current position is ${position.latitude.toString()}, ${position.longitude.toString()}');
});
} catch (err){
locationPermission.clear();
locationPermission.add(err.toString());
}
}
void checkPermission() async {
LocationPermission permission = await Geolocator.checkPermission();
if (permission != LocationPermission.whileInUse ||
permission != LocationPermission.always) {
locationPermission.clear();
locationPermission.add(permission.name);
permission = await Geolocator.requestPermission();
}
}
void deleteDestination(Destination d){
//int id = destinations[index].location_id!;
//print("---- index ${destinations[index].location_id!}-----");
for(Destination ss in currentSelectedDestinations){
if(ss.location_id == d.location_id){
currentSelectedDestinations.remove(ss);
break;
}
}
DatabaseHelper db = DatabaseHelper.instance;
db.deleteDestination(d.location_id!).then((value){
PopulateDestinations();
});
}
// ---------- database ------------------///
void addDestinations(Destination dest){
print('------ destination controller in add destination ${dest.name} ---- :::::');
DatabaseHelper db = DatabaseHelper.instance;
db.getDestinationByLatLon(dest.lat!, dest.lon!).then((value){
if(value.isNotEmpty){
db.deleteDestination(value[0].location_id!).then((value){
db.insertDestination(dest).then((value){
print("----- destination controller deleted and inserted destination id $value ---- :::::");
PopulateDestinations();
});
});
}
else {
db.insertDestination(dest).then((value){
print("----- destination controller added as new ${value}--- :::::");
PopulateDestinations();
});
}
});
}
void PopulateDestinations(){
print("--------- destination controller populsting destinations ----------- ::::::");
destinations.clear();
destinationCount.value = 0;
DatabaseHelper db = DatabaseHelper.instance;
db.getDestinations().then((value){
for(Destination d in value){
for(Destination s in currentSelectedDestinations){
if(d.location_id == s.location_id){
d.selected = !d.selected!;
}
}
destinations.add(d);
}
// destinationCount.value = 0;
destinationCount.value = destinations.length;
print("------ destination controller destinationcount-------- ${destinationCount}-------- :::::");
MatrixService.getDestinations(value).then((mat){
print(mat);
matrix = mat;
});
});
}
void makeOrder(int action_id, int order, String dir){
DestinationService.updateOrder(action_id, order, dir).then((value){
//print("----action value----${value}");
PopulateDestinations();
destination_index_data.clear();
});
}
void makeNext(Destination pt){
for(int i=0; i<= destinations.length - 1; i++){
Destination p = destinations[i];
if(p.lat == pt.lat && p.lon == pt.lon ){
if(indexController.currentDestinationFeature.isNotEmpty){
indexController.currentDestinationFeature.clear();
}
if(i >= destinations.length - 1 ){
indexController.currentDestinationFeature.add(destinations[0]);
//getAction();
}
else{
indexController.currentDestinationFeature.add(destinations[i + 1]);
//getAction();
}
}
}
}
void makePrevious(Destination pt){
for(int i=0; i<= destinations.length - 1; i++){
Destination p = destinations[i];
if(p.lat == pt.lat && p.lon == pt.lon ){
if(indexController.currentDestinationFeature.isNotEmpty){
indexController.currentDestinationFeature.clear();
}
if(i <= 0){
indexController.currentDestinationFeature.add(destinations[destinations.length -1]);
//getAction();
}
else{
indexController.currentDestinationFeature.add(destinations[i - 1]);
//getAction();
}
}
}
}
}

View File

@ -1,125 +0,0 @@
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:get/get.dart';
import 'package:latlong2/latlong.dart';
import 'package:rogapp/pages/destination/destination_controller.dart';
import 'package:rogapp/pages/destination_map/destination_map_page.dart';
import 'package:rogapp/pages/drawer/drawer_page.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/routes/app_pages.dart';
import 'package:rogapp/widgets/destination_widget.dart';
import 'package:timeline_tile/timeline_tile.dart';
class DestinationPage extends StatefulWidget {
DestinationPage({ Key? key }) : super(key: key);
@override
State<DestinationPage> createState() => _DestinationPageState();
}
class _DestinationPageState extends State<DestinationPage> {
final DestinationController destinationController = Get.find<DestinationController>();
final IndexController indexController = Get.find<IndexController>();
final List<int> _items = List<int>.generate(50, (int index) => index);
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);
indexController.rogMapController?.move(LatLng(position.latitude, position.longitude), 14);
}
Image getImage(int index){
if(destinationController.destinations[index].photos == null || destinationController.destinations[index].photos == ""){
return Image(image: AssetImage('assets/images/empty_image.png'));
}
else{
return Image(image: NetworkImage(destinationController.destinations[index].photos!));
}
}
@override
void initState() {
//destinationController.context = context;
//destinationController.PopulateDestinations();
super.initState();
}
@override
Widget build(BuildContext context) {
final ColorScheme colorScheme = Theme.of(context).colorScheme;
final Color oddItemColor = colorScheme.primary.withOpacity(0.05);
final Color evenItemColor = colorScheme.primary.withOpacity(0.15);
return WillPopScope(
onWillPop: () async {
indexController.switchPage(AppPages.INITIAL);
return false;
},
child: Scaffold(
drawer: const DrawerPage(),
bottomNavigationBar: BottomAppBar(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(child: IconButton(icon: const Icon(Icons.camera_enhance), onPressed: (){},),),
const Expanded(child: Text('')),
Expanded(child: IconButton(icon: const Icon(Icons.travel_explore), onPressed: (){
indexController.switchPage(AppPages.INITIAL);
}),),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: (){
//print("######");
indexController.toggleDestinationMode();
},
tooltip: 'Increment',
child: const Icon(Icons.document_scanner),
elevation: 4.0,
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
appBar:AppBar(
automaticallyImplyLeading: true,
title: Text("app_title".tr),
actions: [
//Obx(() =>
ToggleButtons(
disabledColor: Colors.grey.shade200,
selectedColor: Colors.red,
children: <Widget>[
Icon(Icons.explore
)],
onPressed: (int index) {
setState(() {
destinationController.isSelected[index] = !destinationController.isSelected[index];
});
},
isSelected: destinationController.isSelected,
),
//),
// IconButton(onPressed: (){
// showCurrentPosition();
// },
// icon: Icon(Icons.location_on_outlined))
],
),
body: Obx(() =>
indexController.desination_mode.value == 0 ?
DestinationWidget():
DestinationMapPage()
)
),
);
}
}

View File

@ -1,284 +0,0 @@
import 'dart:async';
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:flutter_map_marker_popup/flutter_map_marker_popup.dart';
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
import 'package:geolocator/geolocator.dart';
import 'package:get/get.dart';
import 'package:latlong2/latlong.dart';
import 'package:rogapp/model/destination.dart';
import 'package:rogapp/pages/destination/destination_controller.dart';
//import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/services/destination_service.dart';
import 'package:rogapp/widgets/bottom_sheet_new.dart';
import 'package:rogapp/widgets/bottom_sheet_widget.dart';
import 'package:rogapp/widgets/bread_crum_widget.dart';
class DestinationMapPage extends StatefulWidget {
DestinationMapPage({ Key? key }) : super(key: key);
@override
State<DestinationMapPage> createState() => _DestinationMapPageState();
}
class _DestinationMapPageState extends State<DestinationMapPage> {
final IndexController indexController = Get.find<IndexController>();
final DestinationController destinationController = Get.find<DestinationController>();
StreamSubscription? subscription;
final PopupController _popupLayerController = PopupController();
// Widget examplePopup(Marker marker){
// return Padding(
// padding: const EdgeInsets.all(10),
// child: Container(
// constraints: const BoxConstraints(minWidth: 100, maxWidth: 200),
// color: Colors.white,
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisAlignment: MainAxisAlignment.start,
// mainAxisSize: MainAxisSize.min,
// children: <Widget>[
// const Text(
// 'Popup for a marker!',
// overflow: TextOverflow.fade,
// softWrap: false,
// style: TextStyle(
// fontWeight: FontWeight.w500,
// fontSize: 14.0,
// ),
// ),
// const Padding(padding: EdgeInsets.symmetric(vertical: 4.0)),
// Text(
// 'Position: ${marker.point.latitude}, ${marker.point.longitude}',
// style: const TextStyle(fontSize: 12.0),
// ),
// Text(
// 'Marker size: ${marker.width}, ${marker.height}',
// style: const TextStyle(fontSize: 12.0),
// ),
// ],
// ),
// ),
// );
// }
List<LatLng>? getPoints(){
//print("##### --- route point ${indexController.routePoints.length}");
List<LatLng> pts = [];
for(PointLatLng p in indexController.routePoints){
LatLng l = LatLng(p.latitude, p.longitude);
pts.add(l);
}
return pts;
}
List<Marker>? getMarkers() {
List<Marker> pts = [];
int index = -1;
for (int i = 0; i < destinationController.destinations.length; i++) {
Destination d = destinationController.destinations[i];
//for(Destination d in destinationController.destinations){
//print("-----lat ${lat}, ----- lon ${lan}");
Marker m = Marker(
point: LatLng(d.lat!, d.lon!),
anchorPos: AnchorPos.align(AnchorAlign.center),
builder:(cts){
return InkWell(
onTap: (){
print("-- Destination is --- ${d.name} ------");
if(d != null){
if(indexController.currentDestinationFeature.length > 0) {
indexController.currentDestinationFeature.clear();
}
indexController.currentDestinationFeature.add(d);
//indexController.getAction();
showModalBottomSheet(context: context, isScrollControlled: true,
//builder:((context) => BottomSheetWidget())
builder:((context) => BottomSheetNew())
);
}
},
child: Container(
decoration: BoxDecoration(
color: Colors.red,
shape: BoxShape.circle,
border: new Border.all(
color: Colors.white,
width: d.checkin_radious != null ? d.checkin_radious! : 1,
),
),
child: new Center(
child: new Text(
(i + 1).toString(),
style: TextStyle(color: Colors.white),
),
),
),
);
//return Icon(Icons.pin_drop);
// return IconButton(
// onPressed: ()async {
// Destination? fs = await destinationController.getDEstinationForLatLong(d.lat!, d.lon!);
// print("-- Destination is --- ${fs!.name} ------");
// if(fs != null){
// if(indexController.currentDestinationFeature.length > 0) {
// indexController.currentDestinationFeature.clear();
// }
// indexController.currentDestinationFeature.add(fs);
// //indexController.getAction();
// showModalBottomSheet(context: context, isScrollControlled: true,
// //builder:((context) => BottomSheetWidget())
// builder:((context) => BottomSheetNew())
// );
// }
// },
// icon: Container(
// width: 60,
// height: 60,
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(d.checkin_radious ?? 0),
// color: Colors.transparent,
// border: BoxBorder()
// ),
// child: Icon(Icons.pin_drop)
// )
// );
});
pts.add(m);
}
return pts;
}
@override
void initState() {
DestinationService.getDestinationLine(destinationController.destinations)?.then((value){
//print("---- loading destination points ------ ${value}");
indexController.routePoints.clear();
setState(() {
indexController.routePoints = value;
});
});
super.initState();
}
@override
Widget build(BuildContext context) {
return Obx((() =>
Stack(
children: [
indexController.is_rog_mapcontroller_loaded.value == false ?
Center(child: CircularProgressIndicator())
:
BreadCrumbWidget(mapController:indexController.rogMapController),
Padding(
padding: const EdgeInsets.only(top:50.0),
//child: TravelMap(),
child:
TravelMap(),
),
// Positioned(
// bottom: 200,
// left: 10,
// child: Container(
// color: Colors.white,
// child: Row(
// children: [
// Text(destinationController.gps[0]),
// Text(destinationController.locationPermission[0])
// ],
// ),
// )
// ),
],
)
));
}
FlutterMap TravelMap() {
return FlutterMap(
options: MapOptions(
onMapCreated: (c){
indexController.rogMapController = c;
indexController.rogMapController!.onReady.then((_) {
indexController.is_rog_mapcontroller_loaded.value = true;
subscription = indexController.rogMapController!.mapEventStream.listen((MapEvent mapEvent) {
if (mapEvent is MapEventMoveStart) {
//print(DateTime.now().toString() + ' [MapEventMoveStart] START');
// do something
}
if (mapEvent is MapEventMoveEnd) {
destinationController.isSelected.clear();
destinationController.isSelected.add(false);
//print(DateTime.now().toString() + ' [MapEventMoveStart] END');
//indexController.loadLocationsBound();
}
});
});
} ,
bounds: indexController.currentBound.length > 0 ? indexController.currentBound[0]: LatLngBounds.fromPoints([LatLng(35.03999881162295, 136.40587119778962), LatLng(36.642756778706904, 137.95226720406063)]),
zoom: 1,
maxZoom: 42,
interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag,
//plugins: [LocationMarkerPlugin(),]
),
children: [
TileLayerWidget(
options: TileLayerOptions(
urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
subdomains: ['a', 'b', 'c'],
),
),
//Obx(() =>
indexController.routePoints.length > 0 ?
PolylineLayerWidget(
options: PolylineLayerOptions(
polylines: [
Polyline(
points: getPoints()!,
strokeWidth: 4.0,
color: Colors.purple),
],
),
)
:
Container(),
//),
// PopupMarkerLayerWidget(
// options: PopupMarkerLayerOptions(
// popupController: _popupLayerController,
// markers: _markers,
// markerRotateAlignment:
// PopupMarkerLayerOptions.rotationAlignmentFor(AnchorAlign.top),
// popupBuilder: (BuildContext context, Marker marker) =>
// examplePopup(marker),
// ),
// ),
LocationMarkerLayerWidget(),
MarkerLayerWidget(
options: MarkerLayerOptions(
markers: getMarkers()!
),
),
],
);
}
}

View File

@ -1,12 +0,0 @@
import 'package:get/get.dart';
import 'package:rogapp/pages/home/home_controller.dart';
class HomeBinding extends Bindings{
@override
void dependencies() {
Get.put<HomeController>(HomeController());
}
}

View File

@ -1,7 +0,0 @@
import 'package:get/get.dart';
import 'package:get/get_state_manager/get_state_manager.dart';
class HomeController extends GetxController{
}

View File

@ -1,42 +0,0 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:rogapp/pages/search/search_page.dart';
class HomePage extends GetView{
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
elevation: 0,
backgroundColor: Colors.white,
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("app_title".tr,
style: const TextStyle(
color: Colors.blue
),
),
InkWell(
onTap: (){
Navigator.push(context, MaterialPageRoute(builder: (context) => SearchPage()));
},
child: Container(
height: 32,
width: 75,
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(25),
),
child: const Center(child: Icon(Icons.search),),
),
),
],
),
),
body: Container(),
);
}
}

View File

@ -1,11 +0,0 @@
import 'package:flutter_map/plugin_api.dart';
import 'package:get/get.dart';
import 'package:rogapp/pages/index/index_controller.dart';
class IndexBinding extends Bindings {
@override
void dependencies() {
Get.put<IndexController>(IndexController());
}
}

View File

@ -1,514 +0,0 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_map/plugin_api.dart';
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
import 'package:get/get.dart';
import 'package:latlong2/latlong.dart';
import 'package:rogapp/model/destination.dart';
import 'package:rogapp/model/location.dart';
import 'package:rogapp/pages/destination/destination_binding.dart';
import 'package:rogapp/pages/destination/destination_controller.dart';
import 'package:rogapp/pages/destination/destination_page.dart';
import 'package:rogapp/pages/destination_map/destination_map_page.dart';
import 'package:rogapp/routes/app_pages.dart';
import 'package:rogapp/services/action_service.dart';
import 'package:rogapp/services/auth_service.dart';
import 'package:rogapp/services/cat_service.dart';
import 'package:rogapp/services/location_service.dart';
import 'package:rogapp/services/perfecture_service.dart';
import 'package:rogapp/utils/database_helper.dart';
class IndexController extends GetxController {
List<Location> locations = <Location>[].obs;
List<Location> currentFeature = <Location>[].obs;
List<Location> currentDestinationFeature = <Location>[].obs;
List<dynamic> perfectures = <dynamic>[].obs;
List<LatLngBounds> currentBound = <LatLngBounds>[].obs;
List<dynamic> subPerfs = <dynamic>[].obs;
List<dynamic> areas = <dynamic>[].obs;
List<dynamic> customAreas = <dynamic>[].obs;
List<dynamic> cats = <dynamic>[].obs;
List<String> currentCat = <String>[].obs;
List<Map<String, dynamic>> currentUser = <Map<String, dynamic>>[].obs;
List<dynamic> currentAction = <dynamic>[].obs;
List<PointLatLng> routePoints = <PointLatLng>[].obs;
var is_loading = false.obs;
var is_mapController_loaded = false.obs;
var is_rog_mapcontroller_loaded = false.obs;
var is_custom_area_selected = false.obs;
MapController? mapController;
MapController? rogMapController;
var mode = 0.obs;
// master mode, rog or selection
var rog_mode = 1.obs;
var desination_mode = 1.obs;
bool showPopup = true;
String dropdownValue = "9";
String subDropdownValue = "-1";
String areaDropdownValue = "-1";
String cateogory = "-all-";
LocationService locationService = Get.find<LocationService>();
late Worker _ever;
void toggleMode(){
if(mode.value==0){
mode += 1;
}
else{
mode -= 1;
}
}
void toggleDestinationMode(){
if(desination_mode.value==0){
desination_mode.value += 1;
}
else{
desination_mode.value -= 1;
}
}
void switchPage(String page){
//print("######## ${currentUser[0]["user"]["id"]}");
switch (page) {
case AppPages.INITIAL :{
rog_mode.value = 0;
print("-- rog mode is ctrl is ${rog_mode.value}");
Get.toNamed(page);
}
break;
case AppPages.TRAVEL : {
rog_mode.value = 1;
//Get.back();
Get.off(DestinationPage(), binding: DestinationBinding());
}
break;
case AppPages.LOGIN :{
rog_mode.value = 2;
Get.toNamed(page);
}
break;
default:{
rog_mode.value = 0;
Get.toNamed(AppPages.INITIAL);
}
}
}
@override
void onInit() {
// if(locations.length == 0){
// LocationService.loadLocations().then((value){
// locations.add(value!);
// //print(value);
// });
// }
_ever = ever(rog_mode, (_) => print("$_ has been changed (ever)"));
if(perfectures.length == 0){
PerfectureService.loadPerfectures().then((value){
perfectures.add(value);
loadAreaFor("9");
//loadSubPerfFor("9");
});
}
super.onInit();
}
LatLngBounds boundsFromLatLngList(List<LatLng> list) {
double? x0, x1, y0, y1;
for (LatLng latLng in list) {
if (x0 == null || x1 == null || y0 == null || y1 == null) {
x0 = x1 = latLng.latitude;
y0 = y1 = latLng.longitude;
} else {
if (latLng.latitude > x1) x1 = latLng.latitude;
if (latLng.latitude < x0) x0 = latLng.latitude;
if (latLng.longitude > y1) y1 = latLng.longitude;
if (latLng.longitude < y0) y0 = latLng.longitude;
}
}
return LatLngBounds(LatLng(x1!, y1!), LatLng(x0!, y0!));
}
List<LatLng> getLocationsList(){
List<LatLng> locs = [];
for(int i=0; i<= locations.length - 1; i++){
Location p = locations[i];
LatLng latLng = LatLng(p.latitude!, p.longitude!);
locs.add(latLng);
}
return locs;
}
void login(String email, String password, BuildContext context){
AuthService.login(email, password).then((value){
if(value.isNotEmpty){
currentUser.clear();
currentUser.add(value);
is_loading.value = false;
Navigator.pop(context);
loadUserDetails();
if(rog_mode.value == 1){
switchPage(AppPages.TRAVEL);
}
else{
switchPage(AppPages.INITIAL);
}
//Get.toNamed(AppPages.INITIAL);
}else{
is_loading.value = false;
Get.snackbar(
"Failed",
"User login failed, please try again.",
icon: Icon(Icons.error, size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: Duration(milliseconds: 800),
backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
}
});
}
void register(String email, String password, BuildContext context){
AuthService.register(email, password).then((value){
if(value.isNotEmpty){
currentUser.clear();
currentUser.add(value);
is_loading.value = false;
Navigator.pop(context);
loadUserDetails();
Get.toNamed(AppPages.INITIAL);
}else{
is_loading.value = false;
Get.snackbar(
"Failed",
"User registration failed, please try again.",
icon: Icon(Icons.error, size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: Duration(milliseconds: 800),
backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
}
});
}
void loadCatsv2(){
dynamic initVal = {'category':'-all-'};
LatLngBounds bounds = mapController!.bounds!;
if(bounds.southEast != null && bounds.southWest != null && bounds.northEast != null && bounds.southEast != null ){
CatService.loadCats(bounds.southWest!.latitude, bounds.southWest!.longitude, bounds.northWest.latitude, bounds.northWest.longitude, bounds.northEast!.latitude, bounds.northEast!.longitude, bounds.southEast.latitude, bounds.southEast.longitude).then((value) {
cats.clear();
cats.add(initVal);
for(dynamic cat in value!){
if(cat['category'] != null){
cats.add(cat!);
}
}
});
}
}
void loadCatForCity(String city){
dynamic initVal = {'category':'-all-'};
LatLngBounds bounds = mapController!.bounds!;
if(bounds.southEast != null && bounds.southWest != null && bounds.northEast != null && bounds.southEast != null ){
CatService.loadCatByCity(city).then((value) {
cats.clear();
cats.add(initVal);
for(dynamic cat in value!){
if(cat['category'] != null){
cats.add(cat!);
}
}
});
}
}
void refreshLocationForCat(){
loadLocationsBound();
}
void loadAreaFor(String perf){
areas.clear();
dynamic initVal = {'id':'-1', 'adm2_ja':'----'};
PerfectureService.loadGifuAreas(perf).then((value){
value!.add(initVal);
areas.add(value);
});
}
void loadUserDetails(){
if(currentUser.length > 0){
int user_id = currentUser[0]["user"]["id"] as int;
AuthService.UserDetails(user_id).then((value){
//print("--------- user details ----- ${value}");
bool paid = value![0]["paid"] as bool;
if(paid){
loadCustomAreas();
}
});
}
}
void loadCustomAreas(){
customAreas.clear();
PerfectureService.loadCustomAreas().then((value){
print("--- loading custom areas ${value}");
customAreas.add(value);
});
}
void loadSubPerfFor(String perf){
subPerfs.clear();
dynamic initVal = {'id':'-1', 'adm2_ja':'----'};
PerfectureService.loadSubPerfectures(perf).then((value){
value!.add(initVal);
subPerfs.add(value);
subDropdownValue = getSubInitialVal();
});
}
String getSubInitialVal(){
int min = 0;
if(subPerfs.length > 0){
min = int.parse(subPerfs[0][0]['id'].toString());
for(var sub in subPerfs[0]){
int x = int.parse(sub['id'].toString()); // as int;
if(x < min){
min = x;
}
}
}
return min.toString();
}
void loadLocationforPerf(String perf, MapController mapController) async {
String cat = currentCat.isNotEmpty == true ? currentCat[0] : "";
print(currentCat);
locations.clear();
mapController.fitBounds(currentBound[0]);
}
void loadLocationforSubPerf(String subperf, MapController mapController) async {
String cat = currentCat.isNotEmpty == true ? currentCat[0] : "";
if(currentCat[0] == "-all-"){
cat = "";
}
locationService.loadLocationsSubFor(subperf, cat).then((value){
locations.clear();
locations.addAll(value);
});
}
void loadCustomLocation(String customarea) async {
String cat = currentCat.isNotEmpty == true ? currentCat[0] : "";
print("----- ${customarea}");
locationService.loadCustomLocations(customarea, cat).then((value){
locations.clear();
locations.addAll(value);
List<LatLng> locs = getLocationsList();
LatLngBounds bounds = boundsFromLatLngList(locs);
mapController!.fitBounds(bounds);
setBound(bounds);
Future.delayed(Duration(microseconds: 400), () {
mapController!.fitBounds(bounds);
});
});
}
void loadLocationsBound(){
if(is_custom_area_selected.value == true){
return;
}
String cat = currentCat.isNotEmpty ? currentCat[0] : "";
LatLngBounds bounds = mapController!.bounds!;
currentBound.clear();
currentBound.add(bounds);
//print(currentCat);
if(bounds.southEast != null && bounds.southWest != null && bounds.northEast != null && bounds.southEast != null ){
locationService.loadLocationsBound(bounds.southWest!.latitude, bounds.southWest!.longitude, bounds.northWest.latitude, bounds.northWest.longitude, bounds.northEast!.latitude, bounds.northEast!.longitude, bounds.southEast.latitude, bounds.southEast.longitude, cat).then((value){
//print("---value length ------ ${value!.collection.length}");
if(value == null){
return;
}
locations.clear();
if(value != null && value.isEmpty){
if(showPopup == false) {
return;
}
Get.snackbar(
"Too many Points",
"please zoom in",
icon: Icon(Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: Duration(milliseconds: 800),
backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
showPopup = false;
//Get.showSnackbar(GetSnackBar(message: "Too many points, please zoom in",));
}
if(value != null && value.isNotEmpty){
//print("---- added---");
locations.addAll(value);
loadCatsv2();
}
});
}
}
void setBound(LatLngBounds bounds){
currentBound.clear();
currentBound.add(bounds);
}
void zoomtoMainPerf(String id){
PerfectureService.getMainPerfExt(id).then((value){
LatLng lat1 = LatLng(value![1], value[0]);
LatLng lat2 = LatLng(value[3], value[2]);
LatLngBounds bound = LatLngBounds(lat1, lat2);
mapController!.fitBounds(bound);
setBound(bound);
});
}
void zoomtoSubPerf(String id){
print("zooooom");
PerfectureService.getSubExt(id).then((value){
LatLng lat1 = LatLng(value![1], value[0]);
LatLng lat2 = LatLng(value[3], value[2]);
LatLngBounds bound = LatLngBounds(lat1, lat2);
mapController!.fitBounds(bound);
setBound(bound);
});
}
void populateForPerf(String perf, MapController mapController){
loadSubPerfFor(perf);
loadLocationforPerf(perf, mapController);
zoomtoMainPerf(perf);
is_loading.value = false;
}
void populateForSubPerf(String subperf, MapController mapController){
//subDropdownValue = subperf;
loadLocationforSubPerf(subperf, mapController);
zoomtoSubPerf(subperf);
is_loading.value = false;
}
void populateSubPerForArea(String area, MapController mapController){
loadSubPerfFor(area);
//loadCustomLocation("cus", mapController);
//zoomtoSubPerf(subperf);
is_loading.value = false;
}
Location? getFeatureForLatLong(double lat, double long){
if(locations.length > 0){
for(Location i in locations){
if(i.latitude == lat && i.longitude == long){
return i;
}
}
}
}
void makeNext(Location fs){
if(rog_mode == 1){
DestinationController destinationController = Get.find<DestinationController>();
print("---- destination index--- ${destinationController.destination_index_data} --------");
}
for(int i=0; i<= locations.length - 1; i++){
Location p = locations[i];
if(p.latitude == fs.latitude && p.longitude == fs.longitude ){
if(currentFeature.length > 0){
currentFeature.clear();
}
if(i >= locations.length - 1 ){
currentFeature.add(locations[0]);
}
else{
currentFeature.add(locations[i + 1]);
}
}
}
}
void makePrevious(Location fs){
if(rog_mode == 1){
DestinationController destinationController = Get.find<DestinationController>();
print("---- destination index--- ${destinationController.destination_index_data} --------");
}
for(int i=0; i<= locations.length - 1; i++){
Location p = locations[i];
if(p.latitude == fs.longitude && p.longitude == fs.longitude ){
if(currentFeature.length > 0){
currentFeature.clear();
}
if(i == 0 ){
currentFeature.add(locations[locations.length -1]);
}
else{
currentFeature.add(locations[i - 1]);
}
}
}
}
}

View File

@ -1,149 +0,0 @@
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:rogapp/model/destination.dart';
import 'package:rogapp/pages/drawer/drawer_page.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/routes/app_pages.dart';
import 'package:rogapp/services/maxtrix_service.dart';
import 'package:rogapp/utils/database_helper.dart';
import 'package:rogapp/widgets/bread_crum_widget.dart';
import 'package:rogapp/widgets/cat_widget.dart';
import 'package:rogapp/widgets/list_widget.dart';
import 'package:rogapp/widgets/map_widget.dart';
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
class IndexPage extends GetView<IndexController> {
IndexPage({Key? key}) : super(key: key);
final IndexController indexController = Get.find<IndexController>();
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () async {
indexController.switchPage(AppPages.INITIAL);
return false;
},
child: Scaffold(
//drawer: const DrawerPage(),
appBar: AppBar(
leading: IconButton(
icon: Icon(Icons.arrow_back_ios),
onPressed: (){
indexController.switchPage(AppPages.TRAVEL);
},
),
//automaticallyImplyLeading: false,
title: Text("Add locations"),
actions: [
InkWell(
onTap: (){
Get.toNamed(AppPages.SEARCH);
},
child: Container(
height: 32,
width: 75,
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(25),
),
child: const Center(child: Icon(Icons.search),),
),
),
//CatWidget(indexController: indexController,),
],
),
bottomNavigationBar: BottomAppBar(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(child: IconButton(icon: const Icon(Icons.camera_enhance), onPressed: (){},),),
const Expanded(child: Text('')),
Expanded(child: IconButton(icon: const Icon(Icons.travel_explore), onPressed: (){
indexController.switchPage(AppPages.TRAVEL);
}),),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: (){
indexController.toggleMode();
if(indexController.currentCat.isNotEmpty){
print(indexController.currentCat[0].toString());
}
},
tooltip: 'Increment',
child: const Icon(Icons.document_scanner),
elevation: 4.0,
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
body: SafeArea(
child: Column(
children: [
Container(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
alignment: Alignment.centerLeft,
height: 50.0,
//child: SingleChildScrollView(
// scrollDirection: Axis.horizontal,
// child:Row(
// mainAxisAlignment: MainAxisAlignment.start,
// children: [
// TextButton(child:Text("Main Pef >", style: TextStyle(fontSize:16.0, fontWeight: FontWeight.bold),), onPressed: (){Get.toNamed(AppPages.MAINPERF);},),
// TextButton(child:Text("Sub Pef >", style: TextStyle(fontSize:16.0, fontWeight: FontWeight.bold),), onPressed: (){Get.toNamed(AppPages.SUBPERF);},),
// TextButton(child:Text("Cities >", style: TextStyle(fontSize:16.0, fontWeight: FontWeight.bold),), onPressed: (){Get.toNamed(AppPages.CITY);},),
// TextButton(child:Text("Categories", style: TextStyle(fontSize:16.0, fontWeight: FontWeight.bold),), onPressed: (){Get.toNamed(AppPages.CATEGORY);},),
// ],
// )
// ),
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Obx(() =>
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
indexController.is_mapController_loaded.value == false ?
Center(child: CircularProgressIndicator())
:
BreadCrumbWidget(mapController: indexController.mapController),
Container(width: 24.0,),
// Row(
// children: [
// indexController.currentCat.isNotEmpty ? Text(indexController.currentCat[0].toString()): Text(""),
// indexController.currentCat.isNotEmpty ?
// IconButton(
// onPressed: (){
// indexController.currentCat.clear();
// indexController.loadLocationsBound();
// },
// icon: Icon(Icons.cancel, color: Colors.red,)
// ) :
// Container(width: 0, height: 0,)
// ],
// )
],
)
),
),
),
Expanded(
child: Obx(() =>
indexController.mode == 0 ?
MapWidget() :
ListWidget(),
)
)
],
),
),
),
);
}
}

View File

@ -1,91 +1,91 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:rogapp/routes/app_pages.dart';
// import 'package:flutter/material.dart';
// import 'package:get/get.dart';
// import 'package:rogapp/routes/app_pages.dart';
class LandingPage extends StatefulWidget {
const LandingPage({ Key? key }) : super(key: key);
// class LandingPage extends StatefulWidget {
// const LandingPage({ Key? key }) : super(key: key);
@override
State<LandingPage> createState() => _LandingPageState();
}
// @override
// State<LandingPage> createState() => _LandingPageState();
// }
class _LandingPageState extends State<LandingPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Container(
width: double.infinity,
height: MediaQuery.of(context).size.height,
padding: EdgeInsets.symmetric(horizontal: 30,vertical: 30),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"こんにちは!",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 40),
),
SizedBox(height: 30,),
Text("ログインを有効にして本人確認を行うと、サーバーが改善されます",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.grey[700],
fontSize: 15
),
),
Container(
height: MediaQuery.of(context).size.height/3,
decoration: BoxDecoration(
image:DecorationImage(image: AssetImage('assets/gradient_japanese_temple.jpg'))
),
),
SizedBox(height: 20.0,),
MaterialButton(
minWidth: double.infinity,
height:60,
onPressed: (){
Get.toNamed(AppPages.LOGIN);
},
color: Colors.indigoAccent[400],
shape: RoundedRectangleBorder(
side: BorderSide(
color: Colors.black,
),
borderRadius: BorderRadius.circular(40)
),
child: Text("ログイン",style: TextStyle(
fontWeight: FontWeight.w600,fontSize: 16,color: Colors.white70
// class _LandingPageState extends State<LandingPage> {
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// body: SafeArea(
// child: Container(
// width: double.infinity,
// height: MediaQuery.of(context).size.height,
// padding: EdgeInsets.symmetric(horizontal: 30,vertical: 30),
// child: Column(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Column(
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// Text(
// "こんにちは!",
// style: TextStyle(fontWeight: FontWeight.bold, fontSize: 40),
// ),
// SizedBox(height: 30,),
// Text("ログインを有効にして本人確認を行うと、サーバーが改善されます",
// textAlign: TextAlign.center,
// style: TextStyle(
// color: Colors.grey[700],
// fontSize: 15
// ),
// ),
// Container(
// height: MediaQuery.of(context).size.height/3,
// decoration: BoxDecoration(
// image:DecorationImage(image: AssetImage('assets/gradient_japanese_temple.jpg'))
// ),
// ),
// SizedBox(height: 20.0,),
// MaterialButton(
// minWidth: double.infinity,
// height:60,
// onPressed: (){
// Get.toNamed(AppPages.LOGIN);
// },
// color: Colors.indigoAccent[400],
// shape: RoundedRectangleBorder(
// side: BorderSide(
// color: Colors.black,
// ),
// borderRadius: BorderRadius.circular(40)
// ),
// child: Text("ログイン",style: TextStyle(
// fontWeight: FontWeight.w600,fontSize: 16,color: Colors.white70
),
),
),
SizedBox(height: 15.0,),
// ),
// ),
// ),
// SizedBox(height: 15.0,),
MaterialButton(
minWidth: double.infinity,
height:60,
onPressed: (){
Get.toNamed(AppPages.REGISTER);
},
color: Colors.redAccent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40)
),
child: Text("サインアップ",style: TextStyle(
fontWeight: FontWeight.w600,fontSize: 16,
// MaterialButton(
// minWidth: double.infinity,
// height:60,
// onPressed: (){
// Get.toNamed(AppPages.REGISTER);
// },
// color: Colors.redAccent,
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(40)
// ),
// child: Text("サインアップ",style: TextStyle(
// fontWeight: FontWeight.w600,fontSize: 16,
),),
),
// ),),
// ),
],
)
],
),
),
),
);
}
}
// ],
// )
// ],
// ),
// ),
// ),
// );
// }
// }

View File

@ -1,178 +1,178 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/routes/app_pages.dart';
// import 'package:flutter/material.dart';
// import 'package:get/get.dart';
// //import 'package:rogapp/pages/index/index_controller.dart';
// import 'package:rogapp/routes/app_pages.dart';
class LoginPage extends StatelessWidget {
// class LoginPage extends StatelessWidget {
final IndexController indexController = Get.find<IndexController>();
// // final IndexController indexController = Get.find<IndexController>();
TextEditingController emailController = TextEditingController();
TextEditingController passwordController = TextEditingController();
// TextEditingController emailController = TextEditingController();
// TextEditingController passwordController = TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.white,
appBar: AppBar(
elevation: 0,
brightness: Brightness.light,
backgroundColor: Colors.white,
leading:
IconButton( onPressed: (){
Navigator.pop(context);
},icon:Icon(Icons.arrow_back_ios,size: 20,color: Colors.black,)),
),
body: Container(
height: MediaQuery.of(context).size.height,
width: double.infinity,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Column(
children: [
Column(
children: [
Text ("ログイン", style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.bold,
),),
SizedBox(height: 20,),
Text("お帰りなさい !資格情報を使用してログインします",style: TextStyle(
fontSize: 15,
color: Colors.grey[700],
),),
SizedBox(height: 30,)
],
),
Padding(
padding: EdgeInsets.symmetric(
horizontal: 40
),
child: Column(
children: [
makeInput(label: "Eメール", controller: emailController),
makeInput(label: "パスワード", controller: passwordController, obsureText: true),
],
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 40),
child: Container(
padding: EdgeInsets.only(top: 3,left: 3),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40),
border: Border(
bottom: BorderSide(color: Colors.black),
top: BorderSide(color: Colors.black),
right: BorderSide(color: Colors.black),
left: BorderSide(color: Colors.black)
)
),
child: Obx((() =>
indexController.is_loading == true ? MaterialButton(
minWidth: double.infinity,
height:60,
onPressed: (){
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// resizeToAvoidBottomInset: false,
// backgroundColor: Colors.white,
// appBar: AppBar(
// elevation: 0,
// brightness: Brightness.light,
// backgroundColor: Colors.white,
// leading:
// IconButton( onPressed: (){
// Navigator.pop(context);
// },icon:Icon(Icons.arrow_back_ios,size: 20,color: Colors.black,)),
// ),
// body: Container(
// height: MediaQuery.of(context).size.height,
// width: double.infinity,
// child: Column(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// children: [
// Column(
// children: [
// Column(
// children: [
// Text ("ログイン", style: TextStyle(
// fontSize: 30,
// fontWeight: FontWeight.bold,
// ),),
// SizedBox(height: 20,),
// Text("お帰りなさい !資格情報を使用してログインします",style: TextStyle(
// fontSize: 15,
// color: Colors.grey[700],
// ),),
// SizedBox(height: 30,)
// ],
// ),
// Padding(
// padding: EdgeInsets.symmetric(
// horizontal: 40
// ),
// child: Column(
// children: [
// makeInput(label: "Eメール", controller: emailController),
// makeInput(label: "パスワード", controller: passwordController, obsureText: true),
// ],
// ),
// ),
// Padding(
// padding: EdgeInsets.symmetric(horizontal: 40),
// child: Container(
// padding: EdgeInsets.only(top: 3,left: 3),
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(40),
// border: Border(
// bottom: BorderSide(color: Colors.black),
// top: BorderSide(color: Colors.black),
// right: BorderSide(color: Colors.black),
// left: BorderSide(color: Colors.black)
// )
// ),
// child: Obx((() =>
// indexController.is_loading == true ? MaterialButton(
// minWidth: double.infinity,
// height:60,
// onPressed: (){
},
color: Colors.grey[400],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40)
),
child: CircularProgressIndicator(),
) :
MaterialButton(
minWidth: double.infinity,
height:60,
onPressed: (){
if(emailController.text.isEmpty || passwordController.text.isEmpty){
Get.snackbar(
"No values",
"Email and password required",
icon: Icon(Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: Duration(milliseconds: 800),
backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
return;
}
indexController.is_loading.value = true;
indexController.login(emailController.text, passwordController.text, context);
},
color: Colors.indigoAccent[400],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40)
),
child: Text("ログイン",style: TextStyle(
fontWeight: FontWeight.w600,fontSize: 16,color: Colors.white70
),
),
)
),
),
)
),
SizedBox(height: 20,),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flexible(
child: Text("アカウントをお持ちではありませんか?", style: TextStyle(
overflow: TextOverflow.ellipsis,
),),
),
TextButton(
onPressed: (){
Get.toNamed(AppPages.REGISTER);
},
child: Text("サインアップ",style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 18
),),
),
],
)
],
// },
// color: Colors.grey[400],
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(40)
// ),
// child: CircularProgressIndicator(),
// ) :
// MaterialButton(
// minWidth: double.infinity,
// height:60,
// onPressed: (){
// if(emailController.text.isEmpty || passwordController.text.isEmpty){
// Get.snackbar(
// "No values",
// "Email and password required",
// icon: Icon(Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue),
// snackPosition: SnackPosition.TOP,
// duration: Duration(milliseconds: 800),
// backgroundColor: Colors.yellow,
// //icon:Image(image:AssetImage("assets/images/dora.png"))
// );
// return;
// }
// indexController.is_loading.value = true;
// indexController.login(emailController.text, passwordController.text, context);
// },
// color: Colors.indigoAccent[400],
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(40)
// ),
// child: Text("ログイン",style: TextStyle(
// fontWeight: FontWeight.w600,fontSize: 16,color: Colors.white70
// ),
// ),
// )
// ),
// ),
// )
// ),
// SizedBox(height: 20,),
// Row(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// Flexible(
// child: Text("アカウントをお持ちではありませんか?", style: TextStyle(
// overflow: TextOverflow.ellipsis,
// ),),
// ),
// TextButton(
// onPressed: (){
// Get.toNamed(AppPages.REGISTER);
// },
// child: Text("サインアップ",style: TextStyle(
// fontWeight: FontWeight.w600,
// fontSize: 18
// ),),
// ),
// ],
// )
// ],
),
],
),
),
);
}
}
// ),
// ],
// ),
// ),
// );
// }
// }
Widget makeInput({label, required TextEditingController controller, obsureText = false}){
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(label,style:TextStyle(
fontSize: 15,
fontWeight: FontWeight.w400,
color: Colors.black87
),),
SizedBox(height: 5,),
TextField(
controller: controller,
obscureText: obsureText,
decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(vertical: 0,horizontal: 10),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: (Colors.grey[400])!,
),
),
border: OutlineInputBorder(
borderSide: BorderSide(color: (Colors.grey[400])!
),
),
),
),
SizedBox(height: 30.0,)
],
);
}
// Widget makeInput({label, required TextEditingController controller, obsureText = false}){
// return Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text(label,style:TextStyle(
// fontSize: 15,
// fontWeight: FontWeight.w400,
// color: Colors.black87
// ),),
// SizedBox(height: 5,),
// TextField(
// controller: controller,
// obscureText: obsureText,
// decoration: InputDecoration(
// contentPadding: EdgeInsets.symmetric(vertical: 0,horizontal: 10),
// enabledBorder: OutlineInputBorder(
// borderSide: BorderSide(
// color: (Colors.grey[400])!,
// ),
// ),
// border: OutlineInputBorder(
// borderSide: BorderSide(color: (Colors.grey[400])!
// ),
// ),
// ),
// ),
// SizedBox(height: 30.0,)
// ],
// );
// }

View File

@ -1,31 +0,0 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:rogapp/pages/index/index_controller.dart';
class MainPerfPage extends StatelessWidget {
MainPerfPage({Key? key}) : super(key: key);
IndexController indexController = Get.find<IndexController>();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Select Main Perfecture"),
),
body: ListView.builder(
itemCount: indexController.perfectures.length,
itemBuilder: (context, index){
return ListTile(
onTap: (){
indexController.dropdownValue = indexController.perfectures[index][0]["id"].toString();
indexController.populateForPerf(indexController.dropdownValue, indexController.mapController!);
Get.back();
},
title: Text(indexController.perfectures[index][0]["adm1_ja"].toString()),
);
},
),
);
}
}

View File

@ -1,79 +1,79 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:rogapp/routes/app_pages.dart';
// import 'package:flutter/material.dart';
// import 'package:get/get.dart';
// import 'package:permission_handler/permission_handler.dart';
// import 'package:rogapp/routes/app_pages.dart';
class PermissionHandlerScreen extends StatefulWidget {
PermissionHandlerScreen({Key? key}) : super(key: key);
// class PermissionHandlerScreen extends StatefulWidget {
// PermissionHandlerScreen({Key? key}) : super(key: key);
@override
State<PermissionHandlerScreen> createState() => _PermissionHandlerScreenState();
}
// @override
// State<PermissionHandlerScreen> createState() => _PermissionHandlerScreenState();
// }
class _PermissionHandlerScreenState extends State<PermissionHandlerScreen> {
// class _PermissionHandlerScreenState extends State<PermissionHandlerScreen> {
@override
void initState() {
// TODO: implement initState
super.initState();
permissionServiceCall();
}
// @override
// void initState() {
// // TODO: implement initState
// super.initState();
// permissionServiceCall();
// }
permissionServiceCall() async {
await permissionServices().then(
(value) {
if (value != null) {
if (value[Permission.location]!.isGranted ) {
/* ========= New Screen Added ============= */
// permissionServiceCall() async {
// await permissionServices().then(
// (value) {
// if (value != null) {
// if (value[Permission.location]!.isGranted ) {
// /* ========= New Screen Added ============= */
Get.toNamed(AppPages.TRAVEL);
// Get.toNamed(AppPages.TRAVEL);
// Navigator.pushReplacement(
// context,
// MaterialPageRoute(builder: (context) => SplashScreen()),
// );
}
}
},
);
}
// // Navigator.pushReplacement(
// // context,
// // MaterialPageRoute(builder: (context) => SplashScreen()),
// // );
// }
// }
// },
// );
// }
/*Permission services*/
Future<Map<Permission, PermissionStatus>> permissionServices() async {
// You can request multiple permissions at once.
Map<Permission, PermissionStatus> statuses = await [
Permission.location,
// /*Permission services*/
// Future<Map<Permission, PermissionStatus>> permissionServices() async {
// // You can request multiple permissions at once.
// Map<Permission, PermissionStatus> statuses = await [
// Permission.location,
//add more permission to request here.
].request();
// //add more permission to request here.
// ].request();
if (statuses[Permission.location]!.isPermanentlyDenied) {
await openAppSettings().then(
(value) async {
if (value) {
if (await Permission.location.status.isPermanentlyDenied == true &&
await Permission.location.status.isGranted == false) {
// openAppSettings();
permissionServiceCall(); /* opens app settings until permission is granted */
}
}
},
);
} else {
if (statuses[Permission.location]!.isDenied) {
permissionServiceCall();
}
}
// if (statuses[Permission.location]!.isPermanentlyDenied) {
// await openAppSettings().then(
// (value) async {
// if (value) {
// if (await Permission.location.status.isPermanentlyDenied == true &&
// await Permission.location.status.isGranted == false) {
// // openAppSettings();
// permissionServiceCall(); /* opens app settings until permission is granted */
// }
// }
// },
// );
// } else {
// if (statuses[Permission.location]!.isDenied) {
// permissionServiceCall();
// }
// }
/*{Permission.camera: PermissionStatus.granted, Permission.storage: PermissionStatus.granted}*/
return statuses;
}
// /*{Permission.camera: PermissionStatus.granted, Permission.storage: PermissionStatus.granted}*/
// return statuses;
// }
@override
Widget build(BuildContext context) {
return Container();
}
}
// @override
// Widget build(BuildContext context) {
// return Container();
// }
// }

View File

@ -1,179 +1,179 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/routes/app_pages.dart';
// import 'package:flutter/material.dart';
// import 'package:get/get.dart';
// import 'package:rogapp/pages/index/index_controller.dart';
// import 'package:rogapp/routes/app_pages.dart';
class RegisterPage extends StatelessWidget {
// class RegisterPage extends StatelessWidget {
final IndexController indexController = Get.find<IndexController>();
// final IndexController indexController = Get.find<IndexController>();
TextEditingController emailController = TextEditingController();
TextEditingController passwordController = TextEditingController();
TextEditingController confirmPasswordController = TextEditingController();
// TextEditingController emailController = TextEditingController();
// TextEditingController passwordController = TextEditingController();
// TextEditingController confirmPasswordController = TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.white,
appBar: AppBar(
elevation: 0,
brightness: Brightness.light,
backgroundColor: Colors.white,
leading:
IconButton( onPressed: (){
Navigator.pop(context);
},icon:Icon(Icons.arrow_back_ios,size: 20,color: Colors.black,)),
),
body: SafeArea(
child: SingleChildScrollView(
child: Container(
height: MediaQuery.of(context).size.height,
width: double.infinity,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text ("サインアップ", style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.bold,
),),
SizedBox(height: 20,),
Text("アカウントを作成し、無料です",style: TextStyle(
fontSize: 15,
color: Colors.grey[700],
),),
SizedBox(height: 30,)
],
),
Padding(
padding: EdgeInsets.symmetric(
horizontal: 40
),
child: Column(
children: [
makeInput(label: "Eメール", controller: emailController),
makeInput(label: "パスワード", controller: passwordController,obsureText: true),
makeInput(label: "パスワードを認証する", controller: confirmPasswordController,obsureText: true)
],
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 40),
child: Container(
padding: EdgeInsets.only(top: 3,left: 3),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40),
border: Border(
bottom: BorderSide(color: Colors.black),
top: BorderSide(color: Colors.black),
right: BorderSide(color: Colors.black),
left: BorderSide(color: Colors.black)
)
),
child: MaterialButton(
minWidth: double.infinity,
height:60,
onPressed: (){
if(passwordController.text != confirmPasswordController.text){
Get.snackbar(
"No match",
"Passwords does not match",
icon: Icon(Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: Duration(milliseconds: 800),
backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
}
if(emailController.text.isEmpty || passwordController.text.isEmpty){
Get.snackbar(
"No values",
"Email and password required",
icon: Icon(Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: Duration(milliseconds: 800),
backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
return;
}
indexController.is_loading.value = true;
indexController.register(emailController.text, passwordController.text, context);
},
color: Colors.redAccent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40)
),
child: Text("サインアップ",style: TextStyle(
fontWeight: FontWeight.w600,fontSize: 16,
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// resizeToAvoidBottomInset: false,
// backgroundColor: Colors.white,
// appBar: AppBar(
// elevation: 0,
// brightness: Brightness.light,
// backgroundColor: Colors.white,
// leading:
// IconButton( onPressed: (){
// Navigator.pop(context);
// },icon:Icon(Icons.arrow_back_ios,size: 20,color: Colors.black,)),
// ),
// body: SafeArea(
// child: SingleChildScrollView(
// child: Container(
// height: MediaQuery.of(context).size.height,
// width: double.infinity,
// child: Column(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Column(
// children: [
// Column(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// children: [
// Text ("サインアップ", style: TextStyle(
// fontSize: 30,
// fontWeight: FontWeight.bold,
// ),),
// SizedBox(height: 20,),
// Text("アカウントを作成し、無料です",style: TextStyle(
// fontSize: 15,
// color: Colors.grey[700],
// ),),
// SizedBox(height: 30,)
// ],
// ),
// Padding(
// padding: EdgeInsets.symmetric(
// horizontal: 40
// ),
// child: Column(
// children: [
// makeInput(label: "Eメール", controller: emailController),
// makeInput(label: "パスワード", controller: passwordController,obsureText: true),
// makeInput(label: "パスワードを認証する", controller: confirmPasswordController,obsureText: true)
// ],
// ),
// ),
// Padding(
// padding: EdgeInsets.symmetric(horizontal: 40),
// child: Container(
// padding: EdgeInsets.only(top: 3,left: 3),
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(40),
// border: Border(
// bottom: BorderSide(color: Colors.black),
// top: BorderSide(color: Colors.black),
// right: BorderSide(color: Colors.black),
// left: BorderSide(color: Colors.black)
// )
// ),
// child: MaterialButton(
// minWidth: double.infinity,
// height:60,
// onPressed: (){
// if(passwordController.text != confirmPasswordController.text){
// Get.snackbar(
// "No match",
// "Passwords does not match",
// icon: Icon(Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue),
// snackPosition: SnackPosition.TOP,
// duration: Duration(milliseconds: 800),
// backgroundColor: Colors.yellow,
// //icon:Image(image:AssetImage("assets/images/dora.png"))
// );
// }
// if(emailController.text.isEmpty || passwordController.text.isEmpty){
// Get.snackbar(
// "No values",
// "Email and password required",
// icon: Icon(Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue),
// snackPosition: SnackPosition.TOP,
// duration: Duration(milliseconds: 800),
// backgroundColor: Colors.yellow,
// //icon:Image(image:AssetImage("assets/images/dora.png"))
// );
// return;
// }
// indexController.is_loading.value = true;
// indexController.register(emailController.text, passwordController.text, context);
// },
// color: Colors.redAccent,
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(40)
// ),
// child: Text("サインアップ",style: TextStyle(
// fontWeight: FontWeight.w600,fontSize: 16,
),),
),
),
),
SizedBox(height: 20,),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flexible(child: Text("すでにアカウントをお持ちですか?")),
TextButton(
onPressed: (){
Get.toNamed(AppPages.LOGIN);
},
child: Text("ログイン",style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 18
),),
),
],
)
],
// ),),
// ),
// ),
// ),
// SizedBox(height: 20,),
// Row(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// Flexible(child: Text("すでにアカウントをお持ちですか?")),
// TextButton(
// onPressed: (){
// Get.toNamed(AppPages.LOGIN);
// },
// child: Text("ログイン",style: TextStyle(
// fontWeight: FontWeight.w600,
// fontSize: 18
// ),),
// ),
// ],
// )
// ],
),
],
),
),
),
),
);
}
}
// ),
// ],
// ),
// ),
// ),
// ),
// );
// }
// }
Widget makeInput({label, required TextEditingController controller, obsureText = false}){
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(label,style:TextStyle(
fontSize: 15,
fontWeight: FontWeight.w400,
color: Colors.black87
),),
SizedBox(height: 5,),
TextField(
controller: controller,
obscureText: obsureText,
decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(vertical: 0,horizontal: 10),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: (Colors.grey[400])!,
),
),
border: OutlineInputBorder(
borderSide: BorderSide(color: (Colors.grey[400])!
),
),
),
),
SizedBox(height: 30,)
// Widget makeInput({label, required TextEditingController controller, obsureText = false}){
// return Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text(label,style:TextStyle(
// fontSize: 15,
// fontWeight: FontWeight.w400,
// color: Colors.black87
// ),),
// SizedBox(height: 5,),
// TextField(
// controller: controller,
// obscureText: obsureText,
// decoration: InputDecoration(
// contentPadding: EdgeInsets.symmetric(vertical: 0,horizontal: 10),
// enabledBorder: OutlineInputBorder(
// borderSide: BorderSide(
// color: (Colors.grey[400])!,
// ),
// ),
// border: OutlineInputBorder(
// borderSide: BorderSide(color: (Colors.grey[400])!
// ),
// ),
// ),
// ),
// SizedBox(height: 30,)
],
);
}
// ],
// );
// }

View File

@ -0,0 +1,11 @@
import 'package:get/get.dart';
import 'package:rogapp/pages/rog/rog_controller.dart';
import 'package:rogapp/utils/app_controller.dart';
class RogBinding extends Bindings {
@override
void dependencies() {
Get.put<AppController>(AppController());
Get.put<RogController>(RogController());
}
}

View File

@ -0,0 +1,32 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:get/get.dart';
import 'package:rogapp/model/location.dart';
import 'package:sliding_up_panel/sliding_up_panel.dart';
class RogController extends GetxController {
// RX vars
List<Location> locations = <Location>[].obs;
var currentLocation = {}.obs;
var currentUser = {}.obs;
var isLoading = false.obs;
// Controllers in home page
PanelController panelController = PanelController();
MapController mapController = MapController();
Location? getIncidentForLatLong(double lat, double long){
for(Location l in locations){
print("i - ${l.latitude}, ${l.longitude} -- ${lat}, ${long}");
if(l.latitude == lat && l.longitude == long){
return l;
}
}
return null;
}
}

View File

@ -0,0 +1,46 @@
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:get/get.dart';
import 'package:latlong2/latlong.dart';
import 'package:rogapp/model/location.dart';
import 'package:rogapp/pages/rog/rog_controller.dart';
import 'package:rogapp/utils/app_controller.dart';
import 'package:rogapp/widgets/collapsed_widget.dart';
import 'package:sliding_up_panel/sliding_up_panel.dart';
class RogPage extends StatelessWidget {
RogPage({Key? key}) : super(key: key);
final AppController appController = Get.find<AppController>();
final RogController rogController = Get.find<RogController>();
void addlocation(){
print("called add location");
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("app_title".tr, style: TextStyle(fontSize: 28),),
),
body: ,
);
}
_scrollingList(ScrollController sc) {
return ListView.builder(
controller: sc,
itemCount: 50,
itemBuilder: (BuildContext context, int i){
return Container(
padding: const EdgeInsets.all(12.0),
child: Text("$i"),
);
},
);
}
}

View File

@ -1,9 +1,9 @@
import 'package:get/get.dart';
import 'package:rogapp/pages/search/search_controller.dart';
// import 'package:get/get.dart';
// import 'package:rogapp/pages/search/search_controller.dart';
class SearchBinding extends Bindings {
@override
void dependencies() {
Get.put<SearchController>(SearchController());
}
}
// class SearchBinding extends Bindings {
// @override
// void dependencies() {
// Get.put<SearchController>(SearchController());
// }
// }

View File

@ -1,26 +1,26 @@
import 'package:flutter/material.dart';
import 'package:geojson/geojson.dart';
import 'package:get/get.dart';
import 'package:get/get_state_manager/get_state_manager.dart';
import 'package:rogapp/model/destination.dart';
import 'package:rogapp/pages/index/index_controller.dart';
// import 'package:flutter/material.dart';
// import 'package:geojson/geojson.dart';
// import 'package:get/get.dart';
// import 'package:get/get_state_manager/get_state_manager.dart';
// import 'package:rogapp/model/destination.dart';
// import 'package:rogapp/pages/index/index_controller.dart';
class SearchController extends GetxController {
// class SearchController extends GetxController {
List<GeoJsonFeature> searchResults = <GeoJsonFeature>[].obs;
// List<GeoJsonFeature> searchResults = <GeoJsonFeature>[].obs;
@override
void onInit() {
IndexController indexController = Get.find<IndexController>();
if(indexController.locations.isNotEmpty){
for(int i=0; i<= indexController.locations[0].collection.length - 1; i++){
GeoJsonFeature p = indexController.locations[0].collection[i];
searchResults.add(p);
}
}
super.onInit();
}
// @override
// void onInit() {
// IndexController indexController = Get.find<IndexController>();
// if(indexController.locations.isNotEmpty){
// for(int i=0; i<= indexController.locations[0].collection.length - 1; i++){
// GeoJsonFeature p = indexController.locations[0].collection[i];
// searchResults.add(p);
// }
// }
// super.onInit();
// }
}
// }

View File

@ -1,96 +1,96 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_typeahead/flutter_typeahead.dart';
import 'package:get/get.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/pages/search/search_controller.dart';
import 'package:rogapp/widgets/bottom_sheet_new.dart';
// import 'package:flutter/cupertino.dart';
// import 'package:flutter/material.dart';
// import 'package:flutter_typeahead/flutter_typeahead.dart';
// import 'package:get/get.dart';
// import 'package:rogapp/pages/index/index_controller.dart';
// import 'package:rogapp/pages/search/search_controller.dart';
// import 'package:rogapp/widgets/bottom_sheet_new.dart';
class SearchPage extends StatelessWidget {
SearchPage({Key? key}) : super(key: key);
// class SearchPage extends StatelessWidget {
// SearchPage({Key? key}) : super(key: key);
SearchController searchController = Get.find<SearchController>();
IndexController indexController = Get.find<IndexController>();
// SearchController searchController = Get.find<SearchController>();
// IndexController indexController = Get.find<IndexController>();
Image getImage(int index){
if(searchController.searchResults[index].properties!["photos"] == null || searchController.searchResults[index].properties!["photos"] == ""){
return Image(image: AssetImage('assets/images/empty_image.png'));
}
else{
return Image(
image: NetworkImage(searchController.searchResults[index].properties!["photos"]),
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
return Image.asset("assets/images/empty_image.png");
},
);
}
}
// Image getImage(int index){
// if(searchController.searchResults[index].properties!["photos"] == null || searchController.searchResults[index].properties!["photos"] == ""){
// return Image(image: AssetImage('assets/images/empty_image.png'));
// }
// else{
// return Image(
// image: NetworkImage(searchController.searchResults[index].properties!["photos"]),
// errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
// return Image.asset("assets/images/empty_image.png");
// },
// );
// }
// }
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
elevation: 0,
backgroundColor: Colors.white,
leading: IconButton(
onPressed:(){
Navigator.pop(context);
},
icon: const Icon(Icons.arrow_back_ios_new, color: Colors.black,)),
title: TypeAheadField(
textFieldConfiguration: TextFieldConfiguration(
autofocus: true,
),
suggestionsCallback: (pattern) async{
return searchController.searchResults.where((GeoJsonFeature element) => element.properties!["location_name"].toString().contains(pattern));
//return await
},
itemBuilder: (context, GeoJsonFeature suggestion){
return ListTile(
title: Text(suggestion.properties!["location_name"]),
subtitle: suggestion.properties!["category"] != null ? Text(suggestion.properties!["category"]) : Text(""),
//leading: getImage(index),
);
},
onSuggestionSelected: (GeoJsonFeature suggestion){
indexController.currentFeature.clear();
indexController.currentFeature.add(suggestion);
Get.back();
showModalBottomSheet(
isScrollControlled: true,
context: context,
//builder: (context) => BottomSheetWidget(),
builder:((context) => BottomSheetNew())
);
},
),
//title: const CupertinoSearchTextField(),
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// appBar: AppBar(
// elevation: 0,
// backgroundColor: Colors.white,
// leading: IconButton(
// onPressed:(){
// Navigator.pop(context);
// },
// icon: const Icon(Icons.arrow_back_ios_new, color: Colors.black,)),
// title: TypeAheadField(
// textFieldConfiguration: TextFieldConfiguration(
// autofocus: true,
// ),
// suggestionsCallback: (pattern) async{
// return searchController.searchResults.where((GeoJsonFeature element) => element.properties!["location_name"].toString().contains(pattern));
// //return await
// },
// itemBuilder: (context, GeoJsonFeature suggestion){
// return ListTile(
// title: Text(suggestion.properties!["location_name"]),
// subtitle: suggestion.properties!["category"] != null ? Text(suggestion.properties!["category"]) : Text(""),
// //leading: getImage(index),
// );
// },
// onSuggestionSelected: (GeoJsonFeature suggestion){
// indexController.currentFeature.clear();
// indexController.currentFeature.add(suggestion);
// Get.back();
// showModalBottomSheet(
// isScrollControlled: true,
// context: context,
// //builder: (context) => BottomSheetWidget(),
// builder:((context) => BottomSheetNew())
// );
// },
// ),
// //title: const CupertinoSearchTextField(),
),
//body:
// Obx(() =>
// ListView.builder(
// itemCount: searchController.searchResults.length,
// itemBuilder: (context, index){
// return ListTile(
// title: searchController.searchResults[index].properties!["location_name"] != null ? Text(searchController.searchResults[index].properties!["location_name"]) : Text(""),
// subtitle: searchController.searchResults[index].properties!["category"] != null ? Text(searchController.searchResults[index].properties!["category"]) : Text(""),
// leading: getImage(index),
// onTap: (){
// indexController.currentFeature.clear();
// indexController.currentFeature.add(searchController.searchResults[index]);
// Get.back();
// showModalBottomSheet(
// isScrollControlled: true,
// context: context,
// //builder: (context) => BottomSheetWidget(),
// builder:((context) => BottomSheetNew())
// );
// },
// );
// },
// ),
// )
);
}
}
// ),
// //body:
// // Obx(() =>
// // ListView.builder(
// // itemCount: searchController.searchResults.length,
// // itemBuilder: (context, index){
// // return ListTile(
// // title: searchController.searchResults[index].properties!["location_name"] != null ? Text(searchController.searchResults[index].properties!["location_name"]) : Text(""),
// // subtitle: searchController.searchResults[index].properties!["category"] != null ? Text(searchController.searchResults[index].properties!["category"]) : Text(""),
// // leading: getImage(index),
// // onTap: (){
// // indexController.currentFeature.clear();
// // indexController.currentFeature.add(searchController.searchResults[index]);
// // Get.back();
// // showModalBottomSheet(
// // isScrollControlled: true,
// // context: context,
// // //builder: (context) => BottomSheetWidget(),
// // builder:((context) => BottomSheetNew())
// // );
// // },
// // );
// // },
// // ),
// // )
// );
// }
// }

View File

@ -0,0 +1,9 @@
import 'package:get/get.dart';
import 'package:rogapp/pages/select/select_controller.dart';
class SelectBinding extends Bindings {
@override
void dependencies() {
Get.put<SelectController>(SelectController());
}
}

View File

@ -0,0 +1,5 @@
import 'package:get/get_state_manager/get_state_manager.dart';
class SelectController extends GetxController{
}

View File

@ -0,0 +1,10 @@
import 'package:flutter/material.dart';
class SelectPage extends StatelessWidget {
const SelectPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container();
}
}

View File

@ -0,0 +1,76 @@
import 'package:flutter/material.dart';
import 'package:flutter/src/foundation/key.dart';
import 'package:flutter/src/widgets/container.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:sliding_up_panel/sliding_up_panel.dart';
class SelectSliderPage extends StatelessWidget {
const SelectSliderPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return SlidingUpPanel(
//header: Text("header"),
minHeight: 55,
footer: Text("footer"),
//isDraggable: true,
backdropTapClosesPanel: true,
parallaxEnabled: true,
parallaxOffset: 0.6,
borderRadius: BorderRadius.only(topLeft: Radius.circular(10), topRight: Radius.circular(10)),
backdropEnabled: true,
backdropOpacity: 0.2,
controller: rogController.panelController,
collapsed: CollapsedWidget(addIncident : addlocation),
panelBuilder:(sc) => _scrollingList(sc),
body: Center(
child: Obx((() =>
FlutterMap(
mapController: rogController.mapController,
options: MapOptions(
center: LatLng(8, 80),
zoom: 8,
),
nonRotatedChildren: [
//Center(
// child: Image(
// image: AssetImage('assets/icons/crosshair.512x512.png'),
// width: 35,
// height: 35,
// ),
// ),
],
children: [
TileLayer(
urlTemplate: "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
userAgentPackageName: 'dev.fleaflet.flutter_map.example',
),
MarkerLayer(
markers: rogController.locations.map((l) {
return Marker(
anchorPos: AnchorPos.align(AnchorAlign.center),
height: 70.0,
width: 70.0,
point: LatLng(l.latitude!, l.longitude!),
builder: (ctx){
return IconButton(
onPressed: () {
Location? loc = rogController.getIncidentForLatLong(l.latitude!, l.longitude!);
if(loc != null){
rogController.currentLocation.value = loc.toMap();
rogController.panelController.open();
}
},
icon: Icon(Icons.pin_drop, size: 38, color: Colors.red,)
);
},
);
}).toList(),
)
],
)
)),
),
);
}
}

View File

@ -1,31 +0,0 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:rogapp/pages/index/index_controller.dart';
class SubPerfPage extends StatelessWidget {
SubPerfPage({Key? key}) : super(key: key);
IndexController indexController = Get.find<IndexController>();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Select Sub Perfecture"),
),
body: ListView.builder(
itemCount: indexController.subPerfs.length,
itemBuilder: (context, index){
return ListTile(
onTap: (){
indexController.dropdownValue = indexController.perfectures[index][0]["id"].toString();
//indexController.populateForPerf(indexController.dropdownValue, indexController.mapController!);
Get.back();
},
title: Text(indexController.perfectures[index][0]["adm1_ja"].toString()),
);
},
),
);
}
}