2022-03-24 14:20:04 +05:30
|
|
|
import 'package:flutter/material.dart';
|
2022-04-17 11:45:21 +05:30
|
|
|
import 'package:flutter_map/flutter_map.dart';
|
2022-03-24 14:20:04 +05:30
|
|
|
import 'package:get/get.dart';
|
2022-05-12 02:17:08 +05:30
|
|
|
import 'package:rogapp/pages/index/index_controller.dart';
|
2022-07-23 19:28:35 +05:30
|
|
|
import 'package:rogapp/widgets/cat_widget.dart';
|
2022-03-24 14:20:04 +05:30
|
|
|
|
|
|
|
|
|
2022-04-17 11:45:21 +05:30
|
|
|
class PerfectureWidget extends StatefulWidget {
|
2022-03-24 14:20:04 +05:30
|
|
|
|
2022-04-17 11:45:21 +05:30
|
|
|
IndexController indexController;
|
|
|
|
|
MapController mapController;
|
2022-03-24 14:20:04 +05:30
|
|
|
|
2022-07-09 22:51:34 +05:30
|
|
|
|
2022-04-17 11:45:21 +05:30
|
|
|
PerfectureWidget({Key? key, required this.indexController, required this.mapController}) : super(key: key){
|
|
|
|
|
//indexController.zoomtoMainPerf("9", mapController);
|
|
|
|
|
}
|
2022-03-24 14:20:04 +05:30
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<PerfectureWidget> createState() => _PerfectureWidgetState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _PerfectureWidgetState extends State<PerfectureWidget> {
|
2022-06-14 14:37:59 +05:30
|
|
|
|
2022-07-09 22:51:34 +05:30
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-14 14:37:59 +05:30
|
|
|
|
|
|
|
|
bool isNumeric(String s) {
|
|
|
|
|
if (s == null) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return double.tryParse(s) != null;
|
|
|
|
|
}
|
2022-05-12 02:17:08 +05:30
|
|
|
|
2022-03-24 14:20:04 +05:30
|
|
|
|
|
|
|
|
List<DropdownMenuItem<String>> getDropdownItems() {
|
|
|
|
|
List<DropdownMenuItem<String>> dropDownItems = [];
|
|
|
|
|
|
2022-04-17 11:45:21 +05:30
|
|
|
for (Map<String, dynamic> currency in widget.indexController.perfectures[0]) {
|
2022-03-30 16:19:18 +05:30
|
|
|
//print(currency["id"].toString());
|
|
|
|
|
var newDropdown = DropdownMenuItem(
|
|
|
|
|
child: Text(currency["adm1_ja"].toString()),
|
|
|
|
|
value: currency["id"].toString(),
|
|
|
|
|
);
|
2022-03-24 14:20:04 +05:30
|
|
|
|
2022-03-30 16:19:18 +05:30
|
|
|
dropDownItems.add(newDropdown);
|
|
|
|
|
}
|
|
|
|
|
return dropDownItems;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<DropdownMenuItem<String>> getSubDropdownItems() {
|
|
|
|
|
List<DropdownMenuItem<String>> dropDownItems = [];
|
2022-03-24 14:20:04 +05:30
|
|
|
|
2022-04-17 11:45:21 +05:30
|
|
|
if(widget.indexController.subPerfs.isNotEmpty){
|
|
|
|
|
|
|
|
|
|
for (Map<String, dynamic> currency in widget.indexController.subPerfs[0]) {
|
|
|
|
|
var newDropdown = DropdownMenuItem(
|
|
|
|
|
child: Text(currency["adm2_ja"].toString()),
|
|
|
|
|
value: currency["id"].toString(),
|
|
|
|
|
);
|
|
|
|
|
dropDownItems.add(newDropdown);
|
|
|
|
|
}
|
2022-03-30 16:19:18 +05:30
|
|
|
}
|
2022-03-24 14:20:04 +05:30
|
|
|
return dropDownItems;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-06 21:15:58 +05:30
|
|
|
List<DropdownMenuItem<String>> getCustomArea(){
|
|
|
|
|
List<DropdownMenuItem<String>> dropDownItems = [];
|
|
|
|
|
if(widget.indexController.areas.isNotEmpty){
|
|
|
|
|
|
|
|
|
|
for (Map<String, dynamic> currency in widget.indexController.areas[0]) {
|
|
|
|
|
var newDropdown = DropdownMenuItem(
|
|
|
|
|
child: Text(currency["area_nm"].toString()),
|
|
|
|
|
value: currency["id"].toString(),
|
|
|
|
|
);
|
|
|
|
|
dropDownItems.add(newDropdown);
|
2022-09-29 15:32:33 +05:30
|
|
|
|
2022-06-06 21:15:58 +05:30
|
|
|
}
|
2022-06-14 14:37:59 +05:30
|
|
|
|
2022-06-06 21:15:58 +05:30
|
|
|
}
|
2022-06-14 14:37:59 +05:30
|
|
|
|
|
|
|
|
if(widget.indexController.customAreas.isNotEmpty){
|
|
|
|
|
|
|
|
|
|
for (Map<String, dynamic> currency in widget.indexController.customAreas[0]) {
|
|
|
|
|
var newDropdown = DropdownMenuItem(
|
|
|
|
|
child: Text(currency["event_name"].toString()),
|
|
|
|
|
value: currency["event_name"].toString(),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
dropDownItems.add(newDropdown);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-06 21:15:58 +05:30
|
|
|
return dropDownItems;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-23 19:28:35 +05:30
|
|
|
List<DropdownMenuItem<String>> getCategory(){
|
|
|
|
|
List<DropdownMenuItem<String>> dropDownItems = [];
|
|
|
|
|
|
|
|
|
|
dropDownItems.clear();
|
|
|
|
|
|
|
|
|
|
//print("--------cats ------############### ${widget.indexController.cats.toString()} -------------");
|
|
|
|
|
for(dynamic d in widget.indexController.cats){
|
2022-07-25 19:56:32 +05:30
|
|
|
//print("-------- ddd ------############### ${d} --------dddd-----");
|
2022-07-23 19:28:35 +05:30
|
|
|
var newDropdown = DropdownMenuItem(child: Text(d['category'].toString()), value: d['category'].toString());
|
|
|
|
|
//print("--------cats ------############### ${d['category'].toString()} -------------");
|
|
|
|
|
dropDownItems.add(newDropdown);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//return [];
|
|
|
|
|
|
|
|
|
|
return dropDownItems;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-24 14:20:04 +05:30
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2022-07-09 22:51:34 +05:30
|
|
|
|
2022-03-30 16:19:18 +05:30
|
|
|
return Obx(() =>
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
DropdownButton<String>(
|
2022-05-12 02:17:08 +05:30
|
|
|
value: widget.indexController.dropdownValue,
|
2022-03-24 14:20:04 +05:30
|
|
|
icon: const Icon(Icons.arrow_downward),
|
|
|
|
|
elevation: 16,
|
|
|
|
|
style: const TextStyle(color: Colors.deepPurple),
|
|
|
|
|
underline: Container(
|
|
|
|
|
height: 2,
|
|
|
|
|
color: Colors.deepPurpleAccent,
|
|
|
|
|
),
|
|
|
|
|
onChanged: (String? newValue) {
|
2022-04-17 11:45:21 +05:30
|
|
|
//setState(() {
|
|
|
|
|
if(newValue != null){
|
2022-05-18 19:09:26 +05:30
|
|
|
widget.indexController.is_loading.value = true;
|
2022-05-12 02:17:08 +05:30
|
|
|
widget.indexController.dropdownValue = newValue;
|
2022-04-17 11:45:21 +05:30
|
|
|
widget.indexController.populateForPerf(newValue, widget.mapController);
|
|
|
|
|
}
|
|
|
|
|
//});
|
2022-03-24 14:20:04 +05:30
|
|
|
},
|
2022-04-17 11:45:21 +05:30
|
|
|
items: getDropdownItems()
|
|
|
|
|
),
|
2022-03-30 16:19:18 +05:30
|
|
|
|
2022-06-14 14:37:59 +05:30
|
|
|
// Gifu areas
|
2022-06-06 21:15:58 +05:30
|
|
|
widget.indexController.areas.isNotEmpty ?
|
|
|
|
|
DropdownButton<String>(
|
|
|
|
|
value: widget.indexController.areaDropdownValue,
|
|
|
|
|
icon: const Icon(Icons.arrow_downward),
|
|
|
|
|
elevation: 16,
|
|
|
|
|
style: const TextStyle(color: Colors.deepPurple),
|
|
|
|
|
hint: const Text("select"),
|
|
|
|
|
underline: Container(
|
|
|
|
|
height: 2,
|
|
|
|
|
color: Colors.deepPurpleAccent,
|
|
|
|
|
),
|
|
|
|
|
onChanged: (String? newValue) {
|
2022-06-14 14:37:59 +05:30
|
|
|
if (isNumeric(newValue!)){
|
2022-07-28 19:01:45 +05:30
|
|
|
widget.indexController.is_custom_area_selected.value = false;
|
2022-06-14 14:37:59 +05:30
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
widget.indexController.loadCustomLocation(newValue);
|
2022-07-28 19:01:45 +05:30
|
|
|
widget.indexController.is_custom_area_selected.value = true;
|
|
|
|
|
widget.indexController.subPerfs.clear();
|
|
|
|
|
widget.indexController.cats.clear();
|
2022-06-14 14:37:59 +05:30
|
|
|
}
|
2022-06-06 21:15:58 +05:30
|
|
|
setState(() {
|
2022-07-28 19:01:45 +05:30
|
|
|
widget.indexController.locations.clear();
|
2022-06-06 21:15:58 +05:30
|
|
|
if(newValue != null){
|
|
|
|
|
widget.indexController.is_loading.value = true;
|
2022-06-14 14:37:59 +05:30
|
|
|
widget.indexController.areaDropdownValue = newValue;
|
|
|
|
|
widget.indexController.populateSubPerForArea(newValue, widget.mapController);
|
2022-06-06 21:15:58 +05:30
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
items: getCustomArea(),
|
|
|
|
|
): const Text(""),
|
|
|
|
|
|
2022-04-17 11:45:21 +05:30
|
|
|
widget.indexController.subPerfs.isNotEmpty ?
|
2022-03-30 16:19:18 +05:30
|
|
|
DropdownButton<String>(
|
2022-04-17 11:45:21 +05:30
|
|
|
value: widget.indexController.subDropdownValue,
|
2022-03-30 16:19:18 +05:30
|
|
|
icon: const Icon(Icons.arrow_downward),
|
|
|
|
|
elevation: 16,
|
|
|
|
|
style: const TextStyle(color: Colors.deepPurple),
|
2022-04-17 11:45:21 +05:30
|
|
|
hint: const Text("select"),
|
2022-03-30 16:19:18 +05:30
|
|
|
underline: Container(
|
|
|
|
|
height: 2,
|
|
|
|
|
color: Colors.deepPurpleAccent,
|
|
|
|
|
),
|
|
|
|
|
onChanged: (String? newValue) {
|
|
|
|
|
setState(() {
|
2022-04-17 11:45:21 +05:30
|
|
|
if(newValue != null){
|
2022-07-25 19:56:32 +05:30
|
|
|
//widget.indexController.is_loading.value = true;
|
|
|
|
|
//widget.indexController.populateForSubPerf(newValue, widget.mapController);
|
2022-04-17 11:45:21 +05:30
|
|
|
//widget.indexController.loadLocationforSubPerf(newValue, widget.mapController);
|
2022-07-25 19:56:32 +05:30
|
|
|
widget.indexController.subDropdownValue = newValue;
|
|
|
|
|
widget.indexController.loadCatForCity(newValue);
|
2022-04-17 11:45:21 +05:30
|
|
|
}
|
2022-03-30 16:19:18 +05:30
|
|
|
});
|
|
|
|
|
},
|
2022-04-17 11:45:21 +05:30
|
|
|
items:
|
|
|
|
|
getSubDropdownItems()
|
|
|
|
|
) :
|
2022-07-23 19:28:35 +05:30
|
|
|
const Text(""),
|
|
|
|
|
//CatWidget(indexController: widget.indexController,),
|
2022-07-25 19:56:32 +05:30
|
|
|
widget.indexController.cats.length > 0 ?
|
2022-07-23 19:28:35 +05:30
|
|
|
DropdownButton<String>(
|
2022-10-12 21:46:17 +05:30
|
|
|
value: widget.indexController.getCatText(),
|
2022-07-23 19:28:35 +05:30
|
|
|
icon: const Icon(Icons.arrow_downward),
|
|
|
|
|
elevation: 16,
|
|
|
|
|
style: const TextStyle(color: Colors.deepPurple),
|
|
|
|
|
hint: const Text("select"),
|
|
|
|
|
underline: Container(
|
|
|
|
|
height: 2,
|
|
|
|
|
color: Colors.deepPurpleAccent,
|
|
|
|
|
),
|
|
|
|
|
onChanged: (String? newValue) {
|
|
|
|
|
setState(() {
|
|
|
|
|
if(newValue != null){
|
|
|
|
|
widget.indexController.is_loading.value = true;
|
2022-07-25 19:56:32 +05:30
|
|
|
widget.indexController.cateogory = newValue;
|
|
|
|
|
widget.indexController.currentCat.clear();
|
|
|
|
|
widget.indexController.currentCat.add(newValue);
|
|
|
|
|
widget.indexController.populateForSubPerf(widget.indexController.subDropdownValue, widget.mapController);
|
2022-07-23 19:28:35 +05:30
|
|
|
//widget.indexController.loadLocationforSubPerf(newValue, widget.mapController);
|
|
|
|
|
//widget.indexController.subDropdownValue = newValue;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
items:
|
|
|
|
|
getCategory(),
|
|
|
|
|
)
|
2022-07-25 19:56:32 +05:30
|
|
|
:
|
|
|
|
|
Container(),
|
2022-03-30 16:19:18 +05:30
|
|
|
|
|
|
|
|
],
|
2022-04-17 11:45:21 +05:30
|
|
|
),
|
2022-03-30 16:19:18 +05:30
|
|
|
);
|
2022-03-24 14:20:04 +05:30
|
|
|
}
|
|
|
|
|
}
|