feat : local location loading
This commit is contained in:
@@ -10,6 +10,6 @@ abstract class LivestockRepository {
|
||||
|
||||
Future<bool> createTaggingLiveStock({required LivestockData data});
|
||||
|
||||
/* Future<List<LatLng>> getLocations();
|
||||
Future<void> addLocations(List<LatLng> latList);*/
|
||||
Future<List<LatLng>> getLocations();
|
||||
Future<void> addLocations(List<LatLng> latList);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_core/data/services/network_status.dart';
|
||||
import 'package:rasadyar_livestock/data/data_source/local/tmp/tmp_local_data-source.dart';
|
||||
@@ -11,8 +10,9 @@ import 'livestock_repository.dart';
|
||||
|
||||
class LivestockRepositoryImp implements LivestockRepository {
|
||||
final LivestockRemoteDataSource livestockRemote;
|
||||
final TmpLocalDataSource tmpLocalDataSource;
|
||||
|
||||
LivestockRepositoryImp({required this.livestockRemote});
|
||||
LivestockRepositoryImp({required this.livestockRemote,required this.tmpLocalDataSource});
|
||||
|
||||
@override
|
||||
Future<LocationDetails?> getLocationDetails({
|
||||
@@ -29,7 +29,7 @@ class LivestockRepositoryImp implements LivestockRepository {
|
||||
Future<bool> createTaggingLiveStock({required LivestockData data}) async {
|
||||
return await livestockRemote.createTaggingLiveStock(data: data);
|
||||
}
|
||||
/*
|
||||
|
||||
@override
|
||||
Future<List<LatLng>> getLocations() async {
|
||||
if (NetworkStatus().isConnected.value) {
|
||||
@@ -47,17 +47,17 @@ class LivestockRepositoryImp implements LivestockRepository {
|
||||
LatLng(35.832000, 50.956055),
|
||||
];
|
||||
} else {
|
||||
*//*var res = await tmpLocalDataSource.getLocations();
|
||||
var res = await tmpLocalDataSource.getLocations();
|
||||
|
||||
return res.map((e) => LatLng(e.lat ?? 0.0, e.long ?? 0.0)).toList();*//*
|
||||
return res.map((e) => LatLng(e.lat ?? 0.0, e.long ?? 0.0)).toList();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> addLocations(List<LatLng> latList) async {
|
||||
*//* await tmpLocalDataSource.addLocations(
|
||||
await tmpLocalDataSource.addLocations(
|
||||
latList.map((e) => TmpLocations(lat: e.latitude, long: e.longitude)).toList(),
|
||||
);*//*
|
||||
);
|
||||
iLog("it is done");
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,21 +8,19 @@ import 'package:rasadyar_livestock/data/repository/auth/auth_repository.dart';
|
||||
import 'package:rasadyar_livestock/data/repository/auth/auth_repository_imp.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/data/service/live_stock_storage_service.dart';
|
||||
import 'package:rasadyar_livestock/hive_registrar.g.dart';
|
||||
import 'package:rasadyar_livestock/presentation/routes/app_pages.dart';
|
||||
|
||||
import '../data/data_source/local/tmp/tmp_local_data-source.dart';
|
||||
|
||||
GetIt get diLiveStock => GetIt.instance;
|
||||
|
||||
Future<void> setupLiveStockDI() async {
|
||||
diLiveStock.registerSingleton(DioErrorHandler());
|
||||
await IsolatedHive.initFlutter();
|
||||
IsolatedHive.registerAdapters();
|
||||
iLog("Sssssssssssssssssssss");
|
||||
final tokenService = Get.find<TokenStorageService>();
|
||||
|
||||
|
||||
|
||||
if (tokenService.baseurl.value == null) {
|
||||
await tokenService.saveBaseUrl('https://api.dam.rasadyar.net/');
|
||||
}
|
||||
@@ -80,8 +78,14 @@ Future<void> setupLiveStockDI() async {
|
||||
diLiveStock.registerLazySingleton<LivestockRemoteDataSource>(
|
||||
() => LivestockRemoteDataSourceImp(),
|
||||
);
|
||||
|
||||
diLiveStock.registerLazySingleton<TmpLocalDataSource>(() => TmpLocalDataSource());
|
||||
|
||||
diLiveStock.registerLazySingleton<LivestockRepository>(
|
||||
() => LivestockRepositoryImp(livestockRemote: diLiveStock.get<LivestockRemoteDataSource>()),
|
||||
() => LivestockRepositoryImp(
|
||||
livestockRemote: diLiveStock.get<LivestockRemoteDataSource>(),
|
||||
tmpLocalDataSource: diLiveStock.get<TmpLocalDataSource>(),
|
||||
),
|
||||
);
|
||||
//endregion
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class MapWidgetLogic extends GetxController with GetTickerProviderStateMixin {
|
||||
|
||||
RxList<LatLng> markerLocations = RxList();
|
||||
RootLogic rootLogic = Get.find<RootLogic>();
|
||||
late LivestockRepository repository ;
|
||||
LivestockRepository repository = diLiveStock.get<LivestockRepository>();
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@@ -59,7 +59,7 @@ class MapWidgetLogic extends GetxController with GetTickerProviderStateMixin {
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
determineCurrentPosition();
|
||||
// getLoc();
|
||||
getLoc();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -151,7 +151,7 @@ class MapWidgetLogic extends GetxController with GetTickerProviderStateMixin {
|
||||
return rawMarkers.where((marker) => distance(center, marker) <= radiusInMeters).toList();
|
||||
}
|
||||
|
||||
/* Future<void> getLoc() async {
|
||||
Future<void> getLoc() async {
|
||||
await Future.delayed(Duration(seconds: 3));
|
||||
await safeCall(
|
||||
call: () async => repository.getLocations(),
|
||||
@@ -160,5 +160,5 @@ class MapWidgetLogic extends GetxController with GetTickerProviderStateMixin {
|
||||
},
|
||||
onError: (error, stackTrace) {},
|
||||
);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user