タイマーを設定で変更できるようにした。現在地ボタンの長押しおよびドロワーへの設定ボタンの追加
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart'; // これを追加
|
||||
|
||||
class CurrentPosition extends StatefulWidget {
|
||||
const CurrentPosition({super.key});
|
||||
@ -13,20 +14,28 @@ class _CurrentPositionState extends State<CurrentPosition> {
|
||||
final DestinationController destinationController =
|
||||
Get.find<DestinationController>();
|
||||
|
||||
void _onLongPress() {
|
||||
Get.toNamed(AppPages.SETTINGS); // これを追加
|
||||
}
|
||||
|
||||
@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,
|
||||
return GestureDetector( // GestureDetectorを追加
|
||||
onLongPress: _onLongPress, // 長押しイベントを追加
|
||||
child: Container (
|
||||
// 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,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@ -6,6 +6,7 @@ import 'package:flutter_polyline_points/flutter_polyline_points.dart';
|
||||
import 'package:geojson_vi/geojson_vi.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:rogapp/pages/settings/settings_binding.dart';
|
||||
import 'package:rogapp/model/destination.dart';
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
import 'package:rogapp/pages/index/index_controller.dart';
|
||||
@ -16,8 +17,13 @@ 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';
|
||||
import 'package:rogapp/pages/settings/settings_controller.dart';
|
||||
import 'package:flutter_map_tile_caching/flutter_map_tile_caching.dart';
|
||||
|
||||
class MapResetController {
|
||||
void Function()? resetIdleTimer;
|
||||
}
|
||||
|
||||
class MapWidget extends StatefulWidget {
|
||||
const MapWidget({Key? key}) : super(key: key);
|
||||
|
||||
@ -31,6 +37,7 @@ class _MapWidgetState extends State<MapWidget> with WidgetsBindingObserver {
|
||||
final DestinationController destinationController =
|
||||
Get.find<DestinationController>();
|
||||
final LocationController locationController = Get.find<LocationController>();
|
||||
final SettingsController settingsController = Get.find<SettingsController>();
|
||||
|
||||
late MapController mapController;
|
||||
final Completer<MapController> mapControllerCompleter = Completer<MapController>();
|
||||
@ -45,6 +52,7 @@ class _MapWidgetState extends State<MapWidget> with WidgetsBindingObserver {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
SettingsBinding().dependencies(); // これを追加
|
||||
_startIdleTimer();
|
||||
mapController = MapController();
|
||||
indexController.mapController = mapController;
|
||||
@ -67,10 +75,19 @@ class _MapWidgetState extends State<MapWidget> with WidgetsBindingObserver {
|
||||
});
|
||||
});
|
||||
|
||||
late MapResetController mapResetController = MapResetController();
|
||||
mapResetController.resetIdleTimer = _resetIdleTimer;
|
||||
Get.put(mapResetController);
|
||||
|
||||
// indexController.mapController = MapController(initCompleter: mapControllerCompleter);
|
||||
|
||||
}
|
||||
|
||||
void _resetIdleTimer() {
|
||||
_timer?.cancel();
|
||||
_startIdleTimer();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
WidgetsBinding.instance.removeObserver(this); // added
|
||||
@ -90,7 +107,10 @@ class _MapWidgetState extends State<MapWidget> with WidgetsBindingObserver {
|
||||
|
||||
// _centerMapOnUser を10秒間でコール
|
||||
void _startIdleTimer() {
|
||||
_timer = Timer(const Duration(milliseconds: (1000 * 10)), _centerMapOnUser);
|
||||
final settingsController = Get.find<SettingsController>();
|
||||
if (!settingsController.autoReturnDisabled.value) {
|
||||
_timer = Timer(settingsController.timerDuration.value, _centerMapOnUser);
|
||||
}
|
||||
}
|
||||
|
||||
// タイマーをリセットして_startIdleTimer をコール
|
||||
@ -174,6 +194,7 @@ class _MapWidgetState extends State<MapWidget> with WidgetsBindingObserver {
|
||||
|
||||
// Widget getMarkerShape(GeoJSONFeature i, BuildContext context) {
|
||||
Widget getMarkerShape(GeoJSONFeature i) {
|
||||
/*
|
||||
String labelText = TextUtils.getDisplayTextFeture(i);
|
||||
if( i.properties!['cp'] == 0 ){
|
||||
labelText="Start/Goal";
|
||||
@ -184,10 +205,11 @@ class _MapWidgetState extends State<MapWidget> with WidgetsBindingObserver {
|
||||
//}else{
|
||||
// labelText=i.properties!['cp'];
|
||||
}
|
||||
*/
|
||||
//if( i.properties!['cp'] <= 0 ) {
|
||||
// debugPrint("Text=${labelText}");
|
||||
//}
|
||||
final double maxWidth = labelText.length * 16.0; //16.0;
|
||||
//final double maxWidth = labelText.length * 16.0; //16.0;
|
||||
GeoJSONMultiPoint p = i.geometry as GeoJSONMultiPoint;
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
@ -238,21 +260,20 @@ class _MapWidgetState extends State<MapWidget> with WidgetsBindingObserver {
|
||||
Icons.circle,
|
||||
size: 6.0,
|
||||
),
|
||||
i.properties!['cp'] <= 0
|
||||
? Transform.translate
|
||||
i.properties!['cp'] <= 0 ? Transform.translate
|
||||
(
|
||||
offset: const Offset(-3, 0),
|
||||
offset: const Offset(-3, 0), //-3
|
||||
child: Transform.rotate(
|
||||
alignment: Alignment.centerLeft,
|
||||
origin: Offset.fromDirection(1, 26),
|
||||
angle: 270 * pi / 180,
|
||||
child: const Icon(
|
||||
Icons.play_arrow_outlined,
|
||||
color: Colors.red,
|
||||
size: 70,
|
||||
),
|
||||
),
|
||||
alignment: Alignment.centerLeft,
|
||||
origin: Offset.fromDirection(1, 26),
|
||||
angle: 270 * pi / 180,
|
||||
child: const Icon(
|
||||
Icons.play_arrow_outlined,
|
||||
color: Colors.red,
|
||||
size: 70,
|
||||
)),
|
||||
)
|
||||
|
||||
: Container(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
@ -262,42 +283,42 @@ class _MapWidgetState extends State<MapWidget> with WidgetsBindingObserver {
|
||||
Transform.translate(
|
||||
offset: const Offset(30, 0), // 30,0
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
alignment: Alignment.center,
|
||||
child: Container (
|
||||
//width: 200, // 幅を指定
|
||||
//height: 60, // 40
|
||||
color: Colors.transparent,
|
||||
//child: Text(' ').
|
||||
//constraints: const BoxConstraints(maxWidth: 1000.0), // 最大幅を設定
|
||||
constraints: BoxConstraints(maxWidth: maxWidth), // 最大幅を設定
|
||||
//constraints: BoxConstraints(maxWidth: maxWidth), // 最大幅を設定
|
||||
//color: Colors.purple.withOpacity(0.2),
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
Text( // アウトライン
|
||||
labelText,
|
||||
TextUtils.getDisplayTextFeture(i),
|
||||
style: TextStyle(
|
||||
fontSize: 14, // 16
|
||||
fontSize: 16, // 16
|
||||
fontWeight: FontWeight.w700,
|
||||
height: 1.2,
|
||||
//height: 1.2,
|
||||
foreground: Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 2
|
||||
..color = Colors.white,
|
||||
),
|
||||
maxLines: 1, // テキストを1行に制限
|
||||
softWrap: false, // テキストの折り返しを無効化
|
||||
//maxLines: 1, // テキストを1行に制限
|
||||
//softWrap: false, // テキストの折り返しを無効化
|
||||
),
|
||||
Text( // テキスト
|
||||
labelText,
|
||||
TextUtils.getDisplayTextFeture(i),
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
//fontWeight: FontWeight.bold,
|
||||
height: 1.2,
|
||||
//height: 1.2,
|
||||
color: Colors.black,
|
||||
),
|
||||
maxLines: 1, // テキストを1行に制限
|
||||
softWrap: false, // テキストの折り返しを無効化
|
||||
//maxLines: 1, // テキストを1行に制限
|
||||
//softWrap: false, // テキストの折り返しを無効化
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -321,6 +342,7 @@ class _MapWidgetState extends State<MapWidget> with WidgetsBindingObserver {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final settingsController = Get.find<SettingsController>(); // これを追加
|
||||
//final PopupController popupController = PopupController();
|
||||
return Stack(
|
||||
children: [
|
||||
|
||||
Reference in New Issue
Block a user