feat : new injection logic
test : some file :) chore : upgrade android gradle
This commit is contained in:
@@ -2,7 +2,10 @@ import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import 'package:rasadyar_livestock/data/repository/livestock/livestock_repository.dart';
|
||||
import 'package:rasadyar_livestock/data/repository/livestock/livestock_repository_imp.dart';
|
||||
import 'package:rasadyar_livestock/injection/live_stock_di.dart';
|
||||
import 'package:rasadyar_livestock/presentation/page/root/logic.dart';
|
||||
|
||||
enum ErrorLocationType { serviceDisabled, permissionDenied, none }
|
||||
|
||||
@@ -11,7 +14,6 @@ class MapWidgetLogic extends GetxController with GetTickerProviderStateMixin {
|
||||
String tileType = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
|
||||
RxDouble currentZoom = 15.0.obs;
|
||||
|
||||
|
||||
RxList<LatLng> allMarkers = <LatLng>[].obs;
|
||||
Rx<MapController> mapController = MapController().obs;
|
||||
RxList<ErrorLocationType> errorLocationType = RxList();
|
||||
@@ -19,19 +21,9 @@ class MapWidgetLogic extends GetxController with GetTickerProviderStateMixin {
|
||||
Timer? _debounceTimer;
|
||||
RxBool isLoading = false.obs;
|
||||
|
||||
RxList<LatLng> markerLocations = <LatLng>[
|
||||
LatLng(35.824891, 50.948025),
|
||||
LatLng(35.825000, 50.949000),
|
||||
LatLng(35.823000, 50.947000),
|
||||
LatLng(35.826000, 50.950000),
|
||||
LatLng(35.827000, 50.951000),
|
||||
LatLng(35.828000, 50.952000),
|
||||
LatLng(35.829000, 50.953000),
|
||||
LatLng(35.830000, 50.954000),
|
||||
LatLng(35.831000, 50.955000),
|
||||
LatLng(35.832000, 50.956000),
|
||||
LatLng(35.832000, 50.956055),
|
||||
].obs;
|
||||
RxList<LatLng> markerLocations = RxList();
|
||||
RootLogic rootLogic = Get.find<RootLogic>();
|
||||
late LivestockRepository repository ;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@@ -67,6 +59,7 @@ class MapWidgetLogic extends GetxController with GetTickerProviderStateMixin {
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
determineCurrentPosition();
|
||||
// getLoc();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -158,5 +151,14 @@ class MapWidgetLogic extends GetxController with GetTickerProviderStateMixin {
|
||||
return rawMarkers.where((marker) => distance(center, marker) <= radiusInMeters).toList();
|
||||
}
|
||||
|
||||
|
||||
/* Future<void> getLoc() async {
|
||||
await Future.delayed(Duration(seconds: 3));
|
||||
await safeCall(
|
||||
call: () async => repository.getLocations(),
|
||||
onSuccess: (result) {
|
||||
markerLocations.addAll(result);
|
||||
},
|
||||
onError: (error, stackTrace) {},
|
||||
);
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_core/data/services/network_status.dart';
|
||||
import 'package:rasadyar_livestock/presentation/routes/app_pages.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
@@ -148,6 +149,16 @@ class MapWidget extends GetView<MapWidgetLogic> {
|
||||
);
|
||||
}, controller.currentLocation),
|
||||
|
||||
Positioned(
|
||||
top: 15,
|
||||
left: 20,
|
||||
child: ObxValue((status) {
|
||||
|
||||
|
||||
return Text("Connection: ${status.value}", style: TextStyle(fontSize: 20));
|
||||
}, NetworkStatus().isConnected),
|
||||
),
|
||||
|
||||
// Uncomment the following lines to enable the search widget
|
||||
/* Positioned(
|
||||
top: 10,
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_livestock/data/repository/livestock/livestock_repository.dart';
|
||||
import 'package:rasadyar_livestock/data/repository/livestock/livestock_repository_imp.dart';
|
||||
import 'package:rasadyar_livestock/injection/live_stock_di.dart';
|
||||
import 'package:rasadyar_livestock/presentation/page/map/view.dart';
|
||||
import 'package:rasadyar_livestock/presentation/page/profile/view.dart';
|
||||
import 'package:rasadyar_livestock/presentation/page/request_tagging/view.dart';
|
||||
@@ -28,10 +34,49 @@ class RootLogic extends GetxController {
|
||||
];
|
||||
|
||||
RxInt currentIndex = 0.obs;
|
||||
|
||||
|
||||
TokenStorageService tokenService = Get.find<TokenStorageService>();
|
||||
|
||||
late StreamSubscription<List<ConnectivityResult>> connectivitySubscription;
|
||||
RxList<ConnectivityResult> connectivityResults = <ConnectivityResult>[].obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
connectivitySubscription = Connectivity().onConnectivityChanged.listen((result) {
|
||||
if (result.isNotEmpty) {
|
||||
connectivityResults.assignAll(result);
|
||||
}
|
||||
});
|
||||
|
||||
/* GetIt.instance.allReady().then((value) async {
|
||||
await diLiveStock.get<LivestockRepositoryImp>().addLocations(generateRandomPoints());
|
||||
});*/
|
||||
}
|
||||
|
||||
List<LatLng> generateRandomPoints() {
|
||||
final Random random = Random();
|
||||
final double centerLat = 35.824891;
|
||||
final double centerLon = 50.948025;
|
||||
final double radiusKm = 1.0;
|
||||
final double kmToDegLat = 1 / 111.0; // 1 km ≈ 0.009° latitude
|
||||
final double kmToDegLon = 1 / (111.0 * cos(centerLat * pi / 180)); // Adjust for longitude
|
||||
|
||||
List<LatLng> points = [];
|
||||
for (int i = 0; i < 100; i++) {
|
||||
// Generate random angle (0 to 2π) and random radius (0 to 1 km, using sqrt for uniform distribution)
|
||||
double theta = random.nextDouble() * 2 * pi;
|
||||
double r =
|
||||
sqrt(random.nextDouble()) * radiusKm; // Square root for uniform distribution in circle
|
||||
// Convert polar coordinates to Cartesian, then to LatLng
|
||||
double deltaLat = r * cos(theta) * kmToDegLat;
|
||||
double deltaLon = r * sin(theta) * kmToDegLon;
|
||||
double newLat = centerLat + deltaLat;
|
||||
double newLon = centerLon + deltaLon;
|
||||
points.add(LatLng(newLat, newLon));
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
@@ -40,7 +85,7 @@ class RootLogic extends GetxController {
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
connectivitySubscription.cancel();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ class RootPage extends GetView<RootLogic> {
|
||||
final navigatorKey = Get.nestedKey(currentIndex);
|
||||
|
||||
if (currentIndex.value == 0 &&
|
||||
|
||||
navigatorKey != null &&
|
||||
navigatorKey.currentState != null) {
|
||||
if (navigatorKey.currentState!.canPop()) {
|
||||
|
||||
Reference in New Issue
Block a user