大幅変更&環境バージョンアップ

This commit is contained in:
2024-08-22 14:35:09 +09:00
parent 56e9861c7a
commit dc58dc0584
446 changed files with 29645 additions and 8315 deletions

View File

@ -0,0 +1,56 @@
import 'package:flutter/material.dart';
import 'package:gifunavi/widgets/GameState/Colors.dart';
class LocationVisitedWidget extends StatelessWidget {
final int count;
final bool minimized;
const LocationVisitedWidget(
{super.key, required this.count, this.minimized = false});
@override
Widget build(BuildContext context) {
if (minimized) {
return Container(
height: 40,
width: 40,
decoration: const BoxDecoration(
color: JapaneseColors.mizu,
shape: BoxShape.circle,
),
child: Center(
child: Text(
'$count',
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 14,
),
),
),
);
} else {
return Container(
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
decoration: BoxDecoration(
color: JapaneseColors.matcha,
borderRadius: BorderRadius.circular(10),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.check_circle_outline, color: Colors.white, size: 24),
const SizedBox(width: 8),
Text(
'$count チェックイン', // "X Check-ins" in Japanese
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 16),
),
],
),
);
}
}
}

View File

@ -0,0 +1,12 @@
import 'package:flutter/material.dart';
class JapaneseColors {
static const Color mizu = Color(0xFFA4DDED); // Mizu (light blue)
static const Color matcha = Color(0xFFC5E1A5);
static const Color ume = Color(0xFFE1A8A8); // Ume (plum)
static const Color take = Color(0xFF7B8D42); // Take (bamboo)
static const Color sora = Color(0xFFA1CAF1);
static const Color indigo = Color(0xFF264653); // Aizome
static const Color sakuraPink = Color(0xFFFAD2E1); // Sakura-iro
/// Matcha (green tea)
}

View File

@ -0,0 +1,72 @@
import 'package:flutter/material.dart';
import 'package:gifunavi/widgets/GameState/Colors.dart';
enum ConnectionStatus { none, mobile, wifi }
class ConnectionStatusIndicator extends StatelessWidget {
final ConnectionStatus connectionStatus;
final bool minimized;
const ConnectionStatusIndicator({
super.key,
required this.connectionStatus,
this.minimized = false,
});
@override
Widget build(BuildContext context) {
Color backgroundColor;
IconData iconData;
String text;
switch (connectionStatus) {
case ConnectionStatus.none:
backgroundColor = JapaneseColors.ume;
iconData = Icons.signal_cellular_off;
text = 'No Connection';
break;
case ConnectionStatus.mobile:
backgroundColor = JapaneseColors.take;
iconData = Icons.signal_cellular_alt;
text = 'Mobile Data';
break;
case ConnectionStatus.wifi:
backgroundColor = JapaneseColors.sora;
iconData = Icons.wifi;
text = 'Wi-Fi';
break;
default:
backgroundColor = Colors.grey; // Fallback color
iconData = Icons.device_unknown;
text = 'Unknown';
}
return Container(
height: minimized ? 40 : null,
width: minimized ? 40 : null,
padding:
minimized ? null : const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
decoration: BoxDecoration(
color: backgroundColor,
shape: minimized ? BoxShape.circle : BoxShape.rectangle,
borderRadius: minimized ? null : BorderRadius.circular(10),
),
child: minimized
? Center(
child: Icon(iconData, color: Colors.white, size: 24),
)
: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(iconData, color: Colors.white),
const SizedBox(width: 8),
Text(
text,
style: const TextStyle(
color: Colors.white, fontWeight: FontWeight.bold),
),
],
),
);
}
}

View File

@ -0,0 +1,51 @@
import 'package:flutter/material.dart';
import 'package:gifunavi/widgets/GameState/CheckinState.dart';
import 'package:gifunavi/widgets/GameState/game_on_off.dart';
class DashboardWidget extends StatelessWidget {
final bool gameStarted;
final int locationsVisited;
final bool isMinimized;
const DashboardWidget({
super.key,
required this.gameStarted,
required this.locationsVisited,
this.isMinimized = false,
});
@override
Widget build(BuildContext context) {
List<Widget> widgets = [
GameStatusIndicator(gameStarted: gameStarted, minimized: isMinimized),
SizedBox(
height: isMinimized ? 0 : 8, width: isMinimized ? 8 : 0), // Spacing
LocationVisitedWidget(count: locationsVisited, minimized: isMinimized),
];
return Container(
padding: EdgeInsets.all(isMinimized ? 8 : 16),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 5,
blurRadius: 7,
offset: const Offset(0, 3),
),
],
borderRadius: BorderRadius.circular(10),
),
child: isMinimized
? Row(
mainAxisSize: MainAxisSize.min,
children: widgets,
)
: Column(
mainAxisSize: MainAxisSize.min,
children: widgets,
),
);
}
}

View File

@ -0,0 +1,55 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:gifunavi/widgets/GameState/Colors.dart';
class GameStatusIndicator extends StatelessWidget {
final bool gameStarted;
final bool minimized;
const GameStatusIndicator(
{super.key, required this.gameStarted, this.minimized = true});
@override
Widget build(BuildContext context) {
// Icons to show based on the game status
IconData iconData =
gameStarted ? Icons.stop_circle : Icons.play_circle_filled;
// Text to show based on the game status
String text = gameStarted ? 'in_game'.tr : 'start_game'.tr;
// Layout for minimized view
if (minimized) {
return Container(
height: 40, // Square size
width: 40, // Square size
decoration: BoxDecoration(
color:
gameStarted ? JapaneseColors.indigo : JapaneseColors.sakuraPink,
shape: BoxShape
.circle, // Making it circle when minimized for a more distinct look
),
child: Icon(iconData, color: Colors.white),
);
}
// Layout for expanded view
return Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: gameStarted ? JapaneseColors.indigo : JapaneseColors.sakuraPink,
borderRadius: BorderRadius.circular(10),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(iconData, color: Colors.white),
const SizedBox(width: 8),
Text(
text,
style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
),
],
),
);
}
}

View File

@ -1,24 +1,45 @@
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_map_tile_caching/flutter_map_tile_caching.dart';
//import 'package:flutter_map_tile_caching/flutter_map_tile_caching.dart';
class BaseLayer extends StatelessWidget {
const BaseLayer({Key? key}) : super(key: key);
const BaseLayer({super.key});
@override
Widget build(BuildContext context) {
return TileLayer(
urlTemplate: "https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png",
tileProvider: FMTC.instance('OpenStreetMap (A)').getTileProvider(
FMTCTileProviderSettings(
behavior: CacheBehavior.values
.byName('cacheFirst'),
cachedValidDuration: const Duration(
days: 14
),
),
),
);
urlTemplate: "https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png",
/*userAgentPackageName: 'com.example.app',*/
/*
tileProvider: FMTC.instance('OpenStreetMap (A)').getTileProvider(
settings: FMTCTileProviderSettings(
behavior: CacheBehavior.values.byName('cacheFirst'),
cachedValidDuration: const Duration(days: 14),
),
),
*/
userAgentPackageName: 'com.example.app',
tileBuilder: (context, tileWidget, tile) {
return Stack(
fit: StackFit.passthrough,
children: [
tileWidget,
/*
if (tile.loadError != null)
Center(
child: Icon(Icons.error, color: Colors.red.withOpacity(0.5)),
),
*/
],
);
},
errorTileCallback: (tile, error, stackTrace) {
debugPrint('Tile load error: $error');
debugPrint('Stack trace: $stackTrace');
},
);
}
}

View File

