update for reorder and location points

This commit is contained in:
Mohamed Nouffer
2022-09-01 19:14:18 +05:30
parent a4adf24e99
commit 09ac737de5
12 changed files with 196 additions and 143 deletions

View File

@ -18,6 +18,9 @@ class Destination {
int? auto_checkin;
bool? selected = false;
bool? checkedin = false;
double? cp;
double? checkin_point;
double? buy_point;
Destination({
this.name,
@ -36,7 +39,10 @@ class Destination {
this.checkin_radious,
this.auto_checkin,
this.selected,
this.checkedin
this.checkedin,
this.cp,
this.checkin_point,
this.buy_point
});
factory Destination.fromMap(Map<String, dynamic> json) {
@ -61,7 +67,10 @@ class Destination {
checkin_radious: json['checkin_radious'],
auto_checkin:json['auto_checkin'],
selected: selec,
checkedin: checkin
checkedin: checkin,
cp: json['cp'],
checkin_point: json['checkin_point'],
buy_point: json['buy_point']
);
}
@ -85,7 +94,10 @@ class Destination {
'checkin_radious': checkin_radious,
'auto_checkin': auto_checkin,
'selected': sel,
'checkedin': check
'checkedin': check,
'cp' : cp,
'checkin_point' : checkin_point,
'buy_point' : buy_point
};
}

View File

@ -34,45 +34,6 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
StreamSubscription? subscription;
final PopupController _popupLayerController = PopupController();
// Widget examplePopup(Marker marker){
// return Padding(
// padding: const EdgeInsets.all(10),
// child: Container(
// constraints: const BoxConstraints(minWidth: 100, maxWidth: 200),
// color: Colors.white,
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisAlignment: MainAxisAlignment.start,
// mainAxisSize: MainAxisSize.min,
// children: <Widget>[
// const Text(
// 'Popup for a marker!',
// overflow: TextOverflow.fade,
// softWrap: false,
// style: TextStyle(
// fontWeight: FontWeight.w500,
// fontSize: 14.0,
// ),
// ),
// const Padding(padding: EdgeInsets.symmetric(vertical: 4.0)),
// Text(
// 'Position: ${marker.point.latitude}, ${marker.point.longitude}',
// style: const TextStyle(fontSize: 12.0),
// ),
// Text(
// 'Marker size: ${marker.width}, ${marker.height}',
// style: const TextStyle(fontSize: 12.0),
// ),
// ],
// ),
// ),
// );
// }
List<LatLng>? getPoints(){
//print("##### --- route point ${indexController.routePoints.length}");
List<LatLng> pts = [];
@ -83,6 +44,20 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
return pts;
}
String getDisplaytext(Destination dp){
String txt = "";
if(dp.cp! > 0){
txt = "${dp.cp}";
if(dp.checkin_point != null && dp.checkin_point! > 0){
txt = txt + "{${dp.checkin_point}}";
}
if(dp.buy_point != null && dp.buy_point! > 0){
txt = txt + "[${dp.buy_point}]";
}
}
return txt;
}
List<Marker>? getMarkers() {
List<Marker> pts = [];
int index = -1;
@ -111,21 +86,29 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
);
}
},
child: Container(
decoration: BoxDecoration(
color: Colors.red,
shape: BoxShape.circle,
border: new Border.all(
color: Colors.white,
width: d.checkin_radious != null ? d.checkin_radious! : 1,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
width:20,
height:20,
decoration: BoxDecoration(
color: Colors.red,
shape: BoxShape.circle,
border: new Border.all(
color: Colors.white,
width: d.checkin_radious != null ? d.checkin_radious! : 1,
),
),
child: new Center(
child: new Text(
(i + 1).toString(),
style: TextStyle(color: Colors.white),
),
),
),
),
child: new Center(
child: new Text(
(i + 1).toString(),
style: TextStyle(color: Colors.white),
),
),
Container( color: Colors.yellow, child: Text(getDisplaytext(d), style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold, overflow: TextOverflow.visible),)),
],
),
);
@ -242,7 +225,7 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
children: [
TileLayerWidget(
options: TileLayerOptions(
urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
urlTemplate: 'https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png',
subdomains: ['a', 'b', 'c'],
),
),
@ -253,8 +236,8 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
polylines: [
Polyline(
points: getPoints()!,
strokeWidth: 4.0,
color: Colors.purple),
strokeWidth: 6.0,
color: Colors.indigo),
],
),
)

