update
This commit is contained in:
@ -3,11 +3,13 @@
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rogapp/services/location_service.dart';
|
||||
import 'package:rogapp/services/perfecture_service.dart';
|
||||
|
||||
class HomeController extends GetxController {
|
||||
|
||||
List<GeoJsonFeatureCollection> locations = <GeoJsonFeatureCollection>[].obs;
|
||||
List<GeoJsonFeature> currentFeature = <GeoJsonFeature>[].obs;
|
||||
List<dynamic> perfectures = <dynamic>[].obs;
|
||||
|
||||
|
||||
@override
|
||||
@ -16,6 +18,12 @@ class HomeController extends GetxController {
|
||||
LocationService.loadLocations().then((value){
|
||||
locations.add(value!);
|
||||
});
|
||||
|
||||
PerfectureService.loadPerfectures().then((value){
|
||||
perfectures.add(value);
|
||||
print(perfectures);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
GeoJsonFeature? getFeatureForLatLong(double lat, double long){
|
||||
|
||||
@ -7,6 +7,7 @@ import 'package:get/get.dart';
|
||||
import 'package:rogapp/pages/drawer/drawer_page.dart';
|
||||
import 'package:rogapp/pages/home/home_controller.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
import 'package:rogapp/services/perfecture_service.dart';
|
||||
import 'package:rogapp/widgets/bottom_sheet_widget.dart';
|
||||
import 'package:flutter_breadcrumb/flutter_breadcrumb.dart';
|
||||
|
||||
@ -14,6 +15,7 @@ class HomePage extends GetView<HomeController> {
|
||||
|
||||
final HomeController homeController = Get.find<HomeController>();
|
||||
|
||||
|
||||
void changeCurrentFeature(GeoJsonFeature fs){
|
||||
if(homeController.currentFeature.length > 0){
|
||||
homeController.currentFeature.clear();
|
||||
@ -74,7 +76,12 @@ class HomePage extends GetView<HomeController> {
|
||||
height: 50.0,
|
||||
child: BreadCrumb(
|
||||
items: <BreadCrumbItem>[
|
||||
BreadCrumbItem(content: Text('Item1', style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold),)),
|
||||
BreadCrumbItem(
|
||||
content: ElevatedButton(child: Text("Press"), onPressed: (){
|
||||
print("-----");
|
||||
print(homeController.perfectures[0][0]);
|
||||
},)
|
||||
),
|
||||
BreadCrumbItem(content: Text('Item2', style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold),)),
|
||||
],
|
||||
divider: Icon(Icons.chevron_right),
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_breadcrumb/flutter_breadcrumb.dart';
|
||||
import 'package:flutter_map/plugin_api.dart';
|
||||
import 'package:flutter_map_location_marker/flutter_map_location_marker.dart';
|
||||
import 'package:geojson/geojson.dart';
|
||||
@ -11,6 +13,7 @@ import 'package:flutter_map_marker_cluster/flutter_map_marker_cluster.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
import 'package:rogapp/widgets/base_layer_widget.dart';
|
||||
import 'package:rogapp/widgets/bottom_sheet_widget.dart';
|
||||
import 'package:rogapp/widgets/perfecture_widget.dart';
|
||||
|
||||
|
||||
class MapPage extends StatelessWidget {
|
||||
@ -57,6 +60,27 @@ class MapPage extends StatelessWidget {
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.0),
|
||||
alignment: Alignment.centerLeft,
|
||||
height: 50.0,
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: BreadCrumb(
|
||||
items: <BreadCrumbItem>[
|
||||
BreadCrumbItem(content:
|
||||
//Text('Item1', style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold),)
|
||||
PerfectureWidget(),
|
||||
),
|
||||
BreadCrumbItem(content: Text('Item2', style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold),)),
|
||||
],
|
||||
divider: Icon(Icons.chevron_right),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Obx(() =>
|
||||
Stack(
|
||||
children: [
|
||||
@ -136,9 +160,10 @@ class MapPage extends StatelessWidget {
|
||||
)
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ class LocationService{
|
||||
final geo = GeoJson();
|
||||
GeoJsonFeatureCollection? fs;
|
||||
print("#### feature collection ####");
|
||||
String url = 'http://container.intranet.sumasen.net:8100/api/location/';
|
||||
String url = 'http://localhost:8100/api/location/';
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
|
||||
24
lib/services/perfecture_service.dart
Normal file
24
lib/services/perfecture_service.dart
Normal file
@ -0,0 +1,24 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
|
||||
class PerfectureService{
|
||||
|
||||
static Future<List<dynamic>?> loadPerfectures() async {
|
||||
List<dynamic> perfs = [];
|
||||
String url = 'http://localhost:8100/api/perf/';
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
|
||||
perfs = json.decode(response.body);
|
||||
}
|
||||
return perfs;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -22,6 +22,20 @@ class BottomSheetWidget extends StatelessWidget {
|
||||
if (!await launch(url)) throw 'Could not launch $url';
|
||||
}
|
||||
|
||||
// Widget getAttrib(String name){
|
||||
// print("calling ...");
|
||||
// if(homeController.currentFeature[0].properties!["phone"] == null || homeController.currentFeature[0].properties!["phone"] == ""){
|
||||
// return Container(height: 0, width: 0,);
|
||||
// }
|
||||
// else {
|
||||
// return Obx(() =>
|
||||
// Text(homeController.currentFeature[0].properties!["phone"] ?? '',
|
||||
// style: TextStyle(color: Colors.blue,),
|
||||
// overflow: TextOverflow.ellipsis,)
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
@ -84,71 +98,118 @@ class BottomSheetWidget extends StatelessWidget {
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24.0),
|
||||
child: Column(
|
||||
children: [
|
||||
homeController.currentFeature[0].properties!["address"] != null ?
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text("address".tr, style: TextStyle(fontWeight: FontWeight.bold),),
|
||||
Expanded(
|
||||
child: Container(
|
||||
alignment: Alignment.topRight,
|
||||
child: Text("address".tr, style: TextStyle(fontWeight: FontWeight.bold),)),
|
||||
),
|
||||
SizedBox(width: 12.0,),
|
||||
Obx(() => Text(homeController.currentFeature[0].properties!["address"],
|
||||
Expanded(
|
||||
child: Container(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Obx(() => Text(homeController.currentFeature[0].properties!["address"] ?? '',
|
||||
style: TextStyle(color: Colors.blue,),
|
||||
))
|
||||
softWrap: true,
|
||||
overflow: TextOverflow.ellipsis,)
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
): Container(width: 0.0, height: 0,),
|
||||
homeController.currentFeature[0].properties!["phone"] != null ?
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text("telephone".tr, style: TextStyle(fontWeight: FontWeight.bold),),
|
||||
Expanded(child: Container(
|
||||
alignment: Alignment.topRight,
|
||||
child: Text("telephone".tr, style: TextStyle(fontWeight: FontWeight.bold),))),
|
||||
SizedBox(width: 12.0,),
|
||||
Obx(() => Text(homeController.currentFeature[0].properties!["phone"],
|
||||
Expanded(
|
||||
child: Container(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Obx(() => Text(homeController.currentFeature[0].properties!["phone"] ?? '',
|
||||
style: TextStyle(color: Colors.blue,),
|
||||
))
|
||||
overflow: TextOverflow.ellipsis,)
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
): Container(width: 0, height: 0,),
|
||||
homeController.currentFeature[0].properties!["email"] != null ?
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text("email".tr, style: TextStyle(fontWeight: FontWeight.bold),),
|
||||
Expanded(child: Container(
|
||||
alignment: Alignment.topRight,
|
||||
child: Text("email".tr, style: TextStyle(fontWeight: FontWeight.bold),))),
|
||||
SizedBox(width: 12.0,),
|
||||
Obx(() => Text(homeController.currentFeature[0].properties!["email"],
|
||||
Expanded(
|
||||
child: Container(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Obx(() => Text(homeController.currentFeature[0].properties!["email"] ?? '',
|
||||
style: TextStyle(color: Colors.blue,),
|
||||
))
|
||||
overflow: TextOverflow.ellipsis,)
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
): Container(width: 0, height: 0,),
|
||||
homeController.currentFeature[0].properties!["webcontents"] != null ?
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text("web".tr, style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
Expanded(child: Container(
|
||||
alignment: Alignment.topRight,
|
||||
child: Text(
|
||||
"web".tr, style: TextStyle(fontWeight: FontWeight.bold)))),
|
||||
SizedBox(width: 12.0,),
|
||||
Obx(() => InkWell(
|
||||
Expanded(
|
||||
child: Container(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Obx(() => InkWell(
|
||||
onTap: (){
|
||||
_launchURL(homeController.currentFeature[0].properties!["webcontents"]);
|
||||
},
|
||||
child: Text(homeController.currentFeature[0].properties!["webcontents"],
|
||||
child: Text(homeController.currentFeature[0].properties!["webcontents"] ?? '',
|
||||
style: TextStyle(color: Colors.blue,),
|
||||
softWrap: false,
|
||||
overflow: TextOverflow.fade,),
|
||||
)),
|
||||
),
|
||||
))
|
||||
)
|
||||
],
|
||||
): Container(width: 0.0, height: 0.0,),
|
||||
homeController.currentFeature[0].properties!["videos"] != null ?
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text("video".tr, style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
Expanded(child: Container(
|
||||
alignment: Alignment.topRight,
|
||||
child: Text("video".tr, style: TextStyle(fontWeight: FontWeight.bold)))),
|
||||
SizedBox(width: 12.0,),
|
||||
Obx(() => Text(homeController.currentFeature[0].properties!["videos"],
|
||||
Expanded(
|
||||
child: Container(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Obx(() => Text(homeController.currentFeature[0].properties!["videos"] ?? '',
|
||||
style: TextStyle(color: Colors.blue,),
|
||||
))
|
||||
overflow: TextOverflow.ellipsis,)
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
): Container(width: 0.0, height: 0.0,),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 20.0,),
|
||||
|
||||
59
lib/widgets/perfecture_widget.dart
Normal file
59
lib/widgets/perfecture_widget.dart
Normal file
@ -0,0 +1,59 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rogapp/pages/home/home_controller.dart';
|
||||
|
||||
|
||||
|
||||
class PerfectureWidget extends StatefulWidget {
|
||||
PerfectureWidget({Key? key}) : super(key: key);
|
||||
|
||||
final HomeController homeController = Get.find<HomeController>();
|
||||
|
||||
@override
|
||||
State<PerfectureWidget> createState() => _PerfectureWidgetState();
|
||||
}
|
||||
|
||||
class _PerfectureWidgetState extends State<PerfectureWidget> {
|
||||
String dropdownValue = 'One';
|
||||
|
||||
|
||||
|
||||
List<DropdownMenuItem<String>> getDropdownItems() {
|
||||
List<DropdownMenuItem<String>> dropDownItems = [];
|
||||
|
||||
print("---------");
|
||||
print(widget.homeController.perfectures);
|
||||
|
||||
for (List<String> currency in widget.homeController.perfectures[0]) {
|
||||
var newDropdown = DropdownMenuItem(
|
||||
child: Text("dddd"),
|
||||
value: "qqqq",
|
||||
);
|
||||
|
||||
dropDownItems.add(newDropdown);
|
||||
}
|
||||
return dropDownItems;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DropdownButton<String>(
|
||||
value: dropdownValue,
|
||||
icon: const Icon(Icons.arrow_downward),
|
||||
elevation: 16,
|
||||
style: const TextStyle(color: Colors.deepPurple),
|
||||
underline: Container(
|
||||
height: 2,
|
||||
color: Colors.deepPurpleAccent,
|
||||
),
|
||||
onChanged: (String? newValue) {
|
||||
setState(() {
|
||||
dropdownValue = newValue!;
|
||||
});
|
||||
},
|
||||
items:getDropdownItems());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user