@ -1,11 +1,8 @@
import 'package:geojson/geojson.dart';
import 'package:geojson_vi/geojson_vi.dart';
import 'package:get/get_state_manager/get_state_manager.dart';
class BottomSheetController extends GetxController{
List<GeoJsonFeature>? currentFeature = <GeoJsonFeature>[];
class BottomSheetController extends GetxController {
List<GeoJSONFeature>? currentFeature = <GeoJSONFeature>[];
BottomSheetController({this.currentFeature});
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,381 +0,0 @@
import 'package:flutter/material.dart';
import 'package:geojson/geojson.dart';
import 'package:get/get.dart';
import 'package:image_picker/image_picker.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/routes/app_pages.dart';
import 'package:url_launcher/url_launcher.dart';
class BottomSheetWidget extends StatelessWidget {
//const BottomSheetWidget({ Key? key }, GeoJsonFeature? pt) : super(key: key);
final IndexController indexController = Get.find<IndexController>();
BottomSheetWidget({Key? key}) : super(key: key);
Image getImage(GeoJsonFeature? gf){
if(gf!.properties!["photos"] == null || gf.properties!["photos"] == ""){
return const Image(image: AssetImage('assets/images/empty_image.png'));
}
else{
return Image(image: NetworkImage(
gf.properties!["photos"],
),
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
return Image.asset("assets/images/empty_image.png");
},
);
}
}
void _launchURL(url) async {
if (!await launch(url)) throw 'Could not launch $url';
}
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Column(
children: [
const SizedBox(height: 5.0,),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
MaterialButton(
onPressed: () {
indexController.makePrevious(indexController.currentFeature[0]);
},
color: Colors.blue,
textColor: Colors.white,
padding: const EdgeInsets.all(14),
shape: const CircleBorder(),
child: const Icon(
Icons.arrow_back_ios,
size: 14,
),
),
Expanded(
child: Container(
alignment: Alignment.center,
child: Obx(() =>
Text(indexController.currentFeature[0].properties!["location_name"], style: const TextStyle(
fontSize: 15.0,
fontWeight: FontWeight.bold,
),
)
),
),
),
MaterialButton(
onPressed: () {
indexController.makeNext(indexController.currentFeature[0]);
},
color: Colors.blue,
textColor: Colors.white,
padding: const EdgeInsets.all(14),
shape: const CircleBorder(),
child: const Icon(
Icons.arrow_forward_ios,
size: 14,
),
),
],
),
Row(
children: [
Expanded(
child: SizedBox(
height: 260.0,
child: Obx(() => getImage(indexController.currentFeature[0])),
)
),
],
),
Row(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: Column(
children: [
indexController.currentFeature[0].properties!["address"] != null ?
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: Container(
alignment: Alignment.topRight,
child: Text("address".tr, style: const TextStyle(fontWeight: FontWeight.bold),)),
),
const SizedBox(width: 12.0,),
Expanded(
child: Container(
alignment: Alignment.topLeft,
child: Obx(() => Text(indexController.currentFeature[0].properties!["address"] ?? '',
style: const TextStyle(color: Colors.blue,),
softWrap: true,
overflow: TextOverflow.ellipsis,)
),
),
)
],
): const SizedBox(width: 0.0, height: 0,),
indexController.currentFeature[0].properties!["phone"] != null ?
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(child: Container(
alignment: Alignment.topRight,
child: Text("telephone".tr, style: const TextStyle(fontWeight: FontWeight.bold),))),
const SizedBox(width: 12.0,),
Expanded(
child: Container(
alignment: Alignment.topLeft,
child: Obx(() => Text(indexController.currentFeature[0].properties!["phone"] ?? '',
style: const TextStyle(color: Colors.blue,),
overflow: TextOverflow.ellipsis,)
),
),
)
],
): const SizedBox(width: 0, height: 0,),
indexController.currentFeature[0].properties!["email"] != null ?
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(child: Container(
alignment: Alignment.topRight,
child: Text("email".tr, style: const TextStyle(fontWeight: FontWeight.bold),))),
const SizedBox(width: 12.0,),
Expanded(
child: Container(
alignment: Alignment.topLeft,
child: Obx(() => Text(indexController.currentFeature[0].properties!["email"] ?? '',
style: const TextStyle(color: Colors.blue,),
overflow: TextOverflow.ellipsis,)
),
),
)
],
): const SizedBox(width: 0, height: 0,),
indexController.currentFeature[0].properties!["webcontents"] != null ?
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(child: Container(
alignment: Alignment.topRight,
child: Text(
"web".tr, style: const TextStyle(fontWeight: FontWeight.bold)))),
const SizedBox(width: 12.0,),
Expanded(
child: Container(
alignment: Alignment.topLeft,
child: Obx(() => InkWell(
onTap: (){
_launchURL(indexController.currentFeature[0].properties!["webcontents"]);
},
child: Text(indexController.currentFeature[0].properties!["webcontents"] ?? '',
style: const TextStyle(color: Colors.blue,),
softWrap: false,
overflow: TextOverflow.fade,),
)),
),
)
],
): const SizedBox(width: 0.0, height: 0.0,),
indexController.currentFeature[0].properties!["videos"] != null ?
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(child: Container(
alignment: Alignment.topRight,
child: Text("video".tr, style: const TextStyle(fontWeight: FontWeight.bold)))),
const SizedBox(width: 12.0,),
Expanded(
child: Container(
alignment: Alignment.topLeft,
child: Obx(() => Text(indexController.currentFeature[0].properties!["videos"] ?? '',
style: const TextStyle(color: Colors.blue,),
overflow: TextOverflow.ellipsis,)
),
),
)
],
): const SizedBox(width: 0.0, height: 0.0,),
],
),
),
),
],
),
const SizedBox(height: 20.0,),
Obx(() =>
indexController.currentAction.isNotEmpty ?
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
indexController.rog_mode.value == 0 ?
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.end,
children: [
indexController.currentAction[0][0]["wanttogo"] == false ?
ElevatedButton(
onPressed: (){
if(indexController.currentAction.isNotEmpty){
print(indexController.currentAction[0]);
indexController.currentAction[0][0]["wanttogo"] = true;
Map<String,dynamic> temp = Map<String,dynamic>.from(indexController.currentAction[0][0]);
indexController.currentAction.clear();
print("---temp---$temp");
indexController.currentAction.add([temp]);
}
indexController.makeAction(context);
},
child: Text("want_to_go".tr)
) :
ElevatedButton(
onPressed: (){
if(indexController.currentAction.isNotEmpty){
print(indexController.currentAction[0]);
indexController.currentAction[0][0]["wanttogo"] = false;
Map<String,dynamic> temp = Map<String,dynamic>.from(indexController.currentAction[0][0]);
indexController.currentAction.clear();
print("---temp---$temp");
indexController.currentAction.add([temp]);
}
indexController.makeAction(context);
},
child: IconButton(
icon: Icon(Icons.favorite, color: Colors.red, semanticLabel: "want_to_go".tr,), onPressed: () {
},
)
),
indexController.currentAction[0][0]["like"] == false ?
ElevatedButton(
onPressed: (){
if(indexController.currentAction.isNotEmpty){
print(indexController.currentAction[0]);
indexController.currentAction[0][0]["like"] = true;
Map<String,dynamic> temp = Map<String,dynamic>.from(indexController.currentAction[0][0]);
indexController.currentAction.clear();
print("---temp---$temp");
indexController.currentAction.add([temp]);
}
indexController.makeAction(context);
},
child: Text("like".tr)
) :
ElevatedButton(
onPressed: (){
if(indexController.currentAction.isNotEmpty){
print(indexController.currentAction[0]);
indexController.currentAction[0][0]["like"] = false;
Map<String,dynamic> temp = Map<String,dynamic>.from(indexController.currentAction[0][0]);
indexController.currentAction.clear();
print("---temp---$temp");
indexController.currentAction.add([temp]);
}
indexController.makeAction(context);
},
child: IconButton(
icon: Icon(Icons.favorite, color: Colors.red, semanticLabel: "like".tr,), onPressed: () {
},
)
),
],
)
:
const SizedBox(width: 0, height: 0,),
indexController.rog_mode.value == 1 ?
indexController.currentAction[0][0]["checkin"] == false ?
Column(
children: [
Row(
mainAxisSize: MainAxisSize.max,
children: [
ElevatedButton(
child: const Text("Image"), onPressed: (){
final ImagePicker picker = ImagePicker();
picker.pickImage(source: ImageSource.camera).then((value){
print("----- image---- ${value!.path}");
});
},
)
],
),
ElevatedButton(
onPressed: (){
if(indexController.currentAction.isNotEmpty){
print(indexController.currentAction[0]);
indexController.currentAction[0][0]["checkin"] = true;
Map<String,dynamic> temp = Map<String,dynamic>.from(indexController.currentAction[0][0]);
indexController.currentAction.clear();
print("---temp---$temp");
indexController.currentAction.add([temp]);
}
indexController.makeAction(context);
},
child: Text("checkin".tr)
)
],
)
:
ElevatedButton(
onPressed: (){
if(indexController.currentAction.isNotEmpty){
print(indexController.currentAction[0]);
indexController.currentAction[0][0]["checkin"] = false;
Map<String,dynamic> temp = Map<String,dynamic>.from(indexController.currentAction[0][0]);
indexController.currentAction.clear();
print("---temp---$temp");
indexController.currentAction.add([temp]);
}
indexController.makeAction(context);
},
child: const Icon(
Icons.favorite, color: Colors.red)
,
):
const SizedBox(width: 0, height: 0,),
],
): Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton(
onPressed: (){
Get.toNamed(AppPages.LOGIN);
},
child: const Flexible(child: Text("その他のオプションについてはログインしてください")))
],
),
),
const Row(
children: [
SizedBox(height: 60.0,),
],
)
],
),
);
}
}

View File

@ -1,34 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:get/get.dart';
import 'package:flutter_breadcrumb/flutter_breadcrumb.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/widgets/perfecture_widget.dart';
class BreadCrumbWidget extends StatelessWidget {
BreadCrumbWidget({Key? key, this.mapController}) : super(key: key);
final MapController? mapController;
final IndexController indexController = Get.find<IndexController>();
@override
Widget build(BuildContext context) {
print("------ map controller is $mapController------------");
return
Obx(()=>
indexController.perfectures.isNotEmpty && mapController != null ?
BreadCrumb.builder(
itemCount: indexController.perfectures.length,
builder: (index){
return
BreadCrumbItem(
content: PerfectureWidget(indexController: indexController, mapController: mapController!) //Text('Item$index')
);
}
):
const Text("Empty")
);
}
}

View File

@ -0,0 +1,56 @@
import 'package:flutter/material.dart';
class CFormTextField extends StatelessWidget {
const CFormTextField({
super.key,
required this.cFocus,
required TextEditingController cController,
}) : cTextEditingController = cController;
final FocusNode cFocus;
final TextEditingController cTextEditingController;
@override
Widget build(BuildContext context) {
return TextFormField(
autocorrect: false,
autofocus: true,
focusNode: cFocus,
controller: cTextEditingController,
keyboardType: TextInputType.emailAddress,
textInputAction: TextInputAction.done,
validator: (value) {
if (value == null || value.isEmpty) {
return "Need a valied email address";
}
return null;
},
decoration: InputDecoration(
//filled: true,
//fillColor: Theme.of(context).colorScheme.primaryContainer,
hintText: "Enter email address",
labelText: "Email",
labelStyle: TextStyle(
color: Theme.of(context).colorScheme.onPrimaryContainer,
fontSize: 16),
prefixIcon: const Icon(Icons.email_outlined),
suffixIcon: cTextEditingController.text.isNotEmpty
? IconButton(
onPressed: () {
cTextEditingController.clear();
},
icon: const Icon(Icons.clear))
: Container(
width: 0,
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(
width: 1, color: Theme.of(context).colorScheme.secondary)),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(
width: 2, color: Theme.of(context).colorScheme.primary))),
);
}
}

View File

@ -0,0 +1,54 @@
import 'package:flutter/material.dart';
class CPasswordTextField extends StatefulWidget {
const CPasswordTextField(
{super.key, required this.cFocusNode, required this.cController});
final FocusNode cFocusNode;
final TextEditingController cController;
@override
State<CPasswordTextField> createState() => _CPasswordTextFieldState();
}
class _CPasswordTextFieldState extends State<CPasswordTextField> {
var _isVisible = false;
@override
Widget build(BuildContext context) {
return TextFormField(
controller: widget.cController,
textInputAction: TextInputAction.go,
obscureText: !_isVisible,
validator: (value) {
if (value == null || value.isEmpty || value.length < 5) {
return "Need a valied password with more than 4 charectors";
}
return null;
},
decoration: InputDecoration(
//filled: true,
//fillColor: Theme.of(context).colorScheme.tertiaryContainer,
hintText: "Enter password",
labelText: "Password",
labelStyle: TextStyle(
color: Theme.of(context).colorScheme.primary, fontSize: 16),
suffixIcon: IconButton(
onPressed: () {
setState(() {
_isVisible = !_isVisible;
});
},
icon: _isVisible
? const Icon(Icons.visibility)
: const Icon(Icons.visibility_off)),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(
width: 1, color: Theme.of(context).colorScheme.secondary)),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(
width: 2, color: Theme.of(context).colorScheme.primary))));
}
}

View File

