feat : new injection logic
test : some file :) chore : upgrade android gradle
This commit is contained in:
15
packages/livestock/lib/data/common/checkk_di_middleware.dart
Normal file
15
packages/livestock/lib/data/common/checkk_di_middleware.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_livestock/injection/live_stock_di.dart';
|
||||
|
||||
class CheckDiMiddleWare extends GetMiddleware {
|
||||
@override
|
||||
Future<GetNavConfig?> redirectDelegate(GetNavConfig route) async {
|
||||
return super.redirectDelegate(route);
|
||||
}
|
||||
|
||||
@override
|
||||
GetPage? onPageCalled(GetPage? page) {
|
||||
return super.onPageCalled(page);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_livestock/data/model/local/location/tmp_locations.dart';
|
||||
|
||||
class TmpLocalDataSource {
|
||||
Future<void> addLocations(List<TmpLocations> list) async {
|
||||
IsolatedBox<TmpLocations> box = await IsolatedHive.openBox<TmpLocations>('TmpBox');
|
||||
if (await box.isNotEmpty) {
|
||||
box.clear();
|
||||
}
|
||||
box.addAll(list);
|
||||
}
|
||||
|
||||
Future<List<TmpLocations>> getLocations() async {
|
||||
IsolatedBox<TmpLocations> box = await IsolatedHive.openBox<TmpLocations>('TmpBox');
|
||||
var res = await box.values;
|
||||
return res.toList();
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
|
||||
part 'car.g.dart';
|
||||
|
||||
|
||||
@HiveType(typeId: 50)
|
||||
class CarsLocal extends HiveObject {
|
||||
@HiveField(0)
|
||||
String? name;
|
||||
|
||||
@HiveField(1)
|
||||
String? price;
|
||||
|
||||
CarsLocal({this.name, this.price});
|
||||
|
||||
factory CarsLocal.fromJson(Map<String, dynamic> json) {
|
||||
return CarsLocal(name: json['name'] as String?, price: json['price'] as String?);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {'name': name, 'price': price};
|
||||
}
|
||||
}
|
||||
|
||||
class Cars {
|
||||
String? name;
|
||||
String? price;
|
||||
|
||||
Cars({this.name, this.price});
|
||||
|
||||
factory Cars.fromJson(Map<String, dynamic> json) {
|
||||
return Cars(name: json['name'] as String?, price: json['price'] as String?);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {'name': name, 'price': price};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
part 'tmp_locations.g.dart';
|
||||
|
||||
@HiveType(typeId: 100)
|
||||
class TmpLocations extends HiveObject{
|
||||
|
||||
@HiveField(0)
|
||||
double? lat;
|
||||
|
||||
|
||||
@HiveField(1)
|
||||
double? long;
|
||||
|
||||
TmpLocations({this.lat, this.long});
|
||||
}
|
||||
@@ -1,32 +1,34 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'car.dart';
|
||||
part of 'tmp_locations.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// TypeAdapterGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class CarsLocalAdapter extends TypeAdapter<CarsLocal> {
|
||||
class TmpLocationsAdapter extends TypeAdapter<TmpLocations> {
|
||||
@override
|
||||
final typeId = 50;
|
||||
final typeId = 100;
|
||||
|
||||
@override
|
||||
CarsLocal read(BinaryReader reader) {
|
||||
TmpLocations read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return CarsLocal(name: fields[0] as String?, price: fields[1] as String?);
|
||||
return TmpLocations()
|
||||
..lat = (fields[0] as num?)?.toDouble()
|
||||
..long = (fields[1] as num?)?.toDouble();
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, CarsLocal obj) {
|
||||
void write(BinaryWriter writer, TmpLocations obj) {
|
||||
writer
|
||||
..writeByte(2)
|
||||
..writeByte(0)
|
||||
..write(obj.name)
|
||||
..write(obj.lat)
|
||||
..writeByte(1)
|
||||
..write(obj.price);
|
||||
..write(obj.long);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -35,7 +37,7 @@ class CarsLocalAdapter extends TypeAdapter<CarsLocal> {
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is CarsLocalAdapter &&
|
||||
other is TmpLocationsAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_livestock/data/model/response/address/address.dart';
|
||||
import 'package:rasadyar_livestock/data/model/response/auth/auth_response_model.dart';
|
||||
import 'package:rasadyar_livestock/data/model/response/captcha/captcha_response_model.dart';
|
||||
import 'package:rasadyar_livestock/data/model/response/live_tmp/livestock_model.dart';
|
||||
|
||||
abstract class LivestockRepository {
|
||||
@@ -11,4 +10,6 @@ abstract class LivestockRepository {
|
||||
|
||||
Future<bool> createTaggingLiveStock({required LivestockData data});
|
||||
|
||||
/* Future<List<LatLng>> getLocations();
|
||||
Future<void> addLocations(List<LatLng> latList);*/
|
||||
}
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
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';
|
||||
import 'package:rasadyar_livestock/data/data_source/remote/livestock/livestock_remote.dart';
|
||||
import 'package:rasadyar_livestock/data/model/local/location/tmp_locations.dart';
|
||||
import 'package:rasadyar_livestock/data/model/response/address/address.dart';
|
||||
import 'package:rasadyar_livestock/data/model/response/live_tmp/livestock_model.dart';
|
||||
|
||||
@@ -24,4 +29,35 @@ 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) {
|
||||
return [
|
||||
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),
|
||||
];
|
||||
} else {
|
||||
*//*var res = await tmpLocalDataSource.getLocations();
|
||||
|
||||
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(
|
||||
latList.map((e) => TmpLocations(lat: e.latitude, long: e.longitude)).toList(),
|
||||
);*//*
|
||||
iLog("it is done");
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_livestock/data/model/local/live_tmp/car.dart';
|
||||
import 'package:rasadyar_livestock/data/model/local/live_tmp/livestock_local_model.dart';
|
||||
import 'package:rasadyar_livestock/data/model/response/live_tmp/livestock_model.dart';
|
||||
import 'package:rasadyar_livestock/data/utils/mapper.dart';
|
||||
@@ -7,7 +6,7 @@ import 'package:rasadyar_livestock/data/utils/mapper.dart';
|
||||
class LiveStockStorageService extends GetxService {
|
||||
final String _liveStockBoxName = 'LiveStockBox';
|
||||
late IsolatedBox<LivestockLocalModel> _LiveStockbox;
|
||||
late IsolatedBox<CarsLocal> _carbox;
|
||||
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
|
||||
Reference in New Issue
Block a user