View File

@ -360,7 +360,7 @@ void login(String email, String password, BuildContext context){
void loadLocationforSubPerf(String subperf, MapController mapController) async {
String cat = currentCat.isNotEmpty == true ? currentCat[0] : "";
if(currentCat[0] == "-all-"){
if(currentCat.isNotEmpty && currentCat[0] == "-all-"){
cat = "";
}
LocationService.loadLocationsSubFor(subperf, cat).then((value){
@ -371,6 +371,9 @@ void login(String email, String password, BuildContext context){
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();
@ -390,7 +393,11 @@ void login(String email, String password, BuildContext context){
if(is_custom_area_selected.value == true){
return;
}
locations.clear();
String cat = currentCat.isNotEmpty ? currentCat[0] : "";
if(currentCat.isNotEmpty && currentCat[0] == "-all-"){
cat = "";
}
LatLngBounds bounds = mapController!.bounds!;
currentBound.clear();
currentBound.add(bounds);
@ -401,7 +408,6 @@ void login(String email, String password, BuildContext context){
if(value == null){
return;
}
locations.clear();
if(value != null && value.collection.isEmpty){
if(showPopup == false) {
return;

View File

@ -25,7 +25,9 @@ class LoginPage extends StatelessWidget {
Navigator.pop(context);
},icon:Icon(Icons.arrow_back_ios,size: 20,color: Colors.black,)),
),
body: Container(
body:
indexController.currentUser.length == 0 ?
Container(
height: MediaQuery.of(context).size.height,
width: double.infinity,
child: Column(
@ -141,7 +143,16 @@ class LoginPage extends StatelessWidget {
),
],
),
),
):
Container(
child: TextButton(
onPressed: (){
indexController.currentUser.clear();
},
child: Text("Already Logged in, Click to logout"),
),
)
,
);
}
}

View File

@ -60,7 +60,7 @@ class AuthService{
//String url = 'http://container.intranet.sumasen.net:8100/api/cats/';
print("---- cat url is ${url}");
print("---- UserDetails url is ${url}");
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',

View File

@ -15,7 +15,7 @@ class CatService{
//String url = 'http://container.intranet.sumasen.net:8100/api/cats/';
print("---- cat url is ${url}");
print("---- loadCats url is ${url}");
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
@ -38,7 +38,7 @@ class CatService{
//String url = 'http://container.intranet.sumasen.net:8100/api/cats/';
print("---- cat url is ${url}");
print("---- loadCatByCity url is ${url}");
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',

View File

@ -1,14 +1,25 @@
import 'dart:convert';
import 'package:geojson/geojson.dart';
import 'package:get/get.dart';
import 'package:http/http.dart' as http;
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/utils/const.dart';
class LocationService{
static Future<GeoJsonFeatureCollection?> loadLocations() async {
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/location/';
final IndexController indexController = Get.find<IndexController>();
String server_url = ConstValues.currentServer();
String url = "";
if(indexController.currentUser.length > 0){
url = '${server_url}/api/location/?is_rog=True';
}
else {
url = '${server_url}/api/location/';
}
//String url = 'http://localhost:8100/api/location/';
final response = await http.get(Uri.parse(url),
headers: <String, String>{
@ -24,18 +35,27 @@ class LocationService{
}
static Future<GeoJsonFeatureCollection?> loadLocationsFor(String perfecture, String cat) async {
final IndexController indexController = Get.find<IndexController>();
String url = "";
String server_url = ConstValues.currentServer();
if(cat.isNotEmpty){
url = '${server_url}/api/inperf/?perf=' + perfecture + '&cat=' + cat;
//url = 'http://localhost:8100/api/inperf/?perf=' + perfecture + '&cat=' + cat;
if(indexController.currentUser.length > 0){
url = '${server_url}/api/inperf/?rog=True&perf=' + perfecture + '&cat=' + cat;
}
else {
url = '${server_url}/api/inperf/?perf=' + perfecture + '&cat=' + cat;
}
}
else{
url = '${server_url}/api/inperf/?perf=' + perfecture;
//url = 'http://localhost:8100/api/inperf/?perf=' + perfecture;
if(indexController.currentUser.length > 0){
url = '${server_url}/api/inperf/?rog=True&perf=' + perfecture;
}
else {
url = '${server_url}/api/inperf/?perf=' + perfecture;
}
}
//print("----- url ---- ${url} --- ${cat}");
//String url = 'http://localhost:8100/api/inperf/?perf=' + perfecture + '&cat=' + cat;
print("----loadLocationsFor url --- ${url}");
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
@ -52,17 +72,26 @@ class LocationService{
static Future<GeoJsonFeatureCollection?> loadLocationsSubFor(String subperfecture, String cat) async {
final IndexController indexController = Get.find<IndexController>();
String url = "";
String server_url = ConstValues.currentServer();
if(cat.isNotEmpty){
url = '${server_url}/api/insubperf?subperf=' + subperfecture + '&cat=' + cat;
//url = 'http://localhost:8100/api/insubperf?subperf=' + subperfecture + '&cat=' + cat;
if(indexController.currentUser.length > 0){
url = '${server_url}/api/insubperf?rog=True&subperf=' + subperfecture + '&cat=' + cat;
}
else{
url = '${server_url}/api/insubperf?subperf=' + subperfecture + '&cat=' + cat;
}
}
else{
print("------ loading location in sub----");
url = '${server_url}/api/insubperf?subperf=' + subperfecture;
//url = 'http://localhost:8100/api/insubperf?subperf=' + subperfecture;
if(indexController.currentUser.length > 0){
url = '${server_url}/api/insubperf?rog=True&subperf=' + subperfecture;
}
else{
url = '${server_url}/api/insubperf?subperf=' + subperfecture;
}
}
print("----loadLocationsSubFor url --- ${url}");
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
@ -78,19 +107,27 @@ class LocationService{
}
static Future<GeoJsonFeatureCollection?> loadLocationsBound(double lat1, double lon1, double lat2, double lon2, double lat3, double lon3, double lat4, double lon4, String cat) async {
static Future<GeoJsonFeatureCollection?> loadLocationsBound(double lat1, double lon1, double lat2, double lon2, double lat3, double lon3, double lat4, double lon4, String cat) async {
final IndexController indexController = Get.find<IndexController>();
String url = "";
String server_url = ConstValues.currentServer();
print("cat is ----- ${cat}");
if(cat.isNotEmpty){
url = '${server_url}/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}' + '&cat=' + cat;
//url = 'http://localhost:8100/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}' + '&cat=' + cat;
if(indexController.currentUser.length > 0){
url = '${server_url}/api/inbound?rog=True&ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}' + '&cat=' + cat;
}
else{
url = '${server_url}/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}' + '&cat=' + cat;
}
}
else{
url = '${server_url}/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}';
//url = 'http://localhost:8100/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}';
if(indexController.currentUser.length > 0){
url = '${server_url}/api/inbound?rog=True&ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}';
}
else{
url = '${server_url}/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}';
}
}
print("----url --- ${url}");
print("----loadLocationsBound url --- ${url}");
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
@ -115,21 +152,30 @@ class LocationService{
static Future<GeoJsonFeatureCollection?> loadCustomLocations(String name, String cat) async {
final IndexController indexController = Get.find<IndexController>();
String url = "";
if(cat == "-all-"){
cat = "";
}
String server_url = ConstValues.currentServer();
print("cat is ----- ${cat}");
print("loadCustomLocations url is ----- ${cat}");
if(cat.isNotEmpty){
url = '${server_url}/api/custom_area/?&cat=' + cat;
//url = 'http://localhost:8100/api/customarea?name=${name}&cat=' + cat;
if(indexController.currentUser.length > 0){
url = '${server_url}/api/custom_area/?rog=True&&cat=' + cat;
}
else{
url = '${server_url}/api/custom_area/?&cat=' + cat;
}
}
else{
url = '${server_url}/api/customarea?name=${name}&';
//url = 'http://localhost:8100/api/customarea?name=${name}&';
if(indexController.currentUser.length > 0){
url = '${server_url}/api/customarea?rog=True&name=${name}&';
}
else{
url = '${server_url}/api/customarea?name=${name}&';
}
}
print("----url --- ${url}");
print("----loadCustomLocations url --- ${url}");
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',

View File

@ -4,7 +4,7 @@
class ConstValues{
static const server_uri = "http://container.intranet.sumasen.net:8100";
static const dev_server = "http://localhost:8100";
static const dev_ip_server = "http://192.168.8.100:8100";
static const dev_ip_server = "http://192.168.8.103:8100";
static String currentServer(){
return server_uri;

View File

@ -41,14 +41,17 @@ class DatabaseHelper{
checkin_radious REAL,
auto_checkin INTEGER,
selected INTEGER,
checkedin INTEGER
checkedin INTEGER,
cp REAL,
checkin_point REAL,
buy_point REAL
)
''');
}
Future<List<Destination>> getDestinations() async {
Database db = await instance.database;
var dest = await db.query('destination');
var dest = await db.query('destination', orderBy: 'list_order');
List<Destination> destList = dest.isNotEmpty ?
dest.map((e) => Destination.fromMap(e)).toList() : [];
print("--------- ${destList}");
@ -57,7 +60,7 @@ class DatabaseHelper{
Future<List<Destination>> getDestinationByLatLon(double lat, double lon) async {
Database db = await instance.database;
var dest = await db.query('destination', where: "lat = ${lat} and lon= ${lon}");
var dest = await db.query('destination', where: "lat = ${lat} and lon= ${lon}", orderBy: 'list_order');
List<Destination> destList = dest.isNotEmpty
? dest.map((e) => Destination.fromMap(e)).toList() : [];
return destList;
@ -78,6 +81,10 @@ class DatabaseHelper{
Future<int> insertDestination(Destination dest) async {
Database db = await instance.database;
int? next_order = Sqflite.firstIntValue(await db.rawQuery('SELECT MAX(list_order) FROM destination'));
next_order = next_order==null ? 0 : next_order;
next_order = next_order + 1;
dest.list_order = next_order;
int res = await db.insert(
'destination',
dest.toMap(),

View File

@ -9,9 +9,12 @@ class BaseLayer extends StatelessWidget {
return TileLayerWidget(
options: TileLayerOptions(
backgroundColor: Colors.transparent,
urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
//urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
urlTemplate: 'https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png',
//urlTemplate: 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
subdomains: ['a', 'b', 'c'],
//subdomains: ['a', 'b', 'c'],
//subdomains: ['TileMatrix', 'TileCol', 'TileRow'],
),
);
}

View File

@ -74,6 +74,7 @@ class BottomSheetNew extends GetView<BottomSheetController> {
return indexController.rog_mode == 0 ? detailsSheet(context) : destinationSheet(context);
}
// Show destination detais
SingleChildScrollView destinationSheet(BuildContext context) {
return SingleChildScrollView(
child: Column(
@ -136,31 +137,31 @@ class BottomSheetNew extends GetView<BottomSheetController> {
],
),
Obx(() =>
indexController.currentDestinationFeature[0].address!.isNotEmpty ?
indexController.currentDestinationFeature[0].address != null && indexController.currentDestinationFeature[0].address!.isNotEmpty ?
getDetails(context, "address".tr, indexController.currentDestinationFeature[0].address! ?? '')
:
Container(width: 0.0, height: 0,),
),
Obx(() =>
indexController.currentDestinationFeature[0].phone!.isNotEmpty ?
indexController.currentDestinationFeature[0].phone != null && indexController.currentDestinationFeature[0].phone!.isNotEmpty ?
getDetails(context, "telephone".tr, indexController.currentDestinationFeature[0].phone! ?? '')
:
Container(width: 0.0, height: 0,),
),
Obx(() =>
indexController.currentDestinationFeature[0].email!.isNotEmpty ?
indexController.currentDestinationFeature[0].email != null && indexController.currentDestinationFeature[0].email!.isNotEmpty ?
getDetails(context, "email".tr, indexController.currentDestinationFeature[0].email! ?? '')
:
Container(width: 0.0, height: 0,),
),
Obx(() =>
indexController.currentDestinationFeature[0].webcontents!.isNotEmpty ?
indexController.currentDestinationFeature[0].webcontents != null && indexController.currentDestinationFeature[0].webcontents!.isNotEmpty ?
getDetails(context, "web".tr, indexController.currentDestinationFeature[0].webcontents! ?? '', isurl: true)
:
Container(width: 0.0, height: 0,),
),
Obx(() =>
indexController.currentDestinationFeature[0].videos!.isNotEmpty ?
indexController.currentDestinationFeature[0].videos != null && indexController.currentDestinationFeature[0].videos!.isNotEmpty ?
getDetails(context, "video".tr, indexController.currentDestinationFeature[0].videos! ?? '', isurl: true)
:
Container(width: 0.0, height: 0,),
@ -185,6 +186,7 @@ class BottomSheetNew extends GetView<BottomSheetController> {
);
}
// show add location details
SingleChildScrollView detailsSheet(BuildContext context) {
return SingleChildScrollView(
child: Column(
@ -336,7 +338,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
Container(width: 0.0, height: 0,),
],
),
)
),
Text(indexController.currentFeature[0].properties!["cp"].toString()),
],
),
)
@ -381,6 +384,9 @@ class BottomSheetNew extends GetView<BottomSheetController> {
photos: indexController.currentFeature[0].properties!["photos"],
checkin_radious: indexController.currentFeature[0].properties!["checkin_radious"],
auto_checkin: indexController.currentFeature[0].properties!["auto_checkin"] == true ? 1 : 0,
cp: indexController.currentFeature[0].properties!["cp"],
checkin_point: indexController.currentFeature[0].properties!["checkin_point"],
buy_point: indexController.currentFeature[0].properties!["buy_point"],
selected: false,
checkedin: false
);

View File

@ -84,42 +84,6 @@ class MapWidget extends StatelessWidget {
_popupController
.hideAllPopups(), // Hide popup when the map is tapped.
),
layers: [
// MarkerLayerOptions(
// markers: indexController.locations[0].collection.map((i) {
// print("i si ${i.properties!['location_id']}");
// GeoJsonMultiPoint p = i.geometry as GeoJsonMultiPoint;
// print("lat is ${p.geoSerie!.geoPoints[0].latitude} and lon is ${p.geoSerie!.geoPoints[0].longitude}");
// return Marker(
// anchorPos: AnchorPos.align(AnchorAlign.center),
// height: 70.0,
// width: 70.0,
// point: LatLng(p.geoSerie!.geoPoints[0].latitude, p.geoSerie!.geoPoints[0].longitude),
// builder: (ctx) =>
// IconButton(
// icon: const Icon(Icons.pin_drop),
// tooltip: 'Increase volume by 10',
// onPressed: () {
// GeoJsonFeature? fs = indexController.getFeatureForLatLong(p.geoSerie!.geoPoints[0].latitude, p.geoSerie!.geoPoints[0].longitude);
// print(fs);
// if(fs != null){
// if(indexController.currentFeature.length > 0) {
// indexController.currentFeature.clear();
// }
// indexController.currentFeature.add(fs);
// indexController.getAction();
// showModalBottomSheet(context: context, isScrollControlled: true,
// builder:((context) => BottomSheetWidget())
// );
// }
// },
// ),
// );
// }).toList(),
// ),
],
children: [
BaseLayer(),
LocationMarkerLayerWidget(),
@ -167,7 +131,7 @@ class MapWidget extends StatelessWidget {
height: 22.0,
width: 22.0,
point: LatLng(p.geoSerie!.geoPoints[0].latitude, p.geoSerie!.geoPoints[0].longitude),
builder: (ctx) => Icon(Icons.pin_drop),
//builder: (ctx) => Icon(Icons.pin_drop),
// builder: (ctx) => i.properties!["category"] != null ?
// ImageIcon(
// AssetImage("assets/images/${i.properties!["category"]}.png"),
@ -175,7 +139,22 @@ class MapWidget extends StatelessWidget {
// size:12.0,
// )
// : Icon(Icons.pin_drop),
builder: (ctx){
return Container(
width: 7,
height: 7,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.transparent,
border: Border.all(
color: Colors.red,
width: 3,
style: BorderStyle.solid
)
),
child: Icon(Icons.circle,size: 10.0,)
);
},
);
}).toList(),
builder: (context, markers) {