@ -1,49 +0,0 @@
import 'package:flutter/material.dart';
import 'package:rogapp/pages/index/index_controller.dart';
class CatWidget extends StatefulWidget {
CatWidget({ Key? key, required this.indexController, }) : super(key: key);
IndexController indexController;
@override
State<CatWidget> createState() => _CatWidgetState();
}
class _CatWidgetState extends State<CatWidget> {
String defaultValue = "---";
@override
Widget build(BuildContext context) {
return
PopupMenuButton(
onSelected: (value) {
widget.indexController.currentCat.clear();
widget.indexController.currentCat.add(value.toString());
widget.indexController.refreshLocationForCat();
setState(() {
print(value);
//widget.indexController.is_loading.value = true;
defaultValue = value.toString();
});
},
itemBuilder: (BuildContext context){
List<PopupMenuItem> itms = <PopupMenuItem>[];
for(dynamic d in widget.indexController.cats[0]){
PopupMenuItem itm = PopupMenuItem(value: d['category'].toString(), child: Text(d['category'].toString()));
itms.add(itm);
}
return itms;
}
);
}
}
// widget.indexController.cats.map((e) =>
// PopupMenuItem(
// value: defaultValue,
// child: Text(e[0]['category'].toString()),
// )
// ).toList(),

View File

@ -0,0 +1,35 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class CategoryChangeDialog extends StatelessWidget {
final String oldCategory;
final String newCategory;
const CategoryChangeDialog({
Key? key,
required this.oldCategory,
required this.newCategory,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text('カテゴリ変更の警告'),
content: Text(
'チームの構成変更により、カテゴリが $oldCategory から $newCategory に変更されます。'
'このチームは既にエントリーしています。どのように処理しますか?'
),
actions: [
TextButton(
child: Text('新しいチームを作成'),
onPressed: () => Get.back(result: true),
),
TextButton(
child: Text('既存のエントリーを更新'),
onPressed: () => Get.back(result: false),
),
],
);
}
}

View File

@ -0,0 +1,70 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:gifunavi/pages/destination/destination_controller.dart';
import 'package:gifunavi/routes/app_pages.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>();
void _onLongPress() async {
PermissionStatus status = await Permission.location.status;
if (!status.isGranted) {
await showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('位置情報の許可が必要です'),
content: const Text('現在位置を表示するには、位置情報の許可が必要です。「設定」からアプリの権限を許可してください。'),
actions: [
TextButton(
child: const Text('キャンセル'),
onPressed: () => Navigator.of(context).pop(),
),
TextButton(
child: const Text('設定'),
onPressed: () {
Navigator.of(context).pop();
openAppSettings();
},
),
],
);
},
);
} else {
Get.toNamed(AppPages.SETTINGS);
}
}
@override
Widget build(BuildContext context) {
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,
),
),
),
);
}
}

View File

@ -0,0 +1,271 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
class CustomDatePicker extends StatefulWidget {
final DateTime initialDate;
final DateTime firstDate;
final DateTime lastDate;
final String currentDateText;
CustomDatePicker({
required this.initialDate,
required this.firstDate,
required this.lastDate,
required this.currentDateText,
});
@override
_CustomDatePickerState createState() => _CustomDatePickerState();
}
class _CustomDatePickerState extends State<CustomDatePicker> {
late DateTime _selectedDate;
late int _selectedYear;
late int _selectedMonth;
late int _selectedDay;
late ScrollController _yearScrollController;
late ScrollController _monthScrollController;
late ScrollController _dayScrollController;
@override
void initState() {
super.initState();
_selectedDate = _parseDate(widget.currentDateText) ?? widget.initialDate;
_selectedYear = _selectedDate.year;
_selectedMonth = _selectedDate.month;
_selectedDay = _selectedDate.day;
_yearScrollController = ScrollController(
initialScrollOffset: (_selectedYear - widget.firstDate.year) * 70.0,
);
_monthScrollController = ScrollController(
initialScrollOffset: (_selectedMonth - 1) * 50.0,
);
_dayScrollController = ScrollController(
initialScrollOffset: (_selectedDay - 1) * 50.0,
);
WidgetsBinding.instance.addPostFrameCallback((_) {
_centerSelectedYear();
_centerSelectedMonth();
_centerSelectedDay();
});
}
void _centerSelectedYear() {
final screenWidth = MediaQuery.of(context).size.width;
final centerPosition = (_selectedYear - widget.firstDate.year) * 70.0 - (screenWidth / 2) + 35.0;
_yearScrollController.animateTo(
centerPosition,
duration: Duration(milliseconds: 300),
curve: Curves.easeInOut,
);
}
void _centerSelectedMonth() {
final screenWidth = MediaQuery.of(context).size.width;
final centerPosition = (_selectedMonth - 1) * 50.0 - (screenWidth / 2) + 25.0;
_monthScrollController.animateTo(
centerPosition,
duration: Duration(milliseconds: 300),
curve: Curves.easeInOut,
);
}
void _centerSelectedDay() {
final screenWidth = MediaQuery.of(context).size.width;
final centerPosition = (_selectedDay - 1) * 50.0 - (screenWidth / 2) + 25.0;
_dayScrollController.animateTo(
centerPosition,
duration: Duration(milliseconds: 300),
curve: Curves.easeInOut,
);
}
DateTime? _parseDate(String dateString) {
try {
return DateFormat('yyyy/MM/dd').parse(dateString);
} catch (e) {
return null;
}
}
@override
Widget build(BuildContext context) {
return Dialog(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(16.0),
child: Text(
'生年月日の選択',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
),
_buildLabeledPicker('', _buildYearPicker()),
_buildLabeledPicker('', _buildMonthPicker()),
_buildLabeledPicker('', _buildDayPicker()),
_buildActionButtons(),
],
),
);
}
Widget _buildLabeledPicker(String label, Widget picker) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(left: 16.0, top: 8.0),
child: Text(label, style: TextStyle(fontWeight: FontWeight.bold)),
),
picker,
],
);
}
Widget _buildYearPicker() {
return Container(
height: 100,
child: ListView.builder(
controller: _yearScrollController,
scrollDirection: Axis.horizontal,
itemCount: widget.lastDate.year - widget.firstDate.year + 1,
itemBuilder: (context, index) {
final year = widget.firstDate.year + index;
return GestureDetector(
onTap: () {
setState(() {
_selectedYear = year;
_updateSelectedDate();
_centerSelectedYear();
});
},
child: Container(
width: 70,
padding: EdgeInsets.all(8),
alignment: Alignment.center,
decoration: BoxDecoration(
color: _selectedYear == year ? Colors.blue : null,
borderRadius: BorderRadius.circular(4),
),
child: Text(
year.toString(),
style: TextStyle(
color: _selectedYear == year ? Colors.white : null,
),
),
),
);
},
),
);
}
Widget _buildMonthPicker() {
return Container(
height: 50,
child: ListView.builder(
controller: _monthScrollController,
scrollDirection: Axis.horizontal,
itemCount: 12,
itemBuilder: (context, index) {
final month = index + 1;
return GestureDetector(
onTap: () {
setState(() {
_selectedMonth = month;
_updateSelectedDate();
_centerSelectedMonth();
});
},
child: Container(
width: 50,
padding: EdgeInsets.all(8),
alignment: Alignment.center,
decoration: BoxDecoration(
color: _selectedMonth == month ? Colors.blue : null,
borderRadius: BorderRadius.circular(4),
),
child: Text(
month.toString(),
style: TextStyle(
color: _selectedMonth == month ? Colors.white : null,
),
),
),
);
},
),
);
}
Widget _buildDayPicker() {
final daysInMonth = DateTime(_selectedYear, _selectedMonth + 1, 0).day;
return Container(
height: 50,
child: ListView.builder(
controller: _dayScrollController,
scrollDirection: Axis.horizontal,
itemCount: daysInMonth,
itemBuilder: (context, index) {
final day = index + 1;
return GestureDetector(
onTap: () {
setState(() {
_selectedDay = day;
_updateSelectedDate();
_centerSelectedDay();
});
},
child: Container(
width: 50,
padding: EdgeInsets.all(8),
alignment: Alignment.center,
decoration: BoxDecoration(
color: _selectedDay == day ? Colors.blue : null,
borderRadius: BorderRadius.circular(4),
),
child: Text(
day.toString(),
style: TextStyle(
color: _selectedDay == day ? Colors.white : null,
),
),
),
);
},
),
);
}
void _updateSelectedDate() {
final daysInMonth = DateTime(_selectedYear, _selectedMonth + 1, 0).day;
_selectedDay = _selectedDay.clamp(1, daysInMonth);
_selectedDate = DateTime(_selectedYear, _selectedMonth, _selectedDay);
}
Widget _buildActionButtons() {
return ButtonBar(
children: <Widget>[
TextButton(
child: Text('キャンセル'),
onPressed: () => Navigator.of(context).pop(),
),
TextButton(
child: Text('OK'),
onPressed: () => Navigator.of(context).pop(_selectedDate),
),
],
);
}
@override
void dispose() {
_yearScrollController.dispose();
_monthScrollController.dispose();
_dayScrollController.dispose();
super.dispose();
}
}

View File

@ -0,0 +1,9 @@
import 'package:flutter/material.dart';
class CustomIcons {
static const _fontFamily = 'CustomIcons';
static const IconData gps_signal_low = IconData(0xe900, fontFamily: _fontFamily);
static const IconData gps_signal_middle = IconData(0xe913, fontFamily: _fontFamily);
static const IconData gps_signal_high = IconData(0xe91d, fontFamily: _fontFamily);
}

View File

@ -0,0 +1,147 @@
import 'package:flutter/material.dart';
class LogManager {
static final LogManager _instance = LogManager._internal();
factory LogManager() {
return _instance;
}
LogManager._internal();
final List<String> _logs = [];
final List<VoidCallback> _listeners = [];
final List<String> _operationLogs = [];
List<String> get operationLogs => _operationLogs;
List<String> get logs => _logs;
void addLog(String log) {
_logs.add(log);
_notifyListeners(); // Notify all listeners
}
void clearLogs() {
_logs.clear();
_notifyListeners(); // Notify all listeners
}
void addOperationLog(String log) {
_operationLogs.add(log);
_notifyListeners();
}
void clearOperationLogs() {
_operationLogs.clear();
_notifyListeners();
}
void addListener(VoidCallback listener) {
_listeners.add(listener);
}
void removeListener(VoidCallback listener) {
_listeners.remove(listener);
}
void _notifyListeners() {
for (var listener in _listeners) {
listener();
}
}
}
class DebugWidget extends StatefulWidget {
const DebugWidget({super.key});
@override
State<DebugWidget> createState() => _DebugWidgetState();
}
class _DebugWidgetState extends State<DebugWidget> {
final LogManager logManager = LogManager();
@override
void initState() {
super.initState();
logManager.addListener(_updateLogs);
}
@override
void dispose() {
logManager.removeListener(_updateLogs);
super.dispose();
}
void _updateLogs() {
Future.delayed(Duration.zero, () {
if (mounted) {
setState(() {});
}
});
}
void toggleExpanded() {
setState(() {
isExpanded = !isExpanded;
});
}
void clearLogs() {
logManager.clearLogs();
}
bool isExpanded = false;
@override
Widget build(BuildContext context) {
return Positioned(
left: 0,
right: 0,
bottom: 0,
child: GestureDetector(
onTap: toggleExpanded,
child: AnimatedContainer(
duration: const Duration(milliseconds: 200),
color: Colors.black54,
height: isExpanded ? 450.0 : 50.0, // Adjust sizes as needed
child: Column(
children: [
// Top bar with clear button
if (isExpanded)
Container(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
color: Colors.blueGrey, // Adjust color as needed
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text('Debug Logs', style: TextStyle(color: Colors.white)),
IconButton(
icon: const Icon(Icons.clear, color: Colors.white),
onPressed: clearLogs,
),
],
),
),
// Log messages
Expanded(
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: logManager.logs.reversed
.map((log) => Text(
"${DateTime.now().hour}:${DateTime.now().minute}:${DateTime.now().second}:${DateTime.now().microsecond} - $log",
style: const TextStyle(color: Colors.white)))
.toList(),
),
),
),
],
),
),
),
);
}
}

