diff --git a/CHANGELOG.md b/CHANGELOG.md index 8515e49..8bfb34c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # CHANGELOG +## 2.0.0 (2024-08-29) +- fix: replaced pure_extensions with maps_toolkit for kuama_position and removed tuple package + ## 1.3.0 (2024-07-23) - chore: bumped permission_handler to `^11.3.1` - chore: changed rxdart dependency constraints to support version `>=0.27.0 <0.29.0` diff --git a/kuama_core/lib/kuama_core.dart b/kuama_core/lib/kuama_core.dart index 77cad41..5e2b5e1 100644 --- a/kuama_core/lib/kuama_core.dart +++ b/kuama_core/lib/kuama_core.dart @@ -2,9 +2,6 @@ library kuama_core; -export 'package:tuple/tuple.dart'; - export 'src/failures/failure.dart'; export 'src/failures/failure_extensions.dart'; export 'src/identifiable.dart'; -export 'src/tuple.dart'; diff --git a/kuama_core/lib/src/tuple.dart b/kuama_core/lib/src/tuple.dart deleted file mode 100644 index 34b91ac..0000000 --- a/kuama_core/lib/src/tuple.dart +++ /dev/null @@ -1,52 +0,0 @@ -import 'dart:async'; - -import 'package:tuple/tuple.dart'; - -extension Tuple2FutureKuamaExtension on Tuple2, FutureOr> { - Future> get done async => Tuple2(await $0, await $1); -} - -extension Tuple3FutureKuamaExtension - on Tuple3, FutureOr, FutureOr> { - Future> get done async => Tuple3(await $0, await $1, await $2); -} - -extension Tuple4FutureKuamaExtension - on Tuple4, FutureOr, FutureOr, FutureOr> { - Future> get done async => Tuple4(await $0, await $1, await $2, await $3); -} - -extension Tuple5FutureKuamaExtension - on Tuple5, FutureOr, FutureOr, FutureOr, FutureOr> { - Future> get done async => - Tuple5(await $0, await $1, await $2, await $3, await $4); -} - -/// Extensions methods for future support to records feature -/// https://github.com/dart-lang/language/blob/master/accepted/future-releases/records/records-feature-specification.md - -extension Tuple2KuamaExtension on Tuple2 { - I1 get $0 => item1; - I2 get $1 => item2; -} - -extension Tuple3KuamaExtension on Tuple3 { - I1 get $0 => item1; - I2 get $1 => item2; - I3 get $2 => item3; -} - -extension Tuple4KuamaExtension on Tuple4 { - I1 get $0 => item1; - I2 get $1 => item2; - I3 get $2 => item3; - I4 get $3 => item4; -} - -extension Tuple5KuamaExtension on Tuple5 { - I1 get $0 => item1; - I2 get $1 => item2; - I3 get $2 => item3; - I4 get $3 => item4; - I5 get $4 => item5; -} diff --git a/kuama_core/pubspec.yaml b/kuama_core/pubspec.yaml index cd51906..935b404 100644 --- a/kuama_core/pubspec.yaml +++ b/kuama_core/pubspec.yaml @@ -1,7 +1,7 @@ name: kuama_core description: A starting point for Dart libraries or applications. publish_to: 'none' -version: 1.3.1 +version: 2.0.0 environment: sdk: '>=3.0.0 <4.0.0' @@ -11,7 +11,6 @@ scripts: dependencies: get_it: ^7.2.0 # Global packages version - tuple: ^2.0.1 rxdart: '>=0.27.0 <0.29.0' dev_dependencies: @@ -25,8 +24,4 @@ index_generator: # Ignore all generated dart files - '**.g.dart' # Ignore all private folders or files - - '{_,**/_}*{/**,.dart}' - indexes: - - path: lib - exports: - - package: package:tuple/tuple.dart + - '{_,**/_}*{/**,.dart}' \ No newline at end of file diff --git a/kuama_permissions/pubspec.yaml b/kuama_permissions/pubspec.yaml index f6d217f..198b9ad 100644 --- a/kuama_permissions/pubspec.yaml +++ b/kuama_permissions/pubspec.yaml @@ -1,7 +1,7 @@ name: kuama_permissions description: A starting point for Dart libraries or applications. publish_to: 'none' -version: 1.3.1 +version: 2.0.0 environment: sdk: '>=3.0.0 <4.0.0' @@ -20,7 +20,7 @@ dependencies: git: url: https://github.com/Kuama-IT/kuama_dart.git path: kuama_core - ref: 1.3.1 + ref: 2.0.0 permission_handler_platform_interface: ^4.2.1 permission_handler: ^11.3.1 diff --git a/kuama_position/lib/src/blocs/_position_event.dart b/kuama_position/lib/src/blocs/_position_event.dart index 80f9ca1..75886bd 100644 --- a/kuama_position/lib/src/blocs/_position_event.dart +++ b/kuama_position/lib/src/blocs/_position_event.dart @@ -101,7 +101,7 @@ class _UnTrackPositionBloc extends _PositionBlocEvent { /// Event to update the realtime position class _EmitTrackingPositionEvent extends _PositionBlocEvent { - final GeoPoint position; + final LatLng position; const _EmitTrackingPositionEvent(this.position); diff --git a/kuama_position/lib/src/blocs/_position_state.dart b/kuama_position/lib/src/blocs/_position_state.dart index bc5840a..9a8b52b 100644 --- a/kuama_position/lib/src/blocs/_position_state.dart +++ b/kuama_position/lib/src/blocs/_position_state.dart @@ -1,7 +1,7 @@ part of 'position_bloc.dart'; abstract class PositionBlocState extends Equatable { - final GeoPoint? lastPosition; + final LatLng? lastPosition; const PositionBlocState({required this.lastPosition}); @@ -27,7 +27,7 @@ abstract class PositionBlocState extends Equatable { bool get hasLastPosition => lastPosition != null; - PositionBlocState toIdle({GeoPoint? position, bool? hasPermission, bool? isServiceEnabled}) { + PositionBlocState toIdle({LatLng? position, bool? hasPermission, bool? isServiceEnabled}) { return PositionBlocIdle( lastPosition: position ?? lastPosition, hasPermission: hasPermission ?? this.hasPermission, @@ -48,7 +48,7 @@ abstract class PositionBlocState extends Equatable { PositionBlocState toLocated({ required bool isRealTime, - required GeoPoint currentPosition, + required LatLng currentPosition, }) { return PositionBlocLocated( isRealTime: isRealTime, @@ -108,7 +108,7 @@ class PositionBlocFailed extends PositionBlocState { /// Other positions will be issued if [isRealTime] is true class PositionBlocLocated extends PositionBlocState { final bool isRealTime; - final GeoPoint currentPosition; + final LatLng currentPosition; const PositionBlocLocated({ required this.isRealTime, diff --git a/kuama_position/lib/src/blocs/position_bloc.dart b/kuama_position/lib/src/blocs/position_bloc.dart index d1a884b..8238203 100644 --- a/kuama_position/lib/src/blocs/position_bloc.dart +++ b/kuama_position/lib/src/blocs/position_bloc.dart @@ -7,7 +7,7 @@ import 'package:get_it/get_it.dart'; import 'package:kuama_core/kuama_core.dart'; import 'package:kuama_permissions/kuama_permissions.dart'; import 'package:kuama_position/src/service/position_service.dart'; -import 'package:pure_extensions/pure_extensions.dart'; +import 'package:maps_toolkit/maps_toolkit.dart'; import 'package:rxdart/rxdart.dart'; part '_position_event.dart'; @@ -28,7 +28,7 @@ class PositionBloc extends Bloc<_PositionBlocEvent, PositionBlocState> { var _realTimeListenerCount = 0; PositionBloc({ - GeoPoint? lastPosition, + LatLng? lastPosition, required PermissionsBloc permissionsBloc, }) : super(PositionBlocIdle( lastPosition: lastPosition, diff --git a/kuama_position/lib/src/repositories/position_repository.dart b/kuama_position/lib/src/repositories/position_repository.dart index ad9a93f..6fce8b4 100644 --- a/kuama_position/lib/src/repositories/position_repository.dart +++ b/kuama_position/lib/src/repositories/position_repository.dart @@ -1,4 +1,4 @@ -import 'package:pure_extensions/pure_extensions.dart'; +import 'package:maps_toolkit/maps_toolkit.dart'; abstract class PositionRepository { PositionRepository._(); @@ -13,8 +13,8 @@ abstract class PositionRepository { Stream get onServiceChanges; /// Request the current position of the user - Future get currentPosition; + Future get currentPosition; /// Track the current position of the user - Stream get onPositionChanges; + Stream get onPositionChanges; } diff --git a/kuama_position/lib/src/repositories/position_repository_impl.dart b/kuama_position/lib/src/repositories/position_repository_impl.dart index 745fc34..fb74480 100644 --- a/kuama_position/lib/src/repositories/position_repository_impl.dart +++ b/kuama_position/lib/src/repositories/position_repository_impl.dart @@ -1,19 +1,19 @@ import 'package:geolocator_platform_interface/geolocator_platform_interface.dart'; import 'package:get_it/get_it.dart'; import 'package:kuama_position/src/repositories/position_repository.dart'; -import 'package:pure_extensions/pure_extensions.dart'; +import 'package:maps_toolkit/maps_toolkit.dart'; class PositionRepositoryImpl implements PositionRepository { final GeolocatorPlatform geoLocator = GetIt.I(); @override - Future get currentPosition async { + Future get currentPosition async { final position = await geoLocator.getCurrentPosition(); return position.toGeoPoint(); } @override - Stream get onPositionChanges async* { + Stream get onPositionChanges async* { await for (final position in geoLocator.getPositionStream()) { yield position.toGeoPoint(); } @@ -43,5 +43,5 @@ class PositionRepositoryImpl implements PositionRepository { } extension _PositionToGeoPoint on Position { - GeoPoint toGeoPoint() => GeoPoint(latitude, longitude); + LatLng toGeoPoint() => LatLng(latitude, longitude); } diff --git a/kuama_position/lib/src/service/position_service.dart b/kuama_position/lib/src/service/position_service.dart index 59c2e32..7230adb 100644 --- a/kuama_position/lib/src/service/position_service.dart +++ b/kuama_position/lib/src/service/position_service.dart @@ -1,6 +1,6 @@ import 'package:get_it/get_it.dart'; import 'package:kuama_position/src/repositories/position_repository.dart'; -import 'package:pure_extensions/pure_extensions.dart'; +import 'package:maps_toolkit/maps_toolkit.dart'; // TODO: Handle exception in geolocator_platform_interface/src/implementations/method_channel_geolocator.dart:229 class PositionService { @@ -12,12 +12,12 @@ class PositionService { } /// Request the current position of the user - Future getCurrentPosition() async { + Future getCurrentPosition() async { return await locatorRepo.currentPosition; } /// Track the current position of the user - Stream get onPositionChanges { + Stream get onPositionChanges { return locatorRepo.onPositionChanges; } diff --git a/kuama_position/pubspec.yaml b/kuama_position/pubspec.yaml index 4ba2eb8..e1b90a1 100644 --- a/kuama_position/pubspec.yaml +++ b/kuama_position/pubspec.yaml @@ -1,7 +1,7 @@ name: kuama_position description: A new Flutter project. publish_to: 'none' -version: 1.3.1 +version: 2.0.0 environment: sdk: '>=3.0.0 <4.0.0' @@ -18,12 +18,12 @@ dependencies: git: url: https://github.com/Kuama-IT/kuama_dart.git path: kuama_core - ref: 1.3.1 + ref: 2.0.0 kuama_permissions: git: url: https://github.com/Kuama-IT/kuama_dart.git path: kuama_permissions - ref: 1.3.1 + ref: 2.0.0 geolocator_platform_interface: ^4.2.4 @@ -31,10 +31,10 @@ dependencies: get_it: # Version defined in kuama_core rxdart: '>=0.27.0 <0.29.0' - pure_extensions: ^5.0.0 bloc: ^8.1.1 bloc_concurrency: ^0.2.1 equatable: ^2.0.5 + maps_toolkit: ^3.0.0 dependency_overrides: kuama_core: { path: ../kuama_core } diff --git a/kuama_position/test/position_bloc_test.dart b/kuama_position/test/position_bloc_test.dart index 57f03aa..d2c7b5c 100644 --- a/kuama_position/test/position_bloc_test.dart +++ b/kuama_position/test/position_bloc_test.dart @@ -3,8 +3,8 @@ import 'package:get_it/get_it.dart'; import 'package:kuama_permissions/kuama_permissions.dart'; import 'package:kuama_position/src/blocs/position_bloc.dart'; import 'package:kuama_position/src/service/position_service.dart'; +import 'package:maps_toolkit/maps_toolkit.dart'; import 'package:mocktail/mocktail.dart'; -import 'package:pure_extensions/pure_extensions.dart'; class _MockPositionService extends Mock implements PositionService {} @@ -122,7 +122,7 @@ void main() { init(permission: EmissionType.alreadyHas, service: EmissionType.alreadyHas); when(() => mockPositionService.getCurrentPosition()).thenAnswer((_) async { - return const GeoPoint(0.0, 0.0); + return LatLng(0.0, 0.0); }); bloc.locate(); @@ -134,9 +134,9 @@ void main() { isRealTime: false, lastPosition: null, ), - const PositionBlocLocated( + PositionBlocLocated( isRealTime: false, - currentPosition: GeoPoint(0.0, 0.0), + currentPosition: LatLng(0.0, 0.0), ), ]), ); @@ -146,8 +146,8 @@ void main() { expect( bloc.stream, emitsInOrder([ - const PositionBlocIdle( - lastPosition: GeoPoint(0.0, 0.0), + PositionBlocIdle( + lastPosition: LatLng(0.0, 0.0), hasPermission: true, isServiceEnabled: true, ), @@ -162,11 +162,11 @@ void main() { init(permission: EmissionType.alreadyHas, service: EmissionType.alreadyHas); when(() => mockPositionService.getCurrentPosition()).thenAnswer((_) async { - return const GeoPoint(0.0, 0.0); + return LatLng(0.0, 0.0); }); when(() => mockPositionService.onPositionChanges).thenAnswer((_) async* { await Future.delayed(Duration.zero); - yield const GeoPoint(1.0, 1.0); + yield LatLng(1.0, 1.0); }); // ======== Test user tracking ======== @@ -180,13 +180,13 @@ void main() { isRealTime: true, lastPosition: null, ), - const PositionBlocLocated( + PositionBlocLocated( isRealTime: true, - currentPosition: GeoPoint(0.0, 0.0), + currentPosition: LatLng(0.0, 0.0), ), - const PositionBlocLocated( + PositionBlocLocated( isRealTime: true, - currentPosition: GeoPoint(1.0, 1.0), + currentPosition: LatLng(1.0, 1.0), ), ]), ); @@ -196,8 +196,8 @@ void main() { await expectLater( bloc.stream, emitsInOrder([ - const PositionBlocIdle( - lastPosition: GeoPoint(1.0, 1.0), + PositionBlocIdle( + lastPosition: LatLng(1.0, 1.0), hasPermission: true, isServiceEnabled: true, ), @@ -211,17 +211,17 @@ void main() { await expectLater( bloc.stream, emitsInOrder([ - const PositionBlocLocating( + PositionBlocLocating( isRealTime: true, - lastPosition: GeoPoint(1.0, 1.0), + lastPosition: LatLng(1.0, 1.0), ), - const PositionBlocLocated( + PositionBlocLocated( isRealTime: true, - currentPosition: GeoPoint(0.0, 0.0), + currentPosition: LatLng(0.0, 0.0), ), - const PositionBlocLocated( + PositionBlocLocated( isRealTime: true, - currentPosition: GeoPoint(1.0, 1.0), + currentPosition: LatLng(1.0, 1.0), ), ]), ); @@ -231,8 +231,8 @@ void main() { await expectLater( bloc.stream, emitsInOrder([ - const PositionBlocIdle( - lastPosition: GeoPoint(1.0, 1.0), + PositionBlocIdle( + lastPosition: LatLng(1.0, 1.0), hasPermission: true, isServiceEnabled: true, ), @@ -260,10 +260,10 @@ void main() { )); when(() => mockPositionService.getCurrentPosition()).thenAnswer((_) async { - return const GeoPoint(0.0, 0.0); + return LatLng(0.0, 0.0); }); when(() => mockPositionService.onPositionChanges).thenAnswer((_) async* { - yield const GeoPoint(0.0, 0.0); + yield LatLng(0.0, 0.0); }); bloc.track(); @@ -277,9 +277,9 @@ void main() { isRealTime: true, lastPosition: null, ), - const PositionBlocLocated( + PositionBlocLocated( isRealTime: true, - currentPosition: GeoPoint(0.0, 0.0), + currentPosition: LatLng(0.0, 0.0), ), ]), ); @@ -293,8 +293,8 @@ void main() { await expectLater( bloc.stream, emitsInOrder([ - const PositionBlocIdle( - lastPosition: GeoPoint(0.0, 0.0), + PositionBlocIdle( + lastPosition: LatLng(0.0, 0.0), hasPermission: true, isServiceEnabled: true, ), @@ -313,7 +313,7 @@ void main() { test('Emit real time position after bloc is initialized but track request before it', () async { when(() => mockPositionService.getCurrentPosition()).thenAnswer((_) async { - return const GeoPoint(0.0, 0.0); + return LatLng(0.0, 0.0); }); when(() => mockPositionService.onPositionChanges).thenAnswer((_) async* {}); @@ -333,9 +333,9 @@ void main() { isRealTime: true, lastPosition: null, ), - const PositionBlocLocated( + PositionBlocLocated( isRealTime: true, - currentPosition: GeoPoint(0.0, 0.0), + currentPosition: LatLng(0.0, 0.0), ), ]), );