optimized

This commit is contained in:
Mohamed Nouffer
2023-10-06 16:25:21 +05:30
parent 7fdb6c05ee
commit 0e2a8f89f3
101 changed files with 50948 additions and 4137 deletions

View File

@ -57,9 +57,9 @@ class CameraPage extends StatelessWidget {
await destinationController.makeCheckin(destination, true,
destinationController.photos[0].path);
Get.back();
destinationController.rogaining_counted.value = true;
destinationController.skip_gps = false;
destinationController.is_photo_shoot.value = false;
destinationController.rogainingCounted.value = true;
destinationController.skipGps = false;
destinationController.isPhotoShoot.value = false;
Get.snackbar("チェックインしました。",
"${destination.sub_loc_id} : ${destination.name}");
},
@ -69,8 +69,8 @@ class CameraPage extends StatelessWidget {
);
}
if (destinationController.is_at_goal.value &&
destinationController.is_in_rog.value) {
if (destinationController.isAtGoal.value &&
destinationController.isInRog.value) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
@ -87,21 +87,21 @@ class CameraPage extends StatelessWidget {
style:
ElevatedButton.styleFrom(backgroundColor: Colors.red),
onPressed: () async {
print(
"----- user isss ${indexController.currentUser[0]} -----");
// print(
// "----- user isss ${indexController.currentUser[0]} -----");
settingGoal.value = true;
try {
int userId =
indexController.currentUser[0]["user"]["id"];
//print("--- Pressed -----");
String _team = indexController.currentUser[0]["user"]
String team = indexController.currentUser[0]["user"]
['team_name'];
//print("--- _team : ${_team}-----");
String _event_code = indexController.currentUser[0]
String eventCode = indexController.currentUser[0]
["user"]["event_code"];
//print("--- _event_code : ${_event_code}-----");
String _token =
String token =
indexController.currentUser[0]["token"];
//print("--- _token : ${_token}-----");
DateTime now = DateTime.now();
@ -111,21 +111,21 @@ class CameraPage extends StatelessWidget {
await ExternalService()
.makeGoal(
userId,
_token,
_team,
token,
team,
destinationController.photos[0].path,
formattedDate,
_event_code)
eventCode)
.then((value) {
print(
"---called ext api ${value['status']} ------");
// print(
// "---called ext api ${value['status']} ------");
if (value['status'] == 'OK') {
Get.back();
destinationController.skip_gps = false;
destinationController.skipGps = false;
Get.snackbar("目標が保存されました", "目標が正常に追加されました");
destinationController.resetRogaining();
} else {
print("---- status ${value['status']} ---- ");
//print("---- status ${value['status']} ---- ");
Get.snackbar("目標が追加されていません", "please_try_again");
}
});
@ -136,15 +136,13 @@ class CameraPage extends StatelessWidget {
}
},
child: Text("finish_goal".tr))
: Container(
child: const Center(
child: CircularProgressIndicator(),
),
: const Center(
child: CircularProgressIndicator(),
)
: Container())
],
);
} else if (destinationController.is_in_rog.value &&
} else if (destinationController.isInRog.value &&
dbDest?.checkedin != null &&
dbDest?.checkedin == true) {
//make buypoint image
@ -162,16 +160,16 @@ class CameraPage extends StatelessWidget {
? ElevatedButton(
style: ElevatedButton.styleFrom(backgroundColor: Colors.red),
onPressed: () async {
print(
"##### current destination ${indexController.currentDestinationFeature[0].sub_loc_id} #######");
// print(
// "##### current destination ${indexController.currentDestinationFeature[0].sub_loc_id} #######");
await destinationController.makeBuyPoint(
destination!, destinationController.photos[0].path);
destination, destinationController.photos[0].path);
Get.back();
destinationController.rogaining_counted.value = true;
destinationController.skip_gps = false;
destinationController.is_photo_shoot.value = false;
destinationController.rogainingCounted.value = true;
destinationController.skipGps = false;
destinationController.isPhotoShoot.value = false;
Get.snackbar("お買い物加点を行いました。",
"${destination!.sub_loc_id} : ${destination!.name}");
"${destination.sub_loc_id} : ${destination.name}");
},
child: const Text("レシートの写真を撮る"))
: Container())
@ -192,16 +190,16 @@ class CameraPage extends StatelessWidget {
? ElevatedButton(
style: ElevatedButton.styleFrom(backgroundColor: Colors.red),
onPressed: () async {
print(
"##### current destination ${indexController.currentDestinationFeature[0].sub_loc_id} #######");
// print(
// "##### current destination ${indexController.currentDestinationFeature[0].sub_loc_id} #######");
await destinationController.makeCheckin(
indexController.currentDestinationFeature[0],
true,
destinationController.photos[0].path);
Get.back();
destinationController.rogaining_counted.value = true;
destinationController.skip_gps = false;
destinationController.is_photo_shoot.value = false;
destinationController.rogainingCounted.value = true;
destinationController.skipGps = false;
destinationController.isPhotoShoot.value = false;
Get.snackbar("チェックインした", "正常にチェックインしました");
},
child: const Text("チェックイン"))
@ -218,13 +216,13 @@ class CameraPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (buyPointPhoto == true) {
print("--- buy point camera ${destination.toString()}");
//print("--- buy point camera ${destination.toString()}");
return BuyPointCamera(destination: destination);
} else if (destinationController.is_in_rog.value) {
print("--- in normal camera ${destination.toString()}");
} else if (destinationController.isInRog.value) {
//print("--- in normal camera ${destination.toString()}");
return Scaffold(
appBar: destinationController.is_in_rog.value &&
destinationController.rogaining_counted.value == true
appBar: destinationController.isInRog.value &&
destinationController.rogainingCounted.value == true
? AppBar(
automaticallyImplyLeading: false,
title: destination.cp == -1
@ -297,25 +295,23 @@ class StartRogaining extends StatelessWidget {
"Not started yet".tr,
),
),
body: Container(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("You have not started rogaining yet.".tr,
style: const TextStyle(fontSize: 24)),
const SizedBox(
height: 40.0,
),
ElevatedButton(
onPressed: () {
Get.back();
destinationController.skip_gps = false;
},
child: const Text("Back"),
),
],
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("You have not started rogaining yet.".tr,
style: const TextStyle(fontSize: 24)),
const SizedBox(
height: 40.0,
),
ElevatedButton(
onPressed: () {
Get.back();
destinationController.skipGps = false;
},
child: const Text("Back"),
),
],
),
),
);
@ -404,7 +400,7 @@ class BuyPointCamera extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
Obx(() => Row(
mainAxisSize: MainAxisSize.min,
mainAxisSize: MainAxisSize.min,
children: [
ElevatedButton(
onPressed: () {
@ -414,17 +410,17 @@ class BuyPointCamera extends StatelessWidget {
child: destinationController.photos.isNotEmpty
? const Text("再撮影")
: const Text("撮影")),
const SizedBox(width: 10,),
const SizedBox(
width: 10,
),
ElevatedButton(
onPressed: () async {
await destinationController.cancelBuyPoint(
destination);
Get.back();
destinationController.rogaining_counted.value =
true;
destinationController.skip_gps = false;
destinationController.is_photo_shoot.value =
false;
await destinationController
.cancelBuyPoint(destination);
Get.back();
destinationController.rogainingCounted.value = true;
destinationController.skipGps = false;
destinationController.isPhotoShoot.value = false;
},
child: const Text("買い物なし"))
],
@ -449,11 +445,10 @@ class BuyPointCamera extends StatelessWidget {
destination,
destinationController.photos[0].path);
Get.back();
destinationController.rogaining_counted.value =
destinationController.rogainingCounted.value =
true;
destinationController.skip_gps = false;
destinationController.is_photo_shoot.value =
false;
destinationController.skipGps = false;
destinationController.isPhotoShoot.value = false;
Get.snackbar("お買い物加点を行いました",
"${destination.sub_loc_id} : ${destination.name}");
},

View File

@ -13,150 +13,170 @@ class ChangePasswordPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
resizeToAvoidBottomInset: false,
backgroundColor: Colors.white,
appBar: AppBar(
elevation: 0,
backgroundColor: Colors.white,
leading:
IconButton( onPressed: (){
Navigator.pop(context);
},icon:const Icon(Icons.arrow_back_ios,size: 20,color: Colors.black,)),
leading: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: const Icon(
Icons.arrow_back_ios,
size: 20,
color: Colors.black,
)),
),
body:
SizedBox(
width: double.infinity,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Column(
children: [
Column(
children: [
Container(
child: Text("change_password".tr, style: const TextStyle(fontSize: 24.0),),
),
const SizedBox(height: 30,),
],
),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 40
),
child: Column(
body: SizedBox(
width: double.infinity,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Column(
children: [
Column(
children: [
makeInput(label: "old_password".tr, controller: oldPasswordController),
makeInput(label: "new_password".tr, controller: newPasswordController, obsureText: true),
Text(
"change_password".tr,
style: const TextStyle(fontSize: 24.0),
),
const SizedBox(
height: 30,
),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 40),
child: Container(
padding: const EdgeInsets.only(top: 3,left: 3),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40),
),
child: Obx((() =>
indexController.is_loading == true ? MaterialButton(
minWidth: double.infinity,
height:60,
onPressed: (){
},
color: Colors.grey[400],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40)
),
child: const CircularProgressIndicator(),
) :
Column(
children: [
MaterialButton(
minWidth: double.infinity,
height:60,
onPressed: (){
if(oldPasswordController.text.isEmpty || newPasswordController.text.isEmpty){
Get.snackbar(
"no_values".tr,
"values_required".tr,
icon: const Icon(Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: const Duration(milliseconds: 800),
backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
return;
}
indexController.is_loading.value = true;
indexController.changePassword(oldPasswordController.text, newPasswordController.text, context);
//indexController.login(oldPasswordController.text, newPasswordController.text, context);
},
color: Colors.indigoAccent[400],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40)
),
child: const Text("ログイン",style: TextStyle(
fontWeight: FontWeight.w600,fontSize: 16,color: Colors.white70
),
),
),
const SizedBox(height: 10.0,),
],
)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 40),
child: Column(
children: [
makeInput(
label: "old_password".tr,
controller: oldPasswordController),
makeInput(
label: "new_password".tr,
controller: newPasswordController,
obsureText: true),
],
),
),
)
),
const SizedBox(height: 20,),
const Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
],
)
],
),
],
),
)
);
Padding(
padding: const EdgeInsets.symmetric(horizontal: 40),
child: Container(
padding: const EdgeInsets.only(top: 3, left: 3),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40),
),
child: Obx(
(() => indexController.isLoading.value == true
? MaterialButton(
minWidth: double.infinity,
height: 60,
onPressed: () {},
color: Colors.grey[400],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40)),
child: const CircularProgressIndicator(),
)
: Column(
children: [
MaterialButton(
minWidth: double.infinity,
height: 60,
onPressed: () {
if (oldPasswordController
.text.isEmpty ||
newPasswordController
.text.isEmpty) {
Get.snackbar(
"no_values".tr,
"values_required".tr,
icon: const Icon(
Icons.assistant_photo_outlined,
size: 40.0,
color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: const Duration(
milliseconds: 800),
backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
return;
}
indexController.isLoading.value = true;
indexController.changePassword(
oldPasswordController.text,
newPasswordController.text,
context);
//indexController.login(oldPasswordController.text, newPasswordController.text, context);
},
color: Colors.indigoAccent[400],
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(40)),
child: const Text(
"ログイン",
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
color: Colors.white70),
),
),
const SizedBox(
height: 10.0,
),
],
)),
),
)),
const SizedBox(
height: 20,
),
const Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [],
)
],
),
],
),
));
}
Widget makeInput({label, required TextEditingController controller, obsureText = false}){
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(label,style:const TextStyle(
fontSize: 15,
fontWeight: FontWeight.w400,
color: Colors.black87
),),
const SizedBox(height: 5,),
TextField(
controller: controller,
obscureText: obsureText,
decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric(vertical: 0,horizontal: 10),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: (Colors.grey[400])!,
Widget makeInput(
{label, required TextEditingController controller, obsureText = false}) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
label,
style: const TextStyle(
fontSize: 15, fontWeight: FontWeight.w400, color: Colors.black87),
),
const SizedBox(
height: 5,
),
TextField(
controller: controller,
obscureText: obsureText,
decoration: InputDecoration(
contentPadding:
const EdgeInsets.symmetric(vertical: 0, horizontal: 10),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: (Colors.grey[400])!,
),
),
border: OutlineInputBorder(
borderSide: BorderSide(color: (Colors.grey[400])!),
),
),
border: OutlineInputBorder(
borderSide: BorderSide(color: (Colors.grey[400])!
),
),
),
),
const SizedBox(height: 30.0,)
],
);
const SizedBox(
height: 30.0,
)
],
);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,3 @@
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:get/get.dart';
@ -10,10 +9,11 @@ import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/routes/app_pages.dart';
import 'package:rogapp/widgets/destination_widget.dart';
class DestnationPage extends StatelessWidget {
DestnationPage({Key? key}) : super(key: key);
class XDestnationPage extends StatelessWidget {
XDestnationPage({Key? key}) : super(key: key);
final DestinationController destinationController = Get.find<DestinationController>();
final DestinationController destinationController =
Get.find<DestinationController>();
final IndexController indexController = Get.find<IndexController>();
@ -26,33 +26,49 @@ class DestnationPage extends StatelessWidget {
permission = await Geolocator.requestPermission();
}
Position position = await Geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.high, forceAndroidLocationManager: true);
indexController.rogMapController.move(LatLng(position.latitude, position.longitude), 14);
desiredAccuracy: LocationAccuracy.high,
forceAndroidLocationManager: true);
indexController.rogMapController
.move(LatLng(position.latitude, position.longitude), 14);
}
Image getImage(int index){
if(destinationController.destinations[index].photos == null || destinationController.destinations[index].photos == ""){
Image getImage(int index) {
if (destinationController.destinations[index].photos == null ||
destinationController.destinations[index].photos == "") {
return const Image(image: AssetImage('assets/images/empty_image.png'));
}
else{
return Image(image: NetworkImage(destinationController.destinations[index].photos!));
} else {
return Image(
image:
NetworkImage(destinationController.destinations[index].photos!));
}
}
Widget getRoutingImage(int route){
Widget getRoutingImage(int route) {
switch (route) {
case 0:
return const Image(image: AssetImage('assets/images/p4_9_man.png'), width: 35.0,);
return const Image(
image: AssetImage('assets/images/p4_9_man.png'),
width: 35.0,
);
case 1:
return const Image(image: AssetImage('assets/images/p4_8_car.png'), width: 35.0,);
return const Image(
image: AssetImage('assets/images/p4_8_car.png'),
width: 35.0,
);
case 2:
return const Image(image: AssetImage('assets/images/p4_10_train.png'), width: 35.0,);
return const Image(
image: AssetImage('assets/images/p4_10_train.png'),
width: 35.0,
);
default:
return const Image(image: AssetImage('assets/images/p4_9_man.png'), width: 35.0,);
return const Image(
image: AssetImage('assets/images/p4_9_man.png'),
width: 35.0,
);
}
}
@override
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () async {
@ -60,149 +76,177 @@ class DestnationPage extends StatelessWidget {
return false;
},
child: Scaffold(
drawer: DrawerPage(),
bottomNavigationBar: BottomAppBar(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left:13.0),
child: InkWell(
child: Obx((() => getRoutingImage(destinationController.travelMode.value))),
onTap: (){
Get.bottomSheet(
Obx(() =>
ListView(
children: [
Padding(
padding: const EdgeInsets.only(top:30.0, bottom: 30),
child: Center(child: Text("select_travel_mode".tr, style: const TextStyle(fontSize: 22.0, color:Colors.red, fontWeight:FontWeight.bold),),),
),
ListTile(
selected: destinationController.travelMode == 0 ? true : false,
selectedTileColor: Colors.amber.shade200,
leading: const Image(image: AssetImage('assets/images/p4_9_man.png'),),
title: Text("walking".tr),
onTap:(){
destinationController.travelMode.value = 0;
destinationController.PopulateDestinations();
Get.back();
},
drawer: DrawerPage(),
bottomNavigationBar: BottomAppBar(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 13.0),
child: InkWell(
child: Obx((() => getRoutingImage(
destinationController.travelMode.value))),
onTap: () {
Get.bottomSheet(
Obx(
() => ListView(
children: [
Padding(
padding: const EdgeInsets.only(
top: 30.0, bottom: 30),
child: Center(
child: Text(
"select_travel_mode".tr,
style: const TextStyle(
fontSize: 22.0,
color: Colors.red,
fontWeight: FontWeight.bold),
),
),
),
ListTile(
selected: destinationController.travelMode == 1 ? true : false,
selectedTileColor: Colors.amber.shade200,
leading: const Image(image: AssetImage('assets/images/p4_8_car.png'),),
title: Text("driving".tr),
onTap:(){
destinationController.travelMode.value = 1;
destinationController.PopulateDestinations();
Get.back();
},
ListTile(
selected:
destinationController.travelMode.value ==
0
? true
: false,
selectedTileColor: Colors.amber.shade200,
leading: const Image(
image: AssetImage(
'assets/images/p4_9_man.png'),
),
title: Text("walking".tr),
onTap: () {
destinationController.travelMode.value = 0;
destinationController
.populateDestinations();
Get.back();
},
),
// ListTile(
// selected: destinationController.travelMode == 2 ? true : false,
// selectedTileColor: Colors.amber.shade200,
// leading: Image(image: AssetImage('assets/images/p4_10_train.png'),),
// title: Text("transit".tr),
// onTap:(){
// destinationController.travelMode.value = 2;
// destinationController.PopulateDestinations();
// Get.back();
// },
// ),
],
ListTile(
selected:
destinationController.travelMode.value ==
1
? true
: false,
selectedTileColor: Colors.amber.shade200,
leading: const Image(
image: AssetImage(
'assets/images/p4_8_car.png'),
),
title: Text("driving".tr),
onTap: () {
destinationController.travelMode.value = 1;
destinationController
.populateDestinations();
Get.back();
},
),
// ListTile(
// selected: destinationController.travelMode == 2 ? true : false,
// selectedTileColor: Colors.amber.shade200,
// leading: Image(image: AssetImage('assets/images/p4_10_train.png'),),
// title: Text("transit".tr),
// onTap:(){
// destinationController.travelMode.value = 2;
// destinationController.PopulateDestinations();
// Get.back();
// },
// ),
],
),
),
),
isScrollControlled:false,
backgroundColor: Colors.white,
);
//destinationController.PopulateDestinations();
}
),
)
,
IconButton(
icon: const Icon(Icons.travel_explore, size: 35,),
onPressed: (){
indexController.switchPage(AppPages.INITIAL);
}
isScrollControlled: false,
backgroundColor: Colors.white,
);
//destinationController.PopulateDestinations();
}),
),
],
IconButton(
icon: const Icon(
Icons.travel_explore,
size: 35,
),
onPressed: () {
indexController.switchPage(AppPages.INITIAL);
}),
],
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: (){
floatingActionButton: FloatingActionButton(
onPressed: () {
//print("######");
indexController.toggleDestinationMode();
},
tooltip: 'Increment',
child: Obx(() =>
indexController.desination_mode == 1 ?
const Image(image: AssetImage('assets/images/list2.png'))
:
const Image(image: AssetImage('assets/images/map.png'))
),
elevation: 4.0,
child: Obx(() => indexController.desinationMode.value == 1
? const Image(image: AssetImage('assets/images/list2.png'))
: const Image(image: AssetImage('assets/images/map.png'))),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
appBar:AppBar(
automaticallyImplyLeading: true,
title: Text("app_title".tr),
actions: [
InkWell(
onTap: (){
Get.toNamed(AppPages.CAMERA_PAGE);
},
child: destinationController.is_in_rog == true ?
Image.asset("assets/images/basic-walking.gif",height: 10.0,)
:
destinationController.is_at_goal == true ?
IconButton(
onPressed:(){Get.toNamed(AppPages.CAMERA_PAGE);},
icon: const Icon(Icons.assistant_photo),
)
:
IconButton(
onPressed:(){Get.toNamed(AppPages.CAMERA_PAGE);},
icon: const Icon(Icons.accessibility),
),
),
// Obx(() =>
// Text(indexController.connectionStatusName.value)
// ),
Obx(() =>
ToggleButtons(
floatingActionButtonLocation:
FloatingActionButtonLocation.centerDocked,
appBar: AppBar(
automaticallyImplyLeading: true,
title: Text("app_title".tr),
actions: [
InkWell(
onTap: () {
Get.toNamed(AppPages.CAMERA_PAGE);
},
child: destinationController.isInRog.value == true
? Image.asset(
"assets/images/basic-walking.gif",
height: 10.0,
)
: destinationController.isAtGoal.value == true
? IconButton(
onPressed: () {
Get.toNamed(AppPages.CAMERA_PAGE);
},
icon: const Icon(Icons.assistant_photo),
)
: IconButton(
onPressed: () {
Get.toNamed(AppPages.CAMERA_PAGE);
},
icon: const Icon(Icons.accessibility),
),
),
// Obx(() =>
// Text(indexController.connectionStatusName.value)
// ),
Obx(
() => ToggleButtons(
disabledColor: Colors.grey.shade200,
selectedColor: Colors.red,
children: const <Widget>[
Icon(Icons.explore, size: 35.0,
)],
onPressed: (int index) {
destinationController.is_gps_selected.value = !destinationController.is_gps_selected.value;
if(destinationController.is_gps_selected.value){
destinationController.chekcs = 0;
destinationController.skip_gps = false;
//destinationController.resetRogaining();
}
},
isSelected: [destinationController.is_gps_selected.value],
onPressed: (int index) {
destinationController.isGpsSelected.value =
!destinationController.isGpsSelected.value;
if (destinationController.isGpsSelected.value) {
destinationController.chekcs = 0;
destinationController.skipGps = false;
//destinationController.resetRogaining();
}
},
isSelected: [destinationController.isGpsSelected.value],
children: const <Widget>[
Icon(
Icons.explore,
size: 35.0,
)
],
),
),
),
// IconButton(onPressed: (){
// showCurrentPosition();
// },
// icon: Icon(Icons.location_on_outlined))
],
),
body: Obx(() =>
indexController.desination_mode.value == 0 ?
DestinationWidget():
DestinationMapPage()
)
),
// IconButton(onPressed: (){
// showCurrentPosition();
// },
// icon: Icon(Icons.location_on_outlined))
],
),
body: Obx(() => indexController.desinationMode.value == 0
? DestinationWidget()
: DestinationMapPage())),
);
}
}

View File

@ -25,7 +25,7 @@ class DestinationMapPage extends StatelessWidget {
final PopupController _popupLayerController = PopupController();
List<LatLng>? getPoints() {
print("##### --- route point ${indexController.routePoints.length}");
//print("##### --- route point ${indexController.routePoints.length}");
List<LatLng> pts = [];
for (PointLatLng p in indexController.routePoints) {
LatLng l = LatLng(p.latitude, p.longitude);
@ -39,14 +39,14 @@ class DestinationMapPage extends StatelessWidget {
int index = -1;
for (int i = 0; i < destinationController.destinations.length; i++) {
Destination d = destinationController.destinations[i];
print("^^^^ $d ^^^^");
//print("^^^^ $d ^^^^");
Marker m = Marker(
point: LatLng(d.lat!, d.lon!),
anchorPos: AnchorPos.align(AnchorAlign.center),
builder: (cts) {
return InkWell(
onTap: () {
print("-- Destination is --- ${d.name} ------");
//print("-- Destination is --- ${d.name} ------");
if (indexController.currentDestinationFeature.isNotEmpty) {
indexController.currentDestinationFeature.clear();
}
@ -58,9 +58,11 @@ class DestinationMapPage extends StatelessWidget {
isScrollControlled: true,
constraints: BoxConstraints.loose(
Size(Get.width, Get.height * 0.75)),
builder: ((context) => BottomSheetNew(destination: d,))).whenComplete(() {
print("---- set skip gps to false -----");
destinationController.skip_gps = false;
builder: ((context) => BottomSheetNew(
destination: d,
))).whenComplete(() {
//print("---- set skip gps to false -----");
destinationController.skipGps = false;
});
},
child: Row(
@ -118,18 +120,18 @@ class DestinationMapPage extends StatelessWidget {
Padding(
padding: const EdgeInsets.only(top: 0.0),
//child: TravelMap(),
child: TravelMap(),
child: travelMap(),
),
],
)));
}
FlutterMap TravelMap() {
FlutterMap travelMap() {
return FlutterMap(
mapController: indexController.rogMapController,
options: MapOptions(
onMapReady: () {
indexController.is_rog_mapcontroller_loaded.value = true;
indexController.isRogMapcontrollerLoaded.value = true;
subscription = indexController.rogMapController.mapEventStream
.listen((MapEvent mapEvent) {
if (mapEvent is MapEventMoveStart) {}

View File

@ -12,7 +12,7 @@ class DrawerPage extends StatelessWidget {
final IndexController indexController = Get.find<IndexController>();
void _launchURL(url) async {
if (!await launch(url)) throw 'Could not launch $url';
if (!await launchUrl(url)) throw 'Could not launch $url';
}
@override
@ -115,8 +115,8 @@ class DrawerPage extends StatelessWidget {
leading: const Icon(Icons.delete_forever),
title: Text("delete_account".tr),
onTap: () {
String _token = indexController.currentUser[0]['token'];
AuthService.deleteUser(_token).then((value) {
String token = indexController.currentUser[0]['token'];
AuthService.deleteUser(token).then((value) {
if (value.isNotEmpty) {
indexController.logout();
Get.toNamed(AppPages.TRAVEL);

View File

@ -18,7 +18,7 @@ class _HistoryPageState extends State<HistoryPage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("通過履歴"),
title: const Text("通過履歴"),
),
body: SingleChildScrollView(
child: Column(
@ -32,37 +32,45 @@ class _HistoryPageState extends State<HistoryPage> {
return Center(
child: Text(
'${snapshot.error} occurred',
style: TextStyle(fontSize: 18),
style: const TextStyle(fontSize: 18),
),
);
} else if (snapshot.hasData) {
final dests = snapshot.data;
if (dests!.length > 0) {
print("----- history -----");
return Container(
if (dests!.isNotEmpty) {
//print("----- history -----");
return SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: ListView.builder(
itemCount: dests.length,
itemBuilder: (ctx, index) {
print("--- photo ${dests[index].checkin_image!} ----");
//print("--- photo ${dests[index].checkin_image!} ----");
return Padding(
padding: const EdgeInsets.all(8.0),
child: CustomWidget(title: dests[index].name!,
subtitle: "${dests[index].sub_loc_id} : ${dests[index].name}",
image1: dests[index].checkin_image != null ? Image.file(File(dests[index].checkin_image!)) : null,
image2: dests[index].buypoint_image != null ? Image.file(File(dests[index].buypoint_image!)) : null,
),
child: CustomWidget(
title: dests[index].name!,
subtitle:
"${dests[index].sub_loc_id} : ${dests[index].name}",
image1: dests[index].checkin_image != null
? Image.file(
File(dests[index].checkin_image!))
: null,
image2:
dests[index].buypoint_image != null
? Image.file(File(
dests[index].buypoint_image!))
: null,
),
);
}));
} else {
return Center(child: Text("No checkin yet"));
return const Center(child: Text("No checkin yet"));
}
}
} else if (snapshot.connectionState ==
ConnectionState.waiting) {
return Center(
return const Center(
child: CircularProgressIndicator(),
);
}
@ -81,7 +89,8 @@ class CustomWidget extends StatelessWidget {
final String title;
final String subtitle;
CustomWidget({
const CustomWidget({
super.key,
this.image1,
this.image2,
required this.title,
@ -93,30 +102,44 @@ class CustomWidget extends StatelessWidget {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: 104, // 50 (width of each image) + 2 (space between images) + 2*1 (padding on both sides)
SizedBox(
width:
104, // 50 (width of each image) + 2 (space between images) + 2*1 (padding on both sides)
child: Row(
children: [
if (image1 != null) SizedBox(width: 50, height: 100, child: image1,),
if (image1 != null && image2 != null) SizedBox(width: 2),
if (image2 != null) SizedBox(width: 50, height: 100, child: image2,),
if (image1 != null)
SizedBox(
width: 50,
height: 100,
child: image1,
),
if (image1 != null && image2 != null) const SizedBox(width: 2),
if (image2 != null)
SizedBox(
width: 50,
height: 100,
child: image2,
),
],
),
),
SizedBox(width: 10),
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
maxLines: null, // Allows the text to wrap onto an unlimited number of lines
style:
const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
maxLines:
null, // Allows the text to wrap onto an unlimited number of lines
),
Text(
subtitle,
style: TextStyle(fontSize: 16),
maxLines: null, // Allows the text to wrap onto an unlimited number of lines
style: const TextStyle(fontSize: 16),
maxLines:
null, // Allows the text to wrap onto an unlimited number of lines
),
],
),

View File

@ -1,10 +1,11 @@
import 'package:get/get.dart';
import 'package:rogapp/pages/destination/destination_controller.dart';
import 'package:rogapp/pages/index/index_controller.dart';
class IndexBinding extends Bindings {
@override
void dependencies() {
Get.put<IndexController>(IndexController());
Get.put<DestinationController>(DestinationController());
}
}

View File

@ -40,31 +40,30 @@ class IndexController extends GetxController {
List<PointLatLng> routePoints = <PointLatLng>[].obs;
var routePointLenght = 0.obs;
double current_lat = 0.0, current_lon = 0.0;
double currentLat = 0.0, currentLon = 0.0;
var is_loading = false.obs;
var isLoading = false.obs;
var is_mapController_loaded = false.obs;
var is_rog_mapcontroller_loaded = false.obs;
var isRogMapcontrollerLoaded = false.obs;
var is_custom_area_selected = false.obs;
var isCustomAreaSelected = false.obs;
MapController mapController = MapController();
MapController rogMapController = MapController();
String? userToken;
// mode = 0 is map mode, mode = 1 list mode
var mode = 0.obs;
// master mode, rog or selection
var rog_mode = 1.obs;
var rogMode = 1.obs;
var desination_mode = 1.obs;
var desinationMode = 1.obs;
bool showPopup = true;
String dropdownValue = "9";
String dropdownValue = "9";
String subDropdownValue = "-1";
String areaDropdownValue = "-1";
String cateogory = "-all-";
@ -76,133 +75,134 @@ class IndexController extends GetxController {
final Connectivity _connectivity = Connectivity();
late StreamSubscription<ConnectivityResult> _connectivitySubscription;
void toggleMode(){
if(mode.value==0){
void toggleMode() {
if (mode.value == 0) {
mode += 1;
}
else{
} else {
mode -= 1;
}
}
void toggleDestinationMode(){
if(desination_mode.value==0){
desination_mode.value += 1;
}
else{
desination_mode.value -= 1;
void toggleDestinationMode() {
if (desinationMode.value == 0) {
desinationMode.value += 1;
} else {
desinationMode.value -= 1;
}
}
void switchPage(String page){
//print("######## ${currentUser[0]["user"]["id"]}");
void switchPage(String page) {
////print("######## ${currentUser[0]["user"]["id"]}");
switch (page) {
case AppPages.INITIAL :{
rog_mode.value = 0;
print("-- rog mode is ctrl is ${rog_mode.value}");
Get.toNamed(page);
}
case AppPages.INITIAL:
{
rogMode.value = 0;
//print("-- rog mode is ctrl is ${rog_mode.value}");
Get.toNamed(page);
}
break;
case AppPages.TRAVEL : {
rog_mode.value = 1;
//Get.back();
Get.off(DestnationPage(), binding: DestinationBinding());
}
break;
case AppPages.LOGIN :{
rog_mode.value = 2;
Get.toNamed(page);
}
break;
default:{
rog_mode.value = 0;
Get.toNamed(AppPages.INITIAL);
}
case AppPages.TRAVEL:
{
rogMode.value = 1;
//Get.back();
//Get.off(DestnationPage(), binding: DestinationBinding());
}
break;
case AppPages.LOGIN:
{
rogMode.value = 2;
Get.toNamed(page);
}
break;
default:
{
rogMode.value = 0;
Get.toNamed(AppPages.INITIAL);
}
}
}
@override
void onInit() {
_ever = ever(rog_mode, (_) => print("$_ has been changed (ever)"));
//_ever = ever(rogMode, (_) => print("$_ has been changed (ever)"));
if(perfectures.isEmpty){
PerfectureService.loadPerfectures().then((value){
perfectures.add(value);
loadAreaFor("9");
//loadSubPerfFor("9");
});
}
// if (perfectures.isEmpty) {
// PerfectureService.loadPerfectures().then((value) {
// perfectures.add(value);
// loadAreaFor("9");
_connectivitySubscription = _connectivity.onConnectivityChanged.listen(_updateConnectionStatus);
// //loadSubPerfFor("9");
// });
// }
_connectivitySubscription =
_connectivity.onConnectivityChanged.listen(_updateConnectionStatus);
super.onInit();
}
}
@override
void onClose() {
@override
void onClose() {
_connectivitySubscription.cancel();
super.onClose();
}
}
Future<void> _updateConnectionStatus(ConnectivityResult result) async {
connectionStatus = result;
connectionStatusName.value = result.name;
}
Future<void> _updateConnectionStatus(ConnectivityResult result) async {
connectionStatus = result;
connectionStatusName.value = result.name;
}
Future<void> initConnectivity() async {
Future<void> initConnectivity() async {
late ConnectivityResult result;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
result = await _connectivity.checkConnectivity();
} on PlatformException catch (e) {
print('Couldn\'t check connectivity status --- $e');
} on PlatformException catch (_) {
//print('Couldn\'t check connectivity status --- $e');
return;
}
return _updateConnectionStatus(result);
}
LatLngBounds boundsFromLatLngList(List<LatLng> list) {
double? x0, x1, y0, y1;
for (LatLng latLng in list) {
if (x0 == null || x1 == null || y0 == null || y1 == null) {
x0 = x1 = latLng.latitude;
y0 = y1 = latLng.longitude;
} else {
if (latLng.latitude > x1) x1 = latLng.latitude;
if (latLng.latitude < x0) x0 = latLng.latitude;
if (latLng.longitude > y1) y1 = latLng.longitude;
if (latLng.longitude < y0) y0 = latLng.longitude;
LatLngBounds boundsFromLatLngList(List<LatLng> list) {
double? x0, x1, y0, y1;
for (LatLng latLng in list) {
if (x0 == null || x1 == null || y0 == null || y1 == null) {
x0 = x1 = latLng.latitude;
y0 = y1 = latLng.longitude;
} else {
if (latLng.latitude > x1) x1 = latLng.latitude;
if (latLng.latitude < x0) x0 = latLng.latitude;
if (latLng.longitude > y1) y1 = latLng.longitude;
if (latLng.longitude < y0) y0 = latLng.longitude;
}
}
return LatLngBounds(LatLng(x1!, y1!), LatLng(x0!, y0!));
}
return LatLngBounds(LatLng(x1!, y1!), LatLng(x0!, y0!));
}
List<LatLng> getLocationsList() {
List<LatLng> locs = [];
for (int i = 0; i <= locations[0].collection.length - 1; i++) {
GeoJsonMultiPoint p =
locations[0].collection[i].geometry as GeoJsonMultiPoint;
List<LatLng> getLocationsList(){
List<LatLng> locs = [];
for(int i=0; i<= locations[0].collection.length - 1; i++){
GeoJsonMultiPoint p = locations[0].collection[i].geometry as GeoJsonMultiPoint;
LatLng latLng = LatLng(p.geoSerie!.geoPoints[0].latitude, p.geoSerie!.geoPoints[0].longitude);
locs.add(latLng);
LatLng latLng = LatLng(p.geoSerie!.geoPoints[0].latitude,
p.geoSerie!.geoPoints[0].longitude);
locs.add(latLng);
}
return locs;
}
return locs;
}
void login(String email, String password, BuildContext context) {
AuthService.login(email, password).then((value) {
print("------- logged in user details ######## $value ###### --------");
//print("------- logged in user details ######## $value ###### --------");
if (value.isNotEmpty) {
Navigator.pop(context);
print("--------- user details login ----- $value");
//print("--------- user details login ----- $value");
changeUser(value);
} else {
is_loading.value = false;
isLoading.value = false;
Get.snackbar(
"Failed",
"User login failed, please try again.",
@ -216,502 +216,182 @@ List<LatLng> getLocationsList(){
});
}
void changePassword(String oldpassword, String newpassword, BuildContext context){
String _token = currentUser[0]['token'];
//print("------- change password ######## ${currentUser[0]['token']} ###### --------");
AuthService.changePassword(oldpassword, newpassword, _token).then((value){
print("------- change password ######## $value ###### --------");
if(value.isNotEmpty){
is_loading.value = false;
void changePassword(
String oldpassword, String newpassword, BuildContext context) {
String token = currentUser[0]['token'];
////print("------- change password ######## ${currentUser[0]['token']} ###### --------");
AuthService.changePassword(oldpassword, newpassword, token).then((value) {
////print("------- change password ######## $value ###### --------");
if (value.isNotEmpty) {
isLoading.value = false;
Navigator.pop(context);
if(rog_mode.value == 1){
if (rogMode.value == 1) {
switchPage(AppPages.TRAVEL);
}
else{
} else {
switchPage(AppPages.INITIAL);
}
}else{
} else {
Get.snackbar(
'failed'.tr,
'password_change_failed_please_try_again'.tr,
icon: const Icon(Icons.error, size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: const Duration(milliseconds: 800),
backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
}
});
is_loading.value = false;
}
'failed'.tr,
'password_change_failed_please_try_again'.tr,
icon: const Icon(Icons.error, size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: const Duration(milliseconds: 800),
backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
}
});
isLoading.value = false;
}
void logout() async{
void logout() async {
locations.clear();
DatabaseHelper db = DatabaseHelper.instance;
db.deleteAllDestinations().then((value){
DestinationController destinationController = Get.find<DestinationController>();
destinationController.PopulateDestinations();
db.deleteAllDestinations().then((value) {
DestinationController destinationController =
Get.find<DestinationController>();
destinationController.populateDestinations();
});
currentUser.clear();
cats.clear();
}
}
void register(String email, String password, BuildContext context){
AuthService.register(email, password).then((value){
if(value.isNotEmpty){
void register(String email, String password, BuildContext context) {
AuthService.register(email, password).then((value) {
if (value.isNotEmpty) {
currentUser.clear();
currentUser.add(value);
is_loading.value = false;
isLoading.value = false;
Navigator.pop(context);
loadUserDetails();
Get.toNamed(AppPages.INITIAL);
}else{
is_loading.value = false;
Get.snackbar(
'failed'.tr,
'user_registration_failed_please_try_again'.tr,
icon: const Icon(Icons.error, size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: const Duration(milliseconds: 800),
backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
}
});
}
void makeAction(BuildContext context){
int userId = currentUser[0]["user"]["id"] as int;
int locationId = currentFeature[0].properties!["location_id"] as int;
bool wanttogo = currentAction[0][0]["wanttogo"];
bool like = currentAction[0][0]["like"];
bool checkin = currentAction[0][0]["checkin"];
if(userId > 0){
ActionService.makeAction(userId, locationId, wanttogo, like, checkin).then((value){
});
}
}
String getCatText(){
String _cat = 'all'.tr;
if(currentUser.isNotEmpty){
Map<String, dynamic> _urs = currentUser[0];
print('-- is_rogaining :-- ${_urs['user']['is_rogaining']} ------');
if(_urs['user']['is_rogaining'] == true){
_cat = 'rogaining'.tr;
} else {
isLoading.value = false;
Get.snackbar(
'failed'.tr,
'user_registration_failed_please_try_again'.tr,
icon: const Icon(Icons.error, size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: const Duration(milliseconds: 800),
backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
}
else {
_cat = 'sight_seeing'.tr;
}
}
return _cat;
}
void loadCatsv2(){
dynamic initVal = {'category':getCatText()};
LatLngBounds bounds = mapController.bounds!;
if(bounds.southWest != null && bounds.northEast != null ){
CatService.loadCats(bounds.southWest!.latitude, bounds.southWest!.longitude, bounds.northWest.latitude, bounds.northWest.longitude, bounds.northEast!.latitude, bounds.northEast!.longitude, bounds.southEast.latitude, bounds.southEast.longitude).then((value) {
cats.clear();
cats.add(initVal);
for(dynamic cat in value!){
if(cat['category'] != null){
cats.add(cat!);
}
}
});
}
}
void loadCatForCity(String city){
dynamic initVal = {'category':getCatText()};
LatLngBounds bounds = mapController.bounds!;
if(bounds.southWest != null && bounds.northEast != null ){
CatService.loadCatByCity(city).then((value) {
cats.clear();
cats.add(initVal);
for(dynamic cat in value!){
if(cat['category'] != null){
cats.add(cat!);
}
}
});
}
}
void refreshLocationForCat(){
loadLocationsBound();
// if(subDropdownValue == "-1"){
// LocationService.loadLocationsFor(dropdownValue, currentCat[0]).then((value){
// locations.clear();
// locations.add(value!);
// is_loading.value = false;
// });
// print("loading main------");
// }
// else{
// LocationService.loadLocationsSubFor(subDropdownValue, currentCat[0]).then((value){
// locations.clear();
// locations.add(value!);
// is_loading.value = false;
// });
// print("loading sub------");
// }
}
void loadAreaFor(String perf){
areas.clear();
dynamic initVal = {'id':'-1', 'area_nm':'----'};
PerfectureService.loadGifuAreas(perf).then((value){
value!.add(initVal);
areas.add(value);
});
}
void loadUserDetails(){
if(currentUser.isNotEmpty){
int userId = currentUser[0]["user"]["id"] as int;
AuthService.UserDetails(userId).then((value){
print("--------- user details ----- $value");
if(value != null && value.isNotEmpty){
bool paid = value[0]["paid"] as bool;
if(paid){
loadCustomAreas();
}
}
});
}
}
void saveToDevice(String val) async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setString("user_token", val);
}
void changeUser(Map<String, dynamic> value, {bool replace = true}) {
print("---- change user to ${value} -----");
////print("---- change user to $value -----");
currentUser.clear();
currentUser.add(value);
if(replace){
if (replace) {
saveToDevice(currentUser[0]["token"]);
}
is_loading.value = false;
loadUserDetails();
isLoading.value = false;
loadLocationsBound();
cats.clear();
if (currentFeature.isNotEmpty) {
getAction();
}
if (currentUser.isNotEmpty) {
rog_mode.value = 0;
rogMode.value = 0;
} else {
rog_mode.value = 1;
rogMode.value = 1;
}
if (rog_mode.value == 1) {
switchPage(AppPages.TRAVEL);
} else {
switchPage(AppPages.INITIAL);
}
//Get.toNamed(AppPages.INITIAL);
Get.toNamed(AppPages.INITIAL);
}
loadUserDetailsForToken(String token) async {
AuthService.userForToken(token).then((value) {
print("----token val-- $value ------");
if(value![0]["user"].isEmpty){
Get.toNamed(AppPages.LOGIN);
return;
}
changeUser(value[0], replace:false);
print("--------- user details ----- $value");
// if (value != null && value.isNotEmpty) {
// bool paid = value[0]["paid"] as bool;
// if (paid) {
// loadCustomAreas();
// }
// }
});
}
void loadCustomAreas(){
customAreas.clear();
PerfectureService.loadCustomAreas().then((value){
print("--- loading custom areas $value");
customAreas.add(value);
});
}
void loadSubPerfFor(String perf){
subPerfs.clear();
dynamic initVal = {'id':'-1', 'adm2_ja':'----'};
PerfectureService.loadSubPerfectures(perf).then((value){
value!.add(initVal);
subPerfs.add(value);
subDropdownValue = getSubInitialVal();
});
}
String getSubInitialVal(){
int min = 0;
if(subPerfs.isNotEmpty){
min = int.parse(subPerfs[0][0]['id'].toString());
for(var sub in subPerfs[0]){
int x = int.parse(sub['id'].toString()); // as int;
if(x < min){
min = x;
}
AuthService.userForToken(token).then((value) {
////print("----token val-- $value ------");
if (value![0]["user"].isEmpty) {
Get.toNamed(AppPages.LOGIN);
return;
}
}
return min.toString();
}
void loadLocationforPerf(String perf, MapController mapController) async {
String cat = currentCat.isNotEmpty == true ? currentCat[0] : "";
print(currentCat);
// LocationService.loadLocationsFor(perf, cat).then((value){
// locations.clear();
// locations.add(value!);
// mapController.fitBounds(currentBound[0]);
// });
locations.clear();
mapController.fitBounds(currentBound[0]);
}
void loadLocationforSubPerf(String subperf, MapController mapController) async {
String cat = currentCat.isNotEmpty == true ? currentCat[0] : "";
if(currentCat.isNotEmpty && currentCat[0] == "-all-"){
cat = "";
}
LocationService.loadLocationsSubFor(subperf, cat).then((value){
locations.clear();
locations.add(value!);
changeUser(value[0], replace: false);
});
}
void loadCustomLocation(String customarea) async {
String cat = currentCat.isNotEmpty == true ? currentCat[0] : "";
if(currentCat.isNotEmpty && currentCat[0] == "-all-"){
cat = "";
}
print("----- $customarea");
LocationService.loadCustomLocations(customarea, cat).then((value){
locations.clear();
locations.add(value!);
List<LatLng> locs = getLocationsList();
LatLngBounds bounds = boundsFromLatLngList(locs);
mapController.fitBounds(bounds);
setBound(bounds);
Future.delayed(const Duration(microseconds: 400), () {
mapController.fitBounds(bounds);
});
});
}
void loadLocationsBound(){
if(is_custom_area_selected.value == true){
void loadLocationsBound() {
if (isCustomAreaSelected.value == true) {
return;
}
locations.clear();
String cat = currentCat.isNotEmpty ? currentCat[0] : "";
if(currentCat.isNotEmpty && currentCat[0] == "-all-"){
if (currentCat.isNotEmpty && currentCat[0] == "-all-") {
cat = "";
}
LatLngBounds bounds = mapController.bounds!;
currentBound.clear();
currentBound.add(bounds);
//print(currentCat);
if(bounds.southWest != null && bounds.northEast != null ){
LocationService.loadLocationsBound(bounds.southWest!.latitude, bounds.southWest!.longitude, bounds.northWest.latitude, bounds.northWest.longitude, bounds.northEast!.latitude, bounds.northEast!.longitude, bounds.southEast.latitude, bounds.southEast.longitude, cat).then((value){
//print("---value length ------ ${value!.collection.length}");
if(value == null){
////print(currentCat);
LocationService.loadLocationsBound(
bounds.southWest.latitude,
bounds.southWest.longitude,
bounds.northWest.latitude,
bounds.northWest.longitude,
bounds.northEast.latitude,
bounds.northEast.longitude,
bounds.southEast.latitude,
bounds.southEast.longitude,
cat)
.then((value) {
////print("---value length ------ ${value!.collection.length}");
if (value == null) {
return;
}
if(value.collection.isEmpty){
if(showPopup == false) {
if (value.collection.isEmpty) {
if (showPopup == false) {
return;
}
Get.snackbar(
"Too many Points",
"please zoom in",
icon: const Icon(Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: const Duration(milliseconds: 800),
backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
"Too many Points",
"please zoom in",
icon: const Icon(Icons.assistant_photo_outlined,
size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: const Duration(milliseconds: 800),
backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
showPopup = false;
//Get.showSnackbar(GetSnackBar(message: "Too many points, please zoom in",));
}
if(value.collection.isNotEmpty){
//print("---- added---");
locations.add(value);
loadCatsv2();
}
});
}
if (value.collection.isNotEmpty) {
////print("---- added---");
locations.add(value);
}
});
}
void setBound(LatLngBounds bounds){
void setBound(LatLngBounds bounds) {
currentBound.clear();
currentBound.add(bounds);
}
void zoomtoMainPerf(String id){
PerfectureService.getMainPerfExt(id).then((value){
void zoomtoSubPerf(String id) {
////print("zooooom");
PerfectureService.getSubExt(id).then((value) {
LatLng lat1 = LatLng(value![1], value[0]);
LatLng lat2 = LatLng(value[3], value[2]);
LatLngBounds bound = LatLngBounds(lat1, lat2);
mapController.fitBounds(bound);
setBound(bound);
});
}
void zoomtoSubPerf(String id){
print("zooooom");
PerfectureService.getSubExt(id).then((value){
LatLng lat1 = LatLng(value![1], value[0]);
LatLng lat2 = LatLng(value[3], value[2]);
LatLngBounds bound = LatLngBounds(lat1, lat2);
mapController.fitBounds(bound);
setBound(bound);
});
}
void populateForPerf(String perf, MapController mapController){
loadSubPerfFor(perf);
loadLocationforPerf(perf, mapController);
zoomtoMainPerf(perf);
is_loading.value = false;
}
void populateForSubPerf(String subperf, MapController mapController){
//subDropdownValue = subperf;
loadLocationforSubPerf(subperf, mapController);
zoomtoSubPerf(subperf);
is_loading.value = false;
}
void populateSubPerForArea(String area, MapController mapController){
loadSubPerfFor(area);
//loadCustomLocation("cus", mapController);
//zoomtoSubPerf(subperf);
is_loading.value = false;
}
GeoJsonFeature? getFeatureForLatLong(double lat, double long){
if(locations.isNotEmpty){
for(GeoJsonFeature i in locations[0].collection){
GeoJsonMultiPoint p = i.geometry as GeoJsonMultiPoint;
if(p.geoSerie!.geoPoints[0].latitude == lat && p.geoSerie!.geoPoints[0].longitude == long){
return i;
}
}
}
return null;
}
void getAction(){
//print(currentUser[0]["user"]["id"]);
//print(currentFeature[0].properties!["location_id"]);
if(currentUser.isEmpty){
return;
}
int userId = currentUser[0]["user"]["id"] as int;
print("---- loc id ${currentFeature[0].properties}");
int locationId = currentFeature[0].properties!["location_id"] as int;
ActionService.userAction(userId, locationId).then((value){
print("------$value");
if(value != null && value.isNotEmpty){
currentAction.clear();
currentAction.add(value);
print("------${currentAction[0]}");
}else{
List<dynamic> initval = [{"user": userId, "location": locationId, "wanttogo": false, "like": false, "checkin": false}];
currentAction.clear();
currentAction.add(initval);
}
});
}
void makeNext(GeoJsonFeature fs){
if(rog_mode == 1){
DestinationController destinationController = Get.find<DestinationController>();
}
else {
GeoJsonFeature<GeoJsonMultiPoint> pt = fs as GeoJsonFeature<GeoJsonMultiPoint>;
for(int i=0; i<= locations[0].collection.length - 1; i++){
GeoJsonMultiPoint p = locations[0].collection[i].geometry as GeoJsonMultiPoint;
if(p.geoSerie!.geoPoints[0].latitude == pt.geometry!.geoSerie!.geoPoints[0].latitude && p.geoSerie!.geoPoints[0].longitude == pt.geometry!.geoSerie!.geoPoints[0].longitude ){
if(currentFeature.isNotEmpty){
currentFeature.clear();
}
if(i >= locations[0].collection.length - 1 ){
currentFeature.add(locations[0].collection[0]);
getAction();
}
else{
currentFeature.add(locations[0].collection[i + 1]);
getAction();
}
}
}
}
}
void makePrevious(GeoJsonFeature fs){
if(rog_mode == 1){
DestinationController destinationController = Get.find<DestinationController>();
}
else {
GeoJsonFeature<GeoJsonMultiPoint> pt = fs as GeoJsonFeature<GeoJsonMultiPoint>;
for(int i=0; i<= locations[0].collection.length - 1; i++){
GeoJsonMultiPoint p = locations[0].collection[i].geometry as GeoJsonMultiPoint;
if(p.geoSerie!.geoPoints[0].latitude == pt.geometry!.geoSerie!.geoPoints[0].latitude && p.geoSerie!.geoPoints[0].longitude == pt.geometry!.geoSerie!.geoPoints[0].longitude ){
if(currentFeature.isNotEmpty){
currentFeature.clear();
}
if(i == 0 ){
currentFeature.add(locations[0].collection[locations[0].collection.length -1]);
getAction();
}
else{
currentFeature.add(locations[0].collection[i - 1]);
getAction();
}
GeoJsonFeature? getFeatureForLatLong(double lat, double long) {
if (locations.isNotEmpty) {
for (GeoJsonFeature i in locations[0].collection) {
GeoJsonMultiPoint p = i.geometry as GeoJsonMultiPoint;
if (p.geoSerie!.geoPoints[0].latitude == lat &&
p.geoSerie!.geoPoints[0].longitude == long) {
return i;
}
}
}
return null;
}
}
}

View File

@ -21,14 +21,6 @@ class IndexPage extends GetView<IndexController> {
child: Scaffold(
drawer: DrawerPage(),
appBar: AppBar(
// automaticallyImplyLeading: false,
// leading: IconButton(
// icon: Icon(Icons.arrow_back_ios),
// onPressed: (){
// indexController.switchPage(AppPages.TRAVEL);
// },
// ),
//automaticallyImplyLeading: false,
title: Text("add_location".tr),
actions: [
IconButton(
@ -63,124 +55,86 @@ class IndexPage extends GetView<IndexController> {
//CatWidget(indexController: indexController,),
],
),
bottomNavigationBar: BottomAppBar(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Obx(() =>
destinationController.is_in_rog.value == true ?
IconButton(onPressed: (){}, icon: Icon(Icons.run_circle, size: 44, color: Colors.green,))
:
IconButton(onPressed: (){}, icon: Icon(Icons.run_circle, size: 44, color: Colors.black12,)),
),
Padding(
padding:
const EdgeInsets.only(right: 10.0, top: 4.0, bottom: 4.0),
child: InkWell(
child:
Obx(() => destinationController.is_gps_selected == true
? Padding(
padding: const EdgeInsets.only(
right: 10.0, top: 4.0, bottom: 4.0),
child: InkWell(
child: const Image(
image: AssetImage(
'assets/images/route3_off.png'),
width: 35,
height: 35,
),
onTap: () {
//indexController.switchPage(AppPages.TRAVEL);
},
),
)
: Padding(
padding: const EdgeInsets.only(
right: 10.0, top: 4.0, bottom: 4.0),
child: InkWell(
child: const Image(
image: AssetImage(
'assets/images/route2_on.png'),
width: 35,
height: 35,
),
onTap: () {
//indexController.switchPage(AppPages.TRAVEL);
},
),
))),
),
],
),
),
// bottomNavigationBar: BottomAppBar(
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: <Widget>[
// Obx(
// () => destinationController.isInRog.value == true
// ? IconButton(
// onPressed: () {},
// icon: const Icon(
// Icons.run_circle,
// size: 44,
// color: Colors.green,
// ))
// : IconButton(
// onPressed: () {},
// icon: const Icon(
// Icons.run_circle,
// size: 44,
// color: Colors.black12,
// )),
// ),
// Padding(
// padding:
// const EdgeInsets.only(right: 10.0, top: 4.0, bottom: 4.0),
// child: InkWell(
// child: Obx(() => destinationController
// .isGpsSelected.value ==
// true
// ? Padding(
// padding: const EdgeInsets.only(
// right: 10.0, top: 4.0, bottom: 4.0),
// child: InkWell(
// child: const Image(
// image:
// AssetImage('assets/images/route3_off.png'),
// width: 35,
// height: 35,
// ),
// onTap: () {
// //indexController.switchPage(AppPages.TRAVEL);
// },
// ),
// )
// : Padding(
// padding: const EdgeInsets.only(
// right: 10.0, top: 4.0, bottom: 4.0),
// child: InkWell(
// child: const Image(
// image:
// AssetImage('assets/images/route2_on.png'),
// width: 35,
// height: 35,
// ),
// onTap: () {
// //indexController.switchPage(AppPages.TRAVEL);
// },
// ),
// ))),
// ),
// ],
// ),
// ),
floatingActionButton: FloatingActionButton(
onPressed: () {
indexController.toggleMode();
if (indexController.currentCat.isNotEmpty) {
print(indexController.currentCat[0].toString());
}
},
tooltip: 'Increment',
elevation: 1.0,
child: Obx(
() => indexController.mode == 0
() => indexController.mode.value == 0
? const Image(image: AssetImage('assets/images/list2.png'))
: const Image(image: AssetImage('assets/images/map.png')),
),
elevation: 4.0,
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
body: SafeArea(
child: Column(
children: [
// Container(
// padding: const EdgeInsets.symmetric(horizontal: 8.0),
// alignment: Alignment.centerLeft,
// height: 50.0,
// //child: SingleChildScrollView(
// // scrollDirection: Axis.horizontal,
// // child:Row(
// // mainAxisAlignment: MainAxisAlignment.start,
// // children: [
// // TextButton(child:Text("Main Pef >", style: TextStyle(fontSize:16.0, fontWeight: FontWeight.bold),), onPressed: (){Get.toNamed(AppPages.MAINPERF);},),
// // TextButton(child:Text("Sub Pef >", style: TextStyle(fontSize:16.0, fontWeight: FontWeight.bold),), onPressed: (){Get.toNamed(AppPages.SUBPERF);},),
// // TextButton(child:Text("Cities >", style: TextStyle(fontSize:16.0, fontWeight: FontWeight.bold),), onPressed: (){Get.toNamed(AppPages.CITY);},),
// // TextButton(child:Text("Categories", style: TextStyle(fontSize:16.0, fontWeight: FontWeight.bold),), onPressed: (){Get.toNamed(AppPages.CATEGORY);},),
// // ],
// // )
// // ),
// child: SingleChildScrollView(
// scrollDirection: Axis.horizontal,
// child: Obx(() =>
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// indexController.is_mapController_loaded.value == false ?
// Center(child: CircularProgressIndicator())
// :
// BreadCrumbWidget(mapController: indexController.mapController),
// Container(width: 24.0,),
// // Row(
// // children: [
// // indexController.currentCat.isNotEmpty ? Text(indexController.currentCat[0].toString()): Text(""),
// // indexController.currentCat.isNotEmpty ?
// // IconButton(
// // onPressed: (){
// // indexController.currentCat.clear();
// // indexController.loadLocationsBound();
// // },
// // icon: Icon(Icons.cancel, color: Colors.red,)
// // ) :
// // Container(width: 0, height: 0,)
// // ],
// // )
// ],
// )
// ),
// ),
// ),
Expanded(
child: Obx(
() => indexController.mode == 0
() => indexController.mode.value == 0
? MapWidget()
: const ListWidget(),
))

View File

@ -1,11 +1,9 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/routes/app_pages.dart';
class LoginPage extends StatelessWidget {
final IndexController indexController = Get.find<IndexController>();
TextEditingController emailController = TextEditingController();
@ -17,208 +15,248 @@ class LoginPage extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.white,
appBar: AppBar(
elevation: 0,
backgroundColor: Colors.white,
appBar: AppBar(
elevation: 0,
backgroundColor: Colors.white,
leading:
IconButton( onPressed: (){
Navigator.pop(context);
},icon:const Icon(Icons.arrow_back_ios,size: 20,color: Colors.black,)),
),
body:
indexController.currentUser.isEmpty ?
SizedBox(
width: double.infinity,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Column(
children: [
Column(
children: [
Container(
height: MediaQuery.of(context).size.height/6,
decoration: const BoxDecoration(
image:DecorationImage(image: AssetImage('assets/images/login_image.jpg'))
),
),
const SizedBox(height: 5,),
],
),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 40
),
child: Column(
leading: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: const Icon(
Icons.arrow_back_ios,
size: 20,
color: Colors.black,
)),
),
body: indexController.currentUser.isEmpty
? SizedBox(
width: double.infinity,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Column(
children: [
makeInput(label: "email".tr, controller: emailController),
makeInput(label: "password".tr, controller: passwordController, obsureText: true),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 40),
child: Container(
padding: const EdgeInsets.only(top: 3,left: 3),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40),
),
child: Obx((() =>
indexController.is_loading == true ? MaterialButton(
minWidth: double.infinity,
height:60,
onPressed: (){
},
color: Colors.grey[400],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40)
),
child: const CircularProgressIndicator(),
) :
Column(
children: [
MaterialButton(
minWidth: double.infinity,
height:40,
onPressed: (){
if(emailController.text.isEmpty || passwordController.text.isEmpty){
Get.snackbar(
"no_values".tr,
"email_and_password_required".tr,
icon: const Icon(Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: const Duration(milliseconds: 800),
backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
return;
}
indexController.is_loading.value = true;
indexController.login(emailController.text, passwordController.text, context);
},
color: Colors.indigoAccent[400],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40)
),
child: const Text("ログイン",style: TextStyle(
fontWeight: FontWeight.w600,fontSize: 16,color: Colors.white70
),
),
),
const SizedBox(height: 5.0,),
MaterialButton(
minWidth: double.infinity,
height:40,
onPressed: (){
Get.toNamed(AppPages.REGISTER);
},
color: Colors.redAccent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40)
),
child: Text("sign_up".tr,style: const TextStyle(
fontWeight: FontWeight.w600,fontSize: 16,color: Colors.white70
),
),
),
const SizedBox(height: 2.0,),
MaterialButton(
minWidth: double.infinity,
height:40,
onPressed: (){
Get.back();
},
color: Colors.grey,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40)
),
child: Text("cancel".tr,style: const TextStyle(
fontWeight: FontWeight.w600,fontSize: 16,color: Colors.white70
),
),
),
Container(
height: MediaQuery.of(context).size.height / 6,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(
'assets/images/login_image.jpg'))),
),
const SizedBox(
height: 5,
),
],
)
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 40),
child: Column(
children: [
makeInput(
label: "email".tr, controller: emailController),
makeInput(
label: "password".tr,
controller: passwordController,
obsureText: true),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 40),
child: Container(
padding: const EdgeInsets.only(top: 3, left: 3),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40),
),
child: Obx(
(() => indexController.isLoading.value == true
? MaterialButton(
minWidth: double.infinity,
height: 60,
onPressed: () {},
color: Colors.grey[400],
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(40)),
child: const CircularProgressIndicator(),
)
: Column(
children: [
MaterialButton(
minWidth: double.infinity,
height: 40,
onPressed: () {
if (emailController.text.isEmpty ||
passwordController
.text.isEmpty) {
Get.snackbar(
"no_values".tr,
"email_and_password_required"
.tr,
icon: const Icon(
Icons
.assistant_photo_outlined,
size: 40.0,
color: Colors.blue),
snackPosition:
SnackPosition.TOP,
duration: const Duration(
milliseconds: 800),
backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
return;
}
indexController.isLoading.value =
true;
indexController.login(
emailController.text,
passwordController.text,
context);
},
color: Colors.indigoAccent[400],
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(40)),
child: const Text(
"ログイン",
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
color: Colors.white70),
),
),
const SizedBox(
height: 5.0,
),
MaterialButton(
minWidth: double.infinity,
height: 40,
onPressed: () {
Get.toNamed(AppPages.REGISTER);
},
color: Colors.redAccent,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(40)),
child: Text(
"sign_up".tr,
style: const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
color: Colors.white70),
),
),
const SizedBox(
height: 2.0,
),
MaterialButton(
minWidth: double.infinity,
height: 40,
onPressed: () {
Get.back();
},
color: Colors.grey,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(40)),
child: Text(
"cancel".tr,
style: const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
color: Colors.white70),
),
),
],
)),
),
)),
const SizedBox(
height: 5,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flexible(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"rogaining_user_need_tosign_up".tr,
style: const TextStyle(
overflow: TextOverflow.ellipsis,
),
),
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flexible(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"app_developed_by_gifu_dx".tr,
style: const TextStyle(
overflow: TextOverflow.ellipsis,
fontSize: 10.0),
),
),
),
],
)
],
),
)
),
const SizedBox(height: 5,),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flexible(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text("rogaining_user_need_tosign_up".tr, style: const TextStyle(
overflow: TextOverflow.ellipsis,
),),
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flexible(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text("app_developed_by_gifu_dx".tr, style: const TextStyle(
overflow: TextOverflow.ellipsis, fontSize: 10.0
),),
),
),
],
)
],
],
),
)
: TextButton(
onPressed: () {
indexController.currentUser.clear();
},
child: const Text("Already Logged in, Click to logout"),
),
],
),
):
Container(
child: TextButton(
onPressed: (){
indexController.currentUser.clear();
},
child: const Text("Already Logged in, Click to logout"),
),
)
,
);
}
}
Widget makeInput({label, required TextEditingController controller, obsureText = false}){
Widget makeInput(
{label, required TextEditingController controller, obsureText = false}) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(label,style:const TextStyle(
fontSize: 15,
fontWeight: FontWeight.w400,
color: Colors.black87
),),
const SizedBox(height: 5,),
Text(
label,
style: const TextStyle(
fontSize: 15, fontWeight: FontWeight.w400, color: Colors.black87),
),
const SizedBox(
height: 5,
),
TextField(
controller: controller,
obscureText: obsureText,
decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric(vertical: 0,horizontal: 10),
contentPadding:
const EdgeInsets.symmetric(vertical: 0, horizontal: 10),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: (Colors.grey[400])!,
),
),
border: OutlineInputBorder(
borderSide: BorderSide(color: (Colors.grey[400])!
borderSide: BorderSide(color: (Colors.grey[400])!),
),
),
),
),
const SizedBox(height: 30.0,)
const SizedBox(
height: 30.0,
)
],
);
}

View File

@ -15,195 +15,232 @@ class LoginPopupPage extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.white,
appBar: AppBar(
elevation: 0,
backgroundColor: Colors.white,
appBar: AppBar(
elevation: 0,
backgroundColor: Colors.white,
leading:
IconButton( onPressed: (){
Navigator.pop(context);
},icon:const Icon(Icons.arrow_back_ios,size: 20,color: Colors.black,)),
),
body:
indexController.currentUser.isEmpty ?
SizedBox(
width: double.infinity,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Column(
children: [
Column(
children: [
Container(
height: MediaQuery.of(context).size.height/5,
decoration: const BoxDecoration(
image:DecorationImage(image: AssetImage('assets/images/login_image.jpg'))
),
),
const SizedBox(height: 5,),
],
),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 40
),
child: Column(
leading: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: const Icon(
Icons.arrow_back_ios,
size: 20,
color: Colors.black,
)),
),
body: indexController.currentUser.isEmpty
? SizedBox(
width: double.infinity,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Column(
children: [
makeInput(label: "email".tr, controller: emailController),
makeInput(label: "password".tr, controller: passwordController, obsureText: true),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 40),
child: Container(
padding: const EdgeInsets.only(top: 3,left: 3),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40),
),
child: Obx((() =>
indexController.is_loading == true ? MaterialButton(
minWidth: double.infinity,
height:60,
onPressed: (){
},
color: Colors.grey[400],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40)
),
child: const CircularProgressIndicator(),
) :
Column(
children: [
MaterialButton(
minWidth: double.infinity,
height:60,
onPressed: (){
if(emailController.text.isEmpty || passwordController.text.isEmpty){
Get.snackbar(
"no_values".tr,
"email_and_password_required".tr,
icon: const Icon(Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: const Duration(milliseconds: 800),
backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
return;
}
indexController.is_loading.value = true;
indexController.login(emailController.text, passwordController.text, context);
},
color: Colors.indigoAccent[400],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40)
),
child: const Text("ログイン",style: TextStyle(
fontWeight: FontWeight.w600,fontSize: 16,color: Colors.white70
),
),
),
const SizedBox(height: 19.0,),
MaterialButton(
minWidth: double.infinity,
height:50,
onPressed: (){
Get.toNamed(AppPages.REGISTER);
},
color: Colors.redAccent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40)
),
child: Text("sign_up".tr,style: const TextStyle(
fontWeight: FontWeight.w600,fontSize: 16,color: Colors.white70
),
),
),
const SizedBox(height: 19.0,),
MaterialButton(
minWidth: double.infinity,
height:50,
onPressed: (){
Get.toNamed(AppPages.TRAVEL);
},
color: Colors.grey,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40)
),
child: Text("cancel".tr,style: const TextStyle(
fontWeight: FontWeight.w600,fontSize: 16,color: Colors.white70
),
),
)
Container(
height: MediaQuery.of(context).size.height / 5,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(
'assets/images/login_image.jpg'))),
),
const SizedBox(
height: 5,
),
],
)
),
),
)
),
const SizedBox(height: 20,),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flexible(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text("rogaining_user_need_tosign_up".tr, style: const TextStyle(
overflow: TextOverflow.ellipsis,
),),
),
),
],
)
],
Padding(
padding: const EdgeInsets.symmetric(horizontal: 40),
child: Column(
children: [
makeInput(
label: "email".tr, controller: emailController),
makeInput(
label: "password".tr,
controller: passwordController,
obsureText: true),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 40),
child: Container(
padding: const EdgeInsets.only(top: 3, left: 3),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40),
),
child: Obx(
(() => indexController.isLoading.value == true
? MaterialButton(
minWidth: double.infinity,
height: 60,
onPressed: () {},
color: Colors.grey[400],
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(40)),
child: const CircularProgressIndicator(),
)
: Column(
children: [
MaterialButton(
minWidth: double.infinity,
height: 60,
onPressed: () {
if (emailController.text.isEmpty ||
passwordController
.text.isEmpty) {
Get.snackbar(
"no_values".tr,
"email_and_password_required"
.tr,
icon: const Icon(
Icons
.assistant_photo_outlined,
size: 40.0,
color: Colors.blue),
snackPosition:
SnackPosition.TOP,
duration: const Duration(
milliseconds: 800),
backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
return;
}
indexController.isLoading.value =
true;
indexController.login(
emailController.text,
passwordController.text,
context);
},
color: Colors.indigoAccent[400],
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(40)),
child: const Text(
"ログイン",
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
color: Colors.white70),
),
),
const SizedBox(
height: 19.0,
),
MaterialButton(
minWidth: double.infinity,
height: 50,
onPressed: () {
Get.toNamed(AppPages.REGISTER);
},
color: Colors.redAccent,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(40)),
child: Text(
"sign_up".tr,
style: const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
color: Colors.white70),
),
),
const SizedBox(
height: 19.0,
),
MaterialButton(
minWidth: double.infinity,
height: 50,
onPressed: () {
Get.toNamed(AppPages.TRAVEL);
},
color: Colors.grey,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(40)),
child: Text(
"cancel".tr,
style: const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
color: Colors.white70),
),
)
],
)),
),
)),
const SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flexible(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"rogaining_user_need_tosign_up".tr,
style: const TextStyle(
overflow: TextOverflow.ellipsis,
),
),
),
),
],
)
],
),
],
),
)
: TextButton(
onPressed: () {
indexController.currentUser.clear();
},
child: const Text("Already Logged in, Click to logout"),
),
],
),
):
Container(
child: TextButton(
onPressed: (){
indexController.currentUser.clear();
},
child: const Text("Already Logged in, Click to logout"),
),
)
,
);
}
}
Widget makeInput({label, required TextEditingController controller, obsureText = false}){
Widget makeInput(
{label, required TextEditingController controller, obsureText = false}) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(label,style:const TextStyle(
fontSize: 15,
fontWeight: FontWeight.w400,
color: Colors.black87
),),
const SizedBox(height: 5,),
Text(
label,
style: const TextStyle(
fontSize: 15, fontWeight: FontWeight.w400, color: Colors.black87),
),
const SizedBox(
height: 5,
),
TextField(
controller: controller,
obscureText: obsureText,
decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric(vertical: 0,horizontal: 10),
contentPadding:
const EdgeInsets.symmetric(vertical: 0, horizontal: 10),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: (Colors.grey[400])!,
),
),
border: OutlineInputBorder(
borderSide: BorderSide(color: (Colors.grey[400])!
borderSide: BorderSide(color: (Colors.grey[400])!),
),
),
),
),
const SizedBox(height: 30.0,)
const SizedBox(
height: 30.0,
)
],
);
}

View File

@ -1,31 +1,31 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:rogapp/pages/index/index_controller.dart';
// import 'package:flutter/material.dart';
// import 'package:get/get.dart';
// import 'package:rogapp/pages/index/index_controller.dart';
class MainPerfPage extends StatelessWidget {
MainPerfPage({Key? key}) : super(key: key);
// class MainPerfPage extends StatelessWidget {
// MainPerfPage({Key? key}) : super(key: key);
IndexController indexController = Get.find<IndexController>();
// IndexController indexController = Get.find<IndexController>();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Select Main Perfecture"),
),
body: ListView.builder(
itemCount: indexController.perfectures.length,
itemBuilder: (context, index){
return ListTile(
onTap: (){
indexController.dropdownValue = indexController.perfectures[index][0]["id"].toString();
indexController.populateForPerf(indexController.dropdownValue, indexController.mapController);
Get.back();
},
title: Text(indexController.perfectures[index][0]["adm1_ja"].toString()),
);
},
),
);
}
}
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// appBar: AppBar(
// title: const Text("Select Main Perfecture"),
// ),
// body: ListView.builder(
// itemCount: indexController.perfectures.length,
// itemBuilder: (context, index){
// return ListTile(
// onTap: (){
// indexController.dropdownValue = indexController.perfectures[index][0]["id"].toString();
// indexController.populateForPerf(indexController.dropdownValue, indexController.mapController);
// Get.back();
// },
// title: Text(indexController.perfectures[index][0]["adm1_ja"].toString()),
// );
// },
// ),
// );
// }
// }

View File

@ -8,206 +8,118 @@ class PermissionHandlerScreen extends StatefulWidget {
const PermissionHandlerScreen({Key? key}) : super(key: key);
@override
State<PermissionHandlerScreen> createState() => _PermissionHandlerScreenState();
State<PermissionHandlerScreen> createState() =>
_PermissionHandlerScreenState();
}
class _PermissionHandlerScreenState extends State<PermissionHandlerScreen> {
Future<void> _showMyDialog() async {
return showDialog<void>(
context: context,
barrierDismissible: false, // user must tap button!
builder: (BuildContext context) {
return AlertDialog(
title: const Text('ロケーション許可'),
content: const SingleChildScrollView(
child: ListBody(
children: <Widget>[
Text( 'このアプリでは、位置情報の収集を行います。'),
Text( 'このアプリでは、開始時点で位置情報を収集します。'),
],
),
),
actions: <Widget>[
TextButton(
child: const Text('わかった'),
onPressed: () {
//Navigator.of(context).pop();
Get.toNamed(AppPages.TRAVEL);
},
),
],
);
},
);
}
@override
void initState() {
// TODO: implement initState
super.initState();
//permissionServiceCall();
WidgetsBinding.instance.addPostFrameCallback((_) {
_checkPermissionStatus();
});
}
Future<PermissionStatus> checkLocationPermission() async {
return await Permission.location.status;
}
_checkPermissionStatus() async {
PermissionStatus status = await Permission.location.status;
permissionServiceCall() async {
await permissionServices().then(
(value) {
if (value[Permission.location]!.isGranted ) {
/* ========= New Screen Added ============= */
Get.toNamed(AppPages.TRAVEL);
// Navigator.pushReplacement(
// context,
// MaterialPageRoute(builder: (context) => SplashScreen()),
// );
}
else{
_showMyDialog();
}
},
);
}
/*Permission services*/
Future<Map<Permission, PermissionStatus>> permissionServices() async {
// You can request multiple permissions at once.
Map<Permission, PermissionStatus> statuses = await [
Permission.location,
//add more permission to request here.
].request();
if (statuses[Permission.location]!.isPermanentlyDenied) {
await openAppSettings().then(
(value) async {
if (value) {
if (await Permission.location.status.isPermanentlyDenied == true &&
await Permission.location.status.isGranted == false) {
// openAppSettings();
permissionServiceCall(); /* opens app settings until permission is granted */
}
}
},
);
if (status.isGranted == false) {
if (context.mounted) {
showAlert(context);
}
} else if (status.isPermanentlyDenied) {
await requestPermission();
} else {
if (statuses[Permission.location]!.isDenied) {
permissionServiceCall();
if (mounted) {
Get.toNamed(AppPages.LOGIN);
}
}
/*{Permission.camera: PermissionStatus.granted, Permission.storage: PermissionStatus.granted}*/
return statuses;
}
requestPermission() async {
PermissionStatus permission = await Permission.location.status;
if(permission == PermissionStatus.permanentlyDenied){
showPermanentAlert(context);
}else{
PermissionStatus newPermission = await Permission.location.request();
//showAlert(context);
if (newPermission != PermissionStatus.granted) {
// If permission not granted, handle the issue in your own way
exit(0);
}
else{
Get.toNamed(AppPages.TRAVEL);
}
void showAlert(BuildContext context) {
showDialog(
context: context,
builder: (_) => AlertDialog(
title: const Text('ロケーション許可'),
content: const SingleChildScrollView(
child: ListBody(
children: <Widget>[
Text('このアプリでは、位置情報の収集を行います。'),
Text(
'岐阜ナビアプリではチェックポイントの自動チェックインの機能を可能にするために、現在地のデータが収集されます。アプリを閉じている時や、使用していないときにも収集されます。位置情報は、個人を特定できない統計的な情報として、ユーザーの個人情報とは一切結びつかない形で送信されます。お知らせの配信、位置情報の利用を許可しない場合は、この後表示されるダイアログで「許可しない」を選択してください。'),
],
),
),
actions: <Widget>[
ElevatedButton(
child: const Text('OK'),
onPressed: () {
Get.back();
requestPermission();
},
),
],
));
}
// if (permission != PermissionStatus.granted) {
// }
// If permission is granted or already was granted
return true;
}
Future<void> requestPermission() async {
PermissionStatus permission = await Permission.location.status;
if (permission == PermissionStatus.permanentlyDenied) {
showPermanentAlert();
} else {
PermissionStatus newPermission = await Permission.location.request();
if (newPermission != PermissionStatus.granted) {
exit(0);
} else {
if (context.mounted) {
Get.toNamed(AppPages.LOGIN);
}
}
}
}
@override
Widget build(BuildContext context) {
var status = Permission.location.status.then((value){
if(value.isGranted == false){
showAlert(context);
//requestPermission() ? Get.toNamed(AppPages.TRAVEL) : exit(0);
//Future.delayed(Duration.zero, () => showAlert(context));
}
else if(value.isPermanentlyDenied){
}
else {
Get.toNamed(AppPages.TRAVEL);
}
});
return Scaffold(
body: Container(
child: const Text(""),
),
);
}
void showPermanentAlert(BuildContext context) {
showDialog(
context: context,
builder: (_) => AlertDialog(
title: const Text('無効'),
content: const SingleChildScrollView(
child: ListBody(
children: <Widget>[
Text( '位置情報が無効になっています'),
Text('このアプリケーションへの位置情報アクセスが無効になっています。続行するには設定>プライバシーとセキュリティ>位置情報サービス>岐阜ナビ で有効にしてください。'),
],
),
),
actions: <Widget>[
ElevatedButton(
child: const Text('OK'),
onPressed: () {
//requestPermission();
permissionServiceCall();
},
),
],
)
return const Scaffold(
body: Text(""),
);
}
void showAlert(BuildContext context) {
showDialog(
context: context,
builder: (_) => AlertDialog(
title: const Text('ロケーション許可'),
content: const SingleChildScrollView(
child: ListBody(
children: <Widget>[
Text( 'このアプリでは、位置情報の収集を行います。'),
Text('岐阜ナビアプリではチェックポイントの自動チェックインの機能を可能にするために、現在地のデータが収集されます。アプリを閉じている時や、使用していないときにも収集されます。位置情報は、個人を特定できない統計的な情報として、ユーザーの個人情報とは一切結びつかない形で送信されます。お知らせの配信、位置情報の利用を許可しない場合は、この後表示されるダイアログで「許可しない」を選択してください。'),
void showPermanentAlert() {
showDialog(
context: context,
builder: (_) => AlertDialog(
title: const Text('無効'),
content: const SingleChildScrollView(
child: ListBody(
children: <Widget>[
Text('位置情報が無効になっています'),
Text(
'このアプリケーションへの位置情報アクセスが無効になっています。続行するには設定>プライバシーとセキュリティ>位置情報サービス>岐阜ナビ で有効にしてください。'),
],
),
),
actions: <Widget>[
ElevatedButton(
child: const Text('OK'),
onPressed: () async {
await openAppSettings().then(
(value) async {
if (value) {
if (await Permission
.location.status.isPermanentlyDenied ==
true &&
await Permission.location.status.isGranted ==
false) {
requestPermission(); /* opens app settings until permission is granted */
}
}
},
);
},
),
],
),
),
actions: <Widget>[
ElevatedButton(
child: const Text('OK'),
onPressed: () {
requestPermission();
//permissionServiceCall();
},
),
],
)
);
));
}
}
}

View File

@ -1,12 +1,9 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/routes/app_pages.dart';
class RegisterPage extends StatelessWidget {
final IndexController indexController = Get.find<IndexController>();
TextEditingController emailController = TextEditingController();
@ -23,10 +20,15 @@ class RegisterPage extends StatelessWidget {
appBar: AppBar(
elevation: 0,
backgroundColor: Colors.white,
leading:
IconButton( onPressed: (){
Navigator.pop(context);
},icon:const Icon(Icons.arrow_back_ios,size: 20,color: Colors.black,)),
leading: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: const Icon(
Icons.arrow_back_ios,
size: 20,
color: Colors.black,
)),
),
body: SafeArea(
child: SingleChildScrollView(
@ -41,63 +43,79 @@ class RegisterPage extends StatelessWidget {
Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
const Text ("サインアップ", style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.bold,
),),
const SizedBox(height: 20,),
Text("アカウントを作成し、無料です",style: TextStyle(
fontSize: 15,
color: Colors.grey[700],
),),
const SizedBox(height: 30,)
const Text(
"サインアップ",
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.bold,
),
),
const SizedBox(
height: 20,
),
Text(
"アカウントを作成し、無料です",
style: TextStyle(
fontSize: 15,
color: Colors.grey[700],
),
),
const SizedBox(
height: 30,
)
],
),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 40
),
padding: const EdgeInsets.symmetric(horizontal: 40),
child: Column(
children: [
makeInput(label: "Eメール", controller: emailController),
makeInput(label: "パスワード", controller: passwordController,obsureText: true),
makeInput(label: "パスワードを認証する", controller: confirmPasswordController,obsureText: true)
makeInput(
label: "パスワード",
controller: passwordController,
obsureText: true),
makeInput(
label: "パスワードを認証する",
controller: confirmPasswordController,
obsureText: true)
],
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 40),
child: Container(
padding: const EdgeInsets.only(top: 3,left: 3),
padding: const EdgeInsets.only(top: 3, left: 3),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40),
border: const Border(
bottom: BorderSide(color: Colors.black),
top: BorderSide(color: Colors.black),
right: BorderSide(color: Colors.black),
left: BorderSide(color: Colors.black)
)
),
left: BorderSide(color: Colors.black))),
child: MaterialButton(
minWidth: double.infinity,
height:60,
onPressed: (){
if(passwordController.text != confirmPasswordController.text){
height: 60,
onPressed: () {
if (passwordController.text !=
confirmPasswordController.text) {
Get.snackbar(
"No match",
"Passwords does not match",
icon: const Icon(Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue),
"Passwords does not match",
icon: const Icon(Icons.assistant_photo_outlined,
size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: const Duration(milliseconds: 800),
backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
}
if(emailController.text.isEmpty || passwordController.text.isEmpty){
if (emailController.text.isEmpty ||
passwordController.text.isEmpty) {
Get.snackbar(
"no_values".tr,
"email_and_password_required".tr,
icon: const Icon(Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue),
"email_and_password_required".tr,
icon: const Icon(Icons.assistant_photo_outlined,
size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: const Duration(milliseconds: 800),
backgroundColor: Colors.yellow,
@ -105,38 +123,43 @@ class RegisterPage extends StatelessWidget {
);
return;
}
indexController.is_loading.value = true;
indexController.register(emailController.text, passwordController.text, context);
indexController.isLoading.value = true;
indexController.register(emailController.text,
passwordController.text, context);
},
color: Colors.redAccent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40)
borderRadius: BorderRadius.circular(40)),
child: Text(
"sign_up".tr,
style: const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
),
),
child: Text("sign_up".tr,style: const TextStyle(
fontWeight: FontWeight.w600,fontSize: 16,
),),
),
),
),
const SizedBox(height: 20,),
const SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Flexible(child: Text("すでにアカウントをお持ちですか?")),
TextButton(
onPressed: (){
onPressed: () {
Get.toNamed(AppPages.LOGIN);
},
child: const Text("ログイン",style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 18
),),
child: const Text(
"ログイン",
style: TextStyle(
fontWeight: FontWeight.w600, fontSize: 18),
),
),
],
)
],
),
],
),
@ -147,34 +170,38 @@ class RegisterPage extends StatelessWidget {
}
}
Widget makeInput({label, required TextEditingController controller, obsureText = false}){
Widget makeInput(
{label, required TextEditingController controller, obsureText = false}) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(label,style:const TextStyle(
fontSize: 15,
fontWeight: FontWeight.w400,
color: Colors.black87
),),
const SizedBox(height: 5,),
Text(
label,
style: const TextStyle(
fontSize: 15, fontWeight: FontWeight.w400, color: Colors.black87),
),
const SizedBox(
height: 5,
),
TextField(
controller: controller,
obscureText: obsureText,
decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric(vertical: 0,horizontal: 10),
contentPadding:
const EdgeInsets.symmetric(vertical: 0, horizontal: 10),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: (Colors.grey[400])!,
),
),
border: OutlineInputBorder(
borderSide: BorderSide(color: (Colors.grey[400])!
borderSide: BorderSide(color: (Colors.grey[400])!),
),
),
),
),
const SizedBox(height: 30,)
const SizedBox(
height: 30,
)
],
);
}