View File

@ -1,48 +1,55 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
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/const.dart';
import 'package:rogapp/utils/database_helper.dart';
import 'package:rogapp/widgets/bottom_sheet_new.dart';
import 'package:gifunavi/model/destination.dart';
import 'package:gifunavi/pages/destination/destination_controller.dart';
import 'package:gifunavi/pages/index/index_controller.dart';
import 'package:gifunavi/utils/const.dart';
import 'package:gifunavi/utils/database_helper.dart';
//import 'package:gifunavi/widgets/bottom_sheets/bottom_sheet_start.dart';
//import 'package:gifunavi/widgets/bottom_sheets/bottom_sheet_goal.dart';
//import 'package:gifunavi/widgets/bottom_sheets/bottom_sheet_normal_point.dart';
import 'package:gifunavi/widgets/bottom_sheet_new.dart';
import 'package:timeline_tile/timeline_tile.dart';
class DestinationWidget extends StatelessWidget {
DestinationWidget({ Key? key }) : super(key: key);
DestinationWidget({super.key});
final DestinationController destinationController = Get.find<DestinationController>();
final DestinationController destinationController =
Get.find<DestinationController>();
final IndexController indexController = Get.find<IndexController>();
final List<int> _items = List<int>.generate(50, (int index) => index);
Image getImage(int index){
if(destinationController.destinations[index].photos== null || destinationController.destinations[index].photos == ""){
Image getImage(int index) {
if (destinationController.destinations[index].photos == null ||
destinationController.destinations[index].photos == "") {
return const Image(image: AssetImage('assets/images/empty_image.png'));
}
else{
print("------- image is ${destinationController.destinations[index].photos!}------");
} else {
// print(
// "------- image is ${destinationController.destinations[index].photos!}------");
String photo = destinationController.destinations[index].photos!;
if(photo.contains('http')){
return Image(image: NetworkImage(
destinationController.destinations[index].photos!),
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
return Image.asset("assets/images/empty_image.png");
},
);
}
else {
String serverUrl = ConstValues.currentServer();
//print("==== photo is ${server_url + '/media/compressed/' + destinationController.destinations[index].photos!} ===");
return Image(image: NetworkImage(
'$serverUrl/media/compressed/${destinationController.destinations[index].photos!}'),
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
return Image.asset("assets/images/empty_image.png");
},
);
}
if (photo.contains('http')) {
return Image(
image:
NetworkImage(destinationController.destinations[index].photos!),
errorBuilder:
(BuildContext context, Object exception, StackTrace? stackTrace) {
return Image.asset("assets/images/empty_image.png");
},
);
} else {
String serverUrl = ConstValues.currentServer();
//print("==== photo is ${server_url + '/media/compressed/' + destinationController.destinations[index].photos!} ===");
return Image(
image: NetworkImage(
'$serverUrl/media/compressed/${destinationController.destinations[index].photos!}'),
errorBuilder:
(BuildContext context, Object exception, StackTrace? stackTrace) {
return Image.asset("assets/images/empty_image.png");
},
);
}
}
}
@ -73,56 +80,57 @@ class DestinationWidget extends StatelessWidget {
void moveUp() {
Destination? d;
for(Destination ad in destinationController.destinations){
if(ad.selected == true){
for (Destination ad in destinationController.destinations) {
if (ad.selected == true) {
d = ad;
break;
}
}
if(d != null){
print("--- selected destination is ${d.list_order}");
if (d != null) {
//print("--- selected destination is ${d.list_order}");
destinationController.makeOrder(d, -1);
}
}
void moveDown() {
Destination? d;
for(Destination ad in destinationController.destinations){
if(ad.selected == true){
for (Destination ad in destinationController.destinations) {
if (ad.selected == true) {
d = ad;
break;
}
}
if(d != null){
print("--- selected destination is ${d.list_order}");
if (d != null) {
//print("--- selected destination is ${d.list_order}");
destinationController.makeOrder(d, 1);
}
}
void clearall(){
void clearall() {
Get.defaultDialog(
title: "are_you_sure_want_to_delete_all".tr,
middleText: "all_added_destination_will_be_deleted".tr,
backgroundColor: Colors.blue.shade300,
titleStyle: const TextStyle(color: Colors.white),
middleTextStyle: const TextStyle(color: Colors.white),
textConfirm: "confirm".tr,
textCancel: "cancel".tr,
cancelTextColor: Colors.white,
confirmTextColor: Colors.blue,
buttonColor: Colors.white,
barrierDismissible: false,
radius: 10,
content: const Column(
children: [
],
),
onConfirm: (){
destinationController.deleteAllDestinations();
Get.back();
Get.snackbar("deleted".tr, "all_destinations_are_deleted_successfully".tr);
}
);
title: "are_you_sure_want_to_delete_all".tr,
middleText: "all_added_destination_will_be_deleted".tr,
backgroundColor: Colors.blue.shade300,
titleStyle: const TextStyle(color: Colors.white),
middleTextStyle: const TextStyle(color: Colors.white),
textConfirm: "confirm".tr,
textCancel: "cancel".tr,
cancelTextColor: Colors.white,
confirmTextColor: Colors.blue,
buttonColor: Colors.white,
barrierDismissible: false,
radius: 10,
content: const Column(
children: [],
),
onConfirm: () {
destinationController.deleteAllDestinations();
Get.back();
Get.snackbar(
"deleted".tr, "all_destinations_are_deleted_successfully".tr,
backgroundColor: Colors.green,
colorText: Colors.white);
});
}
void interChange() {
@ -142,124 +150,169 @@ class DestinationWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
print(
"------ destination widget------ ${destinationController.destinationCount.value} ----------");
print("------ destination widget------ ${destinationController.destinationCount.value} ----------");
return
Obx(() =>
Stack(
return Obx(() => Stack(
children: [
Padding(
padding: const EdgeInsets.only(top:45.0),
child: ListView.builder(
Padding(
padding: const EdgeInsets.only(top: 45.0),
child: ListView.builder(
itemCount: destinationController.destinationCount.value,
itemBuilder: (BuildContext context, int index) {
return
TimelineTile(
alignment: TimelineAlign.manual,
lineXY: 0.2,
isFirst: index == 0 ? true : false,
indicatorStyle: IndicatorStyle(
indicator: CircleAvatar(
backgroundColor: Colors.red,
child: Text(destinationController.destinations[index].list_order.toString(), style: const TextStyle(color: Colors.white),),
),
),
key: Key(index.toString()),
endChild: Card(
child: Container(
constraints: const BoxConstraints(
minHeight: 80,
),
child: ListTile(
onTap: () async {
{
Destination? fs = destinationController.destinations[index];
print("----fsf-----$index");
if(indexController.currentDestinationFeature.isNotEmpty) {
indexController.currentDestinationFeature.clear();
}
indexController.currentDestinationFeature.add(fs);
print("--- ndexController.currentDestinationFeature ----- ${ indexController.currentDestinationFeature[0].name} ----");
//indexController.getAction();
showModalBottomSheet(context: context, isScrollControlled: true,
//builder:((context) => BottomSheetWidget())
builder:((context) => BottomSheetNew())
);
}
},
onLongPress: (){
destinationController.toggleSelection(destinationController.destinations[index]);
},
selectedTileColor: Colors.amberAccent,
selected:destinationController.destinations[index].selected!,
leading: getImage(index),
title: Text(destinationController.destinations[index].name!),
subtitle: Text(destinationController.destinations[index].category!),
return TimelineTile(
alignment: TimelineAlign.manual,
lineXY: 0.2,
isFirst: index == 0 ? true : false,
indicatorStyle: IndicatorStyle(
indicator: CircleAvatar(
backgroundColor: Colors.red,
child: Text(
destinationController.destinations[index].list_order
.toString(),
style: const TextStyle(color: Colors.white),
),
),
),
),
startChild:
index > 0 && destinationController.matrix["routes"][0]["legs"] != null ?
Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(destinationController.matrix["routes"][0]["legs"][index -1]["distance"] != null ? destinationController.matrix["routes"][0]["legs"][index-1]["distance"]["text"].toString(): ''),
Text(destinationController.matrix["routes"][0]["legs"][index -1]["duration"] != null ? destinationController.matrix["routes"][0]["legs"][index-1]["duration"]["text"].toString() : '')
],
):
Container()
,
);
}
),
key: Key(index.toString()),
endChild: Card(
child: Container(
constraints: const BoxConstraints(
minHeight: 80,
),
child: ListTile(
onTap: () async {
{
Destination? fs =
destinationController.destinations[index];
//print("----fsf-----$index");
if (indexController
.currentDestinationFeature.isNotEmpty) {
indexController.currentDestinationFeature
.clear();
}
indexController.currentDestinationFeature
.add(fs);
// print(
// "--- ndexController.currentDestinationFeature ----- ${indexController.currentDestinationFeature[0].name} ----");
//indexController.getAction();
Widget bottomSheet = BottomSheetNew(destination: fs);
/*
if (fs.cp == -1 || fs.cp == 0) {
bottomSheet = BottomSheetStart(destination: fs);
} else if (fs.cp == -2 || fs.cp == 0) {
bottomSheet = BottomSheetGoal(destination: fs);
} else {
bottomSheet = BottomSheetNormalPoint(destination: fs);
}
*/
showModalBottomSheet(
constraints: BoxConstraints.loose(
Size(Get.width, Get.height * 0.85)),
context: context,
isScrollControlled: true,
//builder:((context) => BottomSheetWidget())
builder: ((context) => bottomSheet)
);
}
},
onLongPress: () {
destinationController.toggleSelection(
destinationController.destinations[index]);
},
selectedTileColor: Colors.amberAccent,
selected: destinationController
.destinations[index].selected!,
leading: getImage(index),
title: Text(destinationController
.destinations[index].name!),
subtitle: Text(destinationController
.destinations[index].category!),
),
),
),
startChild: index > 0 &&
destinationController.matrix["routes"][0]
["legs"] !=
null
? Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(destinationController.matrix["routes"][0]
["legs"][index - 1]["distance"] !=
null
? destinationController.matrix["routes"][0]
["legs"][index - 1]["distance"]
["text"]
.toString()
: ''),
Text(destinationController.matrix["routes"][0]
["legs"][index - 1]["duration"] !=
null
? destinationController.matrix["routes"][0]
["legs"][index - 1]["duration"]
["text"]
.toString()
: '')
],
)
: Container(),
);
}),
),
Container(
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.3),
spreadRadius: 5,
blurRadius: 3,
offset: const Offset(0, 7), // changes position of shadow
),
],
),
height: 44.0,
width: MediaQuery.of(context).size.width,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButton(
icon:const Icon(Icons.delete_forever),
//onPressed: (){doDelete();},
onPressed: clearall,
),
IconButton(
icon:const Icon(Icons.cancel),
//onPressed: (){doDelete();},
onPressed: destinationController.currentSelectedDestinations.isNotEmpty ? doDelete : null,
),
IconButton(
icon:const Icon(Icons.move_up),
onPressed: destinationController.currentSelectedDestinations.isNotEmpty ? moveUp : null,
),
IconButton(
icon:const Icon(Icons.move_down),
onPressed: destinationController.currentSelectedDestinations.isNotEmpty ? moveDown : null,
),
// IconButton(
// icon:Icon(Icons.sync),
// onPressed: destinationController.destination_index_data.length == 2 ? interChange : null,
// ),
],
),
)
Container(
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.3),
spreadRadius: 5,
blurRadius: 3,
offset: const Offset(0, 7), // changes position of shadow
),
],
),
height: 44.0,
width: MediaQuery.of(context).size.width,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButton(
icon: const Icon(Icons.delete_forever),
//onPressed: (){doDelete();},
onPressed: clearall,
),
IconButton(
icon: const Icon(Icons.cancel),
//onPressed: (){doDelete();},
onPressed: destinationController
.currentSelectedDestinations.isNotEmpty
? doDelete
: null,
),
IconButton(
icon: const Icon(Icons.move_up),
onPressed: destinationController
.currentSelectedDestinations.isNotEmpty
? moveUp
: null,
),
IconButton(
icon: const Icon(Icons.move_down),
onPressed: destinationController
.currentSelectedDestinations.isNotEmpty
? moveDown
: null,
),
// IconButton(
// icon:Icon(Icons.sync),
// onPressed: destinationController.destination_index_data.length == 2 ? interChange : null,
// ),
],
),
)
],
)
);
));
}
}
}

