This commit is contained in:
Mohamed Nouffer
2022-03-24 14:20:04 +05:30
parent 92bb6b8dcd
commit ea874c094c
7 changed files with 326 additions and 142 deletions

View File

@ -3,11 +3,13 @@
import 'package:geojson/geojson.dart'; import 'package:geojson/geojson.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:rogapp/services/location_service.dart'; import 'package:rogapp/services/location_service.dart';
import 'package:rogapp/services/perfecture_service.dart';
class HomeController extends GetxController { class HomeController extends GetxController {
List<GeoJsonFeatureCollection> locations = <GeoJsonFeatureCollection>[].obs; List<GeoJsonFeatureCollection> locations = <GeoJsonFeatureCollection>[].obs;
List<GeoJsonFeature> currentFeature = <GeoJsonFeature>[].obs; List<GeoJsonFeature> currentFeature = <GeoJsonFeature>[].obs;
List<dynamic> perfectures = <dynamic>[].obs;
@override @override
@ -16,6 +18,12 @@ class HomeController extends GetxController {
LocationService.loadLocations().then((value){ LocationService.loadLocations().then((value){
locations.add(value!); locations.add(value!);
}); });
PerfectureService.loadPerfectures().then((value){
perfectures.add(value);
print(perfectures);
});
} }
GeoJsonFeature? getFeatureForLatLong(double lat, double long){ GeoJsonFeature? getFeatureForLatLong(double lat, double long){

View File

@ -7,6 +7,7 @@ import 'package:get/get.dart';
import 'package:rogapp/pages/drawer/drawer_page.dart'; import 'package:rogapp/pages/drawer/drawer_page.dart';
import 'package:rogapp/pages/home/home_controller.dart'; import 'package:rogapp/pages/home/home_controller.dart';
import 'package:rogapp/routes/app_pages.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:rogapp/widgets/bottom_sheet_widget.dart';
import 'package:flutter_breadcrumb/flutter_breadcrumb.dart'; import 'package:flutter_breadcrumb/flutter_breadcrumb.dart';
@ -14,6 +15,7 @@ class HomePage extends GetView<HomeController> {
final HomeController homeController = Get.find<HomeController>(); final HomeController homeController = Get.find<HomeController>();
void changeCurrentFeature(GeoJsonFeature fs){ void changeCurrentFeature(GeoJsonFeature fs){
if(homeController.currentFeature.length > 0){ if(homeController.currentFeature.length > 0){
homeController.currentFeature.clear(); homeController.currentFeature.clear();
@ -74,7 +76,12 @@ class HomePage extends GetView<HomeController> {
height: 50.0, height: 50.0,
child: BreadCrumb( child: BreadCrumb(
items: <BreadCrumbItem>[ 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),)), BreadCrumbItem(content: Text('Item2', style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold),)),
], ],
divider: Icon(Icons.chevron_right), divider: Icon(Icons.chevron_right),

View File

@ -1,4 +1,6 @@
import 'package:flutter/material.dart'; 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/plugin_api.dart';
import 'package:flutter_map_location_marker/flutter_map_location_marker.dart'; import 'package:flutter_map_location_marker/flutter_map_location_marker.dart';
import 'package:geojson/geojson.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/routes/app_pages.dart';
import 'package:rogapp/widgets/base_layer_widget.dart'; import 'package:rogapp/widgets/base_layer_widget.dart';
import 'package:rogapp/widgets/bottom_sheet_widget.dart'; import 'package:rogapp/widgets/bottom_sheet_widget.dart';
import 'package:rogapp/widgets/perfecture_widget.dart';
class MapPage extends StatelessWidget { class MapPage extends StatelessWidget {
@ -57,6 +60,27 @@ class MapPage extends StatelessWidget {
), ),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
body: SafeArea( 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(() => child: Obx(() =>
Stack( Stack(
children: [ children: [
@ -136,9 +160,10 @@ class MapPage extends StatelessWidget {
) )
), ),
), ),
],
),
),
); );
} }
} }

View File

@ -9,7 +9,7 @@ class LocationService{
final geo = GeoJson(); final geo = GeoJson();
GeoJsonFeatureCollection? fs; GeoJsonFeatureCollection? fs;
print("#### feature collection ####"); 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), final response = await http.get(Uri.parse(url),
headers: <String, String>{ headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',

View 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;
}
}

View File

@ -22,6 +22,20 @@ class BottomSheetWidget extends StatelessWidget {
if (!await launch(url)) throw 'Could not launch $url'; 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SingleChildScrollView( return SingleChildScrollView(
@ -84,71 +98,118 @@ class BottomSheetWidget extends StatelessWidget {
Row( Row(
children: [ children: [
Expanded( Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24.0),
child: Column( child: Column(
children: [ children: [
homeController.currentFeature[0].properties!["address"] != null ? homeController.currentFeature[0].properties!["address"] != null ?
Row( Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ 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,), 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,), style: TextStyle(color: Colors.blue,),
)) softWrap: true,
overflow: TextOverflow.ellipsis,)
),
),
)
], ],
): Container(width: 0.0, height: 0,), ): Container(width: 0.0, height: 0,),
homeController.currentFeature[0].properties!["phone"] != null ? homeController.currentFeature[0].properties!["phone"] != null ?
Row( Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ 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,), 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,), style: TextStyle(color: Colors.blue,),
)) overflow: TextOverflow.ellipsis,)
),
),
)
], ],
): Container(width: 0, height: 0,), ): Container(width: 0, height: 0,),
homeController.currentFeature[0].properties!["email"] != null ? homeController.currentFeature[0].properties!["email"] != null ?
Row( Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ 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,), 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,), style: TextStyle(color: Colors.blue,),
)) overflow: TextOverflow.ellipsis,)
),
),
)
], ],
): Container(width: 0, height: 0,), ): Container(width: 0, height: 0,),
homeController.currentFeature[0].properties!["webcontents"] != null ? homeController.currentFeature[0].properties!["webcontents"] != null ?
Row( Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ 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,), SizedBox(width: 12.0,),
Obx(() => InkWell( Expanded(
child: Container(
alignment: Alignment.topLeft,
child: Obx(() => InkWell(
onTap: (){ onTap: (){
_launchURL(homeController.currentFeature[0].properties!["webcontents"]); _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,), style: TextStyle(color: Colors.blue,),
softWrap: false,
overflow: TextOverflow.fade,),
)),
), ),
)) )
], ],
): Container(width: 0.0, height: 0.0,), ): Container(width: 0.0, height: 0.0,),
homeController.currentFeature[0].properties!["videos"] != null ? homeController.currentFeature[0].properties!["videos"] != null ?
Row( Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ 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,), 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,), style: TextStyle(color: Colors.blue,),
)) overflow: TextOverflow.ellipsis,)
),
),
)
], ],
): Container(width: 0.0, height: 0.0,), ): Container(width: 0.0, height: 0.0,),
], ],
), ),
), ),
),
], ],
), ),
SizedBox(height: 20.0,), SizedBox(height: 20.0,),

View 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());
}
}