Files
rog_app/lib/widgets/bottom_sheet_widget.dart

380 lines
16 KiB
Dart
Raw Normal View History

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