fixed popup buttons added location stream and center button
This commit is contained in:
@ -111,6 +111,11 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
}
|
||||
|
||||
Widget getActionButton(BuildContext context, Destination destination) {
|
||||
print("getActionButton ${destinationController.rogainingCounted.value}");
|
||||
print("getActionButton ${destinationController.distanceToStart()}");
|
||||
print("getActionButton ${destination.cp}");
|
||||
print("getActionButton ${DestinationController.ready_for_goal}");
|
||||
|
||||
Destination cdest = destinationController
|
||||
.festuretoDestination(indexController.currentFeature[0]);
|
||||
var distance = const Distance();
|
||||
@ -121,8 +126,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
LatLng(cdest.lat!, cdest.lon!));
|
||||
|
||||
if (destinationController.rogainingCounted.value == true &&
|
||||
destinationController.distanceToStart() <= 500 //destination.cp == -1
|
||||
&&
|
||||
destinationController.distanceToStart() <= 500 &&
|
||||
destination.cp == -1 &&
|
||||
DestinationController.ready_for_goal == true) {
|
||||
//goal
|
||||
return ElevatedButton(
|
||||
@ -161,9 +166,12 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
),
|
||||
onPressed: () async {
|
||||
// Check conditions to show confirmation dialog
|
||||
if (destination.cp == -1 &&
|
||||
destinationController.isInRog.value == false &&
|
||||
if (destinationController.isInRog.value == false &&
|
||||
destination.cp == -1 &&
|
||||
DestinationController.ready_for_goal &&
|
||||
destinationController.rogainingCounted.value == false) {
|
||||
print("counted ${destinationController.rogainingCounted.value}");
|
||||
|
||||
// Show confirmation dialog
|
||||
Get.dialog(
|
||||
AlertDialog(
|
||||
@ -182,8 +190,7 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
onPressed: () async {
|
||||
// Clear data and start game logic here
|
||||
destinationController.isInRog.value = true;
|
||||
destinationController
|
||||
.resetRogaining(); // Assuming you have a method to clear data
|
||||
destinationController.resetRogaining();
|
||||
destinationController.addToRogaining(
|
||||
destinationController.currentLat,
|
||||
destinationController.currentLon,
|
||||
@ -199,13 +206,16 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
barrierDismissible:
|
||||
false, // User must tap a button to close the dialog
|
||||
);
|
||||
} else {
|
||||
} else if (destinationController.isInRog.value == true) {
|
||||
//print("counted ${destinationController.rogainingCounted.value}");
|
||||
// Existing logic for other conditions
|
||||
if (destination.cp == -1) {
|
||||
return;
|
||||
}
|
||||
Get.back();
|
||||
await destinationController.callforCheckin(destination);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
@ -218,7 +228,9 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
? "ゲーム中"
|
||||
: isAlreadyCheckedIn == true
|
||||
? "ゲーム中"
|
||||
: "チェックイン",
|
||||
: destinationController.isInRog.value == true
|
||||
? "チェックイン"
|
||||
: "始まっていない",
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.onSecondary),
|
||||
),
|
||||
);
|
||||
|
||||
34
lib/widgets/current_position_widget.dart
Normal file
34
lib/widgets/current_position_widget.dart
Normal file
@ -0,0 +1,34 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
|
||||
class CurrentPosition extends StatefulWidget {
|
||||
const CurrentPosition({super.key});
|
||||
|
||||
@override
|
||||
State<CurrentPosition> createState() => _CurrentPositionState();
|
||||
}
|
||||
|
||||
class _CurrentPositionState extends State<CurrentPosition> {
|
||||
final DestinationController destinationController =
|
||||
Get.find<DestinationController>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey, borderRadius: BorderRadius.circular(20.0)),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
destinationController.centerMapToCurrentLocation();
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.location_searching,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -11,9 +11,11 @@ import 'package:rogapp/model/destination.dart';
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
import 'package:rogapp/pages/index/index_controller.dart';
|
||||
import 'package:rogapp/utils/database_helper.dart';
|
||||
import 'package:rogapp/utils/location_controller.dart';
|
||||
import 'package:rogapp/utils/text_util.dart';
|
||||
import 'package:rogapp/widgets/base_layer_widget.dart';
|
||||
import 'package:rogapp/widgets/bottom_sheet_new.dart';
|
||||
import 'package:rogapp/widgets/current_position_widget.dart';
|
||||
import 'package:rogapp/widgets/game_state_view.dart';
|
||||
|
||||
class MapWidget extends StatefulWidget {
|
||||
@ -28,6 +30,7 @@ class _MapWidgetState extends State<MapWidget> {
|
||||
|
||||
final DestinationController destinationController =
|
||||
Get.find<DestinationController>();
|
||||
final LocationController locationController = Get.find<LocationController>();
|
||||
|
||||
StreamSubscription? subscription;
|
||||
Timer? _timer;
|
||||
@ -50,6 +53,7 @@ class _MapWidgetState extends State<MapWidget> {
|
||||
|
||||
DatabaseHelper db = DatabaseHelper.instance;
|
||||
db.getDestinationByLatLon(des.lat!, des.lon!).then((value) {
|
||||
destinationController.shouldShowBottomSheet = false;
|
||||
showModalBottomSheet(
|
||||
constraints:
|
||||
BoxConstraints.loose(Size(Get.width, Get.height * 0.85)),
|
||||
@ -60,6 +64,7 @@ class _MapWidgetState extends State<MapWidget> {
|
||||
destination: des, isAlreadyCheckedIn: value.isNotEmpty))
|
||||
//builder:((context) => BottomSheetWidget())
|
||||
).whenComplete(() {
|
||||
destinationController.shouldShowBottomSheet = true;
|
||||
destinationController.skipGps = false;
|
||||
});
|
||||
});
|
||||
@ -176,10 +181,10 @@ class _MapWidgetState extends State<MapWidget> {
|
||||
}
|
||||
|
||||
void _centerMapOnUser() {
|
||||
//print("showBottomSheet ${destinationController.shouldShowBottomSheet}");
|
||||
if (destinationController.shouldShowBottomSheet) {
|
||||
destinationController.centerMapToCurrentLocation();
|
||||
}
|
||||
print("showBottomSheet ${destinationController.shouldShowBottomSheet}");
|
||||
//if (destinationController.shouldShowBottomSheet) {
|
||||
destinationController.centerMapToCurrentLocation();
|
||||
//}
|
||||
}
|
||||
|
||||
@override
|
||||
@ -246,7 +251,9 @@ class _MapWidgetState extends State<MapWidget> {
|
||||
: Container(),
|
||||
),
|
||||
CurrentLocationLayer(
|
||||
followOnLocationUpdate: FollowOnLocationUpdate.never,
|
||||
positionStream: locationController
|
||||
.locationMarkerPositionStreamController.stream,
|
||||
alignDirectionOnUpdate: AlignOnUpdate.never,
|
||||
turnOnHeadingUpdate: TurnOnHeadingUpdate.never,
|
||||
style: const LocationMarkerStyle(
|
||||
marker: DefaultLocationMarker(
|
||||
@ -284,6 +291,7 @@ class _MapWidgetState extends State<MapWidget> {
|
||||
],
|
||||
)),
|
||||
const Positioned(top: 0, left: 0, child: GameStateWidget()),
|
||||
const Positioned(bottom: 10, right: 10, child: CurrentPosition())
|
||||
// const Positioned(
|
||||
// bottom: 10,
|
||||
// left: 0,
|
||||
|
||||
Reference in New Issue
Block a user