View File

@ -1,10 +1,10 @@
import 'package:flutter/material.dart';
import 'package:rogapp/pages/search/search_page.dart';
import 'package:gifunavi/pages/search/search_page.dart';
class FakeSearch extends StatelessWidget {
const FakeSearch({
Key? key,
}) : super(key: key);
super.key,
});
@override
Widget build(BuildContext context) {

View File

@ -0,0 +1,221 @@
//import 'dart:ffi';
//import 'dart:math';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:gifunavi/model/destination.dart';
import 'package:gifunavi/pages/destination/destination_controller.dart';
import 'package:gifunavi/pages/index/index_controller.dart';
import 'package:gifunavi/services/DatabaseService.dart';
//import 'package:gifunavi/utils/database_helper.dart';
import 'package:gifunavi/widgets/GameState/CheckinState.dart';
import 'package:gifunavi/widgets/GameState/ConnectionStatus.dart';
//import 'package:gifunavi/widgets/GameState/DashboardWidget.dart';
import 'package:gifunavi/widgets/GameState/game_on_off.dart';
//import 'package:gifunavi/widgets/GameState/Colors.dart';
import 'package:gifunavi/widgets/gps_status.dart';
import 'package:gifunavi/utils/location_controller.dart';
class GameStateManager {
static final GameStateManager _instance = GameStateManager._internal();
factory GameStateManager() {
return _instance;
}
GameStateManager._internal();
final List<String> _logs = [];
final List<VoidCallback> _listeners = [];
List<String> get logs => _logs;
void addLog(String log) {
_logs.add(log);
_notifyListeners(); // Notify all listeners
}
void clearLogs() {
_logs.clear();
_notifyListeners(); // Notify all listeners
}
void addListener(VoidCallback listener) {
_listeners.add(listener);
}
void removeListener(VoidCallback listener) {
_listeners.remove(listener);
}
void _notifyListeners() {
for (var listener in _listeners) {
listener();
}
}
}
class GameStateWidget extends StatefulWidget {
const GameStateWidget({super.key});
@override
State<GameStateWidget> createState() => _GameStateWidgetState();
}
class _GameStateWidgetState extends State<GameStateWidget> {
final GameStateManager gameStateManager = GameStateManager();
final IndexController indexController = Get.find<IndexController>();
final DestinationController destinationController =
Get.find<DestinationController>();
@override
void initState() {
super.initState();
gameStateManager.addListener(_updateLogs);
}
@override
void dispose() {
gameStateManager.removeListener(_updateLogs);
super.dispose();
}
void _updateLogs() {
Future.delayed(Duration.zero, () {
if (mounted) {
setState(() {});
}
});
}
void toggleExpanded() {
setState(() {
isExpanded = !isExpanded;
});
}
void clearLogs() {
gameStateManager.clearLogs();
}
bool isExpanded = false;
@override
Widget build(BuildContext context) {
final DatabaseService dbService = DatabaseService();
//final LocationController locationController = Get.find<LocationController>();
return Container(
width: MediaQuery.of(context).size.width,
decoration: const BoxDecoration(color: Colors.black12),
child: GestureDetector(
onTap: toggleExpanded,
child: AnimatedContainer(
duration: const Duration(milliseconds: 200),
color: isExpanded ? Colors.black54 : Colors.black12,
height: isExpanded ? 160.0 : 48.0, // Adjust sizes as needed
child: Column(
children: [
// Top bar with clear button
if (isExpanded)
Container(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
color: Colors.blueGrey, // Adjust color as needed
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text('game_status'.tr, style: const TextStyle(color: Colors.white)),
IconButton(
icon: const Icon(Icons.clear, color: Colors.white),
onPressed: toggleExpanded,
),
],
),
),
// Log messages
Expanded(
child: SingleChildScrollView(
child: Wrap(
alignment: WrapAlignment.spaceEvenly,
children: [
Obx(() => Padding(
padding: const EdgeInsets.all(4.0),
child: GameStatusIndicator(
gameStarted: destinationController.isInRog.value,
minimized: !isExpanded,
),
)),
Padding(
padding: const EdgeInsets.all(4.0),
child: StreamBuilder<List<Destination>>(
stream: dbService.destinationUpdatesStream,
builder: (context, snapshot) {
if (snapshot.connectionState ==
ConnectionState.waiting) {
return const CircularProgressIndicator();
} else if (snapshot.hasError) {
return LocationVisitedWidget(
count: 0,
minimized: !isExpanded,
);
} else if (snapshot.hasData) {
return LocationVisitedWidget(
count: snapshot.data!.length,
minimized: !isExpanded,
);
} else {
return LocationVisitedWidget(
count: 0,
minimized: !isExpanded,
);
}
},
),
// child: LocationVisitedWidget(
// count:
// minimized: !isExpanded,
// ),
),
Padding(
padding: const EdgeInsets.all(4.0),
child: Obx(() => ConnectionStatusIndicator(
connectionStatus: (indexController
.connectionStatusName.value ==
"wifi" ||
indexController
.connectionStatusName.value ==
"mobile")
? indexController.connectionStatusName.value ==
"wifi"
? ConnectionStatus.wifi
: ConnectionStatus.mobile
: ConnectionStatus.none,
minimized: !isExpanded)),
), // Expanded view
Padding(
padding: const EdgeInsets.all(4.0),
child:GpsSignalStrengthIndicator(
locationController: Get.find<LocationController>(),
minimized: !isExpanded, // isExpanded はあなたのロジックに依存した変数),
)
),
],
),
// child: Obx(
// () => DashboardWidget(
// gameStarted: destinationController.isInRog.value,
// locationsVisited: 3,
// isMinimized: false,
// ),
),
),
],
),
),
),
);
}
}

View File

@ -0,0 +1,78 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:gifunavi/utils/location_controller.dart';
enum GPSStatus { high, middle, low }
class GpsSignalStrengthIndicator extends StatelessWidget {
LocationController locationController;
final bool minimized;
// コンストラクタにminimizedパラメータを追加し、デフォルト値をfalseに設定
GpsSignalStrengthIndicator({
super.key,
required this.locationController,
this.minimized = false, // ここでデフォルト値を指定
}) ;
@override
Widget build(BuildContext context) {
// final LocationController locationController = Get.find<LocationController>();
return Obx(() {
String signalStrength = locationController.latestSignalStrength.value;
//debugPrint("GpsSignalStrengthIndicator : signalStrength=${signalStrength}");
IconData iconData;
Color backgroundColor;
String text;
// signalStrengthに応じて、アイコン、背景色、テキストを設定
switch (signalStrength) {
case 'high':
backgroundColor = Colors.green;
iconData = Icons.signal_cellular_alt;
// iconData = CustomIcons.gps_signal_high;
text = 'GPS 強';
break;
case 'medium':
backgroundColor = Colors.orange;
iconData = Icons.signal_cellular_alt_2_bar;
// iconData = CustomIcons.gps_signal_middle;
text = 'GPS 中';
break;
default:
backgroundColor = Colors.grey; // Fallback color
iconData = Icons.signal_cellular_connected_no_internet_4_bar;
// iconData = CustomIcons.gps_signal_low;
text = 'GPS 弱';
}
// コンテナの設定をminimizedの値に応じて調整
return Container(
height: minimized ? 40 : null,
width: minimized ? 40 : null,
padding: minimized ? null : const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
decoration: BoxDecoration(
color: backgroundColor,
shape: minimized ? BoxShape.circle : BoxShape.rectangle,
borderRadius: minimized ? null : BorderRadius.circular(10),
),
child: minimized
? Center(
child: Icon(iconData, color: Colors.white, size: 24),
)
: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(iconData, color: Colors.white),
const SizedBox(width: 8),
Text(
text,
style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
),
],
),
);
});
}
}

View File

