Skip to content

Commit

Permalink
fix: pure_extensions replacement
Browse files Browse the repository at this point in the history
Replaced pure_extensions with maps_toolkit for kuama_position and removed tuple package
  • Loading branch information
MicheleTrevisanKuama committed Aug 29, 2024
1 parent a68c44b commit 1712248
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 116 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
3 changes: 0 additions & 3 deletions kuama_core/lib/kuama_core.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 0 additions & 52 deletions kuama_core/lib/src/tuple.dart

This file was deleted.

9 changes: 2 additions & 7 deletions kuama_core/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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:
Expand All @@ -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}'
4 changes: 2 additions & 2 deletions kuama_permissions/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion kuama_position/lib/src/blocs/_position_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
8 changes: 4 additions & 4 deletions kuama_position/lib/src/blocs/_position_state.dart
Original file line number Diff line number Diff line change
@@ -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});

Expand All @@ -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,
Expand All @@ -48,7 +48,7 @@ abstract class PositionBlocState extends Equatable {

PositionBlocState toLocated({
required bool isRealTime,
required GeoPoint currentPosition,
required LatLng currentPosition,
}) {
return PositionBlocLocated(
isRealTime: isRealTime,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions kuama_position/lib/src/blocs/position_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions kuama_position/lib/src/repositories/position_repository.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:pure_extensions/pure_extensions.dart';
import 'package:maps_toolkit/maps_toolkit.dart';

abstract class PositionRepository {
PositionRepository._();
Expand All @@ -13,8 +13,8 @@ abstract class PositionRepository {
Stream<bool> get onServiceChanges;

/// Request the current position of the user
Future<GeoPoint> get currentPosition;
Future<LatLng> get currentPosition;

/// Track the current position of the user
Stream<GeoPoint> get onPositionChanges;
Stream<LatLng> get onPositionChanges;
}
Original file line number Diff line number Diff line change
@@ -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<GeoPoint> get currentPosition async {
Future<LatLng> get currentPosition async {
final position = await geoLocator.getCurrentPosition();
return position.toGeoPoint();
}

@override
Stream<GeoPoint> get onPositionChanges async* {
Stream<LatLng> get onPositionChanges async* {
await for (final position in geoLocator.getPositionStream()) {
yield position.toGeoPoint();
}
Expand Down Expand Up @@ -43,5 +43,5 @@ class PositionRepositoryImpl implements PositionRepository {
}

extension _PositionToGeoPoint on Position {
GeoPoint toGeoPoint() => GeoPoint(latitude, longitude);
LatLng toGeoPoint() => LatLng(latitude, longitude);
}
6 changes: 3 additions & 3 deletions kuama_position/lib/src/service/position_service.dart
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -12,12 +12,12 @@ class PositionService {
}

/// Request the current position of the user
Future<GeoPoint> getCurrentPosition() async {
Future<LatLng> getCurrentPosition() async {
return await locatorRepo.currentPosition;
}

/// Track the current position of the user
Stream<GeoPoint> get onPositionChanges {
Stream<LatLng> get onPositionChanges {
return locatorRepo.onPositionChanges;
}

Expand Down
8 changes: 4 additions & 4 deletions kuama_position/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -18,23 +18,23 @@ 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
geolocator: ^12.0.0

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 }
Expand Down
Loading

0 comments on commit 1712248

Please sign in to comment.