From f4e9bdf4349fc123cc2c858904c6652794aaef2b Mon Sep 17 00:00:00 2001 From: Emil Date: Sun, 11 Aug 2024 14:59:20 +0500 Subject: [PATCH] chore: moved `PlaceDetails` & `AutoComplete` in `location_repository.dart` --- lib/src/app/routes/app_router.dart | 5 +--- lib/src/map/bloc/auto_complete_bloc.dart | 1 - lib/src/map/bloc/map_bloc.dart | 1 - lib/src/map/view/google_map_page.dart | 26 +++++----------- .../map/widgets/auto_completes_list_view.dart | 1 - lib/src/map/widgets/google_map_address.dart | 2 +- ...utton.dart => google_map_back_button.dart} | 30 ++----------------- lib/src/map/widgets/google_map_props.dart | 9 ------ .../google_map_save_location_button.dart | 2 +- lib/src/map/widgets/widgets.dart | 3 +- .../location_repository/analysis_options.yaml | 3 ++ .../lib/location_repository.dart | 1 + .../lib/src/location_repository.dart | 5 ++-- .../lib/src/models/auto_complete.dart | 0 .../lib/src/models/models.dart | 2 ++ .../lib/src/models/place_details.dart | 2 -- packages/location_repository/pubspec.yaml | 6 ++++ packages/shared/lib/src/models/models.dart | 2 -- 18 files changed, 28 insertions(+), 73 deletions(-) rename lib/src/map/widgets/{google_map_place_details_button.dart => google_map_back_button.dart} (56%) delete mode 100644 lib/src/map/widgets/google_map_props.dart rename packages/{shared => location_repository}/lib/src/models/auto_complete.dart (100%) create mode 100644 packages/location_repository/lib/src/models/models.dart rename packages/{shared => location_repository}/lib/src/models/place_details.dart (95%) diff --git a/lib/src/app/routes/app_router.dart b/lib/src/app/routes/app_router.dart index f7f3f34..8ead1ac 100644 --- a/lib/src/app/routes/app_router.dart +++ b/lib/src/app/routes/app_router.dart @@ -52,10 +52,7 @@ class AppRouter { path: AppRoutes.googleMap.route, name: AppRoutes.googleMap.name, parentNavigatorKey: _rootNavigatorKey, - builder: (context, state) { - final props = state.extra as GoogleMapProps?; - return GoogleMapPage(props: props ?? const GoogleMapProps()); - }, + builder: (context, state) => const GoogleMapPage(), ), GoRoute( path: AppRoutes.orders.route, diff --git a/lib/src/map/bloc/auto_complete_bloc.dart b/lib/src/map/bloc/auto_complete_bloc.dart index 01ded25..f31f71c 100644 --- a/lib/src/map/bloc/auto_complete_bloc.dart +++ b/lib/src/map/bloc/auto_complete_bloc.dart @@ -1,7 +1,6 @@ import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; import 'package:location_repository/location_repository.dart'; -import 'package:shared/shared.dart'; part 'auto_complete_event.dart'; part 'auto_complete_state.dart'; diff --git a/lib/src/map/bloc/map_bloc.dart b/lib/src/map/bloc/map_bloc.dart index 93abc99..8cf82d4 100644 --- a/lib/src/map/bloc/map_bloc.dart +++ b/lib/src/map/bloc/map_bloc.dart @@ -4,7 +4,6 @@ import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:location_repository/location_repository.dart'; -import 'package:shared/shared.dart'; import 'package:user_repository/user_repository.dart'; import 'package:yandex_food_api/client.dart'; diff --git a/lib/src/map/view/google_map_page.dart b/lib/src/map/view/google_map_page.dart index ff62554..26963dc 100644 --- a/lib/src/map/view/google_map_page.dart +++ b/lib/src/map/view/google_map_page.dart @@ -6,14 +6,11 @@ import 'package:google_maps_flutter/google_maps_flutter.dart' show CameraPosition, GoogleMap; import 'package:location_repository/location_repository.dart'; import 'package:shadcn_ui/shadcn_ui.dart'; -import 'package:shared/shared.dart'; import 'package:user_repository/user_repository.dart'; import 'package:yandex_food_delivery_clone/src/map/map.dart'; class GoogleMapPage extends StatelessWidget { - const GoogleMapPage({required this.props, super.key}); - - final GoogleMapProps props; + const GoogleMapPage({super.key}); @override Widget build(BuildContext context) { @@ -22,20 +19,13 @@ class GoogleMapPage extends StatelessWidget { userRepository: context.read(), locationRepository: context.read(), ), - child: GoogleMapView(props: props), + child: const GoogleMapView(), ); } } class GoogleMapView extends StatelessWidget { - const GoogleMapView({ - required this.props, - super.key, - }); - - final GoogleMapProps props; - - PlaceDetails? get placeDetails => props.placeDetails; + const GoogleMapView({super.key}); @override Widget build(BuildContext context) { @@ -46,12 +36,12 @@ class GoogleMapView extends StatelessWidget { value: context.isIOS ? SystemUiOverlayTheme.iOSDarkSystemBarTheme : SystemUiOverlayTheme.androidTransparentDarkSystemBarTheme, - child: Stack( + child: const Stack( children: [ - const MapView(), - const GoogleMapAddressView(), - GoogleMapPlaceDetailsButton(placeDetails: placeDetails), - const GoogleMapSaveLocationButton(), + MapView(), + GoogleMapAddressView(), + GoogleMapBackButton(), + GoogleMapSaveLocationButton(), ], ), ), diff --git a/lib/src/map/widgets/auto_completes_list_view.dart b/lib/src/map/widgets/auto_completes_list_view.dart index 6e36086..680c554 100644 --- a/lib/src/map/widgets/auto_completes_list_view.dart +++ b/lib/src/map/widgets/auto_completes_list_view.dart @@ -3,7 +3,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:location_repository/location_repository.dart'; -import 'package:shared/shared.dart'; import 'package:yandex_food_delivery_clone/src/map/map.dart'; class AutoCompletesListView extends StatelessWidget { diff --git a/lib/src/map/widgets/google_map_address.dart b/lib/src/map/widgets/google_map_address.dart index 0276922..e7db916 100644 --- a/lib/src/map/widgets/google_map_address.dart +++ b/lib/src/map/widgets/google_map_address.dart @@ -2,7 +2,7 @@ import 'package:app_ui/app_ui.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; -import 'package:shared/shared.dart'; +import 'package:location_repository/location_repository.dart'; import 'package:yandex_food_delivery_clone/src/app/app.dart'; import 'package:yandex_food_delivery_clone/src/map/map.dart'; diff --git a/lib/src/map/widgets/google_map_place_details_button.dart b/lib/src/map/widgets/google_map_back_button.dart similarity index 56% rename from lib/src/map/widgets/google_map_place_details_button.dart rename to lib/src/map/widgets/google_map_back_button.dart index 4372053..3522c31 100644 --- a/lib/src/map/widgets/google_map_place_details_button.dart +++ b/lib/src/map/widgets/google_map_back_button.dart @@ -3,13 +3,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:shadcn_ui/shadcn_ui.dart'; -import 'package:shared/shared.dart'; import 'package:yandex_food_delivery_clone/src/map/map.dart'; -class GoogleMapPlaceDetailsButton extends StatelessWidget { - const GoogleMapPlaceDetailsButton({required this.placeDetails, super.key}); - - final PlaceDetails? placeDetails; +class GoogleMapBackButton extends StatelessWidget { + const GoogleMapBackButton({super.key}); @override Widget build(BuildContext context) { @@ -40,29 +37,6 @@ class GoogleMapPlaceDetailsButton extends StatelessWidget { color: AppColors.black, ), ), - const SizedBox( - width: AppSpacing.md, - ), - if (placeDetails != null) - DecoratedBox( - decoration: const BoxDecoration( - color: AppColors.white, - shape: BoxShape.circle, - boxShadow: [ - BoxShadowEffect.defaultValue, - ], - ), - child: AppIcon.button( - icon: LucideIcons.send, - onTap: () { - context.read().add( - MapAnimateToPlaceDetails( - placeDetails: placeDetails, - ), - ); - }, - ), - ), ], ).ignorePointer(isMoving: isCameraMoving), ); diff --git a/lib/src/map/widgets/google_map_props.dart b/lib/src/map/widgets/google_map_props.dart deleted file mode 100644 index b1c7f2e..0000000 --- a/lib/src/map/widgets/google_map_props.dart +++ /dev/null @@ -1,9 +0,0 @@ -import 'package:shared/shared.dart'; - -class GoogleMapProps { - const GoogleMapProps({ - this.placeDetails, - }); - - final PlaceDetails? placeDetails; -} diff --git a/lib/src/map/widgets/google_map_save_location_button.dart b/lib/src/map/widgets/google_map_save_location_button.dart index 38001ef..1771c70 100644 --- a/lib/src/map/widgets/google_map_save_location_button.dart +++ b/lib/src/map/widgets/google_map_save_location_button.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; +import 'package:location_repository/location_repository.dart'; import 'package:shadcn_ui/shadcn_ui.dart'; -import 'package:shared/shared.dart'; import 'package:yandex_food_delivery_clone/src/app/app.dart'; import 'package:yandex_food_delivery_clone/src/map/map.dart'; diff --git a/lib/src/map/widgets/widgets.dart b/lib/src/map/widgets/widgets.dart index 40ba1a4..f0b22fe 100644 --- a/lib/src/map/widgets/widgets.dart +++ b/lib/src/map/widgets/widgets.dart @@ -1,6 +1,5 @@ export 'auto_completes_list_view.dart'; export 'google_map_address.dart'; -export 'google_map_place_details_button.dart'; -export 'google_map_props.dart'; +export 'google_map_back_button.dart'; export 'google_map_save_location_button.dart'; export 'search_location_autocomplete.dart'; diff --git a/packages/location_repository/analysis_options.yaml b/packages/location_repository/analysis_options.yaml index 799268d..fa798a8 100644 --- a/packages/location_repository/analysis_options.yaml +++ b/packages/location_repository/analysis_options.yaml @@ -1 +1,4 @@ include: package:very_good_analysis/analysis_options.5.1.0.yaml +linter: + rules: + public_member_api_docs: false diff --git a/packages/location_repository/lib/location_repository.dart b/packages/location_repository/lib/location_repository.dart index 2c3fa5f..5db254d 100644 --- a/packages/location_repository/lib/location_repository.dart +++ b/packages/location_repository/lib/location_repository.dart @@ -4,3 +4,4 @@ library; export 'package:geolocator/geolocator.dart'; export 'src/location_repository.dart'; +export 'src/models/models.dart'; diff --git a/packages/location_repository/lib/src/location_repository.dart b/packages/location_repository/lib/src/location_repository.dart index 432390b..6bf89fc 100644 --- a/packages/location_repository/lib/src/location_repository.dart +++ b/packages/location_repository/lib/src/location_repository.dart @@ -1,9 +1,8 @@ -// ignore_for_file: public_member_api_docs, avoid_dynamic_calls +// ignore_for_file: avoid_dynamic_calls import 'package:dio/dio.dart'; import 'package:env/env.dart'; -import 'package:geolocator/geolocator.dart'; -import 'package:shared/shared.dart'; +import 'package:location_repository/location_repository.dart'; /// {@template location_exception} /// Exceptions from location repository. diff --git a/packages/shared/lib/src/models/auto_complete.dart b/packages/location_repository/lib/src/models/auto_complete.dart similarity index 100% rename from packages/shared/lib/src/models/auto_complete.dart rename to packages/location_repository/lib/src/models/auto_complete.dart diff --git a/packages/location_repository/lib/src/models/models.dart b/packages/location_repository/lib/src/models/models.dart new file mode 100644 index 0000000..ed907f3 --- /dev/null +++ b/packages/location_repository/lib/src/models/models.dart @@ -0,0 +1,2 @@ +export 'auto_complete.dart'; +export 'place_details.dart'; diff --git a/packages/shared/lib/src/models/place_details.dart b/packages/location_repository/lib/src/models/place_details.dart similarity index 95% rename from packages/shared/lib/src/models/place_details.dart rename to packages/location_repository/lib/src/models/place_details.dart index 3001443..9763e71 100644 --- a/packages/shared/lib/src/models/place_details.dart +++ b/packages/location_repository/lib/src/models/place_details.dart @@ -1,7 +1,5 @@ -import 'package:flutter/material.dart'; import 'package:yandex_food_api/client.dart'; -@immutable class PlaceDetails { const PlaceDetails({ required this.name, diff --git a/packages/location_repository/pubspec.yaml b/packages/location_repository/pubspec.yaml index f29f1c2..6dff0be 100644 --- a/packages/location_repository/pubspec.yaml +++ b/packages/location_repository/pubspec.yaml @@ -7,6 +7,8 @@ environment: sdk: ^3.4.0 dev_dependencies: + build_runner: ^2.4.11 + json_serializable: ^6.8.0 mocktail: ^1.0.3 test: ^1.25.2 very_good_analysis: ^6.0.0 @@ -15,6 +17,10 @@ dependencies: dio: ^5.5.0+1 env: path: ../env + equatable: ^2.0.5 geolocator: ^12.0.0 + json_annotation: ^4.9.0 shared: path: ../shared + yandex_food_api: + path: ../../api diff --git a/packages/shared/lib/src/models/models.dart b/packages/shared/lib/src/models/models.dart index 3862a4e..955b051 100644 --- a/packages/shared/lib/src/models/models.dart +++ b/packages/shared/lib/src/models/models.dart @@ -1,4 +1,2 @@ export 'address.dart'; -export 'auto_complete.dart'; export 'menu_tab_category.dart'; -export 'place_details.dart';