@ -0,0 +1,73 @@
// lib/widgets/helper_dialog.dart
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:shared_preferences/shared_preferences.dart';
class HelperDialog extends StatefulWidget {
final String message;
final String screenKey;
const HelperDialog({super.key, required this.message, required this.screenKey});
@override
_HelperDialogState createState() => _HelperDialogState();
}
class _HelperDialogState extends State<HelperDialog> {
bool _doNotShowAgain = false;
@override
Widget build(BuildContext context) {
return AlertDialog(
title: const Row(
children: [
Icon(Icons.help_outline, color: Colors.blue),
SizedBox(width: 10),
Text('ヘルプ'),
],
),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(widget.message),
const SizedBox(height: 20),
Row(
children: [
Checkbox(
value: _doNotShowAgain,
onChanged: (value) {
setState(() {
_doNotShowAgain = value!;
});
},
),
const Text('この画面を二度と表示しない'),
],
),
],
),
actions: [
TextButton(
child: const Text('OK'),
onPressed: () async {
if (_doNotShowAgain) {
final prefs = await SharedPreferences.getInstance();
await prefs.setBool('helper_${widget.screenKey}', false);
}
Get.back();
},
),
],
);
}
}
// ヘルパー画面を表示する関数
Future<void> showHelperDialog(String message, String screenKey) async {
final prefs = await SharedPreferences.getInstance();
final showHelper = prefs.getBool('helper_$screenKey') ?? true;
if (showHelper) {
Get.dialog(HelperDialog(message: message, screenKey: screenKey));
}
}

View File

@ -1,83 +1,213 @@
import 'package:flutter/material.dart';
import 'package:geojson/geojson.dart';
import 'package:geojson_vi/geojson_vi.dart';
import 'package:get/get.dart';
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/const.dart';
import 'package:rogapp/widgets/bottom_sheet_new.dart';
import 'package:gifunavi/model/destination.dart';
import 'package:gifunavi/pages/destination/destination_controller.dart';
import 'package:gifunavi/pages/index/index_controller.dart';
import 'package:gifunavi/services/maxtrix_service.dart';
import 'package:gifunavi/utils/const.dart';
//import 'package:gifunavi/widgets/bottom_sheets/bottom_sheet_start.dart';
//import 'package:gifunavi/widgets/bottom_sheets/bottom_sheet_goal.dart';
//import 'package:gifunavi/widgets/bottom_sheets/bottom_sheet_normal_point.dart';
import 'package:gifunavi/widgets/bottom_sheet_new.dart';
class ListWidget extends StatelessWidget {
ListWidget({ Key? key }) : super(key: key);
class ListWidget extends StatefulWidget {
const ListWidget({super.key});
@override
State<ListWidget> createState() => _ListWidgetState();
}
// IndexControllerから目的地のリストを取得し、ListView.builderを使用してリストを表示します。
// 各リストアイテムは、目的地の画像、名前、カテゴリ、サブロケーションID、現在地からの距離を表示します。
// リストアイテムがタップされると、changeCurrentFeatureメソッドを呼び出して現在の目的地を更新し、 BottomSheetウィジェットを表示します。
// 主なロジック:
// IndexControllerから目的地のリストを取得し、ListView.builderを使用してリストを構築します。
// getImageメソッドを使用して、目的地の画像を取得し表示します。画像が存在しない場合は、デフォルトの画像を表示します。
// matrixDistanceメソッドを使用して、現在地から目的地までの距離を計算し表示します。
// リストアイテムがタップされると、changeCurrentFeatureメソッドを呼び出して現在の目的地を更新し、showModalBottomSheetを使用してBottomSheetウィジェットを表示します。
//
class _ListWidgetState extends State<ListWidget> {
final IndexController indexController = Get.find<IndexController>();
final DestinationController destinationController = Get.find<DestinationController>();
Image getImage(int index){
if(indexController.locations[0].collection[index].properties!["photos"] == null || indexController.locations[0].collection[index].properties!["photos"] == ""){
final DestinationController destinationController =
Get.find<DestinationController>();
Image getImage(int index) {
if (indexController.locations[0].features[index]!.properties!["photos"] ==
null ||
indexController.locations[0].features[index]!.properties!["photos"] ==
"") {
return const Image(image: AssetImage('assets/images/empty_image.png'));
}
else{
print("==== photo index is $index ===");
} else {
//print("==== photo index is $index ===");
String serverUrl = ConstValues.currentServer();
GeoJsonFeature<dynamic> gf = indexController.locations[0].collection[index];
GeoJSONFeature gf = indexController.locations[0].features[index]!;
String photo = gf.properties!["photos"];
return Image(
image: NetworkImage(
'$serverUrl/media/compressed/$photo'
),
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
image: NetworkImage('$serverUrl/media/compressed/$photo'),
errorBuilder:
(BuildContext context, Object exception, StackTrace? stackTrace) {
return Image.asset("assets/images/empty_image.png");
},
);
);
}
}
void changeCurrentFeature(GeoJsonFeature fs){
if(indexController.currentFeature.isNotEmpty){
// 未使用?
void changeCurrentFeature(GeoJSONFeature fs) {
if (indexController.currentFeature.isNotEmpty) {
indexController.currentFeature.clear();
}
indexController.currentFeature.add(fs);
}
@override
Widget build(BuildContext context) {
return Obx(() =>
indexController.locations.isNotEmpty ?
ListView.builder(
itemCount: indexController.locations[0].collection.length,
shrinkWrap: true,
itemBuilder: (_, index){
bool isFound = false;
for(Destination d in destinationController.destinations){
if(indexController.locations[0].collection[index].properties!['location_id'] == d.location_id){
isFound = true;
break;
}
}
return Card(
child: ListTile(
selected: isFound,
selectedTileColor: Colors.yellow.shade200,
onTap: (){
GeoJsonFeature gf = indexController.locations[0].collection[index];
changeCurrentFeature(gf);
showModalBottomSheet(
isScrollControlled: true,
context: context,
//builder: (context) => BottomSheetWidget(),
builder:((context) => BottomSheetNew())
);
},
leading: getImage(index),
title: indexController.locations[0].collection[index].properties!['location_name'] != null ? Text(indexController.locations[0].collection[index].properties!['location_name'].toString()) : const Text(""),
subtitle: indexController.locations[0].collection[index].properties!['category'] != null ? Text(indexController.locations[0].collection[index].properties!['category']) : const Text(""),
trailing: indexController.locations[0].collection[index].properties!['sub_loc_id'] != null ? Text(indexController.locations[0].collection[index].properties!['sub_loc_id']) : const Text(""),
),
);
},
) : const SizedBox(width: 0, height: 0,),
);
void initState() {
super.initState();
}
}
Destination createDestination(GeoJSONFeature feature) {
final props = feature.properties;
GeoJSONMultiPoint pt = feature.geometry as GeoJSONMultiPoint;
return Destination(
cp: props!['cp'],
lat: pt.coordinates[0][1],
lon: pt.coordinates[0][0],
);
}
Future<String> matrixDistance(int i) async {
// Create two destinations directly from indexController.locations[0].collection
Destination desCurr = Destination(
lat: indexController.currentLat, lon: indexController.currentLon);
//Destination dest1 = createDestination(indexController.locations[0].collection[0]);
Destination dest2 =
createDestination(indexController.locations[0].features[i]!);
// Get the distance between these two destinations
final res = await MatrixService.getDestinations([desCurr, dest2]);
return res["routes"][0]["legs"][0]["distance"]["text"];
//print("matrix result is ${i} : ${res["routes"][0]["legs"][0]["distance"]["text"]} ");
}
Future<void> _pullRefresh() async {
//print("pull to refesh");
indexController.locations[0].features.sort((a, b) =>
(a!.properties!['cp'] as Comparable)
.compareTo(b!.properties!['cp'] as Comparable));
setState(() {});
}
@override
Widget build(BuildContext context) {
debugPrint("_ListWidgetState");
return Obx(
() => indexController.locations.isNotEmpty
? RefreshIndicator(
onRefresh: _pullRefresh,
child: ListView.builder(
itemCount: indexController.locations[0].features.length,
shrinkWrap: true,
itemBuilder: (_, index) {
bool isFound = false;
for (Destination d in destinationController.destinations) {
if (indexController.locations[0].features[index]!
.properties!['location_id'] ==
d.location_id) {
isFound = true;
break;
}
}
return Card(
child: ListTile(
selected: isFound,
selectedTileColor: Colors.yellow.shade200,
onTap: () {
GeoJSONFeature gf =
indexController.locations[0].features[index]!;
Destination des =
destinationController.festuretoDestination(gf);
changeCurrentFeature(gf);
Widget bottomSheet = BottomSheetNew(destination: des);
/*
if (des.cp == -1 || des.cp == 0) {
bottomSheet = BottomSheetStart(destination: des);
} else if (des.cp == -2 || des.cp == 0) {
bottomSheet = BottomSheetGoal(destination: des);
} else {
bottomSheet = BottomSheetNormalPoint(destination: des);
}
*/
showModalBottomSheet(
constraints: BoxConstraints.loose(
Size(Get.width, Get.height * 0.85)),
isScrollControlled: true,
context: context,
builder: ((context) => bottomSheet ),
);
},
leading: getImage(index),
title: indexController.locations[0].features[index]!
.properties!['location_name'] !=
null
? Text(indexController.locations[0].features[index]!
.properties!['location_name']
.toString())
: const Text(""),
subtitle: indexController.locations[0].features[index]!
.properties!['category'] !=
null
? Text(indexController.locations[0].features[index]!
.properties!['category'])
: const Text(""),
trailing: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
indexController.locations[0].features[index]!
.properties!['sub_loc_id'] !=
null
? Text(indexController.locations[0]
.features[index]!.properties!['sub_loc_id'])
: const Text(""),
SizedBox(
width: 100,
child: FutureBuilder<String>(
future: matrixDistance(index),
builder: (context, snapshot) {
if (snapshot.connectionState ==
ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(),
);
}
if (snapshot.hasError) {
return const Text("-");
} else {
return Text(
snapshot.data ?? '',
style: const TextStyle(
color: Colors.red,
fontWeight: FontWeight.bold),
);
}
},
),
)
],
)),
);
},
),
)
: const SizedBox(
width: 0,
height: 0,
),
);
}
}

View File

@ -1,162 +1,429 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_map/plugin_api.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_map_location_marker/flutter_map_location_marker.dart';
import 'package:flutter_map_marker_cluster/flutter_map_marker_cluster.dart';
import 'package:geojson/geojson.dart';
import 'package: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/destination/destination_controller.dart';
import 'package:rogapp/pages/index/index_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:gifunavi/pages/permission/permission.dart';
import 'package:gifunavi/pages/settings/settings_binding.dart';
import 'package:gifunavi/model/destination.dart';
import 'package:gifunavi/pages/destination/destination_controller.dart';
import 'package:gifunavi/pages/index/index_controller.dart';
import 'package:gifunavi/utils/database_helper.dart';
import 'package:gifunavi/utils/location_controller.dart';
import 'package:gifunavi/utils/text_util.dart';
import 'package:gifunavi/widgets/base_layer_widget.dart';
import 'package:gifunavi/widgets/bottom_sheet_new.dart';
import 'package:gifunavi/widgets/current_position_widget.dart';
import 'package:gifunavi/widgets/game_state_view.dart';
import 'package:gifunavi/pages/settings/settings_controller.dart';
class MapWidget extends StatelessWidget {
class MapResetController {
void Function()? resetIdleTimer;
}
class MapWidget extends StatefulWidget {
const MapWidget({super.key});
@override
State<MapWidget> createState() => _MapWidgetState();
}
class _MapWidgetState extends State<MapWidget> with WidgetsBindingObserver {
//class _MapWidgetState extends State<MapWidget> {
final IndexController indexController = Get.find<IndexController>();
final DestinationController destinationController = Get.find<DestinationController>();
final DestinationController destinationController =
Get.find<DestinationController>();
final LocationController locationController = Get.find<LocationController>();
final SettingsController settingsController = Get.find<SettingsController>();
MapWidget({ Key? key}) : super(key: key);
late MapController mapController;
final Completer<MapController> mapControllerCompleter = Completer<MapController>();
StreamSubscription? subscription;
Timer? _timer;
bool curr_marker_display = false;
Widget getMarkerShape(GeoJsonFeature i, BuildContext context){
GeoJsonMultiPoint p = i.geometry as GeoJsonMultiPoint;
//print("lat is ${p.geoSerie!.geoPoints[0].latitude} and lon is ${p.geoSerie!.geoPoints[0].longitude}");
RegExp regex = RegExp(r'([.]*0)(?!.*\d)');
return Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
InkWell(
onTap: () {
GeoJsonFeature? fs = indexController.getFeatureForLatLong(p.geoSerie!.geoPoints[0].latitude, p.geoSerie!.geoPoints[0].longitude);
if(fs != null){
indexController.currentFeature.clear();
indexController.currentFeature.add(fs);
//print("----- fs is ${fs.properties!['photos']}");
indexController.getAction();
showModalBottomSheet(
context: context,
isScrollControlled: true,
isDismissible: true,
builder:((context) => BottomSheetNew())
//builder:((context) => BottomSheetWidget())
).whenComplete((){
destinationController.skip_gps = false;
});
}
final Map<LatLng, Marker> _markerCache = {};
List<Marker> _markers = [];
@override
void initState() {
super.initState();
debugPrint('MapWidget: initState called');
SettingsBinding().dependencies(); // これを追加
_startIdleTimer();
mapController = MapController();
indexController.mapController = mapController;
// added by Akira
WidgetsBinding.instance.addObserver(this);
_startIdleTimer();
// マップの操作イベントをリッスンして、_resetTimerを呼び出す
mapController.mapEventStream.listen((MapEvent mapEvent) {
if (mapEvent is MapEventMove || mapEvent is MapEventFlingAnimation) {
_resetTimer();
}
});
// MapControllerの初期化が完了するまで待機
WidgetsBinding.instance.addPostFrameCallback((_) {
debugPrint("MapControllerの初期化が完了");
setState(() {
indexController.isMapControllerReady.value = true;
});
// MapControllerの初期化が完了したら、IndexControllerのonInitを呼び出す
//indexController.checkPermission();
PermissionController.checkAndRequestPermissions();
});
late MapResetController mapResetController = MapResetController();
mapResetController.resetIdleTimer = _resetIdleTimer;
Get.put(mapResetController);
// indexController.mapController = MapController(initCompleter: mapControllerCompleter);
}
void _resetIdleTimer() {
debugPrint("_resetIdleTimer...");
_timer?.cancel();
_startIdleTimer();
}
@override
void dispose() {
debugPrint('MapWidget: dispose called');
WidgetsBinding.instance.removeObserver(this); // added
mapController.dispose();
_timer?.cancel();
super.dispose();
}
// added by Akira
/*
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
debugPrint("MapWidget:didChangeAppLifecycleState...state=${state}");
if (state == AppLifecycleState.resumed) {
_resetTimer();
}
}
*/
// _centerMapOnUser を10秒間でコール
void _startIdleTimer() {
//debugPrint("_startIdleTimer ....");
final settingsController = Get.find<SettingsController>();
if (!settingsController.autoReturnDisabled.value) {
_timer = Timer(settingsController.timerDuration.value, _centerMapOnUser);
}
}
// タイマーをリセットして_startIdleTimer をコール
void _resetTimer() {
//debugPrint("_resetTimer ....");
_timer?.cancel();
_startIdleTimer();
}
// マッぷを現在位置を中心にする。
void _centerMapOnUser() {
//debugPrint("_centerMapOnUser ....");
if (mounted) {
//debugPrint("_centerMapOnUser => centering ....");
destinationController.centerMapToCurrentLocation();
}
}
Future<void> _initMarkers() async {
List<Marker> markers = await _getMarkers();
setState(() {
_markers = markers;
});
}
Future<List<Marker>> _getMarkers() async {
debugPrint('Getting markers...');
List<Marker> markers = [];
if (indexController.locations.isNotEmpty && indexController.locations[0].features.isNotEmpty) {
for (var feature in indexController.locations[0].features) {
GeoJSONMultiPoint point = feature!.geometry as GeoJSONMultiPoint;
LatLng latLng = LatLng(point.coordinates[0][1], point.coordinates[0][0]);
markers.add(Marker(
point: latLng,
width: 30.0,
height: 30.0,
child: getMarkerShape(feature),
));
}
}else{
debugPrint('No locations or features available');
}
return markers;
}
// Widget getMarkerShape(GeoJSONFeature i, BuildContext context) {
Widget getMarkerShape(GeoJSONFeature i) {
GeoJSONMultiPoint p = i.geometry as GeoJSONMultiPoint;
return InkWell(
onTap: () {
GeoJSONFeature? fs = indexController.getFeatureForLatLong(
p.coordinates[0][1], p.coordinates[0][0]);
if (fs != null) {
indexController.currentFeature.clear();
indexController.currentFeature.add(fs);
Destination des = destinationController.festuretoDestination(fs);
},
child: Container(
height: 32,
width: 32,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.transparent,
border: Border.all(
color: i.properties!['buy_point'] > 0 ? Colors.blue : Colors.red,
width: 3,
style: BorderStyle.solid
)
),
child: Stack(
alignment: Alignment.center,
children: [
const Icon(Icons.circle,size: 6.0,),
i.properties!['cp'] == -1 ?
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,)):
Container(color: Colors.transparent,),
],
)
),
),
Container(color: Colors.white, child: Text(TextUtils.getDisplayTextFeture(i), style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color:Colors.red,))),
],
);
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)),
context: context,
isScrollControlled: true,
isDismissible: true,
builder: ((context) => BottomSheetNew(
destination: des, isAlreadyCheckedIn: value.isNotEmpty)),
).whenComplete(() {
destinationController.shouldShowBottomSheet = true;
destinationController.skipGps = false;
});
});
}
},
child: Stack(
fit: StackFit.expand,
children: [
Container( // マーカー
height: 32,
width: 32,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.transparent,
border: Border.all(
color: i.properties!['buy_point'] > 0
? Colors.blue
: Colors.red,
width: 3,
style: BorderStyle.solid,
),
),
child: Stack(
alignment: Alignment.center,
children: [
const Icon(
Icons.circle,
size: 6.0,
),
i.properties!['cp'] <= 0 ? Transform.translate
(
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,
)),
)
: Container(
color: Colors.transparent,
),
],
),
),
Transform.translate(
offset: const Offset(30, 0), // 30,0
child: Align(
alignment: Alignment.center,
child: Container (
//width: 80, // 幅を指定
//height: 60, // 40
//color: Colors.purple.withOpacity(0.2),
color: Colors.transparent,
//child: Text(' ').
//constraints: const BoxConstraints(maxWidth: 60.0), // 最大幅を設定
//constraints: BoxConstraints(maxWidth: maxWidth), // 最大幅を設定
//color: Colors.purple.withOpacity(0.2),
child: Stack(
children: <Widget>[
Text( // アウトライン
TextUtils.getDisplayTextFeture(i),
style: TextStyle(
fontSize: 16, // 16
fontWeight: FontWeight.w700,
overflow: TextOverflow.visible,
//height: 1.2,
foreground: Paint()
..style = PaintingStyle.stroke
..strokeWidth = 1 // 2
..color = Colors.white,
),
maxLines: 1, // テキストを1行に制限
softWrap: false, // テキストの折り返しを無効化
),
Text( // テキスト
TextUtils.getDisplayTextFeture(i),
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
overflow: TextOverflow.visible,
//fontWeight: FontWeight.bold,
//height: 1.2,
color: Colors.black,
),
maxLines: 1, // テキストを1行に制限
softWrap: false, // テキストの折り返しを無効化
),
],
),
),
),
)
],
),
);
}
List<LatLng>? getPoints() {
List<LatLng> pts = [];
for (PointLatLng p in indexController.routePoints) {
LatLng l = LatLng(p.latitude, p.longitude);
pts.add(l);
}
return pts;
}
@override
Widget build(BuildContext context) {
print("---------- rog mode is ${indexController.rog_mode.value.toString()}----------");
final PopupController popupController = PopupController();
final settingsController = Get.find<SettingsController>(); // これを追加
//final PopupController popupController = PopupController();
return Stack(
children: [
Obx(() =>
indexController.is_loading == true ? const Padding(
padding: EdgeInsets.only(top: 60.0),
child: CircularProgressIndicator(),
):
FlutterMap(
mapController: indexController.mapController,
options: MapOptions(
maxZoom:18.4,
onMapReady: (){
indexController.is_mapController_loaded.value = true;
subscription = indexController.mapController.mapEventStream.listen((MapEvent mapEvent) {
if (mapEvent is MapEventMoveStart) {
//print(DateTime.now().toString() + ' [MapEventMoveStart] START');
// do something
}
if (mapEvent is MapEventMoveEnd && indexController.currentUser.isEmpty) {
//print(DateTime.now().toString() + ' [MapEventMoveStart] END');
indexController.loadLocationsBound();
//indexController.rogMapController!.move(c.center, c.zoom);
}
});
},
//center: LatLng(37.15319600454702, 139.58765950528198),
bounds: indexController.currentBound.isNotEmpty ? indexController.currentBound[0]: LatLngBounds.fromPoints([LatLng(35.03999881162295, 136.40587119778962), LatLng(36.642756778706904, 137.95226720406063)]),
zoom: 1,
interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag,
onPositionChanged: (MapPosition pos, isvalue){
},
onTap: (_, __) =>
popupController
.hideAllPopups(), // Hide popup when the map is tapped.
),
children: [
const BaseLayer(),
CurrentLocationLayer(),
indexController.locations.isNotEmpty && indexController.locations[0].collection.isNotEmpty ?
MarkerLayer(
markers:indexController.locations[0].collection.map((i) {
print("i si ${i.properties!['location_id']}");
RegExp regex = RegExp(r'([.]*0)(?!.*\d)');
GeoJsonMultiPoint p = i.geometry as GeoJsonMultiPoint;
print("lat is ${p.geoSerie!.geoPoints[0].latitude} and lon is ${p.geoSerie!.geoPoints[0].longitude}");
return Marker(
anchorPos: AnchorPos.exactly(Anchor(108.0, 18.0)),
height: 32.0,
width: 120.0,
point: LatLng(p.geoSerie!.geoPoints[0].latitude, p.geoSerie!.geoPoints[0].longitude),
builder: (ctx){
return getMarkerShape(i, context);
},
);
}).toList(),
children: [
Obx(() => indexController.isLoading.value == true
? const Padding(
padding: EdgeInsets.only(top: 60.0),
child: CircularProgressIndicator(),
)
: FlutterMap(
mapController: mapController,
//mapController: indexController.mapController,
options: MapOptions(
maxZoom: 18.4,
onMapReady: () {
_initMarkers();
//indexController.isMapControllerReady.value = true;
},
initialCenter:
const LatLng(37.15319600454702, 139.58765950528198),
bounds: indexController.currentBound.isNotEmpty
? indexController.currentBound[0]
: LatLngBounds.fromPoints([
const LatLng(35.03999881162295, 136.40587119778962),
const LatLng(36.642756778706904, 137.95226720406063)
]),
initialZoom: 1,
interactiveFlags:
InteractiveFlag.pinchZoom | InteractiveFlag.drag,
onPositionChanged: (MapPosition pos, hasGesture) {
if (hasGesture) {
_resetTimer();
}
indexController.currentBound = [pos.bounds!];
},
onMapEvent: (MapEvent mapEvent) {
//debugPrint('Map event: ${mapEvent.runtimeType}');
if (mapEvent is MapEventMove) {
destinationController.shouldShowBottomSheet = true;
}
},
//onTap: (_, __) => popupController.hideAllPopups(),
),
children: [
const BaseLayer(),
// ルートのポリライン表示
Obx(
() => indexController.routePointLenght > 0
? PolylineLayer(
polylines: [
Polyline(
points: getPoints()!,
strokeWidth: 6.0,
color: Colors.indigo,
),
],
)
:
const Center(child: CircularProgressIndicator())
,
: Container(),
),
// 現在位置のマーカー
CurrentLocationLayer(
positionStream: locationController
.locationMarkerPositionStreamController.stream,
//alignDirectionOnUpdate: AlignOnUpdate.never,
style: const LocationMarkerStyle(
marker: Stack(
children: [
CircleAvatar(
radius: 13.5,
backgroundColor: Colors.blue,
child: Icon(Icons.navigation, color: Colors.white),
),
],
)
)
],
);
),
markerSize: Size(27, 27),
markerDirection: MarkerDirection.heading,
),
//child: const Icon(Icons.navigation),
),
FutureBuilder<List<Marker>>(
future: indexController.locations.isNotEmpty ? _getMarkers() : null,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator());
} else if (snapshot.hasError) {
return const Center(child: Text('マーカーの読み込みに失敗しました'));
} else {
return MarkerLayer(markers: snapshot.data ?? []);
}
},
),
//MarkerLayer(markers: indexController.locations.isNotEmpty ? _getMarkers() : []),
],
)),
const Positioned(top: 0, left: 0, child: GameStateWidget()),
const Positioned(bottom: 10, right: 10, child: CurrentPosition()),
StreamBuilder<LocationMarkerPosition?>(
stream: locationController.locationMarkerPositionStream,
builder: (context, snapshot) {
if (!snapshot.hasData) {
//debugPrint("====== Not display current marker");
curr_marker_display = true;
}else if(curr_marker_display){
debugPrint("====== Displayed current marker");
curr_marker_display = false;
}
return Container();
},
)
],
);
}
}
}

