update
This commit is contained in:
@ -1,6 +1,9 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.rogapp">
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
|
||||
<application
|
||||
android:label="rogapp"
|
||||
android:name="${applicationName}"
|
||||
|
||||
@ -45,5 +45,13 @@
|
||||
</array>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
<key>NSLocationWhenInUseUsageDescription</key>
|
||||
<string>This app needs access to location when open.</string>
|
||||
<key>NSLocationAlwaysUsageDescription</key>
|
||||
<string>This app needs access to location when in the background.</string>
|
||||
<key>NSPhotoLibraryUsageDescription</key>
|
||||
<string>Photo Library Access Warning</string>
|
||||
<key>NSCameraUsageDescription</key>
|
||||
<string>Camera access to take photo</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@ -1,14 +1,18 @@
|
||||
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:get/get.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 'dart:async';
|
||||
|
||||
class DestinationController extends GetxController {
|
||||
|
||||
late LocationSettings locationSettings;
|
||||
|
||||
List<dynamic> destinations = <dynamic>[].obs;
|
||||
List<Map<String, dynamic>> destination_index_data = <Map<String, dynamic>>[].obs;
|
||||
@ -20,6 +24,48 @@ class DestinationController extends GetxController {
|
||||
@override
|
||||
void onInit() {
|
||||
PopulateDestinations();
|
||||
|
||||
|
||||
|
||||
|
||||
if (defaultTargetPlatform == TargetPlatform.android) {
|
||||
locationSettings = AndroidSettings(
|
||||
accuracy: LocationAccuracy.high,
|
||||
distanceFilter: 1,
|
||||
forceLocationManager: true,
|
||||
intervalDuration: const Duration(seconds: 10),
|
||||
//(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.high,
|
||||
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: 1,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
StreamSubscription<Position> positionStream = Geolocator.getPositionStream(locationSettings: locationSettings).listen(
|
||||
(Position? position) {
|
||||
print(position == null ? 'Unknown' : 'current position is ${position.latitude.toString()}, ${position.longitude.toString()}');
|
||||
});
|
||||
|
||||
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@ -55,11 +101,13 @@ class DestinationController extends GetxController {
|
||||
Get.toNamed(AppPages.LOGIN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void makeOrder(BuildContext context, int action_id, int order, String dir){
|
||||
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();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
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/index/index_controller.dart';
|
||||
@ -23,6 +25,18 @@ class _DestinationPageState extends State<DestinationPage> {
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
|
||||
final List<int> _items = List<int>.generate(50, (int index) => index);
|
||||
List<bool> isSelected = [true];
|
||||
|
||||
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]["location"]["properties"]["photos"] == null || destinationController.destinations[index]["location"]["properties"]["photos"] == ""){
|
||||
@ -68,6 +82,25 @@ class _DestinationPageState extends State<DestinationPage> {
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||
appBar:AppBar(
|
||||
title: Text("Iternery"),
|
||||
actions: [
|
||||
ToggleButtons(
|
||||
disabledColor: Colors.grey.shade200,
|
||||
selectedColor: Colors.red,
|
||||
children: <Widget>[
|
||||
Icon(Icons.explore
|
||||
)],
|
||||
onPressed: (int index) {
|
||||
setState(() {
|
||||
isSelected[index] = !isSelected[index];
|
||||
});
|
||||
},
|
||||
isSelected: isSelected,
|
||||
),
|
||||
IconButton(onPressed: (){
|
||||
showCurrentPosition();
|
||||
},
|
||||
icon: Icon(Icons.location_on_outlined))
|
||||
],
|
||||
),
|
||||
body: Obx(() =>
|
||||
indexController.desination_mode.value == 0 ?
|
||||
|
||||
@ -1,7 +1,11 @@
|
||||
|
||||
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_polyline_points/flutter_polyline_points.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
@ -20,6 +24,7 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
|
||||
final DestinationController destinationController = Get.find<DestinationController>();
|
||||
StreamSubscription? subscription;
|
||||
|
||||
List<LatLng>? getPoints(){
|
||||
//print("##### --- route point ${indexController.routePoints.length}");
|
||||
@ -59,8 +64,26 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
|
||||
return Obx((() =>
|
||||
FlutterMap(
|
||||
options: MapOptions(
|
||||
onMapCreated: (c){
|
||||
indexController.rogMapController = c;
|
||||
indexController.rogMapController!.onReady.then((_) {
|
||||
subscription = indexController.rogMapController!.mapEventStream.listen((MapEvent mapEvent) {
|
||||
if (mapEvent is MapEventMoveStart) {
|
||||
//print(DateTime.now().toString() + ' [MapEventMoveStart] START');
|
||||
// do something
|
||||
}
|
||||
if (mapEvent is MapEventMoveEnd) {
|
||||
//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: 5.0,
|
||||
zoom: 1,
|
||||
maxZoom: 20,
|
||||
interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag,
|
||||
plugins: [LocationMarkerPlugin(),]
|
||||
),
|
||||
layers: [
|
||||
TileLayerOptions(
|
||||
@ -78,6 +101,7 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
|
||||
color: Colors.purple),
|
||||
],
|
||||
),
|
||||
LocationMarkerLayerOptions(),
|
||||
],
|
||||
)
|
||||
));
|
||||
|
||||
@ -31,6 +31,7 @@ class IndexController extends GetxController {
|
||||
var is_loading = false.obs;
|
||||
|
||||
MapController? mapController;
|
||||
MapController? rogMapController;
|
||||
|
||||
var mode = 0.obs;
|
||||
|
||||
|
||||
@ -23,6 +23,7 @@ class IndexPage extends GetView<IndexController> {
|
||||
return Scaffold(
|
||||
drawer: const DrawerPage(),
|
||||
appBar: AppBar(
|
||||
automaticallyImplyLeading: false,
|
||||
title: Text("app_title".tr),
|
||||
actions: [
|
||||
ElevatedButton(onPressed: (){}, child: CatWidget(indexController: indexController,)),
|
||||
|
||||
@ -46,15 +46,31 @@ class DestinationWidget extends StatelessWidget {
|
||||
}
|
||||
|
||||
void moveUp() {
|
||||
|
||||
destinationController.destination_index_data.forEach((element) {
|
||||
//print(element["index"]);
|
||||
int action_id = destinationController.destinations[element["index"]]["id"] as int;
|
||||
destinationController.makeOrder(action_id, (element["index"] as int) - 1, "up");
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
void moveDown() {
|
||||
|
||||
destinationController.destination_index_data.forEach((element) {
|
||||
//print(element["index"]);
|
||||
int action_id = destinationController.destinations[element["index"]]["id"] as int;
|
||||
destinationController.makeOrder(action_id, (element["index"] as int) + 1, "up");
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
void interChange() {
|
||||
|
||||
int first_index = -1;
|
||||
destinationController.destination_index_data.forEach((element) {
|
||||
//print(element["index"]);
|
||||
int action_id = destinationController.destinations[element["index"]]["id"] as int;
|
||||
destinationController.makeOrder(action_id, (element["index"] as int) + 1, "up");
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user