Compare commits
32 Commits
static_sta
...
next
| Author | SHA1 | Date | |
|---|---|---|---|
| edbf52825b | |||
| dd36ab8399 | |||
| b37a33bc2f | |||
| e35608651b | |||
| c6eb97bbb2 | |||
| cb3a843566 | |||
| f5922d9034 | |||
| 1414d370f4 | |||
| e30c5f255c | |||
| e6a7d37519 | |||
| 2f329669e9 | |||
| 773650be82 | |||
| cd258744fc | |||
| eaee1ce820 | |||
| d7ff309c09 | |||
| d55ba7cfdb | |||
| 992f9f3414 | |||
| c3cb6d758c | |||
| cfa9e055f5 | |||
| 494b27bf9e | |||
| eda5f77e2d | |||
| b9e4df069f | |||
| 2fb095bd50 | |||
| 591b6f7aed | |||
| 8e050267e1 | |||
| c95cb75934 | |||
| 0b5ce75d6c | |||
| c67914f286 | |||
| 9145e0e27d | |||
| 445c53d21b | |||
| 56c07852f9 | |||
| fa0587178f |
@ -33,7 +33,7 @@ if (keystorePropertiesFile.exists()) {
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
|
|
||||||
compileSdkVersion 33
|
compileSdkVersion 34
|
||||||
|
|
||||||
lintOptions {
|
lintOptions {
|
||||||
checkReleaseBuilds false
|
checkReleaseBuilds false
|
||||||
|
|||||||
@ -21,6 +21,6 @@
|
|||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1.0</string>
|
<string>1.0</string>
|
||||||
<key>MinimumOSVersion</key>
|
<key>MinimumOSVersion</key>
|
||||||
<string>11.0</string>
|
<string>12.0</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
# Uncomment this line to define a global platform for your project
|
# Uncomment this line to define a global platform for your project
|
||||||
# platform :ios, '11.0'
|
# platform :ios, '12.0'
|
||||||
|
|
||||||
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
|
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
|
||||||
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
|
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
|
||||||
|
|||||||
@ -12,10 +12,10 @@ PODS:
|
|||||||
- FMDB (2.7.5):
|
- FMDB (2.7.5):
|
||||||
- FMDB/standard (= 2.7.5)
|
- FMDB/standard (= 2.7.5)
|
||||||
- FMDB/standard (2.7.5)
|
- FMDB/standard (2.7.5)
|
||||||
- gallery_saver (0.0.1):
|
|
||||||
- Flutter
|
|
||||||
- geolocator_apple (1.2.0):
|
- geolocator_apple (1.2.0):
|
||||||
- Flutter
|
- Flutter
|
||||||
|
- image_gallery_saver (2.0.2):
|
||||||
|
- Flutter
|
||||||
- image_picker_ios (0.0.1):
|
- image_picker_ios (0.0.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
- isar_flutter_libs (1.0.0):
|
- isar_flutter_libs (1.0.0):
|
||||||
@ -25,6 +25,8 @@ PODS:
|
|||||||
- FlutterMacOS
|
- FlutterMacOS
|
||||||
- permission_handler_apple (9.1.1):
|
- permission_handler_apple (9.1.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
|
- pointer_interceptor_ios (0.0.1):
|
||||||
|
- Flutter
|
||||||
- ReachabilitySwift (5.0.0)
|
- ReachabilitySwift (5.0.0)
|
||||||
- shared_preferences_foundation (0.0.1):
|
- shared_preferences_foundation (0.0.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
@ -41,12 +43,13 @@ DEPENDENCIES:
|
|||||||
- Flutter (from `Flutter`)
|
- Flutter (from `Flutter`)
|
||||||
- flutter_compass (from `.symlinks/plugins/flutter_compass/ios`)
|
- flutter_compass (from `.symlinks/plugins/flutter_compass/ios`)
|
||||||
- flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`)
|
- flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`)
|
||||||
- gallery_saver (from `.symlinks/plugins/gallery_saver/ios`)
|
|
||||||
- geolocator_apple (from `.symlinks/plugins/geolocator_apple/ios`)
|
- geolocator_apple (from `.symlinks/plugins/geolocator_apple/ios`)
|
||||||
|
- image_gallery_saver (from `.symlinks/plugins/image_gallery_saver/ios`)
|
||||||
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
|
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
|
||||||
- isar_flutter_libs (from `.symlinks/plugins/isar_flutter_libs/ios`)
|
- isar_flutter_libs (from `.symlinks/plugins/isar_flutter_libs/ios`)
|
||||||
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
|
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
|
||||||
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
|
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
|
||||||
|
- pointer_interceptor_ios (from `.symlinks/plugins/pointer_interceptor_ios/ios`)
|
||||||
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
|
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
|
||||||
- sqflite (from `.symlinks/plugins/sqflite/ios`)
|
- sqflite (from `.symlinks/plugins/sqflite/ios`)
|
||||||
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
|
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
|
||||||
@ -67,10 +70,10 @@ EXTERNAL SOURCES:
|
|||||||
:path: ".symlinks/plugins/flutter_compass/ios"
|
:path: ".symlinks/plugins/flutter_compass/ios"
|
||||||
flutter_keyboard_visibility:
|
flutter_keyboard_visibility:
|
||||||
:path: ".symlinks/plugins/flutter_keyboard_visibility/ios"
|
:path: ".symlinks/plugins/flutter_keyboard_visibility/ios"
|
||||||
gallery_saver:
|
|
||||||
:path: ".symlinks/plugins/gallery_saver/ios"
|
|
||||||
geolocator_apple:
|
geolocator_apple:
|
||||||
:path: ".symlinks/plugins/geolocator_apple/ios"
|
:path: ".symlinks/plugins/geolocator_apple/ios"
|
||||||
|
image_gallery_saver:
|
||||||
|
:path: ".symlinks/plugins/image_gallery_saver/ios"
|
||||||
image_picker_ios:
|
image_picker_ios:
|
||||||
:path: ".symlinks/plugins/image_picker_ios/ios"
|
:path: ".symlinks/plugins/image_picker_ios/ios"
|
||||||
isar_flutter_libs:
|
isar_flutter_libs:
|
||||||
@ -79,6 +82,8 @@ EXTERNAL SOURCES:
|
|||||||
:path: ".symlinks/plugins/path_provider_foundation/darwin"
|
:path: ".symlinks/plugins/path_provider_foundation/darwin"
|
||||||
permission_handler_apple:
|
permission_handler_apple:
|
||||||
:path: ".symlinks/plugins/permission_handler_apple/ios"
|
:path: ".symlinks/plugins/permission_handler_apple/ios"
|
||||||
|
pointer_interceptor_ios:
|
||||||
|
:path: ".symlinks/plugins/pointer_interceptor_ios/ios"
|
||||||
shared_preferences_foundation:
|
shared_preferences_foundation:
|
||||||
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
|
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
|
||||||
sqflite:
|
sqflite:
|
||||||
@ -87,23 +92,24 @@ EXTERNAL SOURCES:
|
|||||||
:path: ".symlinks/plugins/url_launcher_ios/ios"
|
:path: ".symlinks/plugins/url_launcher_ios/ios"
|
||||||
|
|
||||||
SPEC CHECKSUMS:
|
SPEC CHECKSUMS:
|
||||||
camera_avfoundation: 3125e8cd1a4387f6f31c6c63abb8a55892a9eeeb
|
camera_avfoundation: 759172d1a77ae7be0de08fc104cfb79738b8a59e
|
||||||
connectivity_plus: 07c49e96d7fc92bc9920617b83238c4d178b446a
|
connectivity_plus: bf0076dd84a130856aa636df1c71ccaff908fa1d
|
||||||
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
|
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
|
||||||
flutter_compass: cbbd285cea1584c7ac9c4e0c3e1f17cbea55e855
|
flutter_compass: cbbd285cea1584c7ac9c4e0c3e1f17cbea55e855
|
||||||
flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069
|
flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069
|
||||||
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
|
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
|
||||||
gallery_saver: 9fc173c9f4fcc48af53b2a9ebea1b643255be542
|
geolocator_apple: 9157311f654584b9bb72686c55fc02a97b73f461
|
||||||
geolocator_apple: cc556e6844d508c95df1e87e3ea6fa4e58c50401
|
image_gallery_saver: cb43cc43141711190510e92c460eb1655cd343cb
|
||||||
image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5
|
image_picker_ios: 99dfe1854b4fa34d0364e74a78448a0151025425
|
||||||
isar_flutter_libs: b69f437aeab9c521821c3f376198c4371fa21073
|
isar_flutter_libs: b69f437aeab9c521821c3f376198c4371fa21073
|
||||||
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
|
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
|
||||||
permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6
|
permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6
|
||||||
|
pointer_interceptor_ios: 9280618c0b2eeb80081a343924aa8ad756c21375
|
||||||
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
|
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
|
||||||
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
|
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
|
||||||
sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a
|
sqflite: 50a33e1d72bd59ee092a519a35d107502757ebed
|
||||||
url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4
|
url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812
|
||||||
|
|
||||||
PODFILE CHECKSUM: a1c2f8dde3796ecc1697a15e7c75eb5205d8a740
|
PODFILE CHECKSUM: fd4b34215e7c57e79d347e509d4d64bfebe797fc
|
||||||
|
|
||||||
COCOAPODS: 1.12.1
|
COCOAPODS: 1.12.1
|
||||||
|
|||||||
@ -155,7 +155,7 @@
|
|||||||
97C146E61CF9000F007C117D /* Project object */ = {
|
97C146E61CF9000F007C117D /* Project object */ = {
|
||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
attributes = {
|
attributes = {
|
||||||
LastUpgradeCheck = 1430;
|
LastUpgradeCheck = 1510;
|
||||||
ORGANIZATIONNAME = "";
|
ORGANIZATIONNAME = "";
|
||||||
TargetAttributes = {
|
TargetAttributes = {
|
||||||
97C146ED1CF9000F007C117D = {
|
97C146ED1CF9000F007C117D = {
|
||||||
@ -342,7 +342,7 @@
|
|||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
@ -358,6 +358,8 @@
|
|||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||||
DEVELOPMENT_TEAM = ECMVJVB7LV;
|
DEVELOPMENT_TEAM = ECMVJVB7LV;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
@ -369,6 +371,7 @@
|
|||||||
);
|
);
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.dvox.gifunavi;
|
PRODUCT_BUNDLE_IDENTIFIER = com.dvox.gifunavi;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
VERSIONING_SYSTEM = "apple-generic";
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
@ -422,7 +425,7 @@
|
|||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||||
MTL_ENABLE_DEBUG_INFO = YES;
|
MTL_ENABLE_DEBUG_INFO = YES;
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
@ -471,7 +474,7 @@
|
|||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
@ -489,6 +492,8 @@
|
|||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||||
DEVELOPMENT_TEAM = ECMVJVB7LV;
|
DEVELOPMENT_TEAM = ECMVJVB7LV;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
@ -500,6 +505,7 @@
|
|||||||
);
|
);
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.dvox.gifunavi;
|
PRODUCT_BUNDLE_IDENTIFIER = com.dvox.gifunavi;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
@ -513,6 +519,8 @@
|
|||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||||
DEVELOPMENT_TEAM = ECMVJVB7LV;
|
DEVELOPMENT_TEAM = ECMVJVB7LV;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
@ -524,6 +532,7 @@
|
|||||||
);
|
);
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.dvox.gifunavi;
|
PRODUCT_BUNDLE_IDENTIFIER = com.dvox.gifunavi;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
VERSIONING_SYSTEM = "apple-generic";
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "1430"
|
LastUpgradeVersion = "1510"
|
||||||
version = "1.3">
|
version = "1.3">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
|
|||||||
71
lib/features/auth/login/login_page.dart
Normal file
71
lib/features/auth/login/login_page.dart
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:rogapp/features/home/home_page.dart';
|
||||||
|
import 'package:rogapp/features/services/auth_repo.dart';
|
||||||
|
import 'package:rogapp/features/state/user_state.dart';
|
||||||
|
|
||||||
|
class LoginPage extends ConsumerStatefulWidget {
|
||||||
|
@override
|
||||||
|
_LoginScreenState createState() => _LoginScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LoginScreenState extends ConsumerState<LoginPage> {
|
||||||
|
final TextEditingController _emailController = TextEditingController();
|
||||||
|
final TextEditingController _passwordController = TextEditingController();
|
||||||
|
bool _isLoading = false; // Track loading state
|
||||||
|
|
||||||
|
void _login() {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = true; // Start loading
|
||||||
|
});
|
||||||
|
String email = _emailController.text.trim();
|
||||||
|
String password = _passwordController.text;
|
||||||
|
|
||||||
|
ref.read(authProvider("$email|$password").future).then((user) {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false; // Stop loading
|
||||||
|
});
|
||||||
|
if (user != null) {
|
||||||
|
ref.read(userNotifierProvider.notifier).setUser(user);
|
||||||
|
Navigator.of(context).pushReplacement(MaterialPageRoute(
|
||||||
|
builder: (context) => const HomePage(),
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
ScaffoldMessenger.of(context)
|
||||||
|
.showSnackBar(const SnackBar(content: Text('Login failed')));
|
||||||
|
}
|
||||||
|
}).catchError((error) {
|
||||||
|
ScaffoldMessenger.of(context)
|
||||||
|
.showSnackBar(SnackBar(content: Text('Error: $error')));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(title: const Text('Login')),
|
||||||
|
body: Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
TextFormField(
|
||||||
|
controller: _emailController,
|
||||||
|
decoration: const InputDecoration(labelText: 'Email'),
|
||||||
|
),
|
||||||
|
TextFormField(
|
||||||
|
controller: _passwordController,
|
||||||
|
decoration: const InputDecoration(labelText: 'Password'),
|
||||||
|
obscureText: true,
|
||||||
|
),
|
||||||
|
_isLoading
|
||||||
|
? CircularProgressIndicator()
|
||||||
|
: ElevatedButton(
|
||||||
|
onPressed: _login,
|
||||||
|
child: const Text('Login'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
397
lib/features/data/checkpoint.dart
Normal file
397
lib/features/data/checkpoint.dart
Normal file
@ -0,0 +1,397 @@
|
|||||||
|
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
class FeatureCollection {
|
||||||
|
final String type;
|
||||||
|
final List<Feature> features;
|
||||||
|
|
||||||
|
FeatureCollection({required this.type, required this.features});
|
||||||
|
|
||||||
|
factory FeatureCollection.fromJson(Map<String, dynamic> json) {
|
||||||
|
return FeatureCollection(
|
||||||
|
type: json['type'],
|
||||||
|
features:
|
||||||
|
List<Feature>.from(json['features'].map((x) => Feature.fromJson(x))),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Feature {
|
||||||
|
final int id;
|
||||||
|
final String type;
|
||||||
|
final Geometry geometry;
|
||||||
|
final Properties properties;
|
||||||
|
|
||||||
|
Feature(
|
||||||
|
{required this.id,
|
||||||
|
required this.type,
|
||||||
|
required this.geometry,
|
||||||
|
required this.properties});
|
||||||
|
|
||||||
|
factory Feature.fromJson(Map<String, dynamic> json) {
|
||||||
|
return Feature(
|
||||||
|
id: json['id'],
|
||||||
|
type: json['type'],
|
||||||
|
geometry: Geometry.fromJson(json['geometry']),
|
||||||
|
properties: Properties.fromJson(json['properties']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String toJson() => json.encode(toMap());
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() {
|
||||||
|
return {
|
||||||
|
'id': id,
|
||||||
|
'type': type,
|
||||||
|
'geometry': geometry.toMap(), // Assuming Geometry has a toMap method
|
||||||
|
'properties':
|
||||||
|
properties.toMap(), // Assuming Properties has a toMap method
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
Feature.fromMap(Map<String, dynamic> map)
|
||||||
|
: id = map['id'],
|
||||||
|
type = map['type'],
|
||||||
|
geometry = Geometry.fromMap(map['geometry']),
|
||||||
|
properties = Properties.fromJson(map['properties']);
|
||||||
|
|
||||||
|
static empty() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Geometry {
|
||||||
|
final String type;
|
||||||
|
final List<List<double>> coordinates;
|
||||||
|
|
||||||
|
Geometry({required this.type, required this.coordinates});
|
||||||
|
|
||||||
|
Geometry copyWith({
|
||||||
|
String? type,
|
||||||
|
List<List<double>>? coordinates,
|
||||||
|
}) {
|
||||||
|
return Geometry(
|
||||||
|
type: type ?? this.type,
|
||||||
|
coordinates: coordinates ?? this.coordinates,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() {
|
||||||
|
return <String, dynamic>{
|
||||||
|
'type': type,
|
||||||
|
'coordinates': coordinates,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
factory Geometry.fromMap(Map<String, dynamic> map) {
|
||||||
|
return Geometry(
|
||||||
|
type: map['type'] as String,
|
||||||
|
coordinates: List<List<double>>.from(
|
||||||
|
(map['coordinates'] as List<dynamic>).map<List<double>>(
|
||||||
|
(coordinateList) {
|
||||||
|
// Ensure 'coordinateList' is treated as a List of dynamic elements.
|
||||||
|
// Then, for each element in the list, explicitly cast or convert it to double.
|
||||||
|
return List<double>.from(coordinateList.map((coordinate) {
|
||||||
|
// 'coordinate' is dynamic, needs explicit conversion to double.
|
||||||
|
// The conversion depends on the original data type of 'coordinate';
|
||||||
|
// if it's already a number, you can use .toDouble(); if it's a String, you might need double.parse.
|
||||||
|
return double.parse(coordinate.toString());
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String toJson() => json.encode(toMap());
|
||||||
|
|
||||||
|
factory Geometry.fromJson(Map<String, dynamic> source) {
|
||||||
|
final geom = Geometry.fromMap(source);
|
||||||
|
return geom;
|
||||||
|
}
|
||||||
|
|
||||||
|
get latitude => coordinates[0][1];
|
||||||
|
get longitude => coordinates[0][0];
|
||||||
|
}
|
||||||
|
|
||||||
|
class Properties {
|
||||||
|
// Include all properties fields
|
||||||
|
final int locationId;
|
||||||
|
final String subLocId;
|
||||||
|
final double cp;
|
||||||
|
final String? name;
|
||||||
|
final String? address;
|
||||||
|
final String? phone;
|
||||||
|
final String? email;
|
||||||
|
final String? webcontents;
|
||||||
|
final String? videos;
|
||||||
|
final String? category;
|
||||||
|
final int? series;
|
||||||
|
final double? lat;
|
||||||
|
final double? lon;
|
||||||
|
final int? listOrder;
|
||||||
|
final String? photos;
|
||||||
|
final double? checkinRadious;
|
||||||
|
final bool? autoCheckin;
|
||||||
|
bool? selected = false;
|
||||||
|
bool? checkedin = false;
|
||||||
|
final double? checkinPoint;
|
||||||
|
final double? buyPoint;
|
||||||
|
final bool? hiddenLocation;
|
||||||
|
String? checkinImage;
|
||||||
|
String? buypointImage;
|
||||||
|
bool? forcedCheckin = false;
|
||||||
|
final String? tags;
|
||||||
|
|
||||||
|
Properties(
|
||||||
|
{required this.locationId,
|
||||||
|
required this.subLocId,
|
||||||
|
required this.cp,
|
||||||
|
this.name,
|
||||||
|
this.address,
|
||||||
|
this.phone,
|
||||||
|
this.email,
|
||||||
|
this.webcontents,
|
||||||
|
this.videos,
|
||||||
|
this.category,
|
||||||
|
this.series,
|
||||||
|
this.lat,
|
||||||
|
this.lon,
|
||||||
|
this.listOrder,
|
||||||
|
this.photos,
|
||||||
|
this.checkinRadious,
|
||||||
|
this.autoCheckin,
|
||||||
|
this.selected,
|
||||||
|
this.checkedin,
|
||||||
|
this.checkinPoint,
|
||||||
|
this.buyPoint,
|
||||||
|
this.hiddenLocation,
|
||||||
|
this.checkinImage,
|
||||||
|
this.buypointImage,
|
||||||
|
this.forcedCheckin,
|
||||||
|
this.tags});
|
||||||
|
|
||||||
|
factory Properties.fromJson(Map<String, dynamic> json) {
|
||||||
|
Properties prop;
|
||||||
|
try {
|
||||||
|
prop = Properties(
|
||||||
|
locationId: json['location_id'],
|
||||||
|
subLocId: json['sub_loc_id'],
|
||||||
|
cp: json['cp'],
|
||||||
|
name: json['name'] ?? '',
|
||||||
|
address: json['address'] ?? '',
|
||||||
|
phone: json['phone'] ?? '',
|
||||||
|
email: json['email'] ?? '',
|
||||||
|
webcontents: json['webcontents'] ?? '',
|
||||||
|
videos: json['videos'] ?? '',
|
||||||
|
category: json['category'] ?? '',
|
||||||
|
series: json['series'] ?? 0,
|
||||||
|
lat: json['lat'] ?? 0.0,
|
||||||
|
lon: json['lon'] ?? 0.0,
|
||||||
|
listOrder: json['list_order'] ?? 0,
|
||||||
|
photos: json['photos'] ?? '',
|
||||||
|
checkinRadious: json['checkin_radious'] ?? 0.0,
|
||||||
|
autoCheckin: json['auto_checkin'] == 0 ? false : true,
|
||||||
|
selected: json['selected'] == 0 ? false : true,
|
||||||
|
checkedin: json['checkedin'] == 0 ? false : true,
|
||||||
|
checkinPoint: json['checkin_point'] ?? 0.0,
|
||||||
|
buyPoint: json['buy_point'] ?? 0.0,
|
||||||
|
hiddenLocation: json['hidden_location'] == 0 ? false : true,
|
||||||
|
checkinImage: json['checkin_image'] ?? '',
|
||||||
|
buypointImage: json['buypoint_image'] ?? '',
|
||||||
|
forcedCheckin: json['forced_checkin'] == 0 ? false : true,
|
||||||
|
tags: json['tags'] ?? '');
|
||||||
|
//print("from json --- $prop");
|
||||||
|
} catch (e) {
|
||||||
|
//print("from json --- $e");
|
||||||
|
return Properties(locationId: 0, subLocId: '', cp: 0.0, name: '');
|
||||||
|
}
|
||||||
|
return prop;
|
||||||
|
}
|
||||||
|
|
||||||
|
factory Properties.toJson(Properties prop) {
|
||||||
|
return Properties(
|
||||||
|
locationId: prop.locationId,
|
||||||
|
subLocId: prop.subLocId,
|
||||||
|
cp: prop.cp,
|
||||||
|
name: prop.name,
|
||||||
|
address: prop.address,
|
||||||
|
phone: prop.phone,
|
||||||
|
email: prop.email,
|
||||||
|
webcontents: prop.webcontents,
|
||||||
|
videos: prop.videos,
|
||||||
|
category: prop.category,
|
||||||
|
series: prop.series,
|
||||||
|
lat: prop.lat,
|
||||||
|
lon: prop.lon,
|
||||||
|
listOrder: prop.listOrder,
|
||||||
|
photos: prop.photos,
|
||||||
|
checkinRadious: prop.checkinRadious,
|
||||||
|
autoCheckin: prop.autoCheckin,
|
||||||
|
selected: prop.selected,
|
||||||
|
checkedin: prop.checkedin,
|
||||||
|
checkinPoint: prop.checkinPoint,
|
||||||
|
buyPoint: prop.buyPoint,
|
||||||
|
hiddenLocation: prop.hiddenLocation,
|
||||||
|
checkinImage: prop.checkinImage,
|
||||||
|
buypointImage: prop.buypointImage,
|
||||||
|
forcedCheckin: prop.forcedCheckin,
|
||||||
|
tags: prop.tags);
|
||||||
|
}
|
||||||
|
|
||||||
|
Properties copyWith({
|
||||||
|
int? locationId,
|
||||||
|
String? subLocId,
|
||||||
|
double? cp,
|
||||||
|
String? name,
|
||||||
|
String? address,
|
||||||
|
String? phone,
|
||||||
|
String? email,
|
||||||
|
String? webcontents,
|
||||||
|
String? videos,
|
||||||
|
String? category,
|
||||||
|
int? series,
|
||||||
|
double? lat,
|
||||||
|
double? lon,
|
||||||
|
int? listOrder,
|
||||||
|
String? photos,
|
||||||
|
double? checkinRadious,
|
||||||
|
bool? autoCheckin,
|
||||||
|
bool? selected,
|
||||||
|
bool? checkedin,
|
||||||
|
double? checkinPoint,
|
||||||
|
double? buyPoint,
|
||||||
|
bool? hiddenLocation,
|
||||||
|
String? checkinImage,
|
||||||
|
String? buypointImage,
|
||||||
|
bool? forcedCheckin,
|
||||||
|
String? tags,
|
||||||
|
}) {
|
||||||
|
return Properties(
|
||||||
|
locationId: locationId ?? this.locationId,
|
||||||
|
subLocId: subLocId ?? this.subLocId,
|
||||||
|
cp: cp ?? this.cp,
|
||||||
|
name: name ?? this.name,
|
||||||
|
address: address ?? this.address,
|
||||||
|
phone: phone ?? this.phone,
|
||||||
|
email: email ?? this.email,
|
||||||
|
webcontents: webcontents ?? this.webcontents,
|
||||||
|
videos: videos ?? this.videos,
|
||||||
|
category: category ?? this.category,
|
||||||
|
series: series ?? this.series,
|
||||||
|
lat: lat ?? this.lat,
|
||||||
|
lon: lon ?? this.lon,
|
||||||
|
listOrder: listOrder ?? this.listOrder,
|
||||||
|
photos: photos ?? this.photos,
|
||||||
|
checkinRadious: checkinRadious ?? this.checkinRadious,
|
||||||
|
autoCheckin: autoCheckin ?? this.autoCheckin,
|
||||||
|
selected: selected ?? this.selected,
|
||||||
|
checkedin: checkedin ?? this.checkedin,
|
||||||
|
checkinPoint: checkinPoint ?? this.checkinPoint,
|
||||||
|
buyPoint: buyPoint ?? this.buyPoint,
|
||||||
|
hiddenLocation: hiddenLocation ?? this.hiddenLocation,
|
||||||
|
checkinImage: checkinImage ?? this.checkinImage,
|
||||||
|
buypointImage: buypointImage ?? this.buypointImage,
|
||||||
|
forcedCheckin: forcedCheckin ?? this.forcedCheckin,
|
||||||
|
tags: tags ?? this.tags,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() {
|
||||||
|
return <String, dynamic>{
|
||||||
|
'locationId': locationId,
|
||||||
|
'subLocId': subLocId,
|
||||||
|
'cp': cp,
|
||||||
|
'name': name,
|
||||||
|
'address': address,
|
||||||
|
'phone': phone,
|
||||||
|
'email': email,
|
||||||
|
'webcontents': webcontents,
|
||||||
|
'videos': videos,
|
||||||
|
'category': category,
|
||||||
|
'series': series,
|
||||||
|
'lat': lat,
|
||||||
|
'lon': lon,
|
||||||
|
'listOrder': listOrder,
|
||||||
|
'photos': photos,
|
||||||
|
'checkinRadious': checkinRadious,
|
||||||
|
'autoCheckin': autoCheckin,
|
||||||
|
'selected': selected,
|
||||||
|
'checkedin': checkedin,
|
||||||
|
'checkinPoint': checkinPoint,
|
||||||
|
'buyPoint': buyPoint,
|
||||||
|
'hiddenLocation': hiddenLocation,
|
||||||
|
'checkinImage': checkinImage,
|
||||||
|
'buypointImage': buypointImage,
|
||||||
|
'forcedCheckin': forcedCheckin,
|
||||||
|
'tags': tags,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
String toJson() => json.encode(toMap());
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'Properties(locationId: $locationId, subLocId: $subLocId, cp: $cp, name: $name, address: $address, phone: $phone, email: $email, webcontents: $webcontents, videos: $videos, category: $category, series: $series, lat: $lat, lon: $lon, listOrder: $listOrder, photos: $photos, checkinRadious: $checkinRadious, autoCheckin: $autoCheckin, selected: $selected, checkedin: $checkedin, checkinPoint: $checkinPoint, buyPoint: $buyPoint, hiddenLocation: $hiddenLocation, checkinImage: $checkinImage, buypointImage: $buypointImage, forcedCheckin: $forcedCheckin, tags: $tags)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(covariant Properties other) {
|
||||||
|
if (identical(this, other)) return true;
|
||||||
|
|
||||||
|
return other.locationId == locationId &&
|
||||||
|
other.subLocId == subLocId &&
|
||||||
|
other.cp == cp &&
|
||||||
|
other.name == name &&
|
||||||
|
other.address == address &&
|
||||||
|
other.phone == phone &&
|
||||||
|
other.email == email &&
|
||||||
|
other.webcontents == webcontents &&
|
||||||
|
other.videos == videos &&
|
||||||
|
other.category == category &&
|
||||||
|
other.series == series &&
|
||||||
|
other.lat == lat &&
|
||||||
|
other.lon == lon &&
|
||||||
|
other.listOrder == listOrder &&
|
||||||
|
other.photos == photos &&
|
||||||
|
other.checkinRadious == checkinRadious &&
|
||||||
|
other.autoCheckin == autoCheckin &&
|
||||||
|
other.selected == selected &&
|
||||||
|
other.checkedin == checkedin &&
|
||||||
|
other.checkinPoint == checkinPoint &&
|
||||||
|
other.buyPoint == buyPoint &&
|
||||||
|
other.hiddenLocation == hiddenLocation &&
|
||||||
|
other.checkinImage == checkinImage &&
|
||||||
|
other.buypointImage == buypointImage &&
|
||||||
|
other.forcedCheckin == forcedCheckin &&
|
||||||
|
other.tags == tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode {
|
||||||
|
return locationId.hashCode ^
|
||||||
|
subLocId.hashCode ^
|
||||||
|
cp.hashCode ^
|
||||||
|
name.hashCode ^
|
||||||
|
address.hashCode ^
|
||||||
|
phone.hashCode ^
|
||||||
|
email.hashCode ^
|
||||||
|
webcontents.hashCode ^
|
||||||
|
videos.hashCode ^
|
||||||
|
category.hashCode ^
|
||||||
|
series.hashCode ^
|
||||||
|
lat.hashCode ^
|
||||||
|
lon.hashCode ^
|
||||||
|
listOrder.hashCode ^
|
||||||
|
photos.hashCode ^
|
||||||
|
checkinRadious.hashCode ^
|
||||||
|
autoCheckin.hashCode ^
|
||||||
|
selected.hashCode ^
|
||||||
|
checkedin.hashCode ^
|
||||||
|
checkinPoint.hashCode ^
|
||||||
|
buyPoint.hashCode ^
|
||||||
|
hiddenLocation.hashCode ^
|
||||||
|
checkinImage.hashCode ^
|
||||||
|
buypointImage.hashCode ^
|
||||||
|
forcedCheckin.hashCode ^
|
||||||
|
tags.hashCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
82
lib/features/data/checkpoint_visitis.dart
Normal file
82
lib/features/data/checkpoint_visitis.dart
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
class CheckpointVisit {
|
||||||
|
final String id;
|
||||||
|
final String checkpointId;
|
||||||
|
final String teamName;
|
||||||
|
final String userName;
|
||||||
|
final String eventCode;
|
||||||
|
final DateTime visitTime;
|
||||||
|
|
||||||
|
CheckpointVisit({
|
||||||
|
required this.id,
|
||||||
|
required this.checkpointId,
|
||||||
|
required this.teamName,
|
||||||
|
required this.userName,
|
||||||
|
required this.eventCode,
|
||||||
|
required this.visitTime,
|
||||||
|
});
|
||||||
|
|
||||||
|
CheckpointVisit copyWith({
|
||||||
|
String? id,
|
||||||
|
String? checkpointId,
|
||||||
|
String? teamName,
|
||||||
|
String? userName,
|
||||||
|
String? eventCode,
|
||||||
|
DateTime? visitTime,
|
||||||
|
}) {
|
||||||
|
return CheckpointVisit(
|
||||||
|
id: id ?? this.id,
|
||||||
|
checkpointId: checkpointId ?? this.checkpointId,
|
||||||
|
teamName: teamName ?? this.teamName,
|
||||||
|
userName: userName ?? this.userName,
|
||||||
|
eventCode: eventCode ?? this.eventCode,
|
||||||
|
visitTime: visitTime ?? this.visitTime,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() {
|
||||||
|
return {
|
||||||
|
'id': id,
|
||||||
|
'checkpointId': checkpointId,
|
||||||
|
'teamName': teamName,
|
||||||
|
'userName': userName,
|
||||||
|
'eventCode': eventCode,
|
||||||
|
'visitTime': visitTime.millisecondsSinceEpoch,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
factory CheckpointVisit.fromMap(Map<String, dynamic> map) {
|
||||||
|
return CheckpointVisit(
|
||||||
|
id: map['id'],
|
||||||
|
checkpointId: map['checkpointId'],
|
||||||
|
teamName: map['teamName'],
|
||||||
|
userName: map['userName'],
|
||||||
|
eventCode: map['eventCode'],
|
||||||
|
visitTime: DateTime.fromMillisecondsSinceEpoch(map['visitTime']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String toJson() => json.encode(toMap());
|
||||||
|
|
||||||
|
factory CheckpointVisit.fromJson(String source) =>
|
||||||
|
CheckpointVisit.fromMap(json.decode(source));
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'CheckpointVisit(id: $id, checkpointId: $checkpointId, teamName: $teamName, userName: $userName, eventCode: $eventCode, visitTime: $visitTime)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
if (identical(this, other)) return true;
|
||||||
|
|
||||||
|
return other is CheckpointVisit &&
|
||||||
|
other.id == id &&
|
||||||
|
other.checkpointId == checkpointId &&
|
||||||
|
other.teamName == teamName &&
|
||||||
|
other.userName == userName &&
|
||||||
|
other.eventCode == eventCode &&
|
||||||
|
other.visitTime == visitTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
329
lib/features/data/data_provider.dart
Normal file
329
lib/features/data/data_provider.dart
Normal file
@ -0,0 +1,329 @@
|
|||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:path_provider/path_provider.dart';
|
||||||
|
import 'package:sqflite/sqflite.dart';
|
||||||
|
import 'package:path/path.dart';
|
||||||
|
import 'package:rogapp/features/data/checkpoint.dart';
|
||||||
|
import 'package:rogapp/features/data/user_location.dart';
|
||||||
|
|
||||||
|
final dataProviderProvider = Provider<DataProvider>((ref) {
|
||||||
|
return DataProvider();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Convert a Feature object to a Map
|
||||||
|
Map<String, dynamic> featureToMap(Feature feature) {
|
||||||
|
var properties = feature.properties;
|
||||||
|
|
||||||
|
try {
|
||||||
|
return {
|
||||||
|
'id': feature.id,
|
||||||
|
'type': feature.type,
|
||||||
|
'name': properties.name ?? '',
|
||||||
|
'address': properties.address ?? '',
|
||||||
|
'phone': properties.phone ?? '',
|
||||||
|
'email': properties.email ?? '',
|
||||||
|
'webcontents': properties.webcontents ?? '',
|
||||||
|
'videos': properties.videos ?? '',
|
||||||
|
'category': properties.category ?? '',
|
||||||
|
'series': properties.series,
|
||||||
|
'lat': feature.geometry.latitude,
|
||||||
|
'lon': feature.geometry.longitude,
|
||||||
|
'list_order': properties.listOrder,
|
||||||
|
'photos': properties.photos ?? '',
|
||||||
|
'checkin_radious': properties.checkinRadious,
|
||||||
|
'sub_loc_id': properties.subLocId,
|
||||||
|
'auto_checkin': properties.autoCheckin! ? 1 : 0,
|
||||||
|
'selected': properties.selected == null
|
||||||
|
? 0
|
||||||
|
: properties.selected!
|
||||||
|
? 1
|
||||||
|
: 0,
|
||||||
|
'checkedin': properties.checkedin == null
|
||||||
|
? 0
|
||||||
|
: properties.checkedin!
|
||||||
|
? 1
|
||||||
|
: 0,
|
||||||
|
'cp': properties.cp,
|
||||||
|
'checkin_point': properties.checkinPoint,
|
||||||
|
'buy_point': properties.buyPoint,
|
||||||
|
'hidden_location': properties.hiddenLocation,
|
||||||
|
'checkin_image': properties.checkinImage,
|
||||||
|
'buypoint_image': properties.buypointImage,
|
||||||
|
'forced_checkin': properties.forcedCheckin == null
|
||||||
|
? 0
|
||||||
|
: properties.forcedCheckin!
|
||||||
|
? 1
|
||||||
|
: 0,
|
||||||
|
'tags': properties.tags ?? '',
|
||||||
|
'location_id': properties.locationId,
|
||||||
|
};
|
||||||
|
} catch (e) {
|
||||||
|
//print("--- feature to map Error: $e");
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert a Map to a Feature object
|
||||||
|
Feature mapToFeature(Map<String, dynamic> map) {
|
||||||
|
Feature feat;
|
||||||
|
//print("mapToFeature id --- ${Properties.fromJson(map)}");
|
||||||
|
//print("mapToFeature --- ${map['type']}");
|
||||||
|
feat = Feature(
|
||||||
|
id: map['id'],
|
||||||
|
type: map['type'],
|
||||||
|
geometry: Geometry(
|
||||||
|
type: map['type'] ?? 'Point',
|
||||||
|
coordinates: [
|
||||||
|
[map['lon'], map['lat']]
|
||||||
|
],
|
||||||
|
),
|
||||||
|
properties: Properties.fromJson(map),
|
||||||
|
);
|
||||||
|
|
||||||
|
//print("mapToFeature --- $feat");
|
||||||
|
|
||||||
|
return feat;
|
||||||
|
}
|
||||||
|
|
||||||
|
class DataProvider {
|
||||||
|
static Database? _database;
|
||||||
|
|
||||||
|
Future<Database> get database async {
|
||||||
|
if (_database != null) return _database!;
|
||||||
|
_database = await initDB();
|
||||||
|
return _database!;
|
||||||
|
}
|
||||||
|
|
||||||
|
initDB() async {
|
||||||
|
var documentsDirectory = await getApplicationDocumentsDirectory();
|
||||||
|
String path = join(documentsDirectory.path, "GameDB.db");
|
||||||
|
return await openDatabase(path,
|
||||||
|
version: 1, onOpen: (db) {}, onCreate: _onCreate);
|
||||||
|
}
|
||||||
|
|
||||||
|
_onCreate(Database db, int version) async {
|
||||||
|
await db.execute('''
|
||||||
|
CREATE TABLE Checkpoints (
|
||||||
|
location_id INTEGER PRIMARY KEY,
|
||||||
|
id INTEGER,
|
||||||
|
type TEXT,
|
||||||
|
name TEXT,
|
||||||
|
address TEXT,
|
||||||
|
phone TEXT,
|
||||||
|
email TEXT,
|
||||||
|
webcontents TEXT,
|
||||||
|
videos TEXT,
|
||||||
|
category TEXT,
|
||||||
|
series INTEGER,
|
||||||
|
lat REAL,
|
||||||
|
lon REAL,
|
||||||
|
list_order INTEGER,
|
||||||
|
photos TEXT,
|
||||||
|
checkin_radious REAL,
|
||||||
|
sub_loc_id TEXT,
|
||||||
|
auto_checkin INTEGER,
|
||||||
|
selected INTEGER,
|
||||||
|
checkedin INTEGER,
|
||||||
|
cp REAL,
|
||||||
|
checkin_point REAL,
|
||||||
|
buy_point REAL,
|
||||||
|
hidden_location INTEGER,
|
||||||
|
checkin_image TEXT,
|
||||||
|
buypoint_image TEXT,
|
||||||
|
forced_checkin INTEGER,
|
||||||
|
recipt_times INTEGER,
|
||||||
|
tags TEXT
|
||||||
|
)
|
||||||
|
''');
|
||||||
|
await db.execute('''
|
||||||
|
CREATE TABLE GPSLocations (
|
||||||
|
timestamp TEXT PRIMARY KEY,
|
||||||
|
latitude REAL,
|
||||||
|
longitude REAL,
|
||||||
|
event_code TEXT,
|
||||||
|
team_name TEXT,
|
||||||
|
user_name TEXT,
|
||||||
|
attempt_count INTEGER
|
||||||
|
)
|
||||||
|
''');
|
||||||
|
await db.execute('''
|
||||||
|
CREATE TABLE GameState (
|
||||||
|
key TEXT PRIMARY KEY,
|
||||||
|
value TEXT,
|
||||||
|
event_code TEXT,
|
||||||
|
team_name TEXT,
|
||||||
|
user_name TEXT,
|
||||||
|
attempt_count INTEGER
|
||||||
|
)
|
||||||
|
''');
|
||||||
|
await db.execute('''
|
||||||
|
CREATE TABLE CheckpointVisits (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
checkpointId INTEGER,
|
||||||
|
photoTaken BOOLEAN,
|
||||||
|
receiptPhotoTaken BOOLEAN,
|
||||||
|
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
event_code TEXT,
|
||||||
|
team_name TEXT,
|
||||||
|
user_name TEXT,
|
||||||
|
attempt_count INTEGER DEFAULT 1,
|
||||||
|
FOREIGN KEY (checkpointId) REFERENCES Checkpoints(location_id)
|
||||||
|
)
|
||||||
|
''');
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> recordCheckpointVisit(
|
||||||
|
int locationId, String userName, String teamName, String eventCode,
|
||||||
|
{bool photoTaken = false, bool? receiptPhotoTaken}) async {
|
||||||
|
final db = await database;
|
||||||
|
|
||||||
|
// Fetching buy_point to determine if a receipt is required
|
||||||
|
var checkpointQueryResult = await db.query(
|
||||||
|
'Checkpoints',
|
||||||
|
columns: ['buy_point'],
|
||||||
|
where: 'location_id = ?',
|
||||||
|
whereArgs: [locationId],
|
||||||
|
);
|
||||||
|
|
||||||
|
var buyPoint = checkpointQueryResult.isNotEmpty
|
||||||
|
? checkpointQueryResult.first['buy_point'] as double?
|
||||||
|
: null;
|
||||||
|
var requiresReceipt = buyPoint != null && buyPoint > 0.0;
|
||||||
|
|
||||||
|
await db.insert(
|
||||||
|
'CheckpointVisits',
|
||||||
|
{
|
||||||
|
'checkpointId': locationId,
|
||||||
|
'user_name': userName,
|
||||||
|
'team_name': teamName,
|
||||||
|
'event_code': eventCode,
|
||||||
|
'photoTaken': photoTaken ? 1 : 0,
|
||||||
|
'receiptPhotoTaken':
|
||||||
|
requiresReceipt ? (receiptPhotoTaken == true ? 1 : 0) : null,
|
||||||
|
},
|
||||||
|
conflictAlgorithm: ConflictAlgorithm.replace,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> getIncompleteTasks(int locationId,
|
||||||
|
String userName, String teamName, String eventCode) async {
|
||||||
|
final db = await database;
|
||||||
|
var checkpoint = await db.query(
|
||||||
|
'Checkpoints',
|
||||||
|
where: 'location_id = ?',
|
||||||
|
whereArgs: [locationId],
|
||||||
|
);
|
||||||
|
|
||||||
|
var buyPointValue =
|
||||||
|
checkpoint.isNotEmpty ? checkpoint.first['buy_point'] as double? : null;
|
||||||
|
var requiresReceipt = buyPointValue != null && buyPointValue > 0.0;
|
||||||
|
|
||||||
|
// Fetch visits considering all relevant identifiers
|
||||||
|
List<Map> visits = await db.query(
|
||||||
|
'CheckpointVisits',
|
||||||
|
where:
|
||||||
|
'checkpointId = ? AND user_name = ? AND team_name = ? AND event_code = ?',
|
||||||
|
whereArgs: [locationId, userName, teamName, eventCode],
|
||||||
|
);
|
||||||
|
|
||||||
|
if (visits.isNotEmpty) {
|
||||||
|
var lastVisit = visits.last;
|
||||||
|
return {
|
||||||
|
'photoTaken': lastVisit['photoTaken'] == 1,
|
||||||
|
'receiptPhotoTaken':
|
||||||
|
requiresReceipt ? lastVisit['receiptPhotoTaken'] == 1 : true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default return values when no visits found
|
||||||
|
return {
|
||||||
|
'photoTaken': false,
|
||||||
|
'receiptPhotoTaken': requiresReceipt ? false : true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> insertMarker(Feature marker) async {
|
||||||
|
//print("--- inserting ${featureToMap(marker)} ---");
|
||||||
|
final db = await database;
|
||||||
|
try {
|
||||||
|
await db.insert(
|
||||||
|
'Checkpoints',
|
||||||
|
featureToMap(marker),
|
||||||
|
conflictAlgorithm: ConflictAlgorithm.replace,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
print("--- ${e.toString()} ---");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<Feature>> getMarkers() async {
|
||||||
|
final db = await database;
|
||||||
|
var res = await db.query('Checkpoints');
|
||||||
|
List<Feature> list =
|
||||||
|
res.isNotEmpty ? res.map((c) => mapToFeature(c)).toList() : [];
|
||||||
|
//print("--- checkpoints ${res} ---");
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<int> deleteMarker(int id) async {
|
||||||
|
final db = await database;
|
||||||
|
return db.delete('Checkpoints', where: 'id = ?', whereArgs: [id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> insertGPSLocation(UserLocation location) async {
|
||||||
|
final db = await database;
|
||||||
|
await db.insert(
|
||||||
|
'GPSLocations',
|
||||||
|
location
|
||||||
|
.toMap(), // Implement a method in UserLocation to convert the object to a Map
|
||||||
|
conflictAlgorithm: ConflictAlgorithm.replace,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<UserLocation>> getGPSLocations() async {
|
||||||
|
final db = await database;
|
||||||
|
var res = await db.query('GPSLocations');
|
||||||
|
List<UserLocation> locations =
|
||||||
|
res.isNotEmpty ? res.map((c) => UserLocation.fromMap(c)).toList() : [];
|
||||||
|
return locations;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updateGameState(
|
||||||
|
String key,
|
||||||
|
String value,
|
||||||
|
String userName,
|
||||||
|
String teamName,
|
||||||
|
String eventCode,
|
||||||
|
) async {
|
||||||
|
final db = await database;
|
||||||
|
await db.insert(
|
||||||
|
'GameState',
|
||||||
|
{
|
||||||
|
'key': key,
|
||||||
|
'value': value,
|
||||||
|
'team_name': teamName,
|
||||||
|
'event_code': eventCode,
|
||||||
|
'user_name': userName,
|
||||||
|
},
|
||||||
|
conflictAlgorithm: ConflictAlgorithm.replace,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String?> getGameState(
|
||||||
|
String key,
|
||||||
|
String userName,
|
||||||
|
String teamName,
|
||||||
|
String eventCode,
|
||||||
|
) async {
|
||||||
|
final db = await database;
|
||||||
|
List<Map<String, dynamic>> results = await db.query(
|
||||||
|
'GameState',
|
||||||
|
where: 'key = ? AND team_name = ? AND event_code = ? AND user_name = ?',
|
||||||
|
whereArgs: [key, teamName, eventCode, userName],
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.isNotEmpty) {
|
||||||
|
return results.first['value'] as String?;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
17
lib/features/data/game_event.dart
Normal file
17
lib/features/data/game_event.dart
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
enum EventType {
|
||||||
|
atStart,
|
||||||
|
starting,
|
||||||
|
started,
|
||||||
|
inCheckin,
|
||||||
|
checkiningIn,
|
||||||
|
checkedIn,
|
||||||
|
atGoal,
|
||||||
|
finishingGoal,
|
||||||
|
finishedGoal,
|
||||||
|
}
|
||||||
|
|
||||||
|
class GameEvent {
|
||||||
|
final EventType type;
|
||||||
|
final DateTime timestamp;
|
||||||
|
GameEvent({this.type = EventType.atStart, required this.timestamp});
|
||||||
|
}
|
||||||
24
lib/features/data/user.dart
Normal file
24
lib/features/data/user.dart
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
class User {
|
||||||
|
User.User();
|
||||||
|
|
||||||
|
//AuthUser.from({required this.id, required this.email, required this.is_rogaining, required this.group, required this.zekken_number, required this.event_code, required this.team_name});
|
||||||
|
|
||||||
|
User.fromMap(Map<String, dynamic> map)
|
||||||
|
: id = int.parse(map["id"].toString()),
|
||||||
|
email = map["email"].toString(),
|
||||||
|
is_rogaining = bool.parse(map["is_rogaining"].toString()),
|
||||||
|
group = map["group"].toString(),
|
||||||
|
zekken_number = map["zekken_number"].toString(),
|
||||||
|
event_code = map["event_code"].toString(),
|
||||||
|
team_name = map["team_name"].toString(),
|
||||||
|
auth_token = map["token"];
|
||||||
|
|
||||||
|
int? id;
|
||||||
|
String? email;
|
||||||
|
bool? is_rogaining;
|
||||||
|
String? group;
|
||||||
|
String? zekken_number;
|
||||||
|
String? event_code;
|
||||||
|
String? team_name;
|
||||||
|
String? auth_token;
|
||||||
|
}
|
||||||
59
lib/features/data/user_location.dart
Normal file
59
lib/features/data/user_location.dart
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:geolocator/geolocator.dart';
|
||||||
|
|
||||||
|
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||||
|
class UserLocation {
|
||||||
|
final double latitude;
|
||||||
|
final double longitude;
|
||||||
|
final DateTime timestamp;
|
||||||
|
UserLocation(
|
||||||
|
{required this.latitude,
|
||||||
|
required this.longitude,
|
||||||
|
required this.timestamp});
|
||||||
|
|
||||||
|
static UserLocation empty() {
|
||||||
|
return UserLocation(
|
||||||
|
latitude: 0.0, longitude: 0.0, timestamp: DateTime.now());
|
||||||
|
}
|
||||||
|
|
||||||
|
factory UserLocation.fromPosition(Position position) {
|
||||||
|
return UserLocation(
|
||||||
|
latitude: position.latitude,
|
||||||
|
longitude: position.longitude,
|
||||||
|
timestamp: position.timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
UserLocation copyWith({
|
||||||
|
double? latitude,
|
||||||
|
double? longitude,
|
||||||
|
DateTime? timestamp,
|
||||||
|
}) {
|
||||||
|
return UserLocation(
|
||||||
|
latitude: latitude ?? this.latitude,
|
||||||
|
longitude: longitude ?? this.longitude,
|
||||||
|
timestamp: timestamp ?? this.timestamp,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() {
|
||||||
|
return <String, dynamic>{
|
||||||
|
'latitude': latitude,
|
||||||
|
'longitude': longitude,
|
||||||
|
'timestamp': timestamp.millisecondsSinceEpoch,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
factory UserLocation.fromMap(Map<String, dynamic> map) {
|
||||||
|
return UserLocation(
|
||||||
|
latitude: map['latitude'] as double,
|
||||||
|
longitude: map['longitude'] as double,
|
||||||
|
timestamp: DateTime.fromMillisecondsSinceEpoch(map['timestamp'] as int),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String toJson() => json.encode(toMap());
|
||||||
|
|
||||||
|
factory UserLocation.fromJson(String source) =>
|
||||||
|
UserLocation.fromMap(json.decode(source) as Map<String, dynamic>);
|
||||||
|
}
|
||||||
131
lib/features/home/home_page.dart
Normal file
131
lib/features/home/home_page.dart
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
import 'package:dio_cache_interceptor_hive_store/dio_cache_interceptor_hive_store.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_map/flutter_map.dart';
|
||||||
|
import 'package:flutter_map_cache/flutter_map_cache.dart';
|
||||||
|
import 'package:flutter_map_location_marker/flutter_map_location_marker.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:latlong2/latlong.dart';
|
||||||
|
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||||
|
import 'package:rogapp/features/location/location_provider.dart';
|
||||||
|
import 'package:rogapp/features/state/game_state.dart';
|
||||||
|
import 'package:rogapp/features/state/game_view_model.dart';
|
||||||
|
import 'package:path_provider/path_provider.dart';
|
||||||
|
|
||||||
|
class HomePage extends ConsumerStatefulWidget {
|
||||||
|
const HomePage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
ConsumerState<HomePage> createState() => _HomePageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _HomePageState extends ConsumerState<HomePage> {
|
||||||
|
MapController mapController = MapController();
|
||||||
|
String? _cachePath;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
//ref.read(featureCheckpointCollectionProvider.future);
|
||||||
|
ref.read(locationNotifierProvider.notifier).startListening();
|
||||||
|
_initializeCachePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _initializeCachePath() async {
|
||||||
|
_cachePath = await getTemporaryDirectory().then((dir) => dir.path);
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final gameState = ref.watch(gameViewModelProvider);
|
||||||
|
final locationState = ref.watch(locationNotifierProvider);
|
||||||
|
|
||||||
|
if (_cachePath == null || gameState.markers.isEmpty) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(),
|
||||||
|
body: Center(child: CircularProgressIndicator()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
actions: [
|
||||||
|
Text(
|
||||||
|
'Current Latitude: ${locationState.currentPosition?.latitude ?? 'No data'}'),
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(MdiIcons.logout),
|
||||||
|
onPressed: () => _logGameState(gameState),
|
||||||
|
),
|
||||||
|
Text(gameState.currentLocation?.latitude.toString() ??
|
||||||
|
'--- No location'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: Column(
|
||||||
|
children: [
|
||||||
|
Expanded(child: _buildMap(gameState, _cachePath!)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _logGameState(GameState gameState) {
|
||||||
|
print("Checkpoint photo taken: ${gameState.checkpointPhotoTaken}");
|
||||||
|
print("Current checkpoint: ${gameState.currentCheckpoint}");
|
||||||
|
print("Has left start area: ${gameState.hasLeftStartArea}");
|
||||||
|
print("Has visited checkpoint: ${gameState.hasVisitedCheckpoint}");
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildMap(GameState gameState, String cachePath) {
|
||||||
|
return FlutterMap(
|
||||||
|
mapController: mapController,
|
||||||
|
options: MapOptions(
|
||||||
|
interactionOptions: const InteractionOptions(
|
||||||
|
enableMultiFingerGestureRace: true,
|
||||||
|
flags: InteractiveFlag.doubleTapDragZoom |
|
||||||
|
InteractiveFlag.doubleTapZoom |
|
||||||
|
InteractiveFlag.drag |
|
||||||
|
InteractiveFlag.flingAnimation |
|
||||||
|
InteractiveFlag.pinchZoom |
|
||||||
|
InteractiveFlag.scrollWheelZoom,
|
||||||
|
),
|
||||||
|
maxZoom: 18.4,
|
||||||
|
onMapReady: () => mapController.move(LatLng(37.153196, 139.587659), 4),
|
||||||
|
),
|
||||||
|
children: [
|
||||||
|
TileLayer(
|
||||||
|
urlTemplate:
|
||||||
|
'https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png',
|
||||||
|
tileProvider: CachedTileProvider(
|
||||||
|
maxStale: Duration(days: 30),
|
||||||
|
store: HiveCacheStore(cachePath, hiveBoxName: 'HiveCacheStore'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
CurrentLocationLayer(
|
||||||
|
alignDirectionOnUpdate: AlignOnUpdate.never,
|
||||||
|
style: const LocationMarkerStyle(
|
||||||
|
marker: DefaultLocationMarker(
|
||||||
|
child: Icon(
|
||||||
|
Icons.navigation,
|
||||||
|
color: Colors.white,
|
||||||
|
size: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
markerSize: Size(27, 27),
|
||||||
|
markerDirection: MarkerDirection.heading,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
MarkerLayer(
|
||||||
|
markers: gameState.markers.map((feature) {
|
||||||
|
return Marker(
|
||||||
|
child: const Icon(Icons.location_on),
|
||||||
|
// Convert each Feature to a Marker
|
||||||
|
width: 80.0,
|
||||||
|
height: 80.0,
|
||||||
|
point:
|
||||||
|
LatLng(feature.geometry.latitude, feature.geometry.longitude),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
53
lib/features/initializer/app_initializer.dart
Normal file
53
lib/features/initializer/app_initializer.dart
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import 'package:rogapp/features/initializer/camera_check.dart';
|
||||||
|
import 'package:rogapp/features/initializer/icheck.dart';
|
||||||
|
import 'package:rogapp/features/initializer/location_check.dart';
|
||||||
|
|
||||||
|
class AppInitializer {
|
||||||
|
final List<ICheck> checks;
|
||||||
|
|
||||||
|
AppInitializer()
|
||||||
|
: checks = [
|
||||||
|
LocationCheck(),
|
||||||
|
CameraCheck(),
|
||||||
|
//NetworkCheck(),
|
||||||
|
];
|
||||||
|
|
||||||
|
Future<bool> permissionStatus() async {
|
||||||
|
return await LocationCheck().locationPermissionStatus() &&
|
||||||
|
await CameraCheck().cameraPermissionStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> initializeApp() async {
|
||||||
|
if (!await runPreFlightChecks()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//await initializeTileCaching();
|
||||||
|
await loadInitialData();
|
||||||
|
await configureGlobalSettings();
|
||||||
|
// Add other initialization tasks as needed
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> runPreFlightChecks() async {
|
||||||
|
for (var check in checks) {
|
||||||
|
if (!await check.check()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> initializeTileCaching() async {}
|
||||||
|
|
||||||
|
Future<void> loadInitialData() async {
|
||||||
|
// Logic to preload data that your app will need
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> configureGlobalSettings() async {
|
||||||
|
// Logic to set up any global configurations for your app
|
||||||
|
}
|
||||||
|
|
||||||
|
// You can add more methods for other initialization tasks
|
||||||
|
}
|
||||||
19
lib/features/initializer/camera_check.dart
Normal file
19
lib/features/initializer/camera_check.dart
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
|
import 'package:rogapp/features/initializer/icheck.dart';
|
||||||
|
|
||||||
|
class CameraCheck implements ICameraCheck {
|
||||||
|
@override
|
||||||
|
Future<bool> cameraPermissionStatus() async {
|
||||||
|
var permission = await Permission.camera.status;
|
||||||
|
return permission.isGranted;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<bool> check() async {
|
||||||
|
var permission = await Permission.camera.status;
|
||||||
|
if (!permission.isGranted) {
|
||||||
|
permission = await Permission.camera.request();
|
||||||
|
}
|
||||||
|
return permission.isGranted;
|
||||||
|
}
|
||||||
|
}
|
||||||
17
lib/features/initializer/icheck.dart
Normal file
17
lib/features/initializer/icheck.dart
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
abstract class ICheck {
|
||||||
|
Future<bool> check();
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class ILocationCheck extends ICheck {
|
||||||
|
Future<bool> locationPermissionStatus();
|
||||||
|
// Additional location-specific methods can be defined here
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class ICameraCheck extends ICheck {
|
||||||
|
Future<bool> cameraPermissionStatus();
|
||||||
|
// Additional camera-specific methods can be defined here
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class INetworkCheck extends ICheck {
|
||||||
|
// Additional network-specific methods can be defined here
|
||||||
|
}
|
||||||
19
lib/features/initializer/location_check.dart
Normal file
19
lib/features/initializer/location_check.dart
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
|
import 'package:geolocator/geolocator.dart';
|
||||||
|
import 'package:rogapp/features/initializer/icheck.dart';
|
||||||
|
|
||||||
|
class LocationCheck implements ILocationCheck {
|
||||||
|
@override
|
||||||
|
Future<bool> check() async {
|
||||||
|
var permission = await Permission.locationWhenInUse.status;
|
||||||
|
if (!permission.isGranted) {
|
||||||
|
permission = await Permission.locationWhenInUse.request();
|
||||||
|
}
|
||||||
|
return permission.isGranted && await Geolocator.isLocationServiceEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<bool> locationPermissionStatus() {
|
||||||
|
return Permission.locationWhenInUse.isGranted;
|
||||||
|
}
|
||||||
|
}
|
||||||
10
lib/features/initializer/network_check.dart
Normal file
10
lib/features/initializer/network_check.dart
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||||
|
import 'package:rogapp/features/initializer/icheck.dart';
|
||||||
|
|
||||||
|
class NetworkCheck implements INetworkCheck {
|
||||||
|
@override
|
||||||
|
Future<bool> check() async {
|
||||||
|
var connectivityResult = await Connectivity().checkConnectivity();
|
||||||
|
return connectivityResult != ConnectivityResult.none;
|
||||||
|
}
|
||||||
|
}
|
||||||
19
lib/features/landing/denied_screen.dart
Normal file
19
lib/features/landing/denied_screen.dart
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
// This screen shows when user denied and intented to close the app
|
||||||
|
|
||||||
|
class DeniedScreen extends StatefulWidget {
|
||||||
|
const DeniedScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<DeniedScreen> createState() => _DeniedScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DeniedScreenState extends State<DeniedScreen> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return const Scaffold(
|
||||||
|
body: Text("Dnied"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
172
lib/features/landing/landing_page.dart
Normal file
172
lib/features/landing/landing_page.dart
Normal file
@ -0,0 +1,172 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:rogapp/features/data/checkpoint.dart';
|
||||||
|
import 'package:rogapp/features/data/data_provider.dart';
|
||||||
|
import 'package:rogapp/features/home/home_page.dart';
|
||||||
|
import 'package:rogapp/features/landing/denied_screen.dart';
|
||||||
|
import 'package:rogapp/features/initializer/app_initializer.dart';
|
||||||
|
import 'package:rogapp/features/services/checkpoint_repo.dart';
|
||||||
|
import 'package:rogapp/features/state/game_state.dart';
|
||||||
|
import 'package:rogapp/features/state/game_view_model.dart';
|
||||||
|
|
||||||
|
// LandingPage serves as the initial screen displayed by the application to perform necessary checks, initialize required values, and set up services essential for the app's functionality.
|
||||||
|
|
||||||
|
class LandingPage extends ConsumerStatefulWidget {
|
||||||
|
const LandingPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
ConsumerState<LandingPage> createState() => _LandingPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LandingPageState extends ConsumerState<LandingPage> {
|
||||||
|
bool? _isInitialized;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
//load only if network available
|
||||||
|
ref.read(featureCheckpointCollectionProvider.future);
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
_initializeApp();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
AsyncValue<FeatureCollection> featureCollection =
|
||||||
|
ref.watch(featureCheckpointCollectionProvider);
|
||||||
|
|
||||||
|
return featureCollection.when(
|
||||||
|
data: (data) {
|
||||||
|
if (_isInitialized == null) {
|
||||||
|
return const MaterialApp(
|
||||||
|
home: Scaffold(body: Center(child: CircularProgressIndicator())));
|
||||||
|
}
|
||||||
|
|
||||||
|
return _isInitialized! ? const HomePage() : const DeniedScreen();
|
||||||
|
},
|
||||||
|
loading: () => const MaterialApp(
|
||||||
|
home: Scaffold(body: Center(child: CircularProgressIndicator()))),
|
||||||
|
error: (error, stack) => ErrorScreen(error: error),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _restoreAppState() async {
|
||||||
|
final dataProvider = ref.read(dataProviderProvider);
|
||||||
|
|
||||||
|
// Example values, replace these with actual values from user and event context
|
||||||
|
String userName =
|
||||||
|
"current_user"; // Fetch the current user's name or identifier
|
||||||
|
String teamName = "user_team"; // Fetch the current user's team
|
||||||
|
String eventCode = "event_code"; // Fetch the current event code
|
||||||
|
|
||||||
|
// Load and restore game state
|
||||||
|
String? gameStateKey = "current_game_state";
|
||||||
|
String? gameStateValue = await dataProvider.getGameState(
|
||||||
|
gameStateKey, userName, teamName, eventCode);
|
||||||
|
if (gameStateValue != null) {
|
||||||
|
Map<String, dynamic> gameStateData = jsonDecode(gameStateValue);
|
||||||
|
GameState gameState = GameState.fromMap(gameStateData);
|
||||||
|
ref.read(gameViewModelProvider.notifier).loadGameState(gameState);
|
||||||
|
}
|
||||||
|
|
||||||
|
// After restoring all necessary states, proceed with the app
|
||||||
|
setState(() {
|
||||||
|
_isInitialized = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Future<void> _restoreAppState() async {
|
||||||
|
// await _initializeApp();
|
||||||
|
// // Add additional restoration logic if needed, for example:
|
||||||
|
// // Restore game state, user progress, etc., from the DataProvider.
|
||||||
|
// // Example:
|
||||||
|
// // var gameState = await _dataProvider.getGameState('current_state');
|
||||||
|
// // Use the gameState to decide what to do next, e.g., navigate to a specific screen.
|
||||||
|
|
||||||
|
// if (_isInitialized != true) {
|
||||||
|
// // If initialization is not done, try to initialize the app.
|
||||||
|
// _isInitialized = await _initializeApp();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (!_isInitialized!) {
|
||||||
|
// await _showRetryCloseDialog();
|
||||||
|
// } else {
|
||||||
|
// setState(() {
|
||||||
|
// _isInitialized = true;
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
Future<bool> _initializeApp() async {
|
||||||
|
AppInitializer initializer = AppInitializer();
|
||||||
|
|
||||||
|
// Check if permissions are already granted
|
||||||
|
bool permissionsAlreadyGranted = await initializer.permissionStatus();
|
||||||
|
if (!permissionsAlreadyGranted) {
|
||||||
|
await _showPermissionRequestMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize the app and return the success status.
|
||||||
|
return await initializer.initializeApp();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _showPermissionRequestMessage() async {
|
||||||
|
return showDialog(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (BuildContext context) => AlertDialog(
|
||||||
|
title: const Text('Permissions Required'),
|
||||||
|
content: const Text(
|
||||||
|
'This app requires certain permissions to function properly. Please grant these permissions in the next steps.'),
|
||||||
|
actions: <Widget>[
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
child: const Text('Okay'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> _requestPermissionsAndInitialize() async {
|
||||||
|
AppInitializer initializer = AppInitializer();
|
||||||
|
return await initializer.initializeApp();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _showRetryCloseDialog() async {
|
||||||
|
await showDialog(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (BuildContext context) => AlertDialog(
|
||||||
|
title: const Text('Initialization Failed'),
|
||||||
|
content: const Text(
|
||||||
|
'The app was unable to start properly due to missing permissions.'),
|
||||||
|
actions: <Widget>[
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
child: const Text('Close'),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () async {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
bool retrySuccess = await _requestPermissionsAndInitialize();
|
||||||
|
if (!retrySuccess) {
|
||||||
|
await _showRetryCloseDialog();
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
_isInitialized = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: const Text('Retry'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorScreen({required Object error}) {}
|
||||||
|
}
|
||||||
109
lib/features/location/location_provider.dart
Normal file
109
lib/features/location/location_provider.dart
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:geolocator/geolocator.dart';
|
||||||
|
import 'package:rogapp/features/data/user_location.dart';
|
||||||
|
import 'package:rogapp/features/state/game_view_model.dart';
|
||||||
|
|
||||||
|
/// The state for the location feature
|
||||||
|
class LocationState {
|
||||||
|
final Position? currentPosition;
|
||||||
|
final bool isStreamPaused;
|
||||||
|
|
||||||
|
LocationState({
|
||||||
|
this.currentPosition,
|
||||||
|
this.isStreamPaused = false,
|
||||||
|
});
|
||||||
|
|
||||||
|
LocationState copyWith({
|
||||||
|
Position? currentPosition,
|
||||||
|
bool? isStreamPaused,
|
||||||
|
}) {
|
||||||
|
return LocationState(
|
||||||
|
currentPosition: currentPosition ?? this.currentPosition,
|
||||||
|
isStreamPaused: isStreamPaused ?? this.isStreamPaused,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A StateNotifier that manages the location state
|
||||||
|
class LocationNotifier extends StateNotifier<LocationState> {
|
||||||
|
final Ref ref;
|
||||||
|
LocationNotifier(this.ref) : super(LocationState()) {
|
||||||
|
startListening();
|
||||||
|
startPeriodicUpdates();
|
||||||
|
}
|
||||||
|
|
||||||
|
StreamSubscription<Position>? _positionSubscription;
|
||||||
|
Position? _lastPosition;
|
||||||
|
final double _distanceThreshold = 220.0;
|
||||||
|
Timer? _periodicUpdateTimer;
|
||||||
|
|
||||||
|
void startPeriodicUpdates() {
|
||||||
|
_periodicUpdateTimer?.cancel();
|
||||||
|
_periodicUpdateTimer = Timer.periodic(Duration(seconds: 5), (timer) {
|
||||||
|
if (state.currentPosition != null) {
|
||||||
|
// Convert Position to UserLocation
|
||||||
|
UserLocation userLocation =
|
||||||
|
UserLocation.fromPosition(state.currentPosition!);
|
||||||
|
ref.read(gameViewModelProvider.notifier).updateLocation(userLocation);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void startListening() {
|
||||||
|
_positionSubscription =
|
||||||
|
Geolocator.getPositionStream().listen((Position position) {
|
||||||
|
if (_shouldUpdatePosition(position)) {
|
||||||
|
state = state.copyWith(currentPosition: position);
|
||||||
|
_lastPosition = position;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _shouldUpdatePosition(Position newPosition) {
|
||||||
|
if (_lastPosition == null) return true;
|
||||||
|
|
||||||
|
double distance = Geolocator.distanceBetween(
|
||||||
|
_lastPosition!.latitude,
|
||||||
|
_lastPosition!.longitude,
|
||||||
|
newPosition.latitude,
|
||||||
|
newPosition.longitude,
|
||||||
|
);
|
||||||
|
|
||||||
|
return distance < _distanceThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
void stopListening() {
|
||||||
|
_positionSubscription?.cancel();
|
||||||
|
_positionSubscription = null;
|
||||||
|
state = state.copyWith(
|
||||||
|
currentPosition: null); // Reset the position state or handle as needed
|
||||||
|
}
|
||||||
|
|
||||||
|
void pauseListening() {
|
||||||
|
_positionSubscription?.pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
void resumeListening() {
|
||||||
|
_positionSubscription?.resume();
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateCurrentPosition(Position? position) {
|
||||||
|
state = state.copyWith(currentPosition: position);
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateStreamPaused(bool isPaused) {
|
||||||
|
state = state.copyWith(isStreamPaused: isPaused);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_positionSubscription?.cancel();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final locationNotifierProvider =
|
||||||
|
StateNotifierProvider<LocationNotifier, LocationState>((ref) {
|
||||||
|
return LocationNotifier(ref); // Pass ref directly
|
||||||
|
});
|
||||||
14
lib/features/services/auth_repo.dart
Normal file
14
lib/features/services/auth_repo.dart
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:rogapp/features/data/user.dart';
|
||||||
|
import 'package:rogapp/features/services/auth_service.dart';
|
||||||
|
|
||||||
|
final authProvider =
|
||||||
|
FutureProvider.family<User?, String>((ref, credentials) async {
|
||||||
|
// Assuming credentials is a combined string of "email|password"
|
||||||
|
List<String> parts = credentials.split('|');
|
||||||
|
String email = parts[0];
|
||||||
|
String password = parts[1];
|
||||||
|
|
||||||
|
AuthService authService = AuthService();
|
||||||
|
return await authService.userLogin(email, password);
|
||||||
|
});
|
||||||
44
lib/features/services/auth_service.dart
Normal file
44
lib/features/services/auth_service.dart
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import 'package:rogapp/features/data/user.dart';
|
||||||
|
|
||||||
|
import '../utils/const.dart';
|
||||||
|
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
|
|
||||||
|
class AuthService {
|
||||||
|
Dio dio = Dio();
|
||||||
|
|
||||||
|
Future<User?> userLogin(String email, String password) async {
|
||||||
|
final String serverUrl = ConstValues.currentServer();
|
||||||
|
final String url = '$serverUrl/api/login/';
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await dio.post(
|
||||||
|
url,
|
||||||
|
data: {
|
||||||
|
'email': email,
|
||||||
|
'password': password,
|
||||||
|
},
|
||||||
|
options: Options(
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json; charset=UTF-8',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.statusCode == 200 && response.data != null) {
|
||||||
|
final data = response.data;
|
||||||
|
User user = User.fromMap(data["user"]);
|
||||||
|
final String token = data["token"];
|
||||||
|
user.auth_token = token;
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} on DioException catch (e) {
|
||||||
|
print("Dio error: ${e.response?.statusCode} - ${e.message}");
|
||||||
|
return null;
|
||||||
|
} catch (e) {
|
||||||
|
print("Unexpected error: $e");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
32
lib/features/services/checkpoint_repo.dart
Normal file
32
lib/features/services/checkpoint_repo.dart
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:rogapp/features/data/checkpoint.dart';
|
||||||
|
import 'package:rogapp/features/data/data_provider.dart';
|
||||||
|
import 'package:rogapp/features/services/checkpoint_service.dart'; // Import your ApiService file
|
||||||
|
|
||||||
|
Future<void> storeFetchedFeatures(FeatureCollection featureCollection) async {
|
||||||
|
final dataProvider =
|
||||||
|
DataProvider(); // Ensure DataProvider is initialized appropriately
|
||||||
|
|
||||||
|
for (Feature feature in featureCollection.features) {
|
||||||
|
await dataProvider.insertMarker(feature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final checkpointProvider = FutureProvider<List<Feature>>((ref) async {
|
||||||
|
final dataProvider =
|
||||||
|
DataProvider(); // Assuming you create or access an instance here
|
||||||
|
final markers = await dataProvider.getMarkers();
|
||||||
|
return markers;
|
||||||
|
});
|
||||||
|
|
||||||
|
final featureCheckpointCollectionProvider =
|
||||||
|
FutureProvider<FeatureCollection>((ref) async {
|
||||||
|
final apiService =
|
||||||
|
ApiService(); // Ensure ApiService is initialized appropriately
|
||||||
|
final featureCollection = await apiService.fetchFeatures();
|
||||||
|
|
||||||
|
// Store the fetched features in the local database
|
||||||
|
await storeFetchedFeatures(featureCollection);
|
||||||
|
|
||||||
|
return featureCollection; // Return the fetched feature collection
|
||||||
|
});
|
||||||
27
lib/features/services/checkpoint_service.dart
Normal file
27
lib/features/services/checkpoint_service.dart
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:rogapp/features/data/checkpoint.dart';
|
||||||
|
|
||||||
|
class ApiService {
|
||||||
|
final Dio _dio = Dio();
|
||||||
|
|
||||||
|
Future<FeatureCollection> fetchFeatures() async {
|
||||||
|
try {
|
||||||
|
final tmp_url =
|
||||||
|
"https://rogaining.sumasen.net/api/inbound?rog=True&grp=養老ロゲ&ln1=136.52675654298724&la1=35.19710769333327&ln2=136.52675654298724&la2=35.38264844179004&ln3=136.65061968584442&la3=35.38264844179004&ln4=136.65061968584442&la4=35.19710769333327";
|
||||||
|
final response = await _dio.get(tmp_url);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
return FeatureCollection.fromJson(response.data);
|
||||||
|
} else {
|
||||||
|
throw Exception('Failed to load features');
|
||||||
|
}
|
||||||
|
} on DioException catch (e) {
|
||||||
|
// Handle Dio errors here
|
||||||
|
print('Dio error: $e');
|
||||||
|
throw Exception('Failed to load features');
|
||||||
|
} catch (e) {
|
||||||
|
// Handle any other errors
|
||||||
|
print('General error: $e');
|
||||||
|
throw Exception('Failed to load features');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
98
lib/features/state/game_state.dart
Normal file
98
lib/features/state/game_state.dart
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:latlong2/latlong.dart';
|
||||||
|
import 'package:rogapp/features/data/checkpoint.dart';
|
||||||
|
import 'package:rogapp/features/data/user_location.dart';
|
||||||
|
|
||||||
|
enum GameStatus {
|
||||||
|
notStarted,
|
||||||
|
started,
|
||||||
|
inProgress,
|
||||||
|
atCheckpoint,
|
||||||
|
gameCompleted,
|
||||||
|
}
|
||||||
|
|
||||||
|
enum PendingAction {
|
||||||
|
none,
|
||||||
|
checkInPhoto,
|
||||||
|
receiptPhoto,
|
||||||
|
endGamePhoto,
|
||||||
|
}
|
||||||
|
|
||||||
|
@immutable
|
||||||
|
class GameState {
|
||||||
|
final GameStatus status;
|
||||||
|
final List<Feature> markers;
|
||||||
|
final UserLocation? currentLocation;
|
||||||
|
final Set<Feature> visitedMarkers;
|
||||||
|
final bool isWithinStartRadius;
|
||||||
|
final bool hasLeftStartArea;
|
||||||
|
final bool hasVisitedCheckpoint;
|
||||||
|
final Feature? currentCheckpoint;
|
||||||
|
final bool checkpointPhotoTaken;
|
||||||
|
final bool receiptPhotoTaken;
|
||||||
|
final PendingAction pendingAction;
|
||||||
|
|
||||||
|
const GameState({
|
||||||
|
this.status = GameStatus.notStarted,
|
||||||
|
this.markers = const [],
|
||||||
|
this.currentLocation,
|
||||||
|
this.visitedMarkers = const {},
|
||||||
|
this.isWithinStartRadius = false,
|
||||||
|
this.hasLeftStartArea = false,
|
||||||
|
this.hasVisitedCheckpoint = false,
|
||||||
|
this.currentCheckpoint,
|
||||||
|
this.checkpointPhotoTaken = false,
|
||||||
|
this.receiptPhotoTaken = false,
|
||||||
|
this.pendingAction = PendingAction.none,
|
||||||
|
});
|
||||||
|
|
||||||
|
LatLng? getUserLatLng() {
|
||||||
|
return currentLocation != null
|
||||||
|
? LatLng(currentLocation!.latitude, currentLocation!.longitude)
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameState.fromMap(Map<String, dynamic> map)
|
||||||
|
: status = GameStatus.values[map['status']],
|
||||||
|
markers =
|
||||||
|
List<Feature>.from(map['markers'].map((x) => Feature.fromMap(x))),
|
||||||
|
currentLocation = UserLocation.fromMap(map['currentLocation']),
|
||||||
|
visitedMarkers = Set<Feature>.from(
|
||||||
|
map['visitedMarkers'].map((x) => Feature.fromMap(x))),
|
||||||
|
isWithinStartRadius = map['isWithinStartRadius'],
|
||||||
|
hasLeftStartArea = map['hasLeftStartArea'],
|
||||||
|
hasVisitedCheckpoint = map['hasVisitedCheckpoint'],
|
||||||
|
currentCheckpoint = map['currentCheckpoint'] != null
|
||||||
|
? Feature.fromMap(map['currentCheckpoint'])
|
||||||
|
: null,
|
||||||
|
checkpointPhotoTaken = map['checkpointPhotoTaken'],
|
||||||
|
receiptPhotoTaken = map['receiptPhotoTaken'],
|
||||||
|
pendingAction = PendingAction.values[map['pendingAction']];
|
||||||
|
|
||||||
|
GameState copyWith({
|
||||||
|
GameStatus? status,
|
||||||
|
List<Feature>? markers,
|
||||||
|
UserLocation? currentLocation,
|
||||||
|
Set<Feature>? visitedMarkers,
|
||||||
|
bool? isWithinStartRadius,
|
||||||
|
bool? hasLeftStartArea,
|
||||||
|
bool? hasVisitedCheckpoint,
|
||||||
|
Feature? currentCheckpoint,
|
||||||
|
bool? checkpointPhotoTaken,
|
||||||
|
bool? receiptPhotoTaken,
|
||||||
|
PendingAction? pendingAction,
|
||||||
|
}) {
|
||||||
|
return GameState(
|
||||||
|
status: status ?? this.status,
|
||||||
|
markers: markers ?? this.markers,
|
||||||
|
currentLocation: currentLocation ?? this.currentLocation,
|
||||||
|
visitedMarkers: visitedMarkers ?? this.visitedMarkers,
|
||||||
|
isWithinStartRadius: isWithinStartRadius ?? this.isWithinStartRadius,
|
||||||
|
hasLeftStartArea: hasLeftStartArea ?? this.hasLeftStartArea,
|
||||||
|
hasVisitedCheckpoint: hasVisitedCheckpoint ?? this.hasVisitedCheckpoint,
|
||||||
|
currentCheckpoint: currentCheckpoint ?? this.currentCheckpoint,
|
||||||
|
checkpointPhotoTaken: checkpointPhotoTaken ?? this.checkpointPhotoTaken,
|
||||||
|
receiptPhotoTaken: receiptPhotoTaken ?? this.receiptPhotoTaken,
|
||||||
|
pendingAction: pendingAction ?? this.pendingAction);
|
||||||
|
}
|
||||||
|
}
|
||||||
199
lib/features/state/game_view_model.dart
Normal file
199
lib/features/state/game_view_model.dart
Normal file
@ -0,0 +1,199 @@
|
|||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:latlong2/latlong.dart';
|
||||||
|
import 'package:rogapp/features/data/checkpoint.dart';
|
||||||
|
import 'package:rogapp/features/data/data_provider.dart';
|
||||||
|
import 'package:rogapp/features/data/user_location.dart';
|
||||||
|
import 'package:rogapp/features/state/game_state.dart';
|
||||||
|
import 'package:rogapp/features/utils/params.dart';
|
||||||
|
|
||||||
|
final gameViewModelProvider =
|
||||||
|
StateNotifierProvider<GameViewModel, GameState>((ref) {
|
||||||
|
final dataProvider = DataProvider();
|
||||||
|
return GameViewModel(dataProvider);
|
||||||
|
});
|
||||||
|
|
||||||
|
class GameViewModel extends StateNotifier<GameState> {
|
||||||
|
final DataProvider _dataProvider;
|
||||||
|
|
||||||
|
GameViewModel(this._dataProvider) : super(const GameState()) {
|
||||||
|
loadInitialData();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> loadInitialData() async {
|
||||||
|
List<Feature> markers = await _dataProvider.getMarkers();
|
||||||
|
state = state.copyWith(markers: markers);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setMarkers(List<Feature> markers) {
|
||||||
|
state = state.copyWith(markers: markers);
|
||||||
|
}
|
||||||
|
|
||||||
|
void startGame() {
|
||||||
|
if (state.isWithinStartRadius) {
|
||||||
|
state = state.copyWith(status: GameStatus.started);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateLocation(UserLocation location) {
|
||||||
|
Feature startMarker = state.markers.firstWhere(
|
||||||
|
(marker) => marker.properties.cp == -1,
|
||||||
|
orElse: () => Feature.empty());
|
||||||
|
List<Feature> checkpoints =
|
||||||
|
state.markers.where((marker) => marker.properties.cp != -1).toList();
|
||||||
|
|
||||||
|
bool isWithinStartRadius =
|
||||||
|
_checkProximity(location, startMarker /* start marker location */
|
||||||
|
);
|
||||||
|
bool hasLeftArea =
|
||||||
|
state.hasLeftStartArea || _checkHasLeftStartArea(location, startMarker);
|
||||||
|
|
||||||
|
Feature? atCheckpoint = _checkAtAnyCheckpoint(location, checkpoints);
|
||||||
|
|
||||||
|
// Check if at any checkpoint (except start point after game started)
|
||||||
|
bool isAtCheckpoint =
|
||||||
|
state.status == GameStatus.started && atCheckpoint != null;
|
||||||
|
if (isAtCheckpoint) {
|
||||||
|
_handleCheckpointArrival(location, atCheckpoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update game state based on the new location
|
||||||
|
state = state.copyWith(
|
||||||
|
currentLocation: location,
|
||||||
|
isWithinStartRadius: isWithinStartRadius,
|
||||||
|
hasLeftStartArea: hasLeftArea,
|
||||||
|
status: isAtCheckpoint ? GameStatus.atCheckpoint : state.status,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _handleCheckpointArrival(UserLocation location, Feature marker) {
|
||||||
|
// Directly set the current checkpoint; no need to check if the photo was taken here
|
||||||
|
state = state.copyWith(currentCheckpoint: marker);
|
||||||
|
|
||||||
|
// If no checkpoint photo has been taken yet, set the pending action to take a checkpoint photo
|
||||||
|
if (!state.checkpointPhotoTaken) {
|
||||||
|
state = state.copyWith(pendingAction: PendingAction.checkInPhoto);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Additional actions specific to buy points can be prepared here, but it's usually better
|
||||||
|
// to handle them after the checkpoint photo is submitted, not at the moment of arrival.
|
||||||
|
}
|
||||||
|
|
||||||
|
void submitCheckInPhoto(String photoPath) {
|
||||||
|
// Logic to save or upload the check-in photo...
|
||||||
|
state = state.copyWith(checkpointPhotoTaken: true);
|
||||||
|
|
||||||
|
// Determine the next action based on the checkpoint type
|
||||||
|
if (state.currentCheckpoint != null &&
|
||||||
|
isBuyPoint(state.currentCheckpoint!)) {
|
||||||
|
state = state.copyWith(pendingAction: PendingAction.receiptPhoto);
|
||||||
|
} else {
|
||||||
|
// If it's not a buy point, mark the checkpoint visit as complete
|
||||||
|
_markCheckpointVisited(state.currentCheckpoint!);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void submitReceiptPhoto(String photoPath) {
|
||||||
|
// Logic to save or upload the receipt photo...
|
||||||
|
state = state.copyWith(receiptPhotoTaken: true);
|
||||||
|
|
||||||
|
// After submitting the receipt photo, mark the checkpoint visit as complete
|
||||||
|
_markCheckpointVisited(state.currentCheckpoint!);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _markCheckpointVisited(Feature checkpoint) {
|
||||||
|
state = state.copyWith(
|
||||||
|
visitedMarkers: Set.from(state.visitedMarkers)..add(checkpoint),
|
||||||
|
hasVisitedCheckpoint: true,
|
||||||
|
pendingAction: PendingAction.none, // Reset the pending action
|
||||||
|
);
|
||||||
|
|
||||||
|
// Additional logic to determine if the game is completed...
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isBuyPoint(Feature checkpoint) {
|
||||||
|
if (checkpoint.properties.buyPoint != null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _checkProximity(UserLocation location, Feature startMarker) {
|
||||||
|
const Distance distance = Distance();
|
||||||
|
return distance(
|
||||||
|
LatLng(location.latitude, location.longitude),
|
||||||
|
LatLng(startMarker.geometry.latitude,
|
||||||
|
startMarker.geometry.longitude)) <=
|
||||||
|
startMinDistance;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _checkHasLeftStartArea(UserLocation location, Feature startMarker) {
|
||||||
|
const Distance distance = Distance();
|
||||||
|
return distance(
|
||||||
|
LatLng(location.latitude, location.longitude),
|
||||||
|
LatLng(startMarker.geometry.latitude,
|
||||||
|
startMarker.geometry.longitude)) >=
|
||||||
|
minAwayfromStartDistance;
|
||||||
|
}
|
||||||
|
|
||||||
|
Feature? _checkAtAnyCheckpoint(UserLocation location, List<Feature> markers) {
|
||||||
|
const Distance distance = Distance();
|
||||||
|
|
||||||
|
for (Feature marker in markers) {
|
||||||
|
final double distanceInMeters = distance(
|
||||||
|
LatLng(location.latitude, location.longitude),
|
||||||
|
LatLng(marker.geometry.latitude, marker.geometry.longitude),
|
||||||
|
);
|
||||||
|
if (marker.properties.checkinRadious != null &&
|
||||||
|
marker.properties.checkinRadious! >= distanceInMeters) {
|
||||||
|
return marker;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Feature? _getCheckpointFromLocation(UserLocation location) {
|
||||||
|
const thresholdDistance = 50.0; // meters, adjust based on your game design
|
||||||
|
const Distance distance = Distance();
|
||||||
|
|
||||||
|
for (final marker in state.markers) {
|
||||||
|
final double distanceInMeters = distance(
|
||||||
|
LatLng(location.latitude, location.longitude),
|
||||||
|
LatLng(marker.geometry.latitude, marker.geometry.longitude),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (distanceInMeters <=
|
||||||
|
(marker.properties.checkinRadious ?? thresholdDistance)) {
|
||||||
|
return marker;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null; // No checkpoint is close enough to the user's location
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _isBackAtStart(UserLocation location) {
|
||||||
|
const startThresholdDistance = 150.0; // Define proximity threshold
|
||||||
|
const Distance distance = Distance();
|
||||||
|
|
||||||
|
// Assuming the start point is the first marker
|
||||||
|
// Adjust based on your game's logic
|
||||||
|
final startPoint = state.markers.first;
|
||||||
|
|
||||||
|
final double distanceToStart = distance(
|
||||||
|
LatLng(location.latitude, location.longitude),
|
||||||
|
LatLng(startPoint.geometry.latitude, startPoint.geometry.longitude),
|
||||||
|
);
|
||||||
|
|
||||||
|
// User is considered back at the start if within the threshold distance
|
||||||
|
return distanceToStart <= startThresholdDistance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void endGame() {
|
||||||
|
if (state.status == GameStatus.gameCompleted) {
|
||||||
|
// Perform any end game actions
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadGameState(GameState gameState) {
|
||||||
|
state = gameState;
|
||||||
|
}
|
||||||
|
}
|
||||||
18
lib/features/state/user_state.dart
Normal file
18
lib/features/state/user_state.dart
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:rogapp/features/data/user.dart';
|
||||||
|
|
||||||
|
class UserNotifier extends StateNotifier<User?> {
|
||||||
|
UserNotifier() : super(null);
|
||||||
|
|
||||||
|
void setUser(User? user) {
|
||||||
|
state = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearUser() {
|
||||||
|
state = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final userNotifierProvider = StateNotifierProvider<UserNotifier, User?>((ref) {
|
||||||
|
return UserNotifier();
|
||||||
|
});
|
||||||
13
lib/features/utils/const.dart
Normal file
13
lib/features/utils/const.dart
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
class ConstValues {
|
||||||
|
static const container_svr = "http://container.intranet.sumasen.net:8100";
|
||||||
|
static const server_uri = "https://rogaining.sumasen.net";
|
||||||
|
static const dev_server = "http://localhost:8100";
|
||||||
|
static const dev_ip_server = "http://192.168.8.100:8100";
|
||||||
|
static const dev_home_ip_server = "http://172.20.10.9:8100";
|
||||||
|
static const dev_home_ip_mserver = "http://192.168.1.10:8100";
|
||||||
|
|
||||||
|
static String currentServer() {
|
||||||
|
//return dev_ip_server;
|
||||||
|
return server_uri;
|
||||||
|
}
|
||||||
|
}
|
||||||
29
lib/features/utils/distance_calculator.dart
Normal file
29
lib/features/utils/distance_calculator.dart
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import 'dart:math';
|
||||||
|
import 'package:latlong2/latlong.dart';
|
||||||
|
|
||||||
|
class DistanceCalculatorHS {
|
||||||
|
static const int _radius = 6371; // Radius of the Earth in kilometers
|
||||||
|
|
||||||
|
static double _degreeToRadian(double degree) {
|
||||||
|
return degree * pi / 180;
|
||||||
|
}
|
||||||
|
|
||||||
|
static double calculateDistance(LatLng location1, LatLng location2) {
|
||||||
|
double latDistance =
|
||||||
|
_degreeToRadian(location2.latitude - location1.latitude);
|
||||||
|
double lonDistance =
|
||||||
|
_degreeToRadian(location2.longitude - location1.longitude);
|
||||||
|
|
||||||
|
double a = sin(latDistance / 2) * sin(latDistance / 2) +
|
||||||
|
cos(_degreeToRadian(location1.latitude)) *
|
||||||
|
cos(_degreeToRadian(location2.latitude)) *
|
||||||
|
sin(lonDistance / 2) *
|
||||||
|
sin(lonDistance / 2);
|
||||||
|
|
||||||
|
double c = 2 * atan2(sqrt(a), sqrt(1 - a));
|
||||||
|
|
||||||
|
double distance = _radius * c * 1000; // Convert to meters
|
||||||
|
|
||||||
|
return distance;
|
||||||
|
}
|
||||||
|
}
|
||||||
17
lib/features/utils/error_reporter.dart
Normal file
17
lib/features/utils/error_reporter.dart
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|
||||||
|
final errorReportingProvider = Provider<ErrorReporter>((ref) {
|
||||||
|
return ErrorReporterImpl();
|
||||||
|
});
|
||||||
|
|
||||||
|
class ErrorReporter {
|
||||||
|
void reportError(Object error, StackTrace stackTrace) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ErrorReporterImpl extends ErrorReporter {
|
||||||
|
@override
|
||||||
|
void reportError(Object error, StackTrace stackTrace) {
|
||||||
|
// Send error and stackTrace to the server
|
||||||
|
// Include app state if necessary
|
||||||
|
}
|
||||||
|
}
|
||||||
2
lib/features/utils/params.dart
Normal file
2
lib/features/utils/params.dart
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
int startMinDistance = 150;
|
||||||
|
int minAwayfromStartDistance = 300;
|
||||||
143
lib/main.dart
143
lib/main.dart
@ -1,136 +1,47 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_map_tile_caching/flutter_map_tile_caching.dart';
|
import 'package:rogapp/features/landing/landing_page.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
import 'package:rogapp/features/utils/error_reporter.dart';
|
||||||
import 'package:rogapp/pages/index/index_binding.dart';
|
|
||||||
import 'package:rogapp/routes/app_pages.dart';
|
|
||||||
import 'package:rogapp/utils/string_values.dart';
|
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
// import 'package:is_lock_screen/is_lock_screen.dart';
|
|
||||||
|
|
||||||
void saveGameState() async {
|
void reportError(
|
||||||
DestinationController destinationController =
|
ProviderContainer container, Object error, StackTrace stackTrace) {
|
||||||
Get.find<DestinationController>();
|
// Log the error locally or report to a server
|
||||||
SharedPreferences pref = await SharedPreferences.getInstance();
|
print('Caught an error: $error');
|
||||||
pref.setBool("is_in_rog", destinationController.isInRog.value);
|
container.read(errorReportingProvider).reportError(error, stackTrace);
|
||||||
pref.setBool(
|
|
||||||
"rogaining_counted", destinationController.rogainingCounted.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void restoreGame() async {
|
|
||||||
SharedPreferences pref = await SharedPreferences.getInstance();
|
|
||||||
DestinationController destinationController =
|
|
||||||
Get.find<DestinationController>();
|
|
||||||
destinationController.skipGps = false;
|
|
||||||
destinationController.isInRog.value = pref.getBool("is_in_rog") ?? false;
|
|
||||||
destinationController.rogainingCounted.value =
|
|
||||||
pref.getBool("rogaining_counted") ?? false;
|
|
||||||
//print(
|
|
||||||
// "--restored -- destinationController.isInRog.value ${pref.getBool("is_in_rog")} -- ${pref.getBool("rogaining_counted")}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
await FlutterMapTileCaching.initialise();
|
final container = ProviderContainer();
|
||||||
final StoreDirectory instanceA = FMTC.instance('OpenStreetMap (A)');
|
runZonedGuarded(() {
|
||||||
await instanceA.manage.createAsync();
|
runApp(UncontrolledProviderScope(container: container, child: const App()));
|
||||||
await instanceA.metadata.addAsync(
|
FlutterError.onError = (FlutterErrorDetails details) {
|
||||||
key: 'sourceURL',
|
final error = details.exception;
|
||||||
value: 'https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png',
|
final stackTrace = details.stack ?? StackTrace.current;
|
||||||
);
|
reportError(container, error, stackTrace);
|
||||||
await instanceA.metadata.addAsync(
|
};
|
||||||
key: 'validDuration',
|
}, (error, stackTrace) {
|
||||||
value: '14',
|
reportError(container, error, stackTrace ?? StackTrace.current);
|
||||||
);
|
});
|
||||||
await instanceA.metadata.addAsync(
|
|
||||||
key: 'behaviour',
|
|
||||||
value: 'cacheFirst',
|
|
||||||
);
|
|
||||||
runApp(const MyApp());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyApp extends StatefulWidget {
|
class App extends StatelessWidget {
|
||||||
const MyApp({Key? key}) : super(key: key);
|
const App({super.key});
|
||||||
|
|
||||||
@override
|
|
||||||
State<MyApp> createState() => _MyAppState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
|
|
||||||
// This widget is the root of your application.
|
// This widget is the root of your application.
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
if (context.mounted) {
|
|
||||||
restoreGame();
|
|
||||||
}
|
|
||||||
WidgetsBinding.instance.addObserver(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
WidgetsBinding.instance.removeObserver(this);
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
// void saveGameState() async {
|
|
||||||
// DestinationController destinationController = Get.find<DestinationController>();
|
|
||||||
// SharedPreferences pref = await SharedPreferences.getInstance();
|
|
||||||
// pref.setBool("is_in_rog", destinationController.is_in_rog.value);
|
|
||||||
// pref.setBool("rogaining_counted", destinationController.rogaining_counted.value);
|
|
||||||
// }
|
|
||||||
|
|
||||||
@override
|
|
||||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
|
||||||
DestinationController destinationController =
|
|
||||||
Get.find<DestinationController>();
|
|
||||||
switch (state) {
|
|
||||||
case AppLifecycleState.resumed:
|
|
||||||
//print("RESUMED");
|
|
||||||
restoreGame();
|
|
||||||
break;
|
|
||||||
case AppLifecycleState.inactive:
|
|
||||||
//print("INACTIVE");
|
|
||||||
break;
|
|
||||||
case AppLifecycleState.paused:
|
|
||||||
//print("PAUSED");
|
|
||||||
saveGameState();
|
|
||||||
break;
|
|
||||||
case AppLifecycleState.detached:
|
|
||||||
//print("DETACHED");
|
|
||||||
saveGameState();
|
|
||||||
break;
|
|
||||||
case AppLifecycleState.hidden:
|
|
||||||
//print("DETACHED");
|
|
||||||
saveGameState();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GetMaterialApp(
|
return MaterialApp(
|
||||||
translations: StringValues(),
|
title: 'Flutter Demo',
|
||||||
locale: const Locale('ja', 'JP'),
|
|
||||||
//locale: const Locale('en', 'US'),
|
|
||||||
fallbackLocale: const Locale('en', 'US'),
|
|
||||||
title: 'ROGAINING',
|
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
colorScheme: ColorScheme.fromSeed(
|
colorScheme: ColorScheme.fromSeed(
|
||||||
seedColor: const Color.fromARGB(255, 36, 135, 221)),
|
seedColor: const Color.fromARGB(255, 0, 35, 140)), //Samurai Blue
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
),
|
),
|
||||||
debugShowCheckedModeBanner: false,
|
home: const LandingPage(),
|
||||||
defaultTransition: Transition.cupertino,
|
|
||||||
opaqueRoute: Get.isOpaqueRouteDefault,
|
|
||||||
popGesture: Get.isPopGestureEnable,
|
|
||||||
transitionDuration: const Duration(milliseconds: 230),
|
|
||||||
initialBinding: IndexBinding(), //HomeBinding(),
|
|
||||||
initialRoute: AppPages.PERMISSION,
|
|
||||||
getPages: AppPages.routes,
|
|
||||||
enableLog: true,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
146
lib/main_mapsix.dart
Normal file
146
lib/main_mapsix.dart
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
// import 'package:flutter/material.dart';
|
||||||
|
// import 'package:flutter_map_tile_caching/flutter_map_tile_caching.dart';
|
||||||
|
// import 'package:get/get.dart';
|
||||||
|
// import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||||
|
// import 'package:rogapp/pages/index/index_binding.dart';
|
||||||
|
// import 'package:rogapp/routes/app_pages.dart';
|
||||||
|
// import 'package:rogapp/utils/location_controller.dart';
|
||||||
|
// import 'package:rogapp/utils/string_values.dart';
|
||||||
|
// import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
// // import 'package:is_lock_screen/is_lock_screen.dart';
|
||||||
|
|
||||||
|
// void saveGameState() async {
|
||||||
|
// DestinationController destinationController =
|
||||||
|
// Get.find<DestinationController>();
|
||||||
|
// SharedPreferences pref = await SharedPreferences.getInstance();
|
||||||
|
// pref.setBool("is_in_rog", destinationController.isInRog.value);
|
||||||
|
// pref.setBool(
|
||||||
|
// "rogaining_counted", destinationController.rogainingCounted.value);
|
||||||
|
// pref.setBool("ready_for_goal", DestinationController.ready_for_goal);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// void restoreGame() async {
|
||||||
|
// SharedPreferences pref = await SharedPreferences.getInstance();
|
||||||
|
// DestinationController destinationController =
|
||||||
|
// Get.find<DestinationController>();
|
||||||
|
// destinationController.skipGps = false;
|
||||||
|
// destinationController.isInRog.value = pref.getBool("is_in_rog") ?? false;
|
||||||
|
// destinationController.rogainingCounted.value =
|
||||||
|
// pref.getBool("rogaining_counted") ?? false;
|
||||||
|
// DestinationController.ready_for_goal =
|
||||||
|
// pref.getBool("ready_for_goal") ?? false;
|
||||||
|
// //print(
|
||||||
|
// // "--restored -- destinationController.isInRog.value ${pref.getBool("is_in_rog")} -- ${pref.getBool("rogaining_counted")}");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// void main() async {
|
||||||
|
// WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
// await FlutterMapTileCaching.initialise();
|
||||||
|
// final StoreDirectory instanceA = FMTC.instance('OpenStreetMap (A)');
|
||||||
|
// await instanceA.manage.createAsync();
|
||||||
|
// await instanceA.metadata.addAsync(
|
||||||
|
// key: 'sourceURL',
|
||||||
|
// value: 'https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png',
|
||||||
|
// );
|
||||||
|
// await instanceA.metadata.addAsync(
|
||||||
|
// key: 'validDuration',
|
||||||
|
// value: '14',
|
||||||
|
// );
|
||||||
|
// await instanceA.metadata.addAsync(
|
||||||
|
// key: 'behaviour',
|
||||||
|
// value: 'cacheFirst',
|
||||||
|
// );
|
||||||
|
// runApp(const MyApp());
|
||||||
|
// }
|
||||||
|
|
||||||
|
// class MyApp extends StatefulWidget {
|
||||||
|
// const MyApp({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
// @override
|
||||||
|
// State<MyApp> createState() => _MyAppState();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
|
||||||
|
// // This widget is the root of your application.
|
||||||
|
|
||||||
|
// @override
|
||||||
|
// void initState() {
|
||||||
|
// super.initState();
|
||||||
|
// if (context.mounted) {
|
||||||
|
// restoreGame();
|
||||||
|
// }
|
||||||
|
// WidgetsBinding.instance.addObserver(this);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @override
|
||||||
|
// void dispose() {
|
||||||
|
// WidgetsBinding.instance.removeObserver(this);
|
||||||
|
// super.dispose();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // void saveGameState() async {
|
||||||
|
// // DestinationController destinationController = Get.find<DestinationController>();
|
||||||
|
// // SharedPreferences pref = await SharedPreferences.getInstance();
|
||||||
|
// // pref.setBool("is_in_rog", destinationController.is_in_rog.value);
|
||||||
|
// // pref.setBool("rogaining_counted", destinationController.rogaining_counted.value);
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// @override
|
||||||
|
// void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||||
|
// LocationController locationController = Get.find<LocationController>();
|
||||||
|
|
||||||
|
// DestinationController destinationController =
|
||||||
|
// Get.find<DestinationController>();
|
||||||
|
// switch (state) {
|
||||||
|
// case AppLifecycleState.resumed:
|
||||||
|
// locationController.resumePositionStream();
|
||||||
|
// //print("RESUMED");
|
||||||
|
// restoreGame();
|
||||||
|
// break;
|
||||||
|
// case AppLifecycleState.inactive:
|
||||||
|
// locationController.resumePositionStream();
|
||||||
|
// //print("INACTIVE");
|
||||||
|
// break;
|
||||||
|
// case AppLifecycleState.paused:
|
||||||
|
// locationController.resumePositionStream();
|
||||||
|
// //print("PAUSED");
|
||||||
|
// saveGameState();
|
||||||
|
// break;
|
||||||
|
// case AppLifecycleState.detached:
|
||||||
|
// locationController.resumePositionStream();
|
||||||
|
// //print("DETACHED");
|
||||||
|
// saveGameState();
|
||||||
|
// break;
|
||||||
|
// case AppLifecycleState.hidden:
|
||||||
|
// locationController.resumePositionStream();
|
||||||
|
// //print("DETACHED");
|
||||||
|
// saveGameState();
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @override
|
||||||
|
// Widget build(BuildContext context) {
|
||||||
|
// return GetMaterialApp(
|
||||||
|
// translations: StringValues(),
|
||||||
|
// locale: const Locale('ja', 'JP'),
|
||||||
|
// //locale: const Locale('en', 'US'),
|
||||||
|
// fallbackLocale: const Locale('en', 'US'),
|
||||||
|
// title: 'ROGAINING',
|
||||||
|
// theme: ThemeData(
|
||||||
|
// colorScheme: ColorScheme.fromSeed(
|
||||||
|
// seedColor: const Color.fromARGB(255, 36, 135, 221)),
|
||||||
|
// useMaterial3: true,
|
||||||
|
// ),
|
||||||
|
// debugShowCheckedModeBanner: false,
|
||||||
|
// defaultTransition: Transition.cupertino,
|
||||||
|
// opaqueRoute: Get.isOpaqueRouteDefault,
|
||||||
|
// popGesture: Get.isPopGestureEnable,
|
||||||
|
// transitionDuration: const Duration(milliseconds: 230),
|
||||||
|
// initialBinding: IndexBinding(), //HomeBinding(),
|
||||||
|
// initialRoute: AppPages.PERMISSION,
|
||||||
|
// getPages: AppPages.routes,
|
||||||
|
// enableLog: true,
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
@ -1,61 +1,61 @@
|
|||||||
import 'package:flutter/material.dart';
|
// import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_map_tile_caching/flutter_map_tile_caching.dart';
|
// import 'package:flutter_map_tile_caching/flutter_map_tile_caching.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
// import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:rogapp/nrog/pages/permission_page.dart';
|
// import 'package:rogapp/nrog/pages/permission_page.dart';
|
||||||
|
|
||||||
void main() async {
|
// void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
// WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
await FlutterMapTileCaching.initialise();
|
// await FlutterMapTileCaching.initialise();
|
||||||
final StoreDirectory instanceA = FMTC.instance('OpenStreetMap (A)');
|
// final StoreDirectory instanceA = FMTC.instance('OpenStreetMap (A)');
|
||||||
await instanceA.manage.createAsync();
|
// await instanceA.manage.createAsync();
|
||||||
await instanceA.metadata.addAsync(
|
// await instanceA.metadata.addAsync(
|
||||||
key: 'sourceURL',
|
// key: 'sourceURL',
|
||||||
value: 'https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png',
|
// value: 'https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png',
|
||||||
);
|
// );
|
||||||
await instanceA.metadata.addAsync(
|
// await instanceA.metadata.addAsync(
|
||||||
key: 'validDuration',
|
// key: 'validDuration',
|
||||||
value: '14',
|
// value: '14',
|
||||||
);
|
// );
|
||||||
await instanceA.metadata.addAsync(
|
// await instanceA.metadata.addAsync(
|
||||||
key: 'behaviour',
|
// key: 'behaviour',
|
||||||
value: 'cacheFirst',
|
// value: 'cacheFirst',
|
||||||
);
|
// );
|
||||||
runApp(
|
// runApp(
|
||||||
const ProviderScope(child: MyApp()),
|
// const ProviderScope(child: MyApp()),
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
class MyApp extends StatefulWidget {
|
// class MyApp extends StatefulWidget {
|
||||||
const MyApp({super.key});
|
// const MyApp({super.key});
|
||||||
|
|
||||||
@override
|
// @override
|
||||||
State<MyApp> createState() => _MyAppState();
|
// State<MyApp> createState() => _MyAppState();
|
||||||
}
|
// }
|
||||||
|
|
||||||
class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
|
// class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
|
||||||
@override
|
// @override
|
||||||
void initState() {
|
// void initState() {
|
||||||
super.initState();
|
// super.initState();
|
||||||
WidgetsBinding.instance.addObserver(this);
|
// WidgetsBinding.instance.addObserver(this);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@override
|
// @override
|
||||||
void dispose() {
|
// void dispose() {
|
||||||
WidgetsBinding.instance.removeObserver(this);
|
// WidgetsBinding.instance.removeObserver(this);
|
||||||
super.dispose();
|
// super.dispose();
|
||||||
}
|
// }
|
||||||
|
|
||||||
@override
|
// @override
|
||||||
Widget build(BuildContext context) {
|
// Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
// return MaterialApp(
|
||||||
debugShowCheckedModeBanner: false,
|
// debugShowCheckedModeBanner: false,
|
||||||
title: 'Flutter Demo',
|
// title: 'Flutter Demo',
|
||||||
theme: ThemeData(
|
// theme: ThemeData(
|
||||||
colorScheme: ColorScheme.fromSeed(
|
// colorScheme: ColorScheme.fromSeed(
|
||||||
seedColor: const Color.fromARGB(255, 124, 156, 9)),
|
// seedColor: const Color.fromARGB(255, 124, 156, 9)),
|
||||||
useMaterial3: true,
|
// useMaterial3: true,
|
||||||
),
|
// ),
|
||||||
home: const PermissionPage());
|
// home: const PermissionPage());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:flutter/material.dart';
|
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_location_marker/flutter_map_location_marker.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:latlong2/latlong.dart';
|
import 'package:latlong2/latlong.dart';
|
||||||
@ -95,7 +95,7 @@ class _HomePageState extends ConsumerState<HomePage> {
|
|||||||
// .hideAllPopups(), // Hide popup when the map is tapped.
|
// .hideAllPopups(), // Hide popup when the map is tapped.
|
||||||
),
|
),
|
||||||
children: [
|
children: [
|
||||||
const BaseLayer(),
|
//const BaseLayer(),
|
||||||
CurrentLocationLayer(
|
CurrentLocationLayer(
|
||||||
followOnLocationUpdate: FollowOnLocationUpdate.once,
|
followOnLocationUpdate: FollowOnLocationUpdate.once,
|
||||||
turnOnHeadingUpdate: TurnOnHeadingUpdate.never,
|
turnOnHeadingUpdate: TurnOnHeadingUpdate.never,
|
||||||
|
|||||||
@ -136,7 +136,9 @@ class CameraPage extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (destinationController.isAtGoal.value &&
|
if (destinationController.isAtGoal.value &&
|
||||||
destinationController.isInRog.value) {
|
destinationController.isInRog.value &&
|
||||||
|
destination.cp == -1) {
|
||||||
|
//goal
|
||||||
return Row(
|
return Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: [
|
children: [
|
||||||
@ -189,7 +191,8 @@ class CameraPage extends StatelessWidget {
|
|||||||
Get.back();
|
Get.back();
|
||||||
destinationController.skipGps = false;
|
destinationController.skipGps = false;
|
||||||
Get.snackbar("目標が保存されました", "目標が正常に追加されました");
|
Get.snackbar("目標が保存されました", "目標が正常に追加されました");
|
||||||
destinationController.resetRogaining();
|
destinationController.resetRogaining(
|
||||||
|
isgoal: true);
|
||||||
} else {
|
} else {
|
||||||
//print("---- status ${value['status']} ---- ");
|
//print("---- status ${value['status']} ---- ");
|
||||||
Get.snackbar("目標が追加されていません", "please_try_again");
|
Get.snackbar("目標が追加されていません", "please_try_again");
|
||||||
@ -210,6 +213,7 @@ class CameraPage extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
} else if (destinationController.isInRog.value &&
|
} else if (destinationController.isInRog.value &&
|
||||||
dbDest?.checkedin != null &&
|
dbDest?.checkedin != null &&
|
||||||
|
destination.cp != -1 &&
|
||||||
dbDest?.checkedin == true) {
|
dbDest?.checkedin == true) {
|
||||||
//make buypoint image
|
//make buypoint image
|
||||||
return Row(
|
return Row(
|
||||||
@ -396,45 +400,6 @@ class StartRogaining extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// class NotAtGoal extends StatelessWidget {
|
|
||||||
// NotAtGoal({Key? key}) : super(key: key);
|
|
||||||
|
|
||||||
// DestinationController destinationController =
|
|
||||||
// Get.find<DestinationController>();
|
|
||||||
|
|
||||||
// @override
|
|
||||||
// Widget build(BuildContext context) {
|
|
||||||
// return Scaffold(
|
|
||||||
// appBar: AppBar(
|
|
||||||
// title: Text(
|
|
||||||
// "Not reached the goal yet".tr,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// body: Container(
|
|
||||||
// child: Center(
|
|
||||||
// child: Column(
|
|
||||||
// mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
// children: [
|
|
||||||
// Text("You have not reached the goal yet.".tr,
|
|
||||||
// style: const TextStyle(fontSize: 24)),
|
|
||||||
// const SizedBox(
|
|
||||||
// height: 40.0,
|
|
||||||
// ),
|
|
||||||
// ElevatedButton(
|
|
||||||
// onPressed: () {
|
|
||||||
// Get.back();
|
|
||||||
// destinationController.skip_gps = false;
|
|
||||||
// },
|
|
||||||
// child: const Text("Back"),
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
class BuyPointCamera extends StatelessWidget {
|
class BuyPointCamera extends StatelessWidget {
|
||||||
BuyPointCamera({Key? key, required this.destination}) : super(key: key);
|
BuyPointCamera({Key? key, required this.destination}) : super(key: key);
|
||||||
|
|
||||||
@ -445,6 +410,8 @@ class BuyPointCamera extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
//print("in camera purchase 1 ${destinationController.isInRog.value}");
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
@ -482,6 +449,8 @@ class BuyPointCamera extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
// print(
|
||||||
|
// "in camera purchase 2 ${destinationController.isInRog.value}");
|
||||||
destinationController.openCamera(
|
destinationController.openCamera(
|
||||||
context, destination);
|
context, destination);
|
||||||
},
|
},
|
||||||
@ -495,7 +464,8 @@ class BuyPointCamera extends StatelessWidget {
|
|||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await destinationController
|
await destinationController
|
||||||
.cancelBuyPoint(destination);
|
.cancelBuyPoint(destination);
|
||||||
Get.back();
|
Navigator.of(Get.context!).pop();
|
||||||
|
//Get.back();
|
||||||
destinationController.rogainingCounted.value = true;
|
destinationController.rogainingCounted.value = true;
|
||||||
destinationController.skipGps = false;
|
destinationController.skipGps = false;
|
||||||
destinationController.isPhotoShoot.value = false;
|
destinationController.isPhotoShoot.value = false;
|
||||||
@ -519,10 +489,14 @@ class BuyPointCamera extends StatelessWidget {
|
|||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Colors.red),
|
backgroundColor: Colors.red),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
// print(
|
||||||
|
// "in camera purchase 3 ${destinationController.isInRog.value}");
|
||||||
await destinationController.makeBuyPoint(
|
await destinationController.makeBuyPoint(
|
||||||
destination,
|
destination,
|
||||||
destinationController.photos[0].path);
|
destinationController.photos[0].path);
|
||||||
Get.back();
|
Get.back();
|
||||||
|
// print(
|
||||||
|
// "in camera purchase 4 ${destinationController.isInRog.value}");
|
||||||
destinationController.rogainingCounted.value =
|
destinationController.rogainingCounted.value =
|
||||||
true;
|
true;
|
||||||
destinationController.skipGps = false;
|
destinationController.skipGps = false;
|
||||||
|
|||||||
@ -6,6 +6,6 @@ class DestinationBinding extends Bindings {
|
|||||||
@override
|
@override
|
||||||
void dependencies() {
|
void dependencies() {
|
||||||
Get.put<DestinationController>(DestinationController());
|
Get.put<DestinationController>(DestinationController());
|
||||||
restoreGame();
|
//restoreGame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'dart:typed_data';
|
||||||
import 'package:camera_camera/camera_camera.dart';
|
import 'package:camera_camera/camera_camera.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_map/flutter_map.dart';
|
import 'package:flutter_map/flutter_map.dart';
|
||||||
import 'package:geojson/geojson.dart';
|
import 'package:flutter_map_location_marker/flutter_map_location_marker.dart';
|
||||||
|
import 'package:geojson_vi/geojson_vi.dart';
|
||||||
import 'package:geolocator/geolocator.dart';
|
import 'package:geolocator/geolocator.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
@ -13,6 +15,7 @@ import 'package:rogapp/model/gps_data.dart';
|
|||||||
import 'package:rogapp/pages/camera/camera_page.dart';
|
import 'package:rogapp/pages/camera/camera_page.dart';
|
||||||
import 'package:rogapp/pages/index/index_controller.dart';
|
import 'package:rogapp/pages/index/index_controller.dart';
|
||||||
import 'package:rogapp/routes/app_pages.dart';
|
import 'package:rogapp/routes/app_pages.dart';
|
||||||
|
import 'package:rogapp/services/DatabaseService.dart';
|
||||||
import 'package:rogapp/services/destination_service.dart';
|
import 'package:rogapp/services/destination_service.dart';
|
||||||
import 'package:rogapp/services/external_service.dart';
|
import 'package:rogapp/services/external_service.dart';
|
||||||
import 'package:rogapp/services/location_service.dart';
|
import 'package:rogapp/services/location_service.dart';
|
||||||
@ -20,13 +23,15 @@ import 'package:rogapp/services/maxtrix_service.dart';
|
|||||||
import 'package:rogapp/services/perfecture_service.dart';
|
import 'package:rogapp/services/perfecture_service.dart';
|
||||||
import 'package:rogapp/utils/database_gps.dart';
|
import 'package:rogapp/utils/database_gps.dart';
|
||||||
import 'package:rogapp/utils/database_helper.dart';
|
import 'package:rogapp/utils/database_helper.dart';
|
||||||
|
import 'package:rogapp/utils/location_controller.dart';
|
||||||
import 'package:rogapp/widgets/bottom_sheet_new.dart';
|
import 'package:rogapp/widgets/bottom_sheet_new.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
|
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
|
||||||
import 'package:rogapp/widgets/debug_widget.dart';
|
import 'package:rogapp/widgets/debug_widget.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:gallery_saver/gallery_saver.dart';
|
|
||||||
|
import 'package:image_gallery_saver/image_gallery_saver.dart';
|
||||||
|
|
||||||
class DestinationController extends GetxController {
|
class DestinationController extends GetxController {
|
||||||
late LocationSettings locationSettings;
|
late LocationSettings locationSettings;
|
||||||
@ -39,8 +44,11 @@ class DestinationController extends GetxController {
|
|||||||
double currentLon = 0.0;
|
double currentLon = 0.0;
|
||||||
DateTime lastGPSCollectedTime = DateTime.now();
|
DateTime lastGPSCollectedTime = DateTime.now();
|
||||||
|
|
||||||
|
bool shouldShowBottomSheet = true;
|
||||||
|
|
||||||
static bool gps_push_started = false;
|
static bool gps_push_started = false;
|
||||||
static bool game_started = false;
|
static bool game_started = false;
|
||||||
|
static bool ready_for_goal = false;
|
||||||
|
|
||||||
bool skip_10s = false;
|
bool skip_10s = false;
|
||||||
|
|
||||||
@ -70,6 +78,8 @@ class DestinationController extends GetxController {
|
|||||||
final photos = <File>[].obs;
|
final photos = <File>[].obs;
|
||||||
|
|
||||||
final IndexController indexController = Get.find<IndexController>();
|
final IndexController indexController = Get.find<IndexController>();
|
||||||
|
final LocationController locationController = Get.put(LocationController());
|
||||||
|
final DatabaseService dbService = DatabaseService();
|
||||||
|
|
||||||
int _start = 0;
|
int _start = 0;
|
||||||
int chekcs = 0;
|
int chekcs = 0;
|
||||||
@ -79,10 +89,9 @@ class DestinationController extends GetxController {
|
|||||||
return DateFormat('yyyy-MM-dd HH:mm:ss').format(datetime);
|
return DateFormat('yyyy-MM-dd HH:mm:ss').format(datetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
Destination festuretoDestination(GeoJsonFeature fs) {
|
Destination festuretoDestination(GeoJSONFeature fs) {
|
||||||
GeoJsonMultiPoint mp = fs.geometry as GeoJsonMultiPoint;
|
GeoJSONMultiPoint mp = fs.geometry as GeoJSONMultiPoint;
|
||||||
LatLng pt = LatLng(mp.geoSerie!.geoPoints[0].latitude,
|
LatLng pt = LatLng(mp.coordinates[0][1], mp.coordinates[0][0]);
|
||||||
mp.geoSerie!.geoPoints[0].longitude);
|
|
||||||
|
|
||||||
//print("----- ${indexController.currentFeature[0].properties} -----");
|
//print("----- ${indexController.currentFeature[0].properties} -----");
|
||||||
|
|
||||||
@ -112,7 +121,7 @@ class DestinationController extends GetxController {
|
|||||||
tags: fs.properties!["tags"]);
|
tags: fs.properties!["tags"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> startTimerLocation(GeoJsonFeature fs, double distance) async {
|
Future<void> startTimerLocation(GeoJSONFeature fs, double distance) async {
|
||||||
//print("---- in startTimer ----");
|
//print("---- in startTimer ----");
|
||||||
// print("---- is in rog is $is_in_rog ----");
|
// print("---- is in rog is $is_in_rog ----");
|
||||||
double checkinRadious = fs.properties!['checkin_radius'] ?? double.infinity;
|
double checkinRadious = fs.properties!['checkin_radius'] ?? double.infinity;
|
||||||
@ -156,7 +165,7 @@ class DestinationController extends GetxController {
|
|||||||
//make current destination
|
//make current destination
|
||||||
// print("---- checkin_radious $checkinRadious ----");
|
// print("---- checkin_radious $checkinRadious ----");
|
||||||
// print("---- distance $distance ----");
|
// print("---- distance $distance ----");
|
||||||
if (checkinRadious >= distance) {
|
if (checkinRadious >= distance || checkinRadious == -1) {
|
||||||
//currentSelectedDestinations.add(d);
|
//currentSelectedDestinations.add(d);
|
||||||
indexController.currentDestinationFeature.clear();
|
indexController.currentDestinationFeature.clear();
|
||||||
indexController.currentDestinationFeature.add(d);
|
indexController.currentDestinationFeature.add(d);
|
||||||
@ -170,15 +179,22 @@ class DestinationController extends GetxController {
|
|||||||
|
|
||||||
if (isPhotoShoot.value == true) {
|
if (isPhotoShoot.value == true) {
|
||||||
photos.clear();
|
photos.clear();
|
||||||
|
if (shouldShowBottomSheet) {
|
||||||
|
shouldShowBottomSheet = false;
|
||||||
|
if (d.cp == -1) return;
|
||||||
await showModalBottomSheet(
|
await showModalBottomSheet(
|
||||||
constraints: BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
constraints:
|
||||||
|
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
||||||
context: Get.context!,
|
context: Get.context!,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
builder: ((context) => CameraPage(destination: d))).whenComplete(() {
|
builder: ((context) => CameraPage(destination: d)))
|
||||||
|
.whenComplete(() {
|
||||||
|
shouldShowBottomSheet = true;
|
||||||
skipGps = false;
|
skipGps = false;
|
||||||
chekcs = 0;
|
chekcs = 0;
|
||||||
isInCheckin.value = false;
|
isInCheckin.value = false;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,6 +208,9 @@ class DestinationController extends GetxController {
|
|||||||
chekcs = 1;
|
chekcs = 1;
|
||||||
isInCheckin.value = true;
|
isInCheckin.value = true;
|
||||||
isAtStart.value = true;
|
isAtStart.value = true;
|
||||||
|
if (shouldShowBottomSheet) {
|
||||||
|
shouldShowBottomSheet = false;
|
||||||
|
if (d.cp == -1) return;
|
||||||
await showModalBottomSheet(
|
await showModalBottomSheet(
|
||||||
constraints:
|
constraints:
|
||||||
BoxConstraints.loose(Size(Get.width, Get.height * 0.85)),
|
BoxConstraints.loose(Size(Get.width, Get.height * 0.85)),
|
||||||
@ -200,16 +219,23 @@ class DestinationController extends GetxController {
|
|||||||
builder: ((context) => BottomSheetNew(
|
builder: ((context) => BottomSheetNew(
|
||||||
destination: d,
|
destination: d,
|
||||||
))).whenComplete(() {
|
))).whenComplete(() {
|
||||||
|
shouldShowBottomSheet = true;
|
||||||
skipGps = false;
|
skipGps = false;
|
||||||
chekcs = 0;
|
chekcs = 0;
|
||||||
isAtStart.value = false;
|
isAtStart.value = false;
|
||||||
isInCheckin.value = false;
|
isInCheckin.value = false;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
} else if (isInRog.value == true && indexController.rogMode.value == 1) {
|
} else if (isInRog.value == true &&
|
||||||
|
indexController.rogMode.value == 1 &&
|
||||||
|
d.cp != -1) {
|
||||||
// print("----- in location popup checkin cp - ${d.cp}----");
|
// print("----- in location popup checkin cp - ${d.cp}----");
|
||||||
chekcs = 2;
|
chekcs = 2;
|
||||||
isInCheckin.value = true;
|
isInCheckin.value = true;
|
||||||
|
if (shouldShowBottomSheet) {
|
||||||
|
shouldShowBottomSheet = false;
|
||||||
|
if (d.cp == -1) return;
|
||||||
await showModalBottomSheet(
|
await showModalBottomSheet(
|
||||||
constraints:
|
constraints:
|
||||||
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
||||||
@ -218,17 +244,19 @@ class DestinationController extends GetxController {
|
|||||||
builder: ((context) => BottomSheetNew(
|
builder: ((context) => BottomSheetNew(
|
||||||
destination: d,
|
destination: d,
|
||||||
))).whenComplete(() {
|
))).whenComplete(() {
|
||||||
|
shouldShowBottomSheet = true;
|
||||||
skipGps = false;
|
skipGps = false;
|
||||||
chekcs = 0;
|
chekcs = 0;
|
||||||
isInCheckin.value = false;
|
isInCheckin.value = false;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// print("---- location checkin radious ${d.checkin_radious} ----");
|
// print("---- location checkin radious ${d.checkin_radious} ----");
|
||||||
// print("---- already checked in $locationAlreadyCheckedIn ----");
|
// print("---- already checked in $locationAlreadyCheckedIn ----");
|
||||||
if (checkinRadious >= distance &&
|
if ((checkinRadious >= distance || checkinRadious == -1) &&
|
||||||
locationAlreadyCheckedIn == false &&
|
locationAlreadyCheckedIn == false &&
|
||||||
isInRog.value == true) {
|
isInRog.value == true) {
|
||||||
if (autoCheckin) {
|
if (autoCheckin) {
|
||||||
@ -253,6 +281,9 @@ class DestinationController extends GetxController {
|
|||||||
isInCheckin.value = true;
|
isInCheckin.value = true;
|
||||||
photos.clear();
|
photos.clear();
|
||||||
// print("--- calling checkin ---");
|
// print("--- calling checkin ---");
|
||||||
|
if (shouldShowBottomSheet) {
|
||||||
|
shouldShowBottomSheet = false;
|
||||||
|
if (d.cp == -1) return;
|
||||||
await showModalBottomSheet(
|
await showModalBottomSheet(
|
||||||
constraints:
|
constraints:
|
||||||
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
||||||
@ -261,15 +292,20 @@ class DestinationController extends GetxController {
|
|||||||
builder: ((context) => CameraPage(
|
builder: ((context) => CameraPage(
|
||||||
destination: d,
|
destination: d,
|
||||||
))).whenComplete(() {
|
))).whenComplete(() {
|
||||||
|
shouldShowBottomSheet = true;
|
||||||
skipGps = false;
|
skipGps = false;
|
||||||
rogainingCounted.value = true;
|
rogainingCounted.value = true;
|
||||||
chekcs = 0;
|
chekcs = 0;
|
||||||
isInCheckin.value = false;
|
isInCheckin.value = false;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
} else if (isInRog.value == true && d.cp != -1) {
|
} else if (isInRog.value == true && d.cp != -1) {
|
||||||
chekcs = 4;
|
chekcs = 4;
|
||||||
isInCheckin.value = true;
|
isInCheckin.value = true;
|
||||||
|
if (shouldShowBottomSheet) {
|
||||||
|
shouldShowBottomSheet = false;
|
||||||
|
if (d.cp == -1) return;
|
||||||
await showMaterialModalBottomSheet(
|
await showMaterialModalBottomSheet(
|
||||||
expand: true,
|
expand: true,
|
||||||
context: Get.context!,
|
context: Get.context!,
|
||||||
@ -277,14 +313,16 @@ class DestinationController extends GetxController {
|
|||||||
builder: (context) => BottomSheetNew(
|
builder: (context) => BottomSheetNew(
|
||||||
destination: d,
|
destination: d,
|
||||||
)).whenComplete(() {
|
)).whenComplete(() {
|
||||||
|
shouldShowBottomSheet = true;
|
||||||
skipGps = false;
|
skipGps = false;
|
||||||
chekcs = 0;
|
chekcs = 0;
|
||||||
isInCheckin.value = false;
|
isInCheckin.value = false;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (checkinRadious >= distance &&
|
} else if ((checkinRadious >= distance || checkinRadious == -1) &&
|
||||||
locationAlreadyCheckedIn == true &&
|
locationAlreadyCheckedIn == true &&
|
||||||
buyPointImageAdded == false &&
|
buyPointImageAdded == false &&
|
||||||
ds.isNotEmpty &&
|
ds.isNotEmpty &&
|
||||||
@ -295,8 +333,12 @@ class DestinationController extends GetxController {
|
|||||||
isInCheckin.value = true;
|
isInCheckin.value = true;
|
||||||
photos.clear();
|
photos.clear();
|
||||||
//print("--- open buy point $buyPointImageAdded ${d.buypoint_image} ----");
|
//print("--- open buy point $buyPointImageAdded ${d.buypoint_image} ----");
|
||||||
|
if (shouldShowBottomSheet) {
|
||||||
|
shouldShowBottomSheet = false;
|
||||||
|
if (d.cp == -1) return;
|
||||||
await showModalBottomSheet(
|
await showModalBottomSheet(
|
||||||
constraints: BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
constraints:
|
||||||
|
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
||||||
context: Get.context!,
|
context: Get.context!,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
builder: ((context) => CameraPage(
|
builder: ((context) => CameraPage(
|
||||||
@ -304,11 +346,13 @@ class DestinationController extends GetxController {
|
|||||||
destination: d,
|
destination: d,
|
||||||
dbDest: ds.first,
|
dbDest: ds.first,
|
||||||
))).whenComplete(() {
|
))).whenComplete(() {
|
||||||
|
shouldShowBottomSheet = true;
|
||||||
skipGps = false;
|
skipGps = false;
|
||||||
rogainingCounted.value = true;
|
rogainingCounted.value = true;
|
||||||
chekcs = 0;
|
chekcs = 0;
|
||||||
isInCheckin.value = false;
|
isInCheckin.value = false;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// print("---- cp --- ${d.cp} -----");
|
// print("---- cp --- ${d.cp} -----");
|
||||||
@ -328,6 +372,9 @@ class DestinationController extends GetxController {
|
|||||||
chekcs = 5;
|
chekcs = 5;
|
||||||
isAtGoal.value = true;
|
isAtGoal.value = true;
|
||||||
photos.clear();
|
photos.clear();
|
||||||
|
if (shouldShowBottomSheet) {
|
||||||
|
shouldShowBottomSheet = false;
|
||||||
|
if (d.cp == -1) return;
|
||||||
await showModalBottomSheet(
|
await showModalBottomSheet(
|
||||||
constraints:
|
constraints:
|
||||||
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
||||||
@ -336,10 +383,12 @@ class DestinationController extends GetxController {
|
|||||||
builder: ((context) => CameraPage(
|
builder: ((context) => CameraPage(
|
||||||
destination: d,
|
destination: d,
|
||||||
))).whenComplete(() {
|
))).whenComplete(() {
|
||||||
|
shouldShowBottomSheet = true;
|
||||||
skipGps = false;
|
skipGps = false;
|
||||||
chekcs = 0;
|
chekcs = 0;
|
||||||
isAtGoal.value = false;
|
isAtGoal.value = false;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
} else if (isInRog.value == false &&
|
} else if (isInRog.value == false &&
|
||||||
indexController.rogMode.value == 1 &&
|
indexController.rogMode.value == 1 &&
|
||||||
@ -348,6 +397,9 @@ class DestinationController extends GetxController {
|
|||||||
//print("---- in start -----");
|
//print("---- in start -----");
|
||||||
chekcs = 6;
|
chekcs = 6;
|
||||||
isAtStart.value = true;
|
isAtStart.value = true;
|
||||||
|
if (shouldShowBottomSheet) {
|
||||||
|
shouldShowBottomSheet = false;
|
||||||
|
if (d.cp == -1) return;
|
||||||
await showModalBottomSheet(
|
await showModalBottomSheet(
|
||||||
constraints:
|
constraints:
|
||||||
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
||||||
@ -356,11 +408,13 @@ class DestinationController extends GetxController {
|
|||||||
builder: ((context) => BottomSheetNew(
|
builder: ((context) => BottomSheetNew(
|
||||||
destination: d,
|
destination: d,
|
||||||
))).whenComplete(() {
|
))).whenComplete(() {
|
||||||
|
shouldShowBottomSheet = true;
|
||||||
//print("----- finished start -------");
|
//print("----- finished start -------");
|
||||||
skipGps = false;
|
skipGps = false;
|
||||||
chekcs = 0;
|
chekcs = 0;
|
||||||
isAtStart.value = false;
|
isAtStart.value = false;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -371,7 +425,7 @@ class DestinationController extends GetxController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> resetRogaining() async {
|
Future<void> resetRogaining({bool isgoal = false}) async {
|
||||||
//print("----- resetting --------");
|
//print("----- resetting --------");
|
||||||
|
|
||||||
isInCheckin.value = false;
|
isInCheckin.value = false;
|
||||||
@ -380,17 +434,25 @@ class DestinationController extends GetxController {
|
|||||||
isAtGoal.value = false;
|
isAtGoal.value = false;
|
||||||
isGpsSelected.value = true;
|
isGpsSelected.value = true;
|
||||||
skipGps = false;
|
skipGps = false;
|
||||||
|
ready_for_goal = false;
|
||||||
|
|
||||||
_start = 0;
|
_start = 0;
|
||||||
chekcs = 0;
|
chekcs = 0;
|
||||||
rogainingCounted.value = false;
|
rogainingCounted.value = false;
|
||||||
|
|
||||||
DatabaseHelper db = DatabaseHelper.instance;
|
DatabaseHelper db = DatabaseHelper.instance;
|
||||||
|
|
||||||
|
if (isgoal == false) {
|
||||||
|
await db.deleteAllDestinations();
|
||||||
|
await db.deleteAllRogaining();
|
||||||
|
}
|
||||||
|
|
||||||
int? latgoal = await db.latestGoal();
|
int? latgoal = await db.latestGoal();
|
||||||
if (latgoal != null) {
|
if (latgoal != null) {
|
||||||
lastGoalAt = DateTime.fromMicrosecondsSinceEpoch(latgoal);
|
lastGoalAt = DateTime.fromMicrosecondsSinceEpoch(latgoal);
|
||||||
//print("===== last goal : $last_goal_at =====");
|
//print("===== last goal : $last_goal_at =====");
|
||||||
}
|
}
|
||||||
|
dbService.updateDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteAllDestinations() {
|
void deleteAllDestinations() {
|
||||||
@ -505,6 +567,8 @@ class DestinationController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> addGPStoDB(double la, double ln, {isCheckin = 0}) async {
|
Future<void> addGPStoDB(double la, double ln, {isCheckin = 0}) async {
|
||||||
|
//print("in addGPStoDB ${indexController.currentUser}");
|
||||||
|
try {
|
||||||
GpsDatabaseHelper db = GpsDatabaseHelper.instance;
|
GpsDatabaseHelper db = GpsDatabaseHelper.instance;
|
||||||
final team_name = indexController.currentUser[0]["user"]['team_name'];
|
final team_name = indexController.currentUser[0]["user"]['team_name'];
|
||||||
final event_code = indexController.currentUser[0]["user"]["event_code"];
|
final event_code = indexController.currentUser[0]["user"]["event_code"];
|
||||||
@ -517,85 +581,36 @@ class DestinationController extends GetxController {
|
|||||||
is_checkin: isCheckin,
|
is_checkin: isCheckin,
|
||||||
created_at: DateTime.now().millisecondsSinceEpoch);
|
created_at: DateTime.now().millisecondsSinceEpoch);
|
||||||
var res = await db.insertGps(gps_data);
|
var res = await db.insertGps(gps_data);
|
||||||
//print("==gps res == ${res}");
|
} catch (err) {
|
||||||
|
print("errr ready gps ${err}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> checkForCheckin() async {
|
Future<void> checkForCheckin() async {
|
||||||
//print("--- Start of checkForCheckin function ---");
|
//print("--- Start of checkForCheckin function ---");
|
||||||
|
dbService.updateDatabase();
|
||||||
|
await Future.delayed(const Duration(milliseconds: 3000));
|
||||||
game_started = true;
|
game_started = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//print("--- 000 ---- $skip_gps----");
|
indexController.locations[0].features.forEach((fs) async {
|
||||||
await Future.delayed(const Duration(milliseconds: 3000));
|
GeoJSONMultiPoint mp = fs!.geometry as GeoJSONMultiPoint;
|
||||||
Position position = await Geolocator.getCurrentPosition(
|
LatLng pt = LatLng(mp.coordinates[0][1], mp.coordinates[0][0]);
|
||||||
desiredAccuracy: LocationAccuracy.bestForNavigation);
|
|
||||||
|
|
||||||
currentLat = position.latitude;
|
|
||||||
currentLon = position.longitude;
|
|
||||||
final la = position.latitude;
|
|
||||||
final ln = position.longitude;
|
|
||||||
|
|
||||||
LogManager().addLog(
|
|
||||||
"GPS : $currentLat, $currentLon - ${DateTime.now().hour}:${DateTime.now().minute}:${DateTime.now().second}:${DateTime.now().microsecond}");
|
|
||||||
|
|
||||||
//print("--- gps is ${la}, ${ln}");
|
|
||||||
|
|
||||||
//add gps to database
|
|
||||||
//check distance to previous point
|
|
||||||
var distance = const Distance();
|
|
||||||
double distanceToDest = distance.as(
|
|
||||||
LengthUnit.Meter,
|
|
||||||
LatLng(position.latitude, position.longitude),
|
|
||||||
LatLng(currentLat, currentLon));
|
|
||||||
Duration difference =
|
|
||||||
lastGPSCollectedTime.difference(DateTime.now()).abs();
|
|
||||||
if (difference.inSeconds >= 10 || distanceToDest >= 10) {
|
|
||||||
print(
|
|
||||||
"^^^^^^^^ GPS data collected ${DateFormat('kk:mm:ss \n EEE d MMM').format(DateTime.now())}, ^^^ ${position.latitude}, ${position.longitude}");
|
|
||||||
|
|
||||||
await addGPStoDB(la, ln);
|
|
||||||
lastGPSCollectedTime = DateTime.now();
|
|
||||||
}
|
|
||||||
|
|
||||||
// GpsDatabaseHelper db = GpsDatabaseHelper.instance;
|
|
||||||
// final team_name = indexController.currentUser[0]["user"]['team_name'];
|
|
||||||
// final event_code = indexController.currentUser[0]["user"]["event_code"];
|
|
||||||
// print("--- curr gps is ${la}, ${ln}");
|
|
||||||
// GpsData gps_data = GpsData(
|
|
||||||
// id: 0,
|
|
||||||
// team_name: team_name,
|
|
||||||
// event_code: event_code,
|
|
||||||
// lat: la,
|
|
||||||
// lon: ln,
|
|
||||||
// created_at: DateTime.now().microsecondsSinceEpoch);
|
|
||||||
// await db.insertGps(gps_data);
|
|
||||||
|
|
||||||
for (GeoJsonFeature fs in indexController.locations[0].collection) {
|
|
||||||
GeoJsonMultiPoint mp = fs.geometry as GeoJsonMultiPoint;
|
|
||||||
LatLng pt = LatLng(mp.geoSerie!.geoPoints[0].latitude,
|
|
||||||
mp.geoSerie!.geoPoints[0].longitude);
|
|
||||||
|
|
||||||
double latFs = pt.latitude;
|
double latFs = pt.latitude;
|
||||||
double lonFs = pt.longitude;
|
double lonFs = pt.longitude;
|
||||||
var distanceFs = const Distance();
|
var distanceFs = const Distance();
|
||||||
//print("--- points : ${pt.latitude}, ${pt.longitude} ----");
|
double distFs = distanceFs.as(LengthUnit.Meter, LatLng(latFs, lonFs),
|
||||||
//print("--- points : ${pt.latitude}, ${pt.longitude} ----");
|
LatLng(currentLat, currentLon));
|
||||||
double distFs = distanceFs.as(
|
|
||||||
LengthUnit.Meter, LatLng(latFs, lonFs), LatLng(la, ln));
|
|
||||||
Destination des = festuretoDestination(fs);
|
Destination des = festuretoDestination(fs);
|
||||||
|
|
||||||
//print(
|
|
||||||
// "--- position is ---- ${position.longitude}, --- ${position.longitude}----");
|
|
||||||
|
|
||||||
//print("--- distFs ---- $distFs, --- ${des.checkin_radious}----");
|
|
||||||
if (distFs <= des.checkin_radious! && skipGps == false) {
|
if (distFs <= des.checkin_radious! && skipGps == false) {
|
||||||
//print("--- 789 ---- $skip_gps----");
|
|
||||||
//near a location
|
|
||||||
//print("---- before call startTimerLocation ----");
|
|
||||||
await startTimerLocation(fs, distFs);
|
await startTimerLocation(fs, distFs);
|
||||||
break;
|
// Note: You cannot break out of forEach. If you need to stop processing, you might have to reconsider using forEach.
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (gps_push_started == false) {
|
if (gps_push_started == false) {
|
||||||
pushGPStoServer();
|
pushGPStoServer();
|
||||||
}
|
}
|
||||||
@ -635,7 +650,7 @@ class DestinationController extends GetxController {
|
|||||||
}
|
}
|
||||||
isInRog.value = true;
|
isInRog.value = true;
|
||||||
|
|
||||||
saveGameState();
|
//saveGameState();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> cancelBuyPoint(Destination destination) async {
|
Future<void> cancelBuyPoint(Destination destination) async {
|
||||||
@ -644,11 +659,21 @@ class DestinationController extends GetxController {
|
|||||||
populateDestinations();
|
populateDestinations();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_saveImageFromPath(String imagePath) async {
|
||||||
|
// Read the image file from the given path
|
||||||
|
File imageFile = File(imagePath);
|
||||||
|
Uint8List imageBytes = await imageFile.readAsBytes();
|
||||||
|
|
||||||
|
// Save the image to the gallery
|
||||||
|
final result = await ImageGallerySaver.saveImage(imageBytes);
|
||||||
|
//print("--- save result --- ${result}");
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> makeBuyPoint(Destination destination, String imageurl) async {
|
Future<void> makeBuyPoint(Destination destination, String imageurl) async {
|
||||||
DatabaseHelper db = DatabaseHelper.instance;
|
DatabaseHelper db = DatabaseHelper.instance;
|
||||||
await db.updateBuyPoint(destination, imageurl);
|
await db.updateBuyPoint(destination, imageurl);
|
||||||
populateDestinations();
|
populateDestinations();
|
||||||
await GallerySaver.saveImage(imageurl);
|
await _saveImageFromPath(imageurl);
|
||||||
|
|
||||||
if (indexController.currentUser.isNotEmpty) {
|
if (indexController.currentUser.isNotEmpty) {
|
||||||
double cpNum = destination.cp!;
|
double cpNum = destination.cp!;
|
||||||
@ -690,7 +715,7 @@ class DestinationController extends GetxController {
|
|||||||
// print("~~~~ inserted into db ~~~~");
|
// print("~~~~ inserted into db ~~~~");
|
||||||
}
|
}
|
||||||
|
|
||||||
await GallerySaver.saveImage(imageurl);
|
await _saveImageFromPath(imageurl);
|
||||||
|
|
||||||
populateDestinations();
|
populateDestinations();
|
||||||
|
|
||||||
@ -719,9 +744,11 @@ class DestinationController extends GetxController {
|
|||||||
// print("------Ext service check point $value ------");
|
// print("------Ext service check point $value ------");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
dbService.updateDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> removeCheckin(int cp) {
|
Future<void> removeCheckin(int cp) {
|
||||||
|
dbService.updateDatabase();
|
||||||
return ExternalService().removeCheckin(cp);
|
return ExternalService().removeCheckin(cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -734,20 +761,84 @@ class DestinationController extends GetxController {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() async {
|
void onInit() async {
|
||||||
startGame();
|
|
||||||
super.onInit();
|
super.onInit();
|
||||||
|
locationController.locationMarkerPositionStream.listen(
|
||||||
|
(locationMarkerPosition) {
|
||||||
|
if (locationMarkerPosition != null) {
|
||||||
|
handleLocationUpdate(locationMarkerPosition);
|
||||||
|
}
|
||||||
|
}, onError: (err) {
|
||||||
|
print("Error: $err");
|
||||||
|
});
|
||||||
|
|
||||||
|
startGame();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onClose() {
|
||||||
|
locationController.stopPositionStream();
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleLocationUpdate(LocationMarkerPosition? position) async {
|
||||||
|
try {
|
||||||
|
if (position != null) {
|
||||||
|
if (distanceToStart() >= 150) {
|
||||||
|
ready_for_goal = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var distance = const Distance();
|
||||||
|
double distanceToDest = distance.as(
|
||||||
|
LengthUnit.Meter,
|
||||||
|
LatLng(position.latitude, position.longitude),
|
||||||
|
LatLng(currentLat, currentLon));
|
||||||
|
|
||||||
|
Duration difference =
|
||||||
|
lastGPSCollectedTime.difference(DateTime.now()).abs();
|
||||||
|
if (difference.inSeconds >= 10 || distanceToDest >= 10) {
|
||||||
|
// print(
|
||||||
|
// "^^^^^^^^ GPS data collected ${DateFormat('kk:mm:ss \n EEE d MMM').format(DateTime.now())}, ^^^ ${position.latitude}, ${position.longitude}");
|
||||||
|
|
||||||
|
LogManager().addLog(
|
||||||
|
"GPS : $currentLat, $currentLon - ${DateTime.now().hour}:${DateTime.now().minute}:${DateTime.now().second}:${DateTime.now().microsecond}");
|
||||||
|
if (isInRog.value) {
|
||||||
|
await addGPStoDB(position.latitude, position.longitude);
|
||||||
|
lastGPSCollectedTime = DateTime.now();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (position != null &&
|
||||||
|
(position.latitude != 0 && position.longitude != 0)) {
|
||||||
|
currentLat = position.latitude;
|
||||||
|
currentLon = position.longitude;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double distanceToStart() {
|
double distanceToStart() {
|
||||||
|
if (indexController.locations.isEmpty) {
|
||||||
|
return 1000000000;
|
||||||
|
}
|
||||||
//print("=== gfs len == ${indexController.locations[0].collection.length}");
|
//print("=== gfs len == ${indexController.locations[0].collection.length}");
|
||||||
GeoJsonFeature gfs = indexController.locations[0].collection
|
double distanceToDest = double.infinity;
|
||||||
.firstWhere((element) => festuretoDestination(element).cp == -1);
|
if (indexController.locations[0].features.isEmpty) {
|
||||||
|
return distanceToDest;
|
||||||
|
}
|
||||||
|
GeoJSONFeature? gfs = indexController.locations[0].features.firstWhere(
|
||||||
|
(element) => festuretoDestination(element!).cp == -1,
|
||||||
|
orElse: () => null, // Provide a null value if no element is found
|
||||||
|
);
|
||||||
|
|
||||||
|
//print("gfs : ${gfs}");
|
||||||
|
|
||||||
|
if (gfs == null) {
|
||||||
|
return distanceToDest;
|
||||||
|
}
|
||||||
|
|
||||||
Destination des = festuretoDestination(gfs);
|
Destination des = festuretoDestination(gfs);
|
||||||
|
|
||||||
//print("=== gfs == ${des.toMap()}");
|
//print("=== gfs == ${des.toMap()}");
|
||||||
|
|
||||||
double distanceToDest = double.infinity;
|
|
||||||
var distance = const Distance();
|
var distance = const Distance();
|
||||||
distanceToDest = distance.as(LengthUnit.Meter,
|
distanceToDest = distance.as(LengthUnit.Meter,
|
||||||
LatLng(currentLat, currentLon), LatLng(des.lat!, des.lon!));
|
LatLng(currentLat, currentLon), LatLng(des.lat!, des.lon!));
|
||||||
@ -756,13 +847,23 @@ class DestinationController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int getForcedChckinDistance(Destination dest) {
|
int getForcedChckinDistance(Destination dest) {
|
||||||
|
if (dest.checkin_radious == -1) {
|
||||||
|
return 10000000000000000;
|
||||||
|
}
|
||||||
|
|
||||||
int _retValue = 100;
|
int _retValue = 100;
|
||||||
if (dest.cp == -1) {
|
if (dest.cp == -1) {
|
||||||
return 500;
|
return 500;
|
||||||
}
|
}
|
||||||
Destination? ds;
|
Destination? ds;
|
||||||
GeoJsonFeature gfs = indexController.locations[0].collection
|
GeoJSONFeature? gfs = indexController.locations[0].features.firstWhere(
|
||||||
.firstWhere((element) => festuretoDestination(element).cp == -1);
|
(element) => festuretoDestination(element!).cp == -1,
|
||||||
|
orElse: () => null, // Provide a null value if no element is found
|
||||||
|
);
|
||||||
|
|
||||||
|
if (gfs == null) {
|
||||||
|
return _retValue;
|
||||||
|
}
|
||||||
|
|
||||||
ds = festuretoDestination(gfs);
|
ds = festuretoDestination(gfs);
|
||||||
var distance = const Distance();
|
var distance = const Distance();
|
||||||
@ -824,10 +925,18 @@ class DestinationController extends GetxController {
|
|||||||
indexController.currentBound.clear();
|
indexController.currentBound.clear();
|
||||||
indexController.currentBound.add(bnds);
|
indexController.currentBound.add(bnds);
|
||||||
indexController.loadLocationsBound();
|
indexController.loadLocationsBound();
|
||||||
|
centerMapToCurrentLocation();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void centerMapToCurrentLocation() {
|
||||||
|
print("center is ${currentLon}, ${currentLon}");
|
||||||
|
if (currentLat != 0 || currentLon != 0) {
|
||||||
|
indexController.mapController.move(LatLng(currentLat, currentLon), 17.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void connectionChanged(String val) {
|
void connectionChanged(String val) {
|
||||||
//print('----- %%%%%%%%%%%%%%%%%%%%% ----- $val');
|
//print('----- %%%%%%%%%%%%%%%%%%%%% ----- $val');
|
||||||
Map<String, dynamic> res = {};
|
Map<String, dynamic> res = {};
|
||||||
@ -903,6 +1012,7 @@ class DestinationController extends GetxController {
|
|||||||
db.deleteDestination(d.location_id!).then((value) {
|
db.deleteDestination(d.location_id!).then((value) {
|
||||||
populateDestinations();
|
populateDestinations();
|
||||||
});
|
});
|
||||||
|
dbService.updateDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteDBDestinations() {
|
void deleteDBDestinations() {
|
||||||
@ -910,6 +1020,7 @@ class DestinationController extends GetxController {
|
|||||||
db.deleteAllDestinations().then((value) {
|
db.deleteAllDestinations().then((value) {
|
||||||
populateDestinations();
|
populateDestinations();
|
||||||
});
|
});
|
||||||
|
dbService.updateDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------- database ------------------///
|
// ---------- database ------------------///
|
||||||
@ -932,6 +1043,7 @@ class DestinationController extends GetxController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
dbService.updateDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggleSelection(Destination dest) async {
|
void toggleSelection(Destination dest) async {
|
||||||
@ -965,7 +1077,7 @@ class DestinationController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void destinationMatrixFromCurrentPoint(List<Destination> points) {
|
void destinationMatrixFromCurrentPoint(List<Destination> points) {
|
||||||
buildShowDialog(Get.context!);
|
//buildShowDialog(Get.context!);
|
||||||
MatrixService.getDestinations(points).then((mat) {
|
MatrixService.getDestinations(points).then((mat) {
|
||||||
//print(" matrix is ------- $mat");
|
//print(" matrix is ------- $mat");
|
||||||
matrix = mat;
|
matrix = mat;
|
||||||
@ -984,7 +1096,7 @@ class DestinationController extends GetxController {
|
|||||||
skipGps = false;
|
skipGps = false;
|
||||||
return;
|
return;
|
||||||
} finally {
|
} finally {
|
||||||
Get.back();
|
//Get.back();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
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_location_marker/flutter_map_location_marker.dart';
|
||||||
import 'package:flutter_map_marker_popup/flutter_map_marker_popup.dart';
|
import 'package:flutter_map_marker_popup/flutter_map_marker_popup.dart';
|
||||||
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
|
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
|
||||||
@ -42,9 +42,8 @@ class DestinationMapPage extends StatelessWidget {
|
|||||||
//print("^^^^ $d ^^^^");
|
//print("^^^^ $d ^^^^");
|
||||||
Marker m = Marker(
|
Marker m = Marker(
|
||||||
point: LatLng(d.lat!, d.lon!),
|
point: LatLng(d.lat!, d.lon!),
|
||||||
anchorPos: AnchorPos.align(AnchorAlign.center),
|
alignment: Alignment.center,
|
||||||
builder: (cts) {
|
child: InkWell(
|
||||||
return InkWell(
|
|
||||||
onTap: () {
|
onTap: () {
|
||||||
//print("-- Destination is --- ${d.name} ------");
|
//print("-- Destination is --- ${d.name} ------");
|
||||||
if (indexController.currentDestinationFeature.isNotEmpty) {
|
if (indexController.currentDestinationFeature.isNotEmpty) {
|
||||||
@ -56,8 +55,8 @@ class DestinationMapPage extends StatelessWidget {
|
|||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: Get.context!,
|
context: Get.context!,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
constraints: BoxConstraints.loose(
|
constraints:
|
||||||
Size(Get.width, Get.height * 0.85)),
|
BoxConstraints.loose(Size(Get.width, Get.height * 0.85)),
|
||||||
builder: ((context) => BottomSheetNew(
|
builder: ((context) => BottomSheetNew(
|
||||||
destination: d,
|
destination: d,
|
||||||
))).whenComplete(() {
|
))).whenComplete(() {
|
||||||
@ -76,8 +75,7 @@ class DestinationMapPage extends StatelessWidget {
|
|||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
width:
|
width: d.checkin_radious != null ? d.checkin_radious! : 1,
|
||||||
d.checkin_radious != null ? d.checkin_radious! : 1,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Center(
|
child: Center(
|
||||||
@ -98,8 +96,7 @@ class DestinationMapPage extends StatelessWidget {
|
|||||||
)),
|
)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
));
|
||||||
});
|
|
||||||
|
|
||||||
pts.add(m);
|
pts.add(m);
|
||||||
}
|
}
|
||||||
@ -158,7 +155,7 @@ class DestinationMapPage extends StatelessWidget {
|
|||||||
interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag,
|
interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag,
|
||||||
),
|
),
|
||||||
children: [
|
children: [
|
||||||
const BaseLayer(),
|
//const BaseLayer(),
|
||||||
Obx(
|
Obx(
|
||||||
() => indexController.routePointLenght > 0
|
() => indexController.routePointLenght > 0
|
||||||
? PolylineLayer(
|
? PolylineLayer(
|
||||||
|
|||||||
@ -115,32 +115,35 @@ class _GpsPageState extends State<GpsPage> {
|
|||||||
]),
|
]),
|
||||||
zoom: 1,
|
zoom: 1,
|
||||||
interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag,
|
interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag,
|
||||||
|
onPositionChanged: (MapPosition pos, bool hasGesture) {
|
||||||
onPositionChanged: (MapPosition pos, isvalue) {
|
if (hasGesture) {
|
||||||
indexController.currentBound = [pos.bounds!];
|
indexController.currentBound = [pos.bounds!];
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onTap: (tapPos, cord) {}, // Hide popup when the map is tapped.
|
onTap: (tapPos, cord) {}, // Hide popup when the map is tapped.
|
||||||
),
|
),
|
||||||
children: [
|
children: [
|
||||||
const BaseLayer(),
|
//const BaseLayer(),
|
||||||
MarkerLayer(
|
MarkerLayer(
|
||||||
markers: gpsData.map((i) {
|
markers: gpsData.map((i) {
|
||||||
return Marker(
|
return Marker(
|
||||||
anchorPos: AnchorPos.exactly(Anchor(108.0, 18.0)),
|
width: 30.0, // Fixed width
|
||||||
height: 32.0,
|
height: 30.0, // Fixed height
|
||||||
width: 120.0,
|
|
||||||
point: LatLng(i.lat, i.lon),
|
point: LatLng(i.lat, i.lon),
|
||||||
builder: (ctx) {
|
child: getMarkerShape(i),
|
||||||
return getMarkerShape(i);
|
alignment: Alignment.center);
|
||||||
// return Container(
|
|
||||||
// width: 40,
|
|
||||||
// height: 40,
|
|
||||||
// color: Colors.orange,
|
|
||||||
// );
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}).toList(),
|
}).toList(),
|
||||||
)
|
),
|
||||||
|
// MarkerLayer(
|
||||||
|
// markers: gpsData.map((i) {
|
||||||
|
// return Marker(
|
||||||
|
// alignment: Alignment.center,
|
||||||
|
// height: 32.0,
|
||||||
|
// width: 120.0,
|
||||||
|
// point: LatLng(i.lat, i.lon),
|
||||||
|
// child: getMarkerShape(i));
|
||||||
|
// }).toList(),
|
||||||
|
// )
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||||
import 'package:rogapp/pages/index/index_controller.dart';
|
import 'package:rogapp/pages/index/index_controller.dart';
|
||||||
|
import 'package:rogapp/utils/location_controller.dart';
|
||||||
|
|
||||||
class IndexBinding extends Bindings {
|
class IndexBinding extends Bindings {
|
||||||
@override
|
@override
|
||||||
void dependencies() {
|
void dependencies() {
|
||||||
Get.put<IndexController>(IndexController());
|
Get.put<IndexController>(IndexController());
|
||||||
|
Get.put<LocationController>(LocationController());
|
||||||
Get.put<DestinationController>(DestinationController());
|
Get.put<DestinationController>(DestinationController());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,9 +4,8 @@ import 'package:connectivity_plus/connectivity_plus.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_map/flutter_map.dart';
|
import 'package:flutter_map/flutter_map.dart';
|
||||||
import 'package:flutter_map/plugin_api.dart';
|
|
||||||
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
|
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
|
||||||
import 'package:geojson/geojson.dart';
|
import 'package:geojson_vi/geojson_vi.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:latlong2/latlong.dart';
|
import 'package:latlong2/latlong.dart';
|
||||||
import 'package:rogapp/model/destination.dart';
|
import 'package:rogapp/model/destination.dart';
|
||||||
@ -18,8 +17,8 @@ import 'package:rogapp/utils/database_helper.dart';
|
|||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
class IndexController extends GetxController {
|
class IndexController extends GetxController {
|
||||||
List<GeoJsonFeatureCollection> locations = <GeoJsonFeatureCollection>[].obs;
|
List<GeoJSONFeatureCollection> locations = <GeoJSONFeatureCollection>[].obs;
|
||||||
List<GeoJsonFeature> currentFeature = <GeoJsonFeature>[].obs;
|
List<GeoJSONFeature> currentFeature = <GeoJSONFeature>[].obs;
|
||||||
List<Destination> currentDestinationFeature = <Destination>[].obs;
|
List<Destination> currentDestinationFeature = <Destination>[].obs;
|
||||||
List<dynamic> perfectures = <dynamic>[].obs;
|
List<dynamic> perfectures = <dynamic>[].obs;
|
||||||
List<LatLngBounds> currentBound = <LatLngBounds>[].obs;
|
List<LatLngBounds> currentBound = <LatLngBounds>[].obs;
|
||||||
@ -117,8 +116,8 @@ class IndexController extends GetxController {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
_connectivitySubscription =
|
// _connectivitySubscription =
|
||||||
_connectivity.onConnectivityChanged.listen(_updateConnectionStatus);
|
// _connectivity.onConnectivityChanged.listen(_updateConnectionStatus);
|
||||||
super.onInit();
|
super.onInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,16 +133,16 @@ class IndexController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> initConnectivity() async {
|
Future<void> initConnectivity() async {
|
||||||
late ConnectivityResult result;
|
// late ConnectivityResult result;
|
||||||
// Platform messages may fail, so we use a try/catch PlatformException.
|
// // Platform messages may fail, so we use a try/catch PlatformException.
|
||||||
try {
|
// try {
|
||||||
result = await _connectivity.checkConnectivity();
|
// //result = await _connectivity.checkConnectivity();
|
||||||
} on PlatformException catch (_) {
|
// } on PlatformException catch (_) {
|
||||||
//print('Couldn\'t check connectivity status --- $e');
|
// //print('Couldn\'t check connectivity status --- $e');
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return _updateConnectionStatus(result);
|
// return _updateConnectionStatus(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
LatLngBounds boundsFromLatLngList(List<LatLng> list) {
|
LatLngBounds boundsFromLatLngList(List<LatLng> list) {
|
||||||
@ -311,7 +310,7 @@ class IndexController extends GetxController {
|
|||||||
if (value == null) {
|
if (value == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (value.collection.isEmpty) {
|
if (value.features.isEmpty) {
|
||||||
if (showPopup == false) {
|
if (showPopup == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -328,7 +327,7 @@ class IndexController extends GetxController {
|
|||||||
showPopup = false;
|
showPopup = false;
|
||||||
//Get.showSnackbar(GetSnackBar(message: "Too many points, please zoom in",));
|
//Get.showSnackbar(GetSnackBar(message: "Too many points, please zoom in",));
|
||||||
}
|
}
|
||||||
if (value.collection.isNotEmpty) {
|
if (value.features.isNotEmpty) {
|
||||||
////print("---- added---");
|
////print("---- added---");
|
||||||
locations.add(value);
|
locations.add(value);
|
||||||
}
|
}
|
||||||
@ -340,15 +339,18 @@ class IndexController extends GetxController {
|
|||||||
currentBound.add(bounds);
|
currentBound.add(bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
GeoJsonFeature? getFeatureForLatLong(double lat, double long) {
|
GeoJSONFeature? getFeatureForLatLong(double lat, double long) {
|
||||||
if (locations.isNotEmpty) {
|
if (locations.isNotEmpty) {
|
||||||
for (GeoJsonFeature i in locations[0].collection) {
|
GeoJSONFeature? foundFeature;
|
||||||
GeoJsonMultiPoint p = i.geometry as GeoJsonMultiPoint;
|
|
||||||
if (p.geoSerie!.geoPoints[0].latitude == lat &&
|
locations[0].features.forEach((i) {
|
||||||
p.geoSerie!.geoPoints[0].longitude == long) {
|
GeoJSONMultiPoint p = i!.geometry as GeoJSONMultiPoint;
|
||||||
return i;
|
if (p.coordinates[0][1] == lat && p.coordinates[0][0] == long) {
|
||||||
}
|
foundFeature = i;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return foundFeature;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,14 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:rogapp/model/destination.dart';
|
||||||
import 'package:rogapp/model/gps_data.dart';
|
import 'package:rogapp/model/gps_data.dart';
|
||||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||||
import 'package:rogapp/pages/drawer/drawer_page.dart';
|
import 'package:rogapp/pages/drawer/drawer_page.dart';
|
||||||
import 'package:rogapp/pages/index/index_controller.dart';
|
import 'package:rogapp/pages/index/index_controller.dart';
|
||||||
import 'package:rogapp/routes/app_pages.dart';
|
import 'package:rogapp/routes/app_pages.dart';
|
||||||
|
import 'package:rogapp/services/DatabaseService.dart';
|
||||||
import 'package:rogapp/utils/database_gps.dart';
|
import 'package:rogapp/utils/database_gps.dart';
|
||||||
|
import 'package:rogapp/utils/database_helper.dart';
|
||||||
import 'package:rogapp/widgets/list_widget.dart';
|
import 'package:rogapp/widgets/list_widget.dart';
|
||||||
import 'package:rogapp/widgets/map_widget.dart';
|
import 'package:rogapp/widgets/map_widget.dart';
|
||||||
|
|
||||||
@ -25,6 +28,13 @@ class IndexPage extends GetView<IndexController> {
|
|||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text("add_location".tr),
|
title: Text("add_location".tr),
|
||||||
actions: [
|
actions: [
|
||||||
|
// IconButton(
|
||||||
|
// onPressed: () {
|
||||||
|
// DatabaseService ds = DatabaseService();
|
||||||
|
// ds.updateDatabase();
|
||||||
|
// },
|
||||||
|
// icon: const Icon(Icons.ten_k_sharp)),
|
||||||
|
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
// GpsDatabaseHelper db = GpsDatabaseHelper.instance;
|
// GpsDatabaseHelper db = GpsDatabaseHelper.instance;
|
||||||
|
|||||||
@ -1,16 +1,15 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class LoadingPage extends StatelessWidget {
|
class LoadingPage extends StatelessWidget {
|
||||||
const LoadingPage({ Key? key }) : super(key: key);
|
const LoadingPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
alignment: Alignment.topCenter,
|
alignment: Alignment.center,
|
||||||
margin: const EdgeInsets.only(top: 20),
|
margin: const EdgeInsets.only(top: 20),
|
||||||
child: const CircularProgressIndicator(
|
child: const CircularProgressIndicator(
|
||||||
value: 0.8,
|
value: 0.8,
|
||||||
)
|
));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -209,7 +209,25 @@ class LoginPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
),
|
||||||
|
const Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Flexible(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.all(8.0),
|
||||||
|
child: Text(
|
||||||
|
"※第8回と第9回は、岐阜県からの「清流の国ぎふ」SDGs推進ネットワーク連携促進補助金を受けています",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize:
|
||||||
|
12, // Consider adjusting the font size if the text is too small.
|
||||||
|
// Removed overflow: TextOverflow.ellipsis to allow text wrapping.
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -1,23 +1,21 @@
|
|||||||
import 'package:geojson/geojson.dart';
|
import 'package:geojson_vi/geojson_vi.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:rogapp/pages/index/index_controller.dart';
|
import 'package:rogapp/pages/index/index_controller.dart';
|
||||||
|
|
||||||
class SearchBarController extends GetxController {
|
class SearchBarController extends GetxController {
|
||||||
|
List<GeoJSONFeature> searchResults = <GeoJSONFeature>[].obs;
|
||||||
|
|
||||||
List<GeoJsonFeature> searchResults = <GeoJsonFeature>[].obs;
|
@override
|
||||||
|
|
||||||
|
|
||||||
@override
|
|
||||||
void onInit() {
|
void onInit() {
|
||||||
IndexController indexController = Get.find<IndexController>();
|
IndexController indexController = Get.find<IndexController>();
|
||||||
if(indexController.locations.isNotEmpty){
|
if (indexController.locations.isNotEmpty) {
|
||||||
for(int i=0; i<= indexController.locations[0].collection.length - 1; i++){
|
for (int i = 0;
|
||||||
GeoJsonFeature p = indexController.locations[0].collection[i];
|
i <= indexController.locations[0].features.length - 1;
|
||||||
|
i++) {
|
||||||
|
GeoJSONFeature p = indexController.locations[0].features[i]!;
|
||||||
searchResults.add(p);
|
searchResults.add(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.onInit();
|
super.onInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_typeahead/flutter_typeahead.dart';
|
import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||||
import 'package:geojson/geojson.dart';
|
import 'package:geojson_vi/geojson_vi.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:rogapp/model/destination.dart';
|
import 'package:rogapp/model/destination.dart';
|
||||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||||
@ -48,46 +48,32 @@ class SearchPage extends StatelessWidget {
|
|||||||
//title: const CupertinoSearchTextField(),
|
//title: const CupertinoSearchTextField(),
|
||||||
),
|
),
|
||||||
body: SingleChildScrollView(
|
body: SingleChildScrollView(
|
||||||
child: TypeAheadField(
|
child: TypeAheadField<GeoJSONFeature>(
|
||||||
textFieldConfiguration: TextFieldConfiguration(
|
// textFieldConfiguration: TextFieldConfiguration(
|
||||||
autofocus: true,
|
// autofocus: true,
|
||||||
style: DefaultTextStyle.of(context).style.copyWith(
|
// style: DefaultTextStyle.of(context).style.copyWith(
|
||||||
fontStyle: FontStyle.normal,
|
// fontStyle: FontStyle.normal,
|
||||||
fontSize: 15.0,
|
// fontSize: 15.0,
|
||||||
),
|
// ),
|
||||||
decoration: InputDecoration(
|
// decoration: InputDecoration(
|
||||||
border: const OutlineInputBorder(),
|
// border: const OutlineInputBorder(),
|
||||||
hintText: "検索",
|
// hintText: "検索",
|
||||||
prefixIcon: const Icon(Icons.search),
|
// prefixIcon: const Icon(Icons.search),
|
||||||
suffixIcon: IconButton(
|
// suffixIcon: IconButton(
|
||||||
icon: const Icon(Icons.clear),
|
// icon: const Icon(Icons.clear),
|
||||||
onPressed: () {
|
// onPressed: () {
|
||||||
// clear the text field
|
// // clear the text field
|
||||||
},
|
// },
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
suggestionsCallback: (pattern) async {
|
onSelected: (GeoJSONFeature suggestion) {
|
||||||
return searchController.searchResults.where(
|
|
||||||
(GeoJsonFeature element) => element.properties!["location_name"]
|
|
||||||
.toString()
|
|
||||||
.contains(pattern));
|
|
||||||
//return await
|
|
||||||
},
|
|
||||||
itemBuilder: (context, GeoJsonFeature suggestion) {
|
|
||||||
return ListTile(
|
|
||||||
title: Text(suggestion.properties!["location_name"]),
|
|
||||||
subtitle: suggestion.properties!["category"] != null
|
|
||||||
? Text(suggestion.properties!["category"])
|
|
||||||
: const Text(""),
|
|
||||||
//leading: getImage(index),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
onSuggestionSelected: (GeoJsonFeature suggestion) {
|
|
||||||
indexController.currentFeature.clear();
|
indexController.currentFeature.clear();
|
||||||
indexController.currentFeature.add(suggestion);
|
indexController.currentFeature.add(suggestion);
|
||||||
DestinationController destinationController = Get.find<DestinationController>();
|
DestinationController destinationController =
|
||||||
Destination des = destinationController.festuretoDestination(suggestion);
|
Get.find<DestinationController>();
|
||||||
|
Destination des =
|
||||||
|
destinationController.festuretoDestination(suggestion);
|
||||||
Get.back();
|
Get.back();
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
constraints:
|
constraints:
|
||||||
@ -95,7 +81,28 @@ class SearchPage extends StatelessWidget {
|
|||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
context: context,
|
context: context,
|
||||||
//builder: (context) => BottomSheetWidget(),
|
//builder: (context) => BottomSheetWidget(),
|
||||||
builder: ((context) => BottomSheetNew(destination: des,)));
|
builder: ((context) => BottomSheetNew(
|
||||||
|
destination: des,
|
||||||
|
)));
|
||||||
|
},
|
||||||
|
|
||||||
|
suggestionsCallback: (pattern) async {
|
||||||
|
return searchController.searchResults
|
||||||
|
.where((GeoJSONFeature element) => element
|
||||||
|
.properties!["location_name"]
|
||||||
|
.toString()
|
||||||
|
.contains(pattern))
|
||||||
|
.toList();
|
||||||
|
//return await
|
||||||
|
},
|
||||||
|
itemBuilder: (context, GeoJSONFeature suggestion) {
|
||||||
|
return ListTile(
|
||||||
|
title: Text(suggestion.properties!["location_name"]),
|
||||||
|
subtitle: suggestion.properties!["category"] != null
|
||||||
|
? Text(suggestion.properties!["category"])
|
||||||
|
: const Text(""),
|
||||||
|
//leading: getImage(index),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
55
lib/services/DatabaseService.dart
Normal file
55
lib/services/DatabaseService.dart
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:rogapp/model/destination.dart';
|
||||||
|
import 'package:rogapp/utils/database_helper.dart';
|
||||||
|
|
||||||
|
class DatabaseService {
|
||||||
|
// Private constructor
|
||||||
|
DatabaseService._privateConstructor();
|
||||||
|
|
||||||
|
// Static instance
|
||||||
|
static final DatabaseService _instance =
|
||||||
|
DatabaseService._privateConstructor();
|
||||||
|
|
||||||
|
// Factory constructor to return the instance
|
||||||
|
factory DatabaseService() {
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// StreamController for updates
|
||||||
|
final StreamController<List<Destination>> _dbUpdateController =
|
||||||
|
StreamController<List<Destination>>.broadcast();
|
||||||
|
|
||||||
|
// Getter for the stream
|
||||||
|
Stream<List<Destination>> get destinationUpdatesStream =>
|
||||||
|
_dbUpdateController.stream;
|
||||||
|
|
||||||
|
// Method to fetch destinations
|
||||||
|
Future<List<Destination>> fetchDestinations() async {
|
||||||
|
// Your database fetch logic here
|
||||||
|
List<Destination> destinations = await _fetchFromDb();
|
||||||
|
_dbUpdateController.add(destinations);
|
||||||
|
return destinations;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to update the database and emit an update through the stream
|
||||||
|
Future<void> updateDatabase() async {
|
||||||
|
// Your update logic here
|
||||||
|
|
||||||
|
// After updating, fetch the updated list and add it to the stream
|
||||||
|
fetchDestinations();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to fetch data from the database (placeholder)
|
||||||
|
Future<List<Destination>> _fetchFromDb() async {
|
||||||
|
// Simulate fetching data with a delay
|
||||||
|
DatabaseHelper db = DatabaseHelper.instance;
|
||||||
|
List<Destination> destinations = await db.getDestinations();
|
||||||
|
return destinations; // Replace with your actual fetch operation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dispose method to close the stream controller
|
||||||
|
void dispose() {
|
||||||
|
_dbUpdateController.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -202,13 +202,13 @@ class ExternalService {
|
|||||||
'image': ""
|
'image': ""
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
var vvv = jsonEncode(<String, String>{
|
// var vvv = jsonEncode(<String, String>{
|
||||||
'team_name': teamname,
|
// 'team_name': teamname,
|
||||||
'cp_number': cp.toString(),
|
// 'cp_number': cp.toString(),
|
||||||
'event_code': eventcode,
|
// 'event_code': eventcode,
|
||||||
'image': res["checkinimage"].toString().replaceAll(
|
// 'image': res["checkinimage"].toString().replaceAll(
|
||||||
'http://localhost:8100', 'http://rogaining.sumasen.net')
|
// 'http://localhost:8100', 'http://rogaining.sumasen.net')
|
||||||
});
|
// });
|
||||||
// print("--json-- $vvv");
|
// print("--json-- $vvv");
|
||||||
// print("--- checnin response ${response3.statusCode}----");
|
// print("--- checnin response ${response3.statusCode}----");
|
||||||
if (response3.statusCode == 200) {
|
if (response3.statusCode == 200) {
|
||||||
@ -293,14 +293,14 @@ class ExternalService {
|
|||||||
.toString()
|
.toString()
|
||||||
.replaceAll('http://localhost:8100', 'http://rogaining.sumasen.net')
|
.replaceAll('http://localhost:8100', 'http://rogaining.sumasen.net')
|
||||||
});
|
});
|
||||||
// print("-- json -- $rec");
|
//print("-- json -- $rec");
|
||||||
// print('----- response2 is $response2 --------');
|
//print('----- response2 is $response2 --------');
|
||||||
if (response2.statusCode == 200) {
|
if (response2.statusCode == 200) {
|
||||||
res2 = json.decode(utf8.decode(response2.bodyBytes));
|
res2 = json.decode(utf8.decode(response2.bodyBytes));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//}
|
//}
|
||||||
destinationController.resetRogaining();
|
destinationController.resetRogaining(isgoal: true);
|
||||||
return res2;
|
return res2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,32 +1,32 @@
|
|||||||
import 'package:geojson/geojson.dart';
|
// import 'package:geojson/geojson.dart';
|
||||||
import 'package:http/http.dart' as http;
|
// import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
import '../utils/const.dart';
|
// import '../utils/const.dart';
|
||||||
|
|
||||||
class LocationLineService {
|
// class LocationLineService {
|
||||||
static Future<GeoJsonFeature?> loadLocationLines() async {
|
// static Future<GeoJsonFeature?> loadLocationLines() async {
|
||||||
final geo = GeoJson();
|
// final geo = GeoJson();
|
||||||
GeoJsonFeature? fs;
|
// GeoJsonFeature? fs;
|
||||||
String serverUrl = ConstValues.currentServer();
|
// String serverUrl = ConstValues.currentServer();
|
||||||
String url = '$serverUrl/api/location_line/';
|
// String url = '$serverUrl/api/location_line/';
|
||||||
//print('++++++++$url');
|
// //print('++++++++$url');
|
||||||
final response = await http.get(
|
// final response = await http.get(
|
||||||
Uri.parse(url),
|
// Uri.parse(url),
|
||||||
headers: <String, String>{
|
// headers: <String, String>{
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
// 'Content-Type': 'application/json; charset=UTF-8',
|
||||||
},
|
// },
|
||||||
);
|
// );
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
// if (response.statusCode == 200) {
|
||||||
geo.processedFeatures.listen((fst) {
|
// geo.processedFeatures.listen((fst) {
|
||||||
fs = fst;
|
// fs = fst;
|
||||||
});
|
// });
|
||||||
|
|
||||||
await geo.parse(response.body, verbose: true);
|
// await geo.parse(response.body, verbose: true);
|
||||||
|
|
||||||
return fs;
|
// return fs;
|
||||||
} else {
|
// } else {
|
||||||
throw Exception('Failed to create album.');
|
// throw Exception('Failed to create album.');
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|||||||
@ -1,33 +1,33 @@
|
|||||||
import 'package:geojson/geojson.dart';
|
// import 'package:geojson/geojson.dart';
|
||||||
import 'package:http/http.dart' as http;
|
// import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
import '../utils/const.dart';
|
// import '../utils/const.dart';
|
||||||
|
|
||||||
class LocationPolygonervice {
|
// class LocationPolygonervice {
|
||||||
static Future<GeoJsonFeature?> loadLocationLines() async {
|
// static Future<GeoJsonFeature?> loadLocationLines() async {
|
||||||
final geo = GeoJson();
|
// final geo = GeoJson();
|
||||||
GeoJsonFeature? fs;
|
// GeoJsonFeature? fs;
|
||||||
|
|
||||||
String serverUrl = ConstValues.currentServer();
|
// String serverUrl = ConstValues.currentServer();
|
||||||
String url = '$serverUrl/api/location_polygon/';
|
// String url = '$serverUrl/api/location_polygon/';
|
||||||
//print('++++++++$url');
|
// //print('++++++++$url');
|
||||||
final response = await http.get(
|
// final response = await http.get(
|
||||||
Uri.parse(url),
|
// Uri.parse(url),
|
||||||
headers: <String, String>{
|
// headers: <String, String>{
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
// 'Content-Type': 'application/json; charset=UTF-8',
|
||||||
},
|
// },
|
||||||
);
|
// );
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
// if (response.statusCode == 200) {
|
||||||
geo.processedFeatures.listen((fst) {
|
// geo.processedFeatures.listen((fst) {
|
||||||
fs = fst;
|
// fs = fst;
|
||||||
});
|
// });
|
||||||
|
|
||||||
await geo.parse(response.body, verbose: true);
|
// await geo.parse(response.body, verbose: true);
|
||||||
|
|
||||||
return fs;
|
// return fs;
|
||||||
} else {
|
// } else {
|
||||||
throw Exception('Failed to create album.');
|
// throw Exception('Failed to create album.');
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|||||||
@ -1,39 +1,13 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'package:geojson_vi/geojson_vi.dart';
|
||||||
import 'package:geojson/geojson.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||||
import 'package:rogapp/pages/index/index_controller.dart';
|
import 'package:rogapp/pages/index/index_controller.dart';
|
||||||
import 'package:rogapp/utils/const.dart';
|
import 'package:rogapp/utils/const.dart';
|
||||||
|
|
||||||
class LocationService {
|
class LocationService {
|
||||||
// static Future<GeoJsonFeatureCollection?> loadLocations() async {
|
static Future<GeoJSONFeatureCollection?> loadLocationsFor(
|
||||||
|
|
||||||
// final IndexController indexController = Get.find<IndexController>();
|
|
||||||
|
|
||||||
// String server_url = ConstValues.currentServer();
|
|
||||||
// String url = "";
|
|
||||||
// if(indexController.currentUser.length > 0){
|
|
||||||
// url = '${server_url}/api/location/?is_rog=True';
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// url = '${server_url}/api/location/';
|
|
||||||
// }
|
|
||||||
// //String url = 'http://localhost:8100/api/location/';
|
|
||||||
// final response = await http.get(Uri.parse(url),
|
|
||||||
// headers: <String, String>{
|
|
||||||
// 'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
// },
|
|
||||||
// );
|
|
||||||
|
|
||||||
// if (response.statusCode == 200) {
|
|
||||||
|
|
||||||
// return featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
static Future<GeoJsonFeatureCollection?> loadLocationsFor(
|
|
||||||
String perfecture, String cat) async {
|
String perfecture, String cat) async {
|
||||||
final IndexController indexController = Get.find<IndexController>();
|
final IndexController indexController = Get.find<IndexController>();
|
||||||
String url = "";
|
String url = "";
|
||||||
@ -67,8 +41,8 @@ class LocationService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
GeoJsonFeatureCollection cc =
|
GeoJSONFeatureCollection cc =
|
||||||
await featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
GeoJSONFeatureCollection.fromJSON(utf8.decode(response.bodyBytes));
|
||||||
//print(cc);
|
//print(cc);
|
||||||
return cc; //featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
return cc; //featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||||
}
|
}
|
||||||
@ -95,48 +69,7 @@ class LocationService {
|
|||||||
return ext;
|
return ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<GeoJsonFeatureCollection?> loadLocationsSubFor(
|
static Future<GeoJSONFeatureCollection?> loadLocationsBound(
|
||||||
String subperfecture, String cat) async {
|
|
||||||
final IndexController indexController = Get.find<IndexController>();
|
|
||||||
String url = "";
|
|
||||||
String serverUrl = ConstValues.currentServer();
|
|
||||||
if (cat.isNotEmpty) {
|
|
||||||
if (indexController.currentUser.isNotEmpty) {
|
|
||||||
bool rog = indexController.currentUser[0]['user']['is_rogaining'];
|
|
||||||
String r = rog == true ? 'True' : 'False';
|
|
||||||
var grp = indexController.currentUser[0]['user']['event_code'];
|
|
||||||
url = '$serverUrl/api/insubperf?rog=$r&subperf=$subperfecture&cat=$cat';
|
|
||||||
} else {
|
|
||||||
url = '$serverUrl/api/insubperf?subperf=$subperfecture&cat=$cat';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (indexController.currentUser.isNotEmpty) {
|
|
||||||
bool rog = indexController.currentUser[0]['user']['is_rogaining'];
|
|
||||||
String r = rog == true ? 'True' : 'False';
|
|
||||||
var grp = indexController.currentUser[0]['user']['event_code'];
|
|
||||||
url = '$serverUrl/api/insubperf?rog=$r&subperf=$subperfecture';
|
|
||||||
} else {
|
|
||||||
url = '$serverUrl/api/insubperf?subperf=$subperfecture';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//print('++++++++$url');
|
|
||||||
final response = await http.get(
|
|
||||||
Uri.parse(url),
|
|
||||||
headers: <String, String>{
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
GeoJsonFeatureCollection cc =
|
|
||||||
await featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
|
||||||
//print(cc);
|
|
||||||
return cc; //featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Future<GeoJsonFeatureCollection?> loadLocationsBound(
|
|
||||||
double lat1,
|
double lat1,
|
||||||
double lon1,
|
double lon1,
|
||||||
double lat2,
|
double lat2,
|
||||||
@ -174,7 +107,7 @@ class LocationService {
|
|||||||
'$serverUrl/api/inbound?ln1=$lon1&la1=$lat1&ln2=$lon2&la2=$lat2&ln3=$lon3&la3=$lat3&ln4=$lon4&la4=$lat4';
|
'$serverUrl/api/inbound?ln1=$lon1&la1=$lat1&ln2=$lon2&la2=$lat2&ln3=$lon3&la3=$lat3&ln4=$lon4&la4=$lat4';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//print('++++++++$url');
|
print('++++++++$url');
|
||||||
final response = await http.get(
|
final response = await http.get(
|
||||||
Uri.parse(url),
|
Uri.parse(url),
|
||||||
headers: <String, String>{
|
headers: <String, String>{
|
||||||
@ -183,13 +116,15 @@ class LocationService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (response.statusCode == 500) {
|
if (response.statusCode == 500) {
|
||||||
return GeoJsonFeatureCollection(); //featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
return null; //featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
GeoJsonFeatureCollection cc =
|
DestinationController destinationController =
|
||||||
await featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
Get.find<DestinationController>();
|
||||||
if (cc.collection.isEmpty) {
|
GeoJSONFeatureCollection cc =
|
||||||
|
GeoJSONFeatureCollection.fromJSON(utf8.decode(response.bodyBytes));
|
||||||
|
if (cc.features.isEmpty) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
//print("---- feature got from server is ${cc.collection[0].properties} ------");
|
//print("---- feature got from server is ${cc.collection[0].properties} ------");
|
||||||
@ -199,7 +134,7 @@ class LocationService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<GeoJsonFeatureCollection?> loadCustomLocations(
|
static Future<GeoJSONFeatureCollection?> loadCustomLocations(
|
||||||
String name, String cat) async {
|
String name, String cat) async {
|
||||||
final IndexController indexController = Get.find<IndexController>();
|
final IndexController indexController = Get.find<IndexController>();
|
||||||
String url = "";
|
String url = "";
|
||||||
@ -236,13 +171,13 @@ class LocationService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (response.statusCode == 500) {
|
if (response.statusCode == 500) {
|
||||||
return GeoJsonFeatureCollection(); //featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
return null; //featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
GeoJsonFeatureCollection cc =
|
GeoJSONFeatureCollection cc =
|
||||||
await featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
GeoJSONFeatureCollection.fromJSON(utf8.decode(response.bodyBytes));
|
||||||
if (cc.collection.isEmpty) {
|
if (cc.features.isEmpty) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return cc;
|
return cc;
|
||||||
|
|||||||
@ -51,7 +51,7 @@ class MatrixService {
|
|||||||
|
|
||||||
Map<String, dynamic> cats = {};
|
Map<String, dynamic> cats = {};
|
||||||
String url =
|
String url =
|
||||||
"https://maps.googleapis.com/maps/api/directions/json?destination=$destination&mode=$mode&waypoints=$locs&origin=$origin&key=AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE";
|
"https://maps.googleapis.com/maps/api/directions/json?destination=$destination&mode=$mode&waypoints=$locs&origin=$origin&key=AIzaSyCN2xFsqFyadWwpjiFxymrxzS6G1tNzraI";
|
||||||
//print('++++++++$url');
|
//print('++++++++$url');
|
||||||
final http.Response response =
|
final http.Response response =
|
||||||
await http.get(Uri.parse(url), headers: <String, String>{
|
await http.get(Uri.parse(url), headers: <String, String>{
|
||||||
|
|||||||
@ -44,20 +44,26 @@ class GpsDatabaseHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<int> insertGps(GpsData gps) async {
|
Future<int> insertGps(GpsData gps) async {
|
||||||
|
try {
|
||||||
|
print("---- try insering ${gps.toMap()}");
|
||||||
Database db = await instance.database;
|
Database db = await instance.database;
|
||||||
int? nextOrder =
|
int? nextOrder =
|
||||||
Sqflite.firstIntValue(await db.rawQuery('SELECT MAX(id) FROM gps'));
|
Sqflite.firstIntValue(await db.rawQuery('SELECT MAX(id) FROM gps'));
|
||||||
nextOrder = nextOrder ?? 0;
|
nextOrder = nextOrder ?? 0;
|
||||||
nextOrder = nextOrder + 1;
|
nextOrder = nextOrder + 1;
|
||||||
gps.id = nextOrder;
|
gps.id = nextOrder;
|
||||||
//print("---- insering ${gps.toMap()}");
|
print("---- insering ${gps.toMap()}");
|
||||||
int res = await db.insert(
|
int res = await db.insert(
|
||||||
'gps',
|
'gps',
|
||||||
gps.toMap(),
|
gps.toMap(),
|
||||||
conflictAlgorithm: ConflictAlgorithm.replace,
|
conflictAlgorithm: ConflictAlgorithm.replace,
|
||||||
);
|
);
|
||||||
//print("------ database helper insert $res-----------::::::::");
|
print("------ database helper insert $res-----------::::::::");
|
||||||
return res;
|
return res;
|
||||||
|
} catch (err) {
|
||||||
|
print("------ error $err-----------::::::::");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<GpsData>> getGPSData(String team_name, String event_code) async {
|
Future<List<GpsData>> getGPSData(String team_name, String event_code) async {
|
||||||
|
|||||||
162
lib/utils/location_controller.dart
Normal file
162
lib/utils/location_controller.dart
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:geolocator/geolocator.dart';
|
||||||
|
import 'package:rogapp/widgets/debug_widget.dart';
|
||||||
|
import 'package:flutter_map_location_marker/flutter_map_location_marker.dart';
|
||||||
|
|
||||||
|
class LocationController extends GetxController {
|
||||||
|
// Reactive variable to hold the current position
|
||||||
|
Rx<Position?> currentPosition = Rx<Position?>(null);
|
||||||
|
|
||||||
|
// Subscription to the position stream
|
||||||
|
StreamSubscription<Position>? positionStream;
|
||||||
|
|
||||||
|
final locationMarkerPositionStreamController =
|
||||||
|
StreamController<LocationMarkerPosition?>.broadcast();
|
||||||
|
|
||||||
|
bool isStreamPaused = false;
|
||||||
|
|
||||||
|
Stream<LocationMarkerPosition?> get locationMarkerPositionStream =>
|
||||||
|
locationMarkerPositionStreamController.stream;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onInit() {
|
||||||
|
super.onInit();
|
||||||
|
// Start listening to location updates when the controller is initialized
|
||||||
|
startPositionStream();
|
||||||
|
}
|
||||||
|
|
||||||
|
void startPositionStream() async {
|
||||||
|
// Check for location service and permissions before starting the stream
|
||||||
|
bool serviceEnabled = await Geolocator.isLocationServiceEnabled();
|
||||||
|
if (!serviceEnabled) {
|
||||||
|
// Use GetX's context to show a dialog
|
||||||
|
Get.dialog(
|
||||||
|
AlertDialog(
|
||||||
|
title: const Text('Location Services Disabled'),
|
||||||
|
content: const Text(
|
||||||
|
'Please enable location services to continue using the app.'),
|
||||||
|
actions: <Widget>[
|
||||||
|
TextButton(
|
||||||
|
child: const Text('OK'),
|
||||||
|
onPressed: () {
|
||||||
|
// Close the dialog
|
||||||
|
Get.back();
|
||||||
|
// Optionally, you can direct the user to the settings page
|
||||||
|
// Geolocator.openLocationSettings();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
barrierDismissible: false, // User must tap button to close dialog
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LocationPermission permission = await Geolocator.checkPermission();
|
||||||
|
if (permission == LocationPermission.denied) {
|
||||||
|
permission = await Geolocator.requestPermission();
|
||||||
|
if (permission == LocationPermission.denied) {
|
||||||
|
// Show a dialog if permissions are still denied
|
||||||
|
Get.dialog(
|
||||||
|
AlertDialog(
|
||||||
|
title: const Text('Location Permission Denied'),
|
||||||
|
content: const Text(
|
||||||
|
'This app requires location permissions to function properly. Please enable location permissions in your device settings.'),
|
||||||
|
actions: <Widget>[
|
||||||
|
TextButton(
|
||||||
|
child: const Text('OK'),
|
||||||
|
onPressed: () {
|
||||||
|
// Close the dialog
|
||||||
|
Get.back();
|
||||||
|
// Optionally, direct the user to the app settings
|
||||||
|
// Geolocator.openAppSettings();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
barrierDismissible: false,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (permission == LocationPermission.deniedForever) {
|
||||||
|
// Show a dialog if permissions are permanently denied
|
||||||
|
Get.dialog(
|
||||||
|
AlertDialog(
|
||||||
|
title: const Text('Location Permission Needed'),
|
||||||
|
content: const Text(
|
||||||
|
'Location permissions have been permanently denied. Please open app settings to enable location permissions.'),
|
||||||
|
actions: <Widget>[
|
||||||
|
TextButton(
|
||||||
|
child: const Text('Open Settings'),
|
||||||
|
onPressed: () {
|
||||||
|
// Close the dialog and open app settings
|
||||||
|
Get.back();
|
||||||
|
Geolocator.openAppSettings();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
barrierDismissible: false,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set up the location options
|
||||||
|
const locationOptions =
|
||||||
|
LocationSettings(accuracy: LocationAccuracy.high, distanceFilter: 0);
|
||||||
|
|
||||||
|
await positionStream?.cancel();
|
||||||
|
|
||||||
|
positionStream =
|
||||||
|
Geolocator.getPositionStream(locationSettings: locationOptions).listen(
|
||||||
|
(Position? position) {
|
||||||
|
if (position != null) {
|
||||||
|
final LocationMarkerPosition locationMarkerPosition =
|
||||||
|
LocationMarkerPosition(
|
||||||
|
latitude: position.latitude,
|
||||||
|
longitude: position.longitude,
|
||||||
|
accuracy: position.accuracy);
|
||||||
|
locationMarkerPositionStreamController.add(locationMarkerPosition);
|
||||||
|
} else {
|
||||||
|
locationMarkerPositionStreamController.add(null);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onError: (e) {
|
||||||
|
locationMarkerPositionStreamController.addError(e);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
// Resume stream if it was paused previously
|
||||||
|
if (isStreamPaused) {
|
||||||
|
isStreamPaused = false;
|
||||||
|
positionStream!.resume();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to stop the position stream
|
||||||
|
void stopPositionStream() {
|
||||||
|
if (positionStream != null) {
|
||||||
|
positionStream!.pause();
|
||||||
|
isStreamPaused = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to resume the position stream
|
||||||
|
void resumePositionStream() {
|
||||||
|
if (positionStream != null && isStreamPaused) {
|
||||||
|
positionStream!.resume();
|
||||||
|
isStreamPaused = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onClose() {
|
||||||
|
// Cancel the position stream subscription when the controller is closed
|
||||||
|
positionStream?.cancel();
|
||||||
|
super.onClose();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,8 +1,8 @@
|
|||||||
import 'package:geojson/geojson.dart';
|
import 'package:geojson_vi/geojson_vi.dart';
|
||||||
import 'package:rogapp/model/destination.dart';
|
import 'package:rogapp/model/destination.dart';
|
||||||
|
|
||||||
class TextUtils {
|
class TextUtils {
|
||||||
static String getDisplayTextFeture(GeoJsonFeature f) {
|
static String getDisplayTextFeture(GeoJSONFeature f) {
|
||||||
RegExp regex = RegExp(r'([.]*0)(?!.*\d)');
|
RegExp regex = RegExp(r'([.]*0)(?!.*\d)');
|
||||||
String txt = "";
|
String txt = "";
|
||||||
// if(f.properties!["cp"] > 0){
|
// if(f.properties!["cp"] > 0){
|
||||||
|
|||||||
57
lib/widgets/GameState/CheckinState.dart
Normal file
57
lib/widgets/GameState/CheckinState.dart
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:rogapp/widgets/GameState/Colors.dart';
|
||||||
|
|
||||||
|
class LocationVisitedWidget extends StatelessWidget {
|
||||||
|
final int count;
|
||||||
|
final bool minimized;
|
||||||
|
|
||||||
|
const LocationVisitedWidget(
|
||||||
|
{Key? key, required this.count, this.minimized = false})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
if (minimized) {
|
||||||
|
return Container(
|
||||||
|
height: 40,
|
||||||
|
width: 40,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: JapaneseColors.mizu,
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
'$count',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Container(
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: JapaneseColors.matcha,
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.check_circle_outline, color: Colors.white, size: 24),
|
||||||
|
SizedBox(width: 8),
|
||||||
|
Text(
|
||||||
|
'$count チェックイン', // "X Check-ins" in Japanese
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 16),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
12
lib/widgets/GameState/Colors.dart
Normal file
12
lib/widgets/GameState/Colors.dart
Normal 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)
|
||||||
|
}
|
||||||
72
lib/widgets/GameState/ConnectionStatus.dart
Normal file
72
lib/widgets/GameState/ConnectionStatus.dart
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:rogapp/widgets/GameState/Colors.dart';
|
||||||
|
|
||||||
|
enum ConnectionStatus { none, mobile, wifi }
|
||||||
|
|
||||||
|
class ConnectionStatusIndicator extends StatelessWidget {
|
||||||
|
final ConnectionStatus connectionStatus;
|
||||||
|
final bool minimized;
|
||||||
|
|
||||||
|
const ConnectionStatusIndicator({
|
||||||
|
Key? key,
|
||||||
|
required this.connectionStatus,
|
||||||
|
this.minimized = false,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@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 : 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),
|
||||||
|
SizedBox(width: 8),
|
||||||
|
Text(
|
||||||
|
text,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
51
lib/widgets/GameState/DashboardWidget.dart
Normal file
51
lib/widgets/GameState/DashboardWidget.dart
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:rogapp/widgets/GameState/CheckinState.dart';
|
||||||
|
import 'package:rogapp/widgets/GameState/game_on_off.dart';
|
||||||
|
|
||||||
|
class DashboardWidget extends StatelessWidget {
|
||||||
|
final bool gameStarted;
|
||||||
|
final int locationsVisited;
|
||||||
|
final bool isMinimized;
|
||||||
|
|
||||||
|
const DashboardWidget({
|
||||||
|
Key? key,
|
||||||
|
required this.gameStarted,
|
||||||
|
required this.locationsVisited,
|
||||||
|
this.isMinimized = false,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@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: Offset(0, 3),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
child: isMinimized
|
||||||
|
? Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: widgets,
|
||||||
|
)
|
||||||
|
: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: widgets,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
55
lib/widgets/GameState/game_on_off.dart
Normal file
55
lib/widgets/GameState/game_on_off.dart
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:rogapp/widgets/GameState/Colors.dart';
|
||||||
|
|
||||||
|
class GameStatusIndicator extends StatelessWidget {
|
||||||
|
final bool gameStarted;
|
||||||
|
final bool minimized;
|
||||||
|
|
||||||
|
const GameStatusIndicator(
|
||||||
|
{Key? key, required this.gameStarted, this.minimized = true})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
|
@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 ? 'ゲーム開始' : 'ゲーム未開始';
|
||||||
|
|
||||||
|
// 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: 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),
|
||||||
|
SizedBox(width: 8),
|
||||||
|
Text(
|
||||||
|
text,
|
||||||
|
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,27 +1,24 @@
|
|||||||
import 'package:flutter/material.dart';
|
// import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_map/flutter_map.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 {
|
// class BaseLayer extends StatelessWidget {
|
||||||
const BaseLayer({Key? key}) : super(key: key);
|
// const BaseLayer({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
// @override
|
||||||
Widget build(BuildContext context) {
|
// Widget build(BuildContext context) {
|
||||||
return TileLayer(
|
// return TileLayer(
|
||||||
urlTemplate: "https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png",
|
// urlTemplate: "https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png",
|
||||||
tileProvider: FMTC.instance('OpenStreetMap (A)').getTileProvider(
|
// tileProvider: FMTC.instance('OpenStreetMap (A)').getTileProvider(
|
||||||
FMTCTileProviderSettings(
|
// settings: FMTCTileProviderSettings(
|
||||||
behavior: CacheBehavior.values
|
// behavior: CacheBehavior.values.byName('cacheFirst'),
|
||||||
.byName('cacheFirst'),
|
// cachedValidDuration: const Duration(days: 14),
|
||||||
cachedValidDuration: const Duration(
|
// ),
|
||||||
days: 14
|
// ),
|
||||||
),
|
// );
|
||||||
),
|
// }
|
||||||
),
|
// }
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// var Esri_WorldImagery = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
|
// // var Esri_WorldImagery = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
|
||||||
// attribution: 'Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'
|
// // attribution: 'Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'
|
||||||
// });
|
// // });
|
||||||
@ -1,11 +1,8 @@
|
|||||||
|
import 'package:geojson_vi/geojson_vi.dart';
|
||||||
|
|
||||||
import 'package:geojson/geojson.dart';
|
|
||||||
import 'package:get/get_state_manager/get_state_manager.dart';
|
import 'package:get/get_state_manager/get_state_manager.dart';
|
||||||
|
|
||||||
class BottomSheetController extends GetxController{
|
class BottomSheetController extends GetxController {
|
||||||
|
List<GeoJSONFeature>? currentFeature = <GeoJSONFeature>[];
|
||||||
List<GeoJsonFeature>? currentFeature = <GeoJsonFeature>[];
|
|
||||||
|
|
||||||
BottomSheetController({this.currentFeature});
|
BottomSheetController({this.currentFeature});
|
||||||
}
|
}
|
||||||
@ -1,7 +1,6 @@
|
|||||||
import 'dart:ffi';
|
|
||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:geojson/geojson.dart';
|
import 'package:geojson_vi/geojson_vi.dart';
|
||||||
import 'package:geolocator/geolocator.dart';
|
import 'package:geolocator/geolocator.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
@ -11,14 +10,12 @@ import 'package:rogapp/model/destination.dart';
|
|||||||
import 'package:rogapp/pages/camera/camera_page.dart';
|
import 'package:rogapp/pages/camera/camera_page.dart';
|
||||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||||
import 'package:rogapp/pages/index/index_controller.dart';
|
import 'package:rogapp/pages/index/index_controller.dart';
|
||||||
import 'package:rogapp/routes/app_pages.dart';
|
|
||||||
import 'package:rogapp/services/external_service.dart';
|
import 'package:rogapp/services/external_service.dart';
|
||||||
import 'package:rogapp/utils/const.dart';
|
import 'package:rogapp/utils/const.dart';
|
||||||
import 'package:rogapp/utils/database_helper.dart';
|
import 'package:rogapp/utils/database_helper.dart';
|
||||||
import 'package:rogapp/utils/text_util.dart';
|
import 'package:rogapp/utils/text_util.dart';
|
||||||
import 'package:rogapp/widgets/bottom_sheet_controller.dart';
|
import 'package:rogapp/widgets/bottom_sheet_controller.dart';
|
||||||
import 'package:rogapp/widgets/debug_widget.dart';
|
import 'package:rogapp/widgets/debug_widget.dart';
|
||||||
import 'package:sqflite/sqflite.dart';
|
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class BottomSheetNew extends GetView<BottomSheetController> {
|
class BottomSheetNew extends GetView<BottomSheetController> {
|
||||||
@ -34,8 +31,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
|||||||
|
|
||||||
Image getImage() {
|
Image getImage() {
|
||||||
String serverUrl = ConstValues.currentServer();
|
String serverUrl = ConstValues.currentServer();
|
||||||
|
|
||||||
if (indexController.rogMode == 1) {
|
if (indexController.rogMode == 1) {
|
||||||
//print("----- rogaining mode 1");
|
|
||||||
if (indexController.currentDestinationFeature.isEmpty ||
|
if (indexController.currentDestinationFeature.isEmpty ||
|
||||||
indexController.currentDestinationFeature[0].photos! == "") {
|
indexController.currentDestinationFeature[0].photos! == "") {
|
||||||
return const Image(image: AssetImage('assets/images/empty_image.png'));
|
return const Image(image: AssetImage('assets/images/empty_image.png'));
|
||||||
@ -65,8 +62,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GeoJsonFeature<dynamic> gf = indexController.currentFeature[0];
|
GeoJSONFeature gf = indexController.currentFeature[0];
|
||||||
//print("=== photo sss ${gf.properties!["photos"]}");
|
print("=== photo sss ${gf.properties!["photos"]}");
|
||||||
if (gf.properties!["photos"] == null || gf.properties!["photos"] == "") {
|
if (gf.properties!["photos"] == null || gf.properties!["photos"] == "") {
|
||||||
return const Image(image: AssetImage('assets/images/empty_image.png'));
|
return const Image(image: AssetImage('assets/images/empty_image.png'));
|
||||||
} else {
|
} else {
|
||||||
@ -113,8 +110,136 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget getActionButton(BuildContext context, Destination destination) {
|
||||||
|
print("getActionButton ${destinationController.rogainingCounted.value}");
|
||||||
|
print("getActionButton ${destinationController.distanceToStart()}");
|
||||||
|
print("getActionButton ${destination.cp}");
|
||||||
|
print("getActionButton ${DestinationController.ready_for_goal}");
|
||||||
|
|
||||||
|
Destination cdest = destinationController
|
||||||
|
.festuretoDestination(indexController.currentFeature[0]);
|
||||||
|
var distance = const Distance();
|
||||||
|
double distanceToDest = distance.as(
|
||||||
|
LengthUnit.Meter,
|
||||||
|
LatLng(
|
||||||
|
destinationController.currentLat, destinationController.currentLon),
|
||||||
|
LatLng(cdest.lat!, cdest.lon!));
|
||||||
|
|
||||||
|
if (destinationController.rogainingCounted.value == true &&
|
||||||
|
destinationController.distanceToStart() <= 500 &&
|
||||||
|
destination.cp == -1 &&
|
||||||
|
DestinationController.ready_for_goal == true) {
|
||||||
|
//goal
|
||||||
|
return ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(backgroundColor: Colors.red),
|
||||||
|
onPressed: destinationController.rogainingCounted.value == true &&
|
||||||
|
destinationController.distanceToStart() <= 500 &&
|
||||||
|
destination.cp == -1 &&
|
||||||
|
DestinationController.ready_for_goal == true
|
||||||
|
? () async {
|
||||||
|
destinationController.isAtGoal.value = true;
|
||||||
|
destinationController.photos.clear();
|
||||||
|
await showModalBottomSheet(
|
||||||
|
constraints: BoxConstraints.loose(
|
||||||
|
ui.Size(Get.width, Get.height * 0.75)),
|
||||||
|
context: Get.context!,
|
||||||
|
isScrollControlled: true,
|
||||||
|
builder: ((context) => CameraPage(
|
||||||
|
destination: destination,
|
||||||
|
))).whenComplete(() {
|
||||||
|
destinationController.skipGps = false;
|
||||||
|
destinationController.chekcs = 0;
|
||||||
|
destinationController.isAtGoal.value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
child: const Text(
|
||||||
|
"ロゲイニングを終える",
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
));
|
||||||
|
} else if (distanceToDest <=
|
||||||
|
destinationController.getForcedChckinDistance(destination)) {
|
||||||
|
//start
|
||||||
|
return ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.secondary,
|
||||||
|
),
|
||||||
|
onPressed: () async {
|
||||||
|
// Check conditions to show confirmation dialog
|
||||||
|
if (destinationController.isInRog.value == false &&
|
||||||
|
destination.cp == -1 &&
|
||||||
|
destinationController.rogainingCounted.value == false) {
|
||||||
|
print("counted ${destinationController.rogainingCounted.value}");
|
||||||
|
|
||||||
|
// Show confirmation dialog
|
||||||
|
Get.dialog(
|
||||||
|
AlertDialog(
|
||||||
|
title: const Text("確認"), //confirm
|
||||||
|
content: const Text(
|
||||||
|
"ロゲを開始すると、今までのロゲデータが全てクリアされます。本当に開始しますか?"), //are you sure
|
||||||
|
actions: <Widget>[
|
||||||
|
TextButton(
|
||||||
|
child: const Text("いいえ"), //no
|
||||||
|
onPressed: () {
|
||||||
|
Get.back(); // Close the dialog
|
||||||
|
},
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
child: const Text("はい"), //yes
|
||||||
|
onPressed: () async {
|
||||||
|
// Clear data and start game logic here
|
||||||
|
destinationController.isInRog.value = true;
|
||||||
|
destinationController.resetRogaining();
|
||||||
|
destinationController.addToRogaining(
|
||||||
|
destinationController.currentLat,
|
||||||
|
destinationController.currentLon,
|
||||||
|
destination.location_id!,
|
||||||
|
);
|
||||||
|
//saveGameState();
|
||||||
|
await ExternalService().startRogaining();
|
||||||
|
Get.back(); // Close the dialog and potentially navigate away
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
barrierDismissible:
|
||||||
|
false, // User must tap a button to close the dialog
|
||||||
|
);
|
||||||
|
} else if (destinationController.isInRog.value == true &&
|
||||||
|
destination.cp != -1) {
|
||||||
|
//print("counted ${destinationController.rogainingCounted.value}");
|
||||||
|
// Existing logic for other conditions
|
||||||
|
|
||||||
|
Get.back();
|
||||||
|
await destinationController.callforCheckin(destination);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
destination.cp == -1 &&
|
||||||
|
destinationController.isInRog.value == false &&
|
||||||
|
destinationController.rogainingCounted.value == false
|
||||||
|
? "ロゲ開始"
|
||||||
|
: destinationController.isInRog.value == true &&
|
||||||
|
destination.cp == -1
|
||||||
|
? "ゲーム中"
|
||||||
|
: isAlreadyCheckedIn == true
|
||||||
|
? "ゲーム中"
|
||||||
|
: destinationController.isInRog.value == true
|
||||||
|
? "チェックイン"
|
||||||
|
: "始まっていない",
|
||||||
|
style: TextStyle(color: Theme.of(context).colorScheme.onSecondary),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return Container();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
//print("to start ${destinationController.distanceToStart()}");
|
||||||
|
|
||||||
destinationController.skipGps = true;
|
destinationController.skipGps = true;
|
||||||
// print('--- c use --- ${indexController.currentUser[0].values}');
|
// print('--- c use --- ${indexController.currentUser[0].values}');
|
||||||
// print('---- rog_mode ----- ${indexController.rogMode.value} -----');
|
// print('---- rog_mode ----- ${indexController.rogMode.value} -----');
|
||||||
@ -124,261 +249,6 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
|||||||
return detailsSheet(context);
|
return detailsSheet(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show destination detais
|
|
||||||
// SingleChildScrollView destinationSheet(BuildContext context) {
|
|
||||||
// // print(
|
|
||||||
// // '---- currentDestinationFeature ----- ${indexController.currentDestinationFeature[0].name} -----');
|
|
||||||
|
|
||||||
// return SingleChildScrollView(
|
|
||||||
// child: Column(
|
|
||||||
// children: [
|
|
||||||
// Padding(
|
|
||||||
// padding: const EdgeInsets.all(8.0),
|
|
||||||
// child: Row(
|
|
||||||
// children: [
|
|
||||||
// MaterialButton(
|
|
||||||
// onPressed: () {
|
|
||||||
// Get.back();
|
|
||||||
// //destinationController.makePrevious(indexController.currentDestinationFeature[0]);
|
|
||||||
// },
|
|
||||||
// color: Colors.blue,
|
|
||||||
// textColor: Colors.white,
|
|
||||||
// padding: const EdgeInsets.all(16),
|
|
||||||
// shape: const CircleBorder(),
|
|
||||||
// child: const Icon(
|
|
||||||
// Icons.arrow_back_ios,
|
|
||||||
// size: 14,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// Expanded(
|
|
||||||
// child: Container(
|
|
||||||
// alignment: Alignment.center,
|
|
||||||
// child: Obx(() => indexController.currentUser.isNotEmpty
|
|
||||||
// ? Text(
|
|
||||||
// "${TextUtils.getDisplayText(indexController.currentDestinationFeature[0])} : ${TextUtils.getDisplayText(indexController.currentDestinationFeature[0])} : ${indexController.currentDestinationFeature[0].name!}",
|
|
||||||
// style: const TextStyle(
|
|
||||||
// fontSize: 15.0,
|
|
||||||
// fontWeight: FontWeight.bold,
|
|
||||||
// ),
|
|
||||||
// )
|
|
||||||
// : Text(
|
|
||||||
// indexController.currentDestinationFeature[0].name!,
|
|
||||||
// style: const TextStyle(
|
|
||||||
// fontSize: 15.0,
|
|
||||||
// fontWeight: FontWeight.bold,
|
|
||||||
// ),
|
|
||||||
// )),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// Row(
|
|
||||||
// children: [
|
|
||||||
// Expanded(
|
|
||||||
// child: SizedBox(
|
|
||||||
// height: 260.0,
|
|
||||||
// child: Obx(() => getImage()),
|
|
||||||
// )),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// Row(
|
|
||||||
// mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
||||||
// children: [
|
|
||||||
// Obx(
|
|
||||||
// () => indexController.currentDestinationFeature.isNotEmpty &&
|
|
||||||
// destinationController.isInCheckin.value == true &&
|
|
||||||
// destinationController.isAtStart.value == false
|
|
||||||
// ? Row(
|
|
||||||
// children: [
|
|
||||||
// ElevatedButton(
|
|
||||||
// onPressed: () {
|
|
||||||
// if (indexController.currentDestinationFeature[0]
|
|
||||||
// .checkedin ==
|
|
||||||
// null ||
|
|
||||||
// indexController.currentDestinationFeature[0]
|
|
||||||
// .checkedin ==
|
|
||||||
// false) {
|
|
||||||
// if (indexController
|
|
||||||
// .currentDestinationFeature[0]
|
|
||||||
// .hidden_location ==
|
|
||||||
// 0) {
|
|
||||||
// destinationController.skipGps = false;
|
|
||||||
// destinationController.isPhotoShoot.value =
|
|
||||||
// true;
|
|
||||||
// Get.back();
|
|
||||||
// } else {
|
|
||||||
// destinationController.makeCheckin(
|
|
||||||
// indexController
|
|
||||||
// .currentDestinationFeature[0],
|
|
||||||
// true,
|
|
||||||
// "");
|
|
||||||
// if (indexController
|
|
||||||
// .currentDestinationFeature[0].cp !=
|
|
||||||
// -1) {
|
|
||||||
// destinationController
|
|
||||||
// .rogainingCounted.value = true;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// destinationController.makeCheckin(
|
|
||||||
// indexController
|
|
||||||
// .currentDestinationFeature[0],
|
|
||||||
// false,
|
|
||||||
// "");
|
|
||||||
// }
|
|
||||||
// //Get.back();
|
|
||||||
// },
|
|
||||||
// child: Text(
|
|
||||||
// //Checkin
|
|
||||||
// indexController.currentDestinationFeature[0]
|
|
||||||
// .checkedin ==
|
|
||||||
// null ||
|
|
||||||
// indexController
|
|
||||||
// .currentDestinationFeature[0]
|
|
||||||
// .checkedin ==
|
|
||||||
// false
|
|
||||||
// ? "チェックイン"
|
|
||||||
// : "チェックアウト")),
|
|
||||||
// ],
|
|
||||||
// )
|
|
||||||
// : Container(),
|
|
||||||
// ),
|
|
||||||
// Obx(
|
|
||||||
// () => destinationController.isAtStart.value == true
|
|
||||||
// ? ElevatedButton(
|
|
||||||
// onPressed: () {
|
|
||||||
// destinationController.isInRog.value = true;
|
|
||||||
// destinationController.addToRogaining(
|
|
||||||
// destinationController.currentLat,
|
|
||||||
// destinationController.currentLon,
|
|
||||||
// indexController
|
|
||||||
// .currentDestinationFeature[0].location_id!);
|
|
||||||
// saveGameState();
|
|
||||||
// ExternalService()
|
|
||||||
// .startRogaining()
|
|
||||||
// .then((value) => Get.back());
|
|
||||||
// },
|
|
||||||
// child: Text(
|
|
||||||
// // start
|
|
||||||
// indexController.currentDestinationFeature[0]
|
|
||||||
// .checkedin !=
|
|
||||||
// null ||
|
|
||||||
// indexController.currentDestinationFeature[0]
|
|
||||||
// .checkedin ==
|
|
||||||
// true
|
|
||||||
// ? "ロゲイニングを開始"
|
|
||||||
// : "間違った目的地..."))
|
|
||||||
// : Container(),
|
|
||||||
// ),
|
|
||||||
// Obx(
|
|
||||||
// () => destinationController.isAtGoal.value == true &&
|
|
||||||
// destinationController.rogainingCounted.value == true
|
|
||||||
// ? ElevatedButton(
|
|
||||||
// onPressed: () {
|
|
||||||
// Get.toNamed(AppPages.CAMERA_PAGE);
|
|
||||||
// Get.back();
|
|
||||||
// },
|
|
||||||
// child: Text(
|
|
||||||
// //goal
|
|
||||||
// indexController.currentDestinationFeature[0]
|
|
||||||
// .checkedin !=
|
|
||||||
// null ||
|
|
||||||
// indexController.currentDestinationFeature[0]
|
|
||||||
// .checkedin ==
|
|
||||||
// true
|
|
||||||
// ? "ロゲイニングを終える"
|
|
||||||
// : "間違った目的地 ..."))
|
|
||||||
// : Container(),
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// Obx(
|
|
||||||
// () => indexController.currentDestinationFeature[0].address !=
|
|
||||||
// null &&
|
|
||||||
// indexController
|
|
||||||
// .currentDestinationFeature[0].address!.isNotEmpty
|
|
||||||
// ? getDetails(context, "address".tr,
|
|
||||||
// indexController.currentDestinationFeature[0].address! ?? '')
|
|
||||||
// : const SizedBox(
|
|
||||||
// width: 0.0,
|
|
||||||
// height: 0,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// Obx(
|
|
||||||
// () => indexController.currentDestinationFeature[0].phone != null &&
|
|
||||||
// indexController
|
|
||||||
// .currentDestinationFeature[0].phone!.isNotEmpty
|
|
||||||
// ? getDetails(context, "telephone".tr,
|
|
||||||
// indexController.currentDestinationFeature[0].phone! ?? '')
|
|
||||||
// : const SizedBox(
|
|
||||||
// width: 0.0,
|
|
||||||
// height: 0,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// Obx(
|
|
||||||
// () => indexController.currentDestinationFeature[0].email != null &&
|
|
||||||
// indexController
|
|
||||||
// .currentDestinationFeature[0].email!.isNotEmpty
|
|
||||||
// ? getDetails(context, "email".tr,
|
|
||||||
// indexController.currentDestinationFeature[0].email! ?? '')
|
|
||||||
// : const SizedBox(
|
|
||||||
// width: 0.0,
|
|
||||||
// height: 0,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// Obx(
|
|
||||||
// () => indexController.currentDestinationFeature[0].webcontents !=
|
|
||||||
// null &&
|
|
||||||
// indexController
|
|
||||||
// .currentDestinationFeature[0].webcontents!.isNotEmpty
|
|
||||||
// ? getDetails(
|
|
||||||
// context,
|
|
||||||
// "web".tr,
|
|
||||||
// indexController.currentDestinationFeature[0].webcontents! ??
|
|
||||||
// '',
|
|
||||||
// isurl: true)
|
|
||||||
// : const SizedBox(
|
|
||||||
// width: 0.0,
|
|
||||||
// height: 0,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// Obx(
|
|
||||||
// () => indexController.currentDestinationFeature[0].videos != null &&
|
|
||||||
// indexController
|
|
||||||
// .currentDestinationFeature[0].videos!.isNotEmpty
|
|
||||||
// ? getDetails(context, "video".tr,
|
|
||||||
// indexController.currentDestinationFeature[0].videos! ?? '',
|
|
||||||
// isurl: true)
|
|
||||||
// : const SizedBox(
|
|
||||||
// width: 0.0,
|
|
||||||
// height: 0,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// const SizedBox(
|
|
||||||
// height: 20.0,
|
|
||||||
// ),
|
|
||||||
// // Obx(() =>
|
|
||||||
// // //wantToGo(context),
|
|
||||||
|
|
||||||
// // FutureBuilder<Widget>(
|
|
||||||
// // future: wantToGo(context),
|
|
||||||
// // builder: (context, snapshot) {
|
|
||||||
// // return Container(
|
|
||||||
// // child: snapshot.data,
|
|
||||||
// // );
|
|
||||||
// // },
|
|
||||||
// // ),
|
|
||||||
|
|
||||||
// // ),
|
|
||||||
// const SizedBox(
|
|
||||||
// height: 60.0,
|
|
||||||
// )
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
Future<bool> isDestinationCheckedIn(Destination d) async {
|
Future<bool> isDestinationCheckedIn(Destination d) async {
|
||||||
DatabaseHelper db = DatabaseHelper.instance;
|
DatabaseHelper db = DatabaseHelper.instance;
|
||||||
List<Destination> ds = await db.getDestinationByLatLon(d.lat!, d.lon!);
|
List<Destination> ds = await db.getDestinationByLatLon(d.lat!, d.lon!);
|
||||||
@ -462,79 +332,13 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
|||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: [
|
children: [
|
||||||
// Obx(
|
// Finish or Goal
|
||||||
// () => indexController
|
getActionButton(context, destination),
|
||||||
// .currentDestinationFeature.isNotEmpty &&
|
|
||||||
// indexController
|
|
||||||
// .currentDestinationFeature[0].cp ==
|
|
||||||
// -1 &&
|
|
||||||
// indexController.currentDestinationFeature[0]
|
|
||||||
// .checkedin ==
|
|
||||||
// false &&
|
|
||||||
// destinationController.isAtStart.value == true
|
|
||||||
// ? ElevatedButton(
|
|
||||||
// onPressed: () async {
|
|
||||||
// await destinationController
|
|
||||||
// .resetRogaining();
|
|
||||||
// //print("~~~~ start button ~~~~");
|
|
||||||
// destinationController.isInRog.value = true;
|
|
||||||
// destinationController.addToRogaining(
|
|
||||||
// destinationController.currentLat,
|
|
||||||
// destinationController.currentLon,
|
|
||||||
// indexController
|
|
||||||
// .currentDestinationFeature[0]
|
|
||||||
// .location_id!);
|
|
||||||
// saveGameState();
|
|
||||||
// ExternalService()
|
|
||||||
// .startRogaining()
|
|
||||||
// .then((value) {
|
|
||||||
// Get.back();
|
|
||||||
// });
|
|
||||||
// },
|
|
||||||
// child: Text(
|
|
||||||
// // start
|
|
||||||
// indexController
|
|
||||||
// .currentDestinationFeature[
|
|
||||||
// 0]
|
|
||||||
// .checkedin !=
|
|
||||||
// null ||
|
|
||||||
// indexController
|
|
||||||
// .currentDestinationFeature[
|
|
||||||
// 0]
|
|
||||||
// .checkedin ==
|
|
||||||
// true
|
|
||||||
// ? "ロゲイニングを開始"
|
|
||||||
// : "間違った目的地..."))
|
|
||||||
// : Container(),
|
|
||||||
// ),
|
|
||||||
|
|
||||||
destinationController.rogainingCounted.value == true &&
|
|
||||||
destinationController.distanceToStart() <=
|
|
||||||
500 &&
|
|
||||||
destination.cp == -1
|
|
||||||
? ElevatedButton(
|
|
||||||
onPressed: () async {
|
|
||||||
destinationController.isAtGoal.value = true;
|
|
||||||
destinationController.photos.clear();
|
|
||||||
await showModalBottomSheet(
|
|
||||||
constraints: BoxConstraints.loose(ui.Size(
|
|
||||||
Get.width, Get.height * 0.75)),
|
|
||||||
context: Get.context!,
|
|
||||||
isScrollControlled: true,
|
|
||||||
builder: ((context) => CameraPage(
|
|
||||||
destination: destination,
|
|
||||||
))).whenComplete(() {
|
|
||||||
destinationController.skipGps = false;
|
|
||||||
destinationController.chekcs = 0;
|
|
||||||
destinationController.isAtGoal.value =
|
|
||||||
false;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: Text("ロゲイニングを終える"))
|
|
||||||
: Container(),
|
|
||||||
//remove checkin
|
//remove checkin
|
||||||
isAlreadyCheckedIn == true && destination.cp != -1
|
isAlreadyCheckedIn == true && destination.cp != -1
|
||||||
? ElevatedButton(
|
? ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: Colors.blueAccent),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await destinationController
|
await destinationController
|
||||||
.removeCheckin(destination.cp!.toInt());
|
.removeCheckin(destination.cp!.toInt());
|
||||||
@ -542,35 +346,11 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
|||||||
.deleteDestination(destination);
|
.deleteDestination(destination);
|
||||||
Get.back();
|
Get.back();
|
||||||
},
|
},
|
||||||
child: const Text("チェックイン取消"))
|
child: const Text(
|
||||||
|
"チェックイン取消",
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
)) //remove checkin
|
||||||
: Container(),
|
: Container(),
|
||||||
|
|
||||||
// Obx(
|
|
||||||
// () => destinationController.rogainingCounted.value ==
|
|
||||||
// false &&
|
|
||||||
// destination.cp == -1 &&
|
|
||||||
// destinationController.distanceToStart() <= 500
|
|
||||||
// ? ElevatedButton(
|
|
||||||
// onPressed: () {
|
|
||||||
// Get.toNamed(AppPages.CAMERA_PAGE);
|
|
||||||
// Get.back();
|
|
||||||
// },
|
|
||||||
// child: Text(
|
|
||||||
// //goal
|
|
||||||
// indexController
|
|
||||||
// .currentDestinationFeature[
|
|
||||||
// 0]
|
|
||||||
// .checkedin !=
|
|
||||||
// null ||
|
|
||||||
// indexController
|
|
||||||
// .currentDestinationFeature[
|
|
||||||
// 0]
|
|
||||||
// .checkedin ==
|
|
||||||
// true
|
|
||||||
// ? "ロゲイニングを終える"
|
|
||||||
// : "間違った目的地 ..."))
|
|
||||||
// : Container(),
|
|
||||||
// ),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
@ -582,11 +362,12 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
|||||||
.colorScheme
|
.colorScheme
|
||||||
.onPrimaryContainer),
|
.onPrimaryContainer),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
// print(
|
||||||
|
// "dist to start ${destinationController.distanceToStart()}");
|
||||||
Get.back();
|
Get.back();
|
||||||
//print("---- go to ----");
|
//print("---- go to ----");
|
||||||
GeoJsonFeature<GeoJsonMultiPoint> mp =
|
// GeoJSONMultiPoint mp = indexController
|
||||||
indexController.currentFeature[0]
|
// .currentFeature[0] as GeoJSONMultiPoint;
|
||||||
as GeoJsonFeature<GeoJsonMultiPoint>;
|
|
||||||
Position position =
|
Position position =
|
||||||
await Geolocator.getCurrentPosition(
|
await Geolocator.getCurrentPosition(
|
||||||
desiredAccuracy:
|
desiredAccuracy:
|
||||||
@ -598,14 +379,12 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
|||||||
lon: position.longitude);
|
lon: position.longitude);
|
||||||
|
|
||||||
Destination tp = Destination(
|
Destination tp = Destination(
|
||||||
lat: mp.geometry!.geoSerie!.geoPoints[0]
|
lat: destination.lat, lon: destination.lon);
|
||||||
.latitude,
|
|
||||||
lon: mp.geometry!.geoSerie!.geoPoints[0]
|
|
||||||
.longitude);
|
|
||||||
|
|
||||||
destinationController
|
destinationController
|
||||||
.destinationMatrixFromCurrentPoint([ds, tp]);
|
.destinationMatrixFromCurrentPoint([ds, tp]);
|
||||||
},
|
},
|
||||||
|
//go here
|
||||||
child: Text(
|
child: Text(
|
||||||
"ここへ行く",
|
"ここへ行く",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
@ -617,61 +396,6 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
|||||||
),
|
),
|
||||||
|
|
||||||
// forced start / checkin
|
// forced start / checkin
|
||||||
distanceToDest <=
|
|
||||||
destinationController
|
|
||||||
.getForcedChckinDistance(destination)
|
|
||||||
? Obx(() => ElevatedButton(
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
backgroundColor: Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.secondary),
|
|
||||||
onPressed: () async {
|
|
||||||
//print("~~~~ manual checkin button ~~~~");
|
|
||||||
if (destination.cp == -1 &&
|
|
||||||
destinationController.isInRog.value ==
|
|
||||||
false &&
|
|
||||||
destinationController
|
|
||||||
.rogainingCounted.value ==
|
|
||||||
false) {
|
|
||||||
destinationController.isInRog.value = true;
|
|
||||||
destinationController.addToRogaining(
|
|
||||||
destinationController.currentLat,
|
|
||||||
destinationController.currentLon,
|
|
||||||
destination.location_id!);
|
|
||||||
saveGameState();
|
|
||||||
ExternalService()
|
|
||||||
.startRogaining()
|
|
||||||
.then((value) => Get.back());
|
|
||||||
} else {
|
|
||||||
if (destination.cp == -1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Get.back();
|
|
||||||
await destinationController
|
|
||||||
.callforCheckin(destination);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
destination.cp == -1 &&
|
|
||||||
destinationController
|
|
||||||
.isInRog.value ==
|
|
||||||
false &&
|
|
||||||
destinationController
|
|
||||||
.rogainingCounted.value ==
|
|
||||||
false
|
|
||||||
? "ロゲ開始"
|
|
||||||
: destinationController.isInRog.value ==
|
|
||||||
true &&
|
|
||||||
destination.cp == -1
|
|
||||||
? "ゲーム中"
|
|
||||||
: isAlreadyCheckedIn == true
|
|
||||||
? "ゲーム中"
|
|
||||||
: "チェックイン",
|
|
||||||
style: TextStyle(
|
|
||||||
color: Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.onSecondary))))
|
|
||||||
: Container(),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
|
|||||||
34
lib/widgets/current_position_widget.dart
Normal file
34
lib/widgets/current_position_widget.dart
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||||
|
|
||||||
|
class CurrentPosition extends StatefulWidget {
|
||||||
|
const CurrentPosition({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CurrentPosition> createState() => _CurrentPositionState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CurrentPositionState extends State<CurrentPosition> {
|
||||||
|
final DestinationController destinationController =
|
||||||
|
Get.find<DestinationController>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey, borderRadius: BorderRadius.circular(20.0)),
|
||||||
|
child: IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
destinationController.centerMapToCurrentLocation();
|
||||||
|
},
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.location_searching,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
210
lib/widgets/game_state_view.dart
Normal file
210
lib/widgets/game_state_view.dart
Normal file
@ -0,0 +1,210 @@
|
|||||||
|
import 'dart:ffi';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
|
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/services/DatabaseService.dart';
|
||||||
|
import 'package:rogapp/utils/database_helper.dart';
|
||||||
|
import 'package:rogapp/widgets/GameState/CheckinState.dart';
|
||||||
|
import 'package:rogapp/widgets/GameState/ConnectionStatus.dart';
|
||||||
|
import 'package:rogapp/widgets/GameState/DashboardWidget.dart';
|
||||||
|
import 'package:rogapp/widgets/GameState/game_on_off.dart';
|
||||||
|
|
||||||
|
class GameStateManager {
|
||||||
|
static final GameStateManager _instance = GameStateManager._internal();
|
||||||
|
|
||||||
|
factory GameStateManager() {
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameStateManager._internal();
|
||||||
|
|
||||||
|
List<String> _logs = [];
|
||||||
|
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();
|
||||||
|
return Container(
|
||||||
|
width: MediaQuery.of(context).size.width,
|
||||||
|
decoration: 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: EdgeInsets.symmetric(horizontal: 10.0),
|
||||||
|
color: Colors.blueGrey, // Adjust color as needed
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text('ゲームステータス', style: TextStyle(color: Colors.white)),
|
||||||
|
IconButton(
|
||||||
|
icon: 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
|
||||||
|
],
|
||||||
|
),
|
||||||
|
// child: Obx(
|
||||||
|
// () => DashboardWidget(
|
||||||
|
// gameStarted: destinationController.isInRog.value,
|
||||||
|
// locationsVisited: 3,
|
||||||
|
// isMinimized: false,
|
||||||
|
// ),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,5 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:geojson/geojson.dart';
|
import 'package:geojson_vi/geojson_vi.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:rogapp/model/destination.dart';
|
import 'package:rogapp/model/destination.dart';
|
||||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||||
@ -22,16 +22,15 @@ class _ListWidgetState extends State<ListWidget> {
|
|||||||
Get.find<DestinationController>();
|
Get.find<DestinationController>();
|
||||||
|
|
||||||
Image getImage(int index) {
|
Image getImage(int index) {
|
||||||
if (indexController.locations[0].collection[index].properties!["photos"] ==
|
if (indexController.locations[0].features[index]!.properties!["photos"] ==
|
||||||
null ||
|
null ||
|
||||||
indexController.locations[0].collection[index].properties!["photos"] ==
|
indexController.locations[0].features[index]!.properties!["photos"] ==
|
||||||
"") {
|
"") {
|
||||||
return const Image(image: AssetImage('assets/images/empty_image.png'));
|
return const Image(image: AssetImage('assets/images/empty_image.png'));
|
||||||
} else {
|
} else {
|
||||||
//print("==== photo index is $index ===");
|
//print("==== photo index is $index ===");
|
||||||
String serverUrl = ConstValues.currentServer();
|
String serverUrl = ConstValues.currentServer();
|
||||||
GeoJsonFeature<dynamic> gf =
|
GeoJSONFeature gf = indexController.locations[0].features[index]!;
|
||||||
indexController.locations[0].collection[index];
|
|
||||||
String photo = gf.properties!["photos"];
|
String photo = gf.properties!["photos"];
|
||||||
return Image(
|
return Image(
|
||||||
image: NetworkImage('$serverUrl/media/compressed/$photo'),
|
image: NetworkImage('$serverUrl/media/compressed/$photo'),
|
||||||
@ -43,7 +42,7 @@ class _ListWidgetState extends State<ListWidget> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void changeCurrentFeature(GeoJsonFeature fs) {
|
void changeCurrentFeature(GeoJSONFeature fs) {
|
||||||
if (indexController.currentFeature.isNotEmpty) {
|
if (indexController.currentFeature.isNotEmpty) {
|
||||||
indexController.currentFeature.clear();
|
indexController.currentFeature.clear();
|
||||||
}
|
}
|
||||||
@ -55,14 +54,14 @@ class _ListWidgetState extends State<ListWidget> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
Destination createDestination(GeoJsonFeature feature) {
|
Destination createDestination(GeoJSONFeature feature) {
|
||||||
final props = feature.properties;
|
final props = feature.properties;
|
||||||
GeoJsonMultiPoint pt = feature.geometry;
|
GeoJSONMultiPoint pt = feature.geometry as GeoJSONMultiPoint;
|
||||||
|
|
||||||
return Destination(
|
return Destination(
|
||||||
cp: props!['cp'],
|
cp: props!['cp'],
|
||||||
lat: pt.geoSerie!.geoPoints.first.latitude,
|
lat: pt.coordinates[0][1],
|
||||||
lon: pt.geoSerie!.geoPoints.first.longitude,
|
lon: pt.coordinates[0][0],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +71,7 @@ class _ListWidgetState extends State<ListWidget> {
|
|||||||
lat: indexController.currentLat, lon: indexController.currentLon);
|
lat: indexController.currentLat, lon: indexController.currentLon);
|
||||||
//Destination dest1 = createDestination(indexController.locations[0].collection[0]);
|
//Destination dest1 = createDestination(indexController.locations[0].collection[0]);
|
||||||
Destination dest2 =
|
Destination dest2 =
|
||||||
createDestination(indexController.locations[0].collection[i]);
|
createDestination(indexController.locations[0].features[i]!);
|
||||||
|
|
||||||
// Get the distance between these two destinations
|
// Get the distance between these two destinations
|
||||||
final res = await MatrixService.getDestinations([desCurr, dest2]);
|
final res = await MatrixService.getDestinations([desCurr, dest2]);
|
||||||
@ -83,9 +82,9 @@ class _ListWidgetState extends State<ListWidget> {
|
|||||||
|
|
||||||
Future<void> _pullRefresh() async {
|
Future<void> _pullRefresh() async {
|
||||||
//print("pull to refesh");
|
//print("pull to refesh");
|
||||||
indexController.locations[0].collection.sort((a, b) =>
|
indexController.locations[0].features.sort((a, b) =>
|
||||||
(a.properties!['cp'] as Comparable)
|
(a!.properties!['cp'] as Comparable)
|
||||||
.compareTo(b.properties!['cp'] as Comparable));
|
.compareTo(b!.properties!['cp'] as Comparable));
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,12 +95,12 @@ class _ListWidgetState extends State<ListWidget> {
|
|||||||
? RefreshIndicator(
|
? RefreshIndicator(
|
||||||
onRefresh: _pullRefresh,
|
onRefresh: _pullRefresh,
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
itemCount: indexController.locations[0].collection.length,
|
itemCount: indexController.locations[0].features.length,
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
itemBuilder: (_, index) {
|
itemBuilder: (_, index) {
|
||||||
bool isFound = false;
|
bool isFound = false;
|
||||||
for (Destination d in destinationController.destinations) {
|
for (Destination d in destinationController.destinations) {
|
||||||
if (indexController.locations[0].collection[index]
|
if (indexController.locations[0].features[index]!
|
||||||
.properties!['location_id'] ==
|
.properties!['location_id'] ==
|
||||||
d.location_id) {
|
d.location_id) {
|
||||||
isFound = true;
|
isFound = true;
|
||||||
@ -113,8 +112,8 @@ class _ListWidgetState extends State<ListWidget> {
|
|||||||
selected: isFound,
|
selected: isFound,
|
||||||
selectedTileColor: Colors.yellow.shade200,
|
selectedTileColor: Colors.yellow.shade200,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
GeoJsonFeature gf =
|
GeoJSONFeature gf =
|
||||||
indexController.locations[0].collection[index];
|
indexController.locations[0].features[index]!;
|
||||||
Destination des =
|
Destination des =
|
||||||
destinationController.festuretoDestination(gf);
|
destinationController.festuretoDestination(gf);
|
||||||
changeCurrentFeature(gf);
|
changeCurrentFeature(gf);
|
||||||
@ -129,29 +128,27 @@ class _ListWidgetState extends State<ListWidget> {
|
|||||||
)));
|
)));
|
||||||
},
|
},
|
||||||
leading: getImage(index),
|
leading: getImage(index),
|
||||||
title: indexController.locations[0].collection[index]
|
title: indexController.locations[0].features[index]!
|
||||||
.properties!['location_name'] !=
|
.properties!['location_name'] !=
|
||||||
null
|
null
|
||||||
? Text(indexController.locations[0]
|
? Text(indexController.locations[0].features[index]!
|
||||||
.collection[index].properties!['location_name']
|
.properties!['location_name']
|
||||||
.toString())
|
.toString())
|
||||||
: const Text(""),
|
: const Text(""),
|
||||||
subtitle: indexController.locations[0].collection[index]
|
subtitle: indexController.locations[0].features[index]!
|
||||||
.properties!['category'] !=
|
.properties!['category'] !=
|
||||||
null
|
null
|
||||||
? Text(indexController.locations[0]
|
? Text(indexController.locations[0].features[index]!
|
||||||
.collection[index].properties!['category'])
|
.properties!['category'])
|
||||||
: const Text(""),
|
: const Text(""),
|
||||||
trailing: Column(
|
trailing: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
indexController.locations[0].collection[index]
|
indexController.locations[0].features[index]!
|
||||||
.properties!['sub_loc_id'] !=
|
.properties!['sub_loc_id'] !=
|
||||||
null
|
null
|
||||||
? Text(indexController
|
? Text(indexController.locations[0]
|
||||||
.locations[0]
|
.features[index]!.properties!['sub_loc_id'])
|
||||||
.collection[index]
|
|
||||||
.properties!['sub_loc_id'])
|
|
||||||
: const Text(""),
|
: const Text(""),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 100,
|
width: 100,
|
||||||
|
|||||||
@ -1,42 +1,48 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:flutter/material.dart';
|
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_location_marker/flutter_map_location_marker.dart';
|
||||||
import 'package:flutter_map_marker_cluster/flutter_map_marker_cluster.dart';
|
import 'package:flutter_map_marker_cluster/flutter_map_marker_cluster.dart';
|
||||||
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
|
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
|
||||||
import 'package:geojson/geojson.dart';
|
import 'package:geojson_vi/geojson_vi.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:latlong2/latlong.dart';
|
import 'package:latlong2/latlong.dart';
|
||||||
import 'package:rogapp/model/destination.dart';
|
import 'package:rogapp/model/destination.dart';
|
||||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||||
import 'package:rogapp/pages/index/index_controller.dart';
|
import 'package:rogapp/pages/index/index_controller.dart';
|
||||||
import 'package:rogapp/utils/database_helper.dart';
|
import 'package:rogapp/utils/database_helper.dart';
|
||||||
|
import 'package:rogapp/utils/location_controller.dart';
|
||||||
import 'package:rogapp/utils/text_util.dart';
|
import 'package:rogapp/utils/text_util.dart';
|
||||||
import 'package:rogapp/widgets/base_layer_widget.dart';
|
import 'package:rogapp/widgets/base_layer_widget.dart';
|
||||||
import 'package:rogapp/widgets/bottom_sheet_new.dart';
|
import 'package:rogapp/widgets/bottom_sheet_new.dart';
|
||||||
import 'package:rogapp/widgets/debug_widget.dart';
|
import 'package:rogapp/widgets/current_position_widget.dart';
|
||||||
|
import 'package:rogapp/widgets/game_state_view.dart';
|
||||||
class MapWidget extends StatelessWidget {
|
|
||||||
final IndexController indexController = Get.find<IndexController>();
|
|
||||||
final DestinationController destinationController =
|
|
||||||
Get.find<DestinationController>();
|
|
||||||
|
|
||||||
|
class MapWidget extends StatefulWidget {
|
||||||
MapWidget({Key? key}) : super(key: key);
|
MapWidget({Key? key}) : super(key: key);
|
||||||
|
|
||||||
StreamSubscription? subscription;
|
@override
|
||||||
|
State<MapWidget> createState() => _MapWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
Widget getMarkerShape(GeoJsonFeature i, BuildContext context) {
|
class _MapWidgetState extends State<MapWidget> {
|
||||||
GeoJsonMultiPoint p = i.geometry as GeoJsonMultiPoint;
|
final IndexController indexController = Get.find<IndexController>();
|
||||||
|
|
||||||
|
final DestinationController destinationController =
|
||||||
|
Get.find<DestinationController>();
|
||||||
|
final LocationController locationController = Get.find<LocationController>();
|
||||||
|
|
||||||
|
StreamSubscription? subscription;
|
||||||
|
Timer? _timer;
|
||||||
|
|
||||||
|
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}");
|
//print("lat is ${p.geoSerie!.geoPoints[0].latitude} and lon is ${p.geoSerie!.geoPoints[0].longitude}");
|
||||||
//RegExp regex = RegExp(r'([.]*0)(?!.*\d)');
|
//RegExp regex = RegExp(r'([.]*0)(?!.*\d)');
|
||||||
return Row(
|
return InkWell(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
InkWell(
|
|
||||||
onTap: () {
|
onTap: () {
|
||||||
GeoJsonFeature? fs = indexController.getFeatureForLatLong(
|
GeoJSONFeature? fs = indexController.getFeatureForLatLong(
|
||||||
p.geoSerie!.geoPoints[0].latitude,
|
p.coordinates[0][1], p.coordinates[0][0]);
|
||||||
p.geoSerie!.geoPoints[0].longitude);
|
|
||||||
//print("------- fs $fs------");
|
//print("------- fs $fs------");
|
||||||
if (fs != null) {
|
if (fs != null) {
|
||||||
indexController.currentFeature.clear();
|
indexController.currentFeature.clear();
|
||||||
@ -47,9 +53,10 @@ class MapWidget extends StatelessWidget {
|
|||||||
|
|
||||||
DatabaseHelper db = DatabaseHelper.instance;
|
DatabaseHelper db = DatabaseHelper.instance;
|
||||||
db.getDestinationByLatLon(des.lat!, des.lon!).then((value) {
|
db.getDestinationByLatLon(des.lat!, des.lon!).then((value) {
|
||||||
|
destinationController.shouldShowBottomSheet = false;
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
constraints: BoxConstraints.loose(
|
constraints:
|
||||||
Size(Get.width, Get.height * 0.85)),
|
BoxConstraints.loose(Size(Get.width, Get.height * 0.85)),
|
||||||
context: context,
|
context: context,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
isDismissible: true,
|
isDismissible: true,
|
||||||
@ -57,12 +64,17 @@ class MapWidget extends StatelessWidget {
|
|||||||
destination: des, isAlreadyCheckedIn: value.isNotEmpty))
|
destination: des, isAlreadyCheckedIn: value.isNotEmpty))
|
||||||
//builder:((context) => BottomSheetWidget())
|
//builder:((context) => BottomSheetWidget())
|
||||||
).whenComplete(() {
|
).whenComplete(() {
|
||||||
|
destinationController.shouldShowBottomSheet = true;
|
||||||
destinationController.skipGps = false;
|
destinationController.skipGps = false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Stack(
|
||||||
|
fit: StackFit.expand,
|
||||||
|
//mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
height: 32,
|
height: 32,
|
||||||
width: 32,
|
width: 32,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@ -82,7 +94,9 @@ class MapWidget extends StatelessWidget {
|
|||||||
size: 6.0,
|
size: 6.0,
|
||||||
),
|
),
|
||||||
i.properties!['cp'] == -1
|
i.properties!['cp'] == -1
|
||||||
? Transform.rotate(
|
? Transform.translate(
|
||||||
|
offset: Offset(18, 0),
|
||||||
|
child: Transform.rotate(
|
||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
origin: Offset.fromDirection(1, 26),
|
origin: Offset.fromDirection(1, 26),
|
||||||
angle: 270 * pi / 180,
|
angle: 270 * pi / 180,
|
||||||
@ -90,34 +104,54 @@ class MapWidget extends StatelessWidget {
|
|||||||
Icons.play_arrow_outlined,
|
Icons.play_arrow_outlined,
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
size: 70,
|
size: 70,
|
||||||
))
|
)),
|
||||||
|
)
|
||||||
: Container(
|
: Container(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
),
|
Transform.translate(
|
||||||
Container(
|
offset: Offset(45, 0),
|
||||||
color: Colors.purple.withOpacity(0.4),
|
child: Align(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: Container(
|
||||||
|
color: Colors.purple.withOpacity(0.2),
|
||||||
// child: Text(TextUtils.getDisplayTextFeture(i),
|
// child: Text(TextUtils.getDisplayTextFeture(i),
|
||||||
// style: const TextStyle(
|
// style: const TextStyle(
|
||||||
// fontSize: 16,
|
// fontSize: 16,
|
||||||
// fontWeight: FontWeight.bold,
|
// fontWeight: FontWeight.bold,
|
||||||
// color: Colors.red,
|
// color: Colors.red,
|
||||||
// ))),
|
// ))),
|
||||||
child: Text(
|
child: Stack(
|
||||||
|
children: <Widget>[
|
||||||
|
// Text with white outline
|
||||||
|
Text(
|
||||||
TextUtils.getDisplayTextFeture(i),
|
TextUtils.getDisplayTextFeture(i),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
// アウトラインの色と幅を設定
|
|
||||||
foreground: Paint()
|
foreground: Paint()
|
||||||
..style = PaintingStyle.stroke
|
..style = PaintingStyle.stroke
|
||||||
..strokeWidth = 1
|
..strokeWidth = 1
|
||||||
..color = Colors.white,
|
..color = Colors.white,
|
||||||
),
|
),
|
||||||
))
|
),
|
||||||
|
// Text with black fill
|
||||||
|
Text(
|
||||||
|
TextUtils.getDisplayTextFeture(i),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,6 +165,28 @@ class MapWidget extends StatelessWidget {
|
|||||||
return pts;
|
return pts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_startIdleTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _startIdleTimer() {
|
||||||
|
_timer = Timer(const Duration(milliseconds: (1000 * 10)), _centerMapOnUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _resetTimer() {
|
||||||
|
_timer?.cancel();
|
||||||
|
_startIdleTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _centerMapOnUser() {
|
||||||
|
print("showBottomSheet ${destinationController.shouldShowBottomSheet}");
|
||||||
|
//if (destinationController.shouldShowBottomSheet) {
|
||||||
|
destinationController.centerMapToCurrentLocation();
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// print(
|
// print(
|
||||||
@ -152,7 +208,8 @@ class MapWidget extends StatelessWidget {
|
|||||||
subscription = indexController.mapController.mapEventStream
|
subscription = indexController.mapController.mapEventStream
|
||||||
.listen((MapEvent mapEvent) {
|
.listen((MapEvent mapEvent) {
|
||||||
if (mapEvent is MapEventMoveStart) {
|
if (mapEvent is MapEventMoveStart) {
|
||||||
//print(DateTime.now().toString() + ' [MapEventMoveStart] START');
|
// print(DateTime.now().toString() +
|
||||||
|
// ' [MapEventMoveStart] START');
|
||||||
// do something
|
// do something
|
||||||
}
|
}
|
||||||
if (mapEvent is MapEventMoveEnd) {}
|
if (mapEvent is MapEventMoveEnd) {}
|
||||||
@ -169,14 +226,18 @@ class MapWidget extends StatelessWidget {
|
|||||||
interactiveFlags:
|
interactiveFlags:
|
||||||
InteractiveFlag.pinchZoom | InteractiveFlag.drag,
|
InteractiveFlag.pinchZoom | InteractiveFlag.drag,
|
||||||
|
|
||||||
onPositionChanged: (MapPosition pos, isvalue) {
|
onPositionChanged: (MapPosition pos, hasGesture) {
|
||||||
|
//print("map position changed ${pos.center!.latitude}");
|
||||||
|
if (hasGesture) {
|
||||||
|
_resetTimer();
|
||||||
|
}
|
||||||
indexController.currentBound = [pos.bounds!];
|
indexController.currentBound = [pos.bounds!];
|
||||||
},
|
},
|
||||||
onTap: (_, __) => popupController
|
onTap: (_, __) => popupController
|
||||||
.hideAllPopups(), // Hide popup when the map is tapped.
|
.hideAllPopups(), // Hide popup when the map is tapped.
|
||||||
),
|
),
|
||||||
children: [
|
children: [
|
||||||
const BaseLayer(),
|
//const BaseLayer(),
|
||||||
Obx(
|
Obx(
|
||||||
() => indexController.routePointLenght > 0
|
() => indexController.routePointLenght > 0
|
||||||
? PolylineLayer(
|
? PolylineLayer(
|
||||||
@ -190,7 +251,9 @@ class MapWidget extends StatelessWidget {
|
|||||||
: Container(),
|
: Container(),
|
||||||
),
|
),
|
||||||
CurrentLocationLayer(
|
CurrentLocationLayer(
|
||||||
followOnLocationUpdate: FollowOnLocationUpdate.never,
|
positionStream: locationController
|
||||||
|
.locationMarkerPositionStreamController.stream,
|
||||||
|
alignDirectionOnUpdate: AlignOnUpdate.never,
|
||||||
turnOnHeadingUpdate: TurnOnHeadingUpdate.never,
|
turnOnHeadingUpdate: TurnOnHeadingUpdate.never,
|
||||||
style: const LocationMarkerStyle(
|
style: const LocationMarkerStyle(
|
||||||
marker: DefaultLocationMarker(
|
marker: DefaultLocationMarker(
|
||||||
@ -204,37 +267,36 @@ class MapWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
indexController.locations.isNotEmpty &&
|
indexController.locations.isNotEmpty &&
|
||||||
indexController.locations[0].collection.isNotEmpty
|
indexController.locations[0].features.isNotEmpty
|
||||||
? MarkerLayer(
|
? MarkerLayer(
|
||||||
markers:
|
markers:
|
||||||
indexController.locations[0].collection.map((i) {
|
indexController.locations[0].features.map((i) {
|
||||||
//print("i si ${i.properties!['location_id']}");
|
//print("i si ${i.properties!['location_id']}");
|
||||||
|
|
||||||
RegExp regex = RegExp(r'([.]*0)(?!.*\d)');
|
RegExp regex = RegExp(r'([.]*0)(?!.*\d)');
|
||||||
GeoJsonMultiPoint p =
|
GeoJSONMultiPoint p =
|
||||||
i.geometry as GeoJsonMultiPoint;
|
i!.geometry as GeoJSONMultiPoint;
|
||||||
//print(
|
//print(
|
||||||
// "lat is ${p.geoSerie!.geoPoints[0].latitude} and lon is ${p.geoSerie!.geoPoints[0].longitude}");
|
// "lat is ${p.geoSerie!.geoPoints[0].latitude} and lon is ${p.geoSerie!.geoPoints[0].longitude}");
|
||||||
return Marker(
|
return Marker(
|
||||||
anchorPos: AnchorPos.exactly(Anchor(108.0, 18.0)),
|
alignment: Alignment.center,
|
||||||
height: 32.0,
|
height: 27.0,
|
||||||
width: 120.0,
|
width: 127.0,
|
||||||
point: LatLng(p.geoSerie!.geoPoints[0].latitude,
|
point: LatLng(
|
||||||
p.geoSerie!.geoPoints[0].longitude),
|
p.coordinates[0][1], p.coordinates[0][0]),
|
||||||
builder: (ctx) {
|
child: getMarkerShape(i, context));
|
||||||
return getMarkerShape(i, context);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}).toList(),
|
}).toList(),
|
||||||
)
|
)
|
||||||
: const Center(child: CircularProgressIndicator()),
|
: const Center(child: CircularProgressIndicator()),
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
const Positioned(
|
const Positioned(top: 0, left: 0, child: GameStateWidget()),
|
||||||
bottom: 10,
|
const Positioned(bottom: 10, right: 10, child: CurrentPosition())
|
||||||
left: 0,
|
// const Positioned(
|
||||||
child: DebugWidget(),
|
// bottom: 10,
|
||||||
)
|
// left: 0,
|
||||||
|
// child: DebugWidget(),
|
||||||
|
// )
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,16 +7,12 @@
|
|||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
#include <file_selector_linux/file_selector_plugin.h>
|
#include <file_selector_linux/file_selector_plugin.h>
|
||||||
#include <isar_flutter_libs/isar_flutter_libs_plugin.h>
|
|
||||||
#include <url_launcher_linux/url_launcher_plugin.h>
|
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||||
|
|
||||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||||
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
|
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
|
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
|
||||||
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
|
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
|
||||||
g_autoptr(FlPluginRegistrar) isar_flutter_libs_registrar =
|
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "IsarFlutterLibsPlugin");
|
|
||||||
isar_flutter_libs_plugin_register_with_registrar(isar_flutter_libs_registrar);
|
|
||||||
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
|
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
|
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
|
||||||
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
|
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
|
||||||
|
|||||||
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
file_selector_linux
|
file_selector_linux
|
||||||
isar_flutter_libs
|
|
||||||
url_launcher_linux
|
url_launcher_linux
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import Foundation
|
|||||||
import connectivity_plus
|
import connectivity_plus
|
||||||
import file_selector_macos
|
import file_selector_macos
|
||||||
import geolocator_apple
|
import geolocator_apple
|
||||||
import isar_flutter_libs
|
|
||||||
import path_provider_foundation
|
import path_provider_foundation
|
||||||
import shared_preferences_foundation
|
import shared_preferences_foundation
|
||||||
import sqflite
|
import sqflite
|
||||||
@ -18,7 +17,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
|||||||
ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin"))
|
ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin"))
|
||||||
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
|
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
|
||||||
GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin"))
|
GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin"))
|
||||||
IsarFlutterLibsPlugin.register(with: registry.registrar(forPlugin: "IsarFlutterLibsPlugin"))
|
|
||||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||||
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
|
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
|
||||||
|
|||||||
@ -259,7 +259,7 @@
|
|||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
attributes = {
|
attributes = {
|
||||||
LastSwiftUpdateCheck = 0920;
|
LastSwiftUpdateCheck = 0920;
|
||||||
LastUpgradeCheck = 1430;
|
LastUpgradeCheck = 1510;
|
||||||
ORGANIZATIONNAME = "";
|
ORGANIZATIONNAME = "";
|
||||||
TargetAttributes = {
|
TargetAttributes = {
|
||||||
331C80D4294CF70F00263BE5 = {
|
331C80D4294CF70F00263BE5 = {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "1430"
|
LastUpgradeVersion = "1510"
|
||||||
version = "1.3">
|
version = "1.3">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
|
|||||||
682
pubspec.lock
682
pubspec.lock
File diff suppressed because it is too large
Load Diff
43
pubspec.yaml
43
pubspec.yaml
@ -15,7 +15,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
|||||||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||||
# Read more about iOS versioning at
|
# Read more about iOS versioning at
|
||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
version: 1.0.26+26
|
version: 1.0.33+33
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=3.1.0 <4.0.0"
|
sdk: ">=3.1.0 <4.0.0"
|
||||||
@ -35,12 +35,12 @@ dependencies:
|
|||||||
cupertino_icons: ^1.0.2
|
cupertino_icons: ^1.0.2
|
||||||
sqflite: ^2.0.1
|
sqflite: ^2.0.1
|
||||||
get: ^4.6.6
|
get: ^4.6.6
|
||||||
flutter_map: ^4.0.0
|
flutter_map: ^6.0.1
|
||||||
geolocator: ^9.0.2
|
geolocator: ^11.0.0
|
||||||
permission_handler: ^10.0.0
|
permission_handler: ^11.1.0
|
||||||
google_api_availability: ^5.0.0
|
google_api_availability: ^5.0.0
|
||||||
tuple: ^2.0.0
|
tuple: ^2.0.0
|
||||||
latlong2: ^0.8.1
|
latlong2: ^0.9.0
|
||||||
positioned_tap_detector_2: ^1.0.4
|
positioned_tap_detector_2: ^1.0.4
|
||||||
transparent_image: ^2.0.0
|
transparent_image: ^2.0.0
|
||||||
async: ^2.8.2
|
async: ^2.8.2
|
||||||
@ -49,35 +49,33 @@ dependencies:
|
|||||||
proj4dart: ^2.0.0
|
proj4dart: ^2.0.0
|
||||||
meta: ^1.7.0
|
meta: ^1.7.0
|
||||||
collection: ^1.15.0
|
collection: ^1.15.0
|
||||||
path_provider: ^2.0.8
|
path_provider: ^2.1.2
|
||||||
flutter_map_location_marker: any
|
flutter_map_location_marker: ^8.0.8
|
||||||
flutter_map_marker_cluster: any
|
flutter_map_marker_cluster: any
|
||||||
material_design_icons_flutter: ^7.0.7296
|
material_design_icons_flutter: ^7.0.7296
|
||||||
google_fonts: ^4.0.4
|
google_fonts: ^6.1.0
|
||||||
keyboard_dismisser: ^3.0.0
|
keyboard_dismisser: ^3.0.0
|
||||||
image_picker: ^1.0.4
|
image_picker: ^1.0.4
|
||||||
#geojson_vi: ^2.0.7
|
geojson_vi: ^2.2.1
|
||||||
geojson: ^1.0.0
|
|
||||||
url_launcher: ^6.0.20
|
url_launcher: ^6.0.20
|
||||||
flutter_breadcrumb: ^1.0.1
|
flutter_breadcrumb: ^1.0.1
|
||||||
timeline_tile: ^2.0.0
|
timeline_tile: ^2.0.0
|
||||||
# google_maps_flutter: ^2.5.0
|
flutter_polyline_points: ^2.0.0
|
||||||
#flutter_map_marker_popup: any
|
flutter_typeahead: ^5.0.1
|
||||||
flutter_polyline_points: ^1.0.0
|
|
||||||
google_maps_webservice: ^0.0.19
|
|
||||||
flutter_typeahead: ^4.0.0
|
|
||||||
flutter_launcher_icons: ^0.13.1
|
flutter_launcher_icons: ^0.13.1
|
||||||
rename: ^2.0.1
|
rename: ^3.0.1
|
||||||
circular_menu: ^2.0.1
|
circular_menu: ^2.0.1
|
||||||
camera_camera: ^3.0.0
|
camera_camera: ^3.0.0
|
||||||
intl: ^0.18.1
|
intl: ^0.19.0
|
||||||
modal_bottom_sheet: ^3.0.0-pre
|
modal_bottom_sheet: ^3.0.0-pre
|
||||||
connectivity_plus: ^4.0.2
|
|
||||||
flutter_map_tile_caching: ^8.0.1
|
|
||||||
shared_preferences: ^2.0.15
|
shared_preferences: ^2.0.15
|
||||||
gallery_saver: ^2.3.2
|
image_gallery_saver: ^2.0.3
|
||||||
flutter_riverpod: ^2.4.0
|
flutter_riverpod: ^2.4.0
|
||||||
http: ^0.13.6
|
http: ^1.1.0
|
||||||
|
dio: ^5.4.1
|
||||||
|
dio_cache_interceptor_hive_store: ^3.2.1
|
||||||
|
flutter_map_cache: ^1.3.0
|
||||||
|
connectivity_plus: ^5.0.2
|
||||||
|
|
||||||
flutter_icons:
|
flutter_icons:
|
||||||
android: true
|
android: true
|
||||||
@ -93,7 +91,8 @@ dev_dependencies:
|
|||||||
# activated in the `analysis_options.yaml` file located at the root of your
|
# activated in the `analysis_options.yaml` file located at the root of your
|
||||||
# package. See that file for information about deactivating specific lint
|
# package. See that file for information about deactivating specific lint
|
||||||
# rules and activating additional ones.
|
# rules and activating additional ones.
|
||||||
flutter_lints: ^2.0.3
|
flutter_lints: ^3.0.1
|
||||||
|
mockito: ^5.4.4
|
||||||
|
|
||||||
# For information on the generic Dart part of this file, see the
|
# For information on the generic Dart part of this file, see the
|
||||||
# following page: https://dart.dev/tools/pub/pubspec
|
# following page: https://dart.dev/tools/pub/pubspec
|
||||||
|
|||||||
1
test/features/services/auth_service_test.dart
Normal file
1
test/features/services/auth_service_test.dart
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
||||||
@ -1,30 +1 @@
|
|||||||
// This is a basic Flutter widget test.
|
|
||||||
//
|
|
||||||
// To perform an interaction with a widget in your test, use the WidgetTester
|
|
||||||
// utility that Flutter provides. For example, you can send tap and scroll
|
|
||||||
// gestures. You can also use WidgetTester to find child widgets in the widget
|
|
||||||
// tree, read text, and verify that the values of widget properties are correct.
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
|
|
||||||
import 'package:rogapp/main.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
|
||||||
// Build our app and trigger a frame.
|
|
||||||
await tester.pumpWidget(const MyApp());
|
|
||||||
|
|
||||||
// Verify that our counter starts at 0.
|
|
||||||
expect(find.text('0'), findsOneWidget);
|
|
||||||
expect(find.text('1'), findsNothing);
|
|
||||||
|
|
||||||
// Tap the '+' icon and trigger a frame.
|
|
||||||
await tester.tap(find.byIcon(Icons.add));
|
|
||||||
await tester.pump();
|
|
||||||
|
|
||||||
// Verify that our counter has incremented.
|
|
||||||
expect(find.text('0'), findsNothing);
|
|
||||||
expect(find.text('1'), findsOneWidget);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|||||||
@ -9,7 +9,6 @@
|
|||||||
#include <connectivity_plus/connectivity_plus_windows_plugin.h>
|
#include <connectivity_plus/connectivity_plus_windows_plugin.h>
|
||||||
#include <file_selector_windows/file_selector_windows.h>
|
#include <file_selector_windows/file_selector_windows.h>
|
||||||
#include <geolocator_windows/geolocator_windows.h>
|
#include <geolocator_windows/geolocator_windows.h>
|
||||||
#include <isar_flutter_libs/isar_flutter_libs_plugin.h>
|
|
||||||
#include <permission_handler_windows/permission_handler_windows_plugin.h>
|
#include <permission_handler_windows/permission_handler_windows_plugin.h>
|
||||||
#include <url_launcher_windows/url_launcher_windows.h>
|
#include <url_launcher_windows/url_launcher_windows.h>
|
||||||
|
|
||||||
@ -20,8 +19,6 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
|
|||||||
registry->GetRegistrarForPlugin("FileSelectorWindows"));
|
registry->GetRegistrarForPlugin("FileSelectorWindows"));
|
||||||
GeolocatorWindowsRegisterWithRegistrar(
|
GeolocatorWindowsRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("GeolocatorWindows"));
|
registry->GetRegistrarForPlugin("GeolocatorWindows"));
|
||||||
IsarFlutterLibsPluginRegisterWithRegistrar(
|
|
||||||
registry->GetRegistrarForPlugin("IsarFlutterLibsPlugin"));
|
|
||||||
PermissionHandlerWindowsPluginRegisterWithRegistrar(
|
PermissionHandlerWindowsPluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
|
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
|
||||||
UrlLauncherWindowsRegisterWithRegistrar(
|
UrlLauncherWindowsRegisterWithRegistrar(
|
||||||
|
|||||||
@ -6,7 +6,6 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
|||||||
connectivity_plus
|
connectivity_plus
|
||||||
file_selector_windows
|
file_selector_windows
|
||||||
geolocator_windows
|
geolocator_windows
|
||||||
isar_flutter_libs
|
|
||||||
permission_handler_windows
|
permission_handler_windows
|
||||||
url_launcher_windows
|
url_launcher_windows
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user