View File

@ -1,237 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:get/get.dart';
import 'package:rogapp/pages/index/index_controller.dart';
class PerfectureWidget extends StatefulWidget {
IndexController indexController;
MapController mapController;
PerfectureWidget({Key? key, required this.indexController, required this.mapController}) : super(key: key){
//indexController.zoomtoMainPerf("9", mapController);
}
@override
State<PerfectureWidget> createState() => _PerfectureWidgetState();
}
class _PerfectureWidgetState extends State<PerfectureWidget> {
@override
void initState() {
super.initState();
}
bool isNumeric(String s) {
if (s == null) {
return false;
}
return double.tryParse(s) != null;
}
List<DropdownMenuItem<String>> getDropdownItems() {
List<DropdownMenuItem<String>> dropDownItems = [];
for (Map<String, dynamic> currency in widget.indexController.perfectures[0]) {
//print(currency["id"].toString());
var newDropdown = DropdownMenuItem(
value: currency["id"].toString(),
child: Text(currency["adm1_ja"].toString()),
);
dropDownItems.add(newDropdown);
}
return dropDownItems;
}
List<DropdownMenuItem<String>> getSubDropdownItems() {
List<DropdownMenuItem<String>> dropDownItems = [];
if(widget.indexController.subPerfs.isNotEmpty){
for (Map<String, dynamic> currency in widget.indexController.subPerfs[0]) {
var newDropdown = DropdownMenuItem(
value: currency["id"].toString(),
child: Text(currency["adm2_ja"].toString()),
);
dropDownItems.add(newDropdown);
}
}
return dropDownItems;
}
List<DropdownMenuItem<String>> getCustomArea(){
List<DropdownMenuItem<String>> dropDownItems = [];
if(widget.indexController.areas.isNotEmpty){
for (Map<String, dynamic> currency in widget.indexController.areas[0]) {
var newDropdown = DropdownMenuItem(
value: currency["id"].toString(),
child: Text(currency["area_nm"].toString()),
);
dropDownItems.add(newDropdown);
}
}
if(widget.indexController.customAreas.isNotEmpty){
for (Map<String, dynamic> currency in widget.indexController.customAreas[0]) {
var newDropdown = DropdownMenuItem(
value: currency["event_name"].toString(),
child: Text(currency["event_name"].toString()),
);
dropDownItems.add(newDropdown);
}
}
return dropDownItems;
}
List<DropdownMenuItem<String>> getCategory(){
List<DropdownMenuItem<String>> dropDownItems = [];
dropDownItems.clear();
//print("--------cats ------############### ${widget.indexController.cats.toString()} -------------");
for(dynamic d in widget.indexController.cats){
//print("-------- ddd ------############### ${d} --------dddd-----");
var newDropdown = DropdownMenuItem(value: d['category'].toString(), child: Text(d['category'].toString()));
//print("--------cats ------############### ${d['category'].toString()} -------------");
dropDownItems.add(newDropdown);
}
//return [];
return dropDownItems;
}
@override
Widget build(BuildContext context) {
return Obx(() =>
Row(
children: [
DropdownButton<String>(
value: widget.indexController.dropdownValue,
icon: const Icon(Icons.arrow_downward),
elevation: 16,
style: const TextStyle(color: Colors.deepPurple),
underline: Container(
height: 2,
color: Colors.deepPurpleAccent,
),
onChanged: (String? newValue) {
//setState(() {
if(newValue != null){
widget.indexController.is_loading.value = true;
widget.indexController.dropdownValue = newValue;
widget.indexController.populateForPerf(newValue, widget.mapController);
}
//});
},
items: getDropdownItems()
),
// Gifu areas
widget.indexController.areas.isNotEmpty ?
DropdownButton<String>(
value: widget.indexController.areaDropdownValue,
icon: const Icon(Icons.arrow_downward),
elevation: 16,
style: const TextStyle(color: Colors.deepPurple),
hint: const Text("select"),
underline: Container(
height: 2,
color: Colors.deepPurpleAccent,
),
onChanged: (String? newValue) {
if (isNumeric(newValue!)){
widget.indexController.is_custom_area_selected.value = false;
}
else{
widget.indexController.loadCustomLocation(newValue);
widget.indexController.is_custom_area_selected.value = true;
widget.indexController.subPerfs.clear();
widget.indexController.cats.clear();
}
setState(() {
widget.indexController.locations.clear();
widget.indexController.is_loading.value = true;
widget.indexController.areaDropdownValue = newValue;
widget.indexController.populateSubPerForArea(newValue, widget.mapController);
});
},
items: getCustomArea(),
): const Text(""),
widget.indexController.subPerfs.isNotEmpty ?
DropdownButton<String>(
value: widget.indexController.subDropdownValue,
icon: const Icon(Icons.arrow_downward),
elevation: 16,
style: const TextStyle(color: Colors.deepPurple),
hint: const Text("select"),
underline: Container(
height: 2,
color: Colors.deepPurpleAccent,
),
onChanged: (String? newValue) {
setState(() {
if(newValue != null){
//widget.indexController.is_loading.value = true;
//widget.indexController.populateForSubPerf(newValue, widget.mapController);
//widget.indexController.loadLocationforSubPerf(newValue, widget.mapController);
widget.indexController.subDropdownValue = newValue;
widget.indexController.loadCatForCity(newValue);
}
});
},
items:
getSubDropdownItems()
) :
const Text(""),
//CatWidget(indexController: widget.indexController,),
widget.indexController.cats.isNotEmpty ?
DropdownButton<String>(
value: widget.indexController.getCatText(),
icon: const Icon(Icons.arrow_downward),
elevation: 16,
style: const TextStyle(color: Colors.deepPurple),
hint: const Text("select"),
underline: Container(
height: 2,
color: Colors.deepPurpleAccent,
),
onChanged: (String? newValue) {
setState(() {
if(newValue != null){
widget.indexController.is_loading.value = true;
widget.indexController.cateogory = newValue;
widget.indexController.currentCat.clear();
widget.indexController.currentCat.add(newValue);
widget.indexController.populateForSubPerf(widget.indexController.subDropdownValue, widget.mapController);
//widget.indexController.loadLocationforSubPerf(newValue, widget.mapController);
//widget.indexController.subDropdownValue = newValue;
}
});
},
items:
getCategory(),
)
:
Container(),
],
),
);
}
}

View File

@ -0,0 +1,32 @@
import 'package:flutter/material.dart';
import 'package:gifunavi/pages/permission/permission.dart';
class PermissionHandlerScreen extends StatefulWidget {
const PermissionHandlerScreen({super.key});
@override
_PermissionHandlerScreenState createState() => _PermissionHandlerScreenState();
}
class _PermissionHandlerScreenState extends State<PermissionHandlerScreen> {
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) async {
await PermissionController.checkAndRequestPermissions();
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('権限の確認'),
),
body: const Center(
child: Text('権限の確認中...'),
),
);
}
}