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