Skip to content

Commit

Permalink
chore: moved PlaceDetails & AutoComplete in `location_repository.…
Browse files Browse the repository at this point in the history
…dart`
  • Loading branch information
Gambley1 committed Aug 11, 2024
1 parent 1bbe8e4 commit f4e9bdf
Show file tree
Hide file tree
Showing 18 changed files with 28 additions and 73 deletions.
5 changes: 1 addition & 4 deletions lib/src/app/routes/app_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion lib/src/map/bloc/auto_complete_bloc.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
1 change: 0 additions & 1 deletion lib/src/map/bloc/map_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
26 changes: 8 additions & 18 deletions lib/src/map/view/google_map_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -22,20 +19,13 @@ class GoogleMapPage extends StatelessWidget {
userRepository: context.read<UserRepository>(),
locationRepository: context.read<LocationRepository>(),
),
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) {
Expand All @@ -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(),
],
),
),
Expand Down
1 change: 0 additions & 1 deletion lib/src/map/widgets/auto_completes_list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/map/widgets/google_map_address.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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<MapBloc>().add(
MapAnimateToPlaceDetails(
placeDetails: placeDetails,
),
);
},
),
),
],
).ignorePointer(isMoving: isCameraMoving),
);
Expand Down
9 changes: 0 additions & 9 deletions lib/src/map/widgets/google_map_props.dart

This file was deleted.

2 changes: 1 addition & 1 deletion lib/src/map/widgets/google_map_save_location_button.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
3 changes: 1 addition & 2 deletions lib/src/map/widgets/widgets.dart
Original file line number Diff line number Diff line change
@@ -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';
3 changes: 3 additions & 0 deletions packages/location_repository/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
include: package:very_good_analysis/analysis_options.5.1.0.yaml
linter:
rules:
public_member_api_docs: false
1 change: 1 addition & 0 deletions packages/location_repository/lib/location_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ library;
export 'package:geolocator/geolocator.dart';

export 'src/location_repository.dart';
export 'src/models/models.dart';
5 changes: 2 additions & 3 deletions packages/location_repository/lib/src/location_repository.dart
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 2 additions & 0 deletions packages/location_repository/lib/src/models/models.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export 'auto_complete.dart';
export 'place_details.dart';
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import 'package:flutter/material.dart';
import 'package:yandex_food_api/client.dart';

@immutable
class PlaceDetails {
const PlaceDetails({
required this.name,
Expand Down
6 changes: 6 additions & 0 deletions packages/location_repository/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 0 additions & 2 deletions packages/shared/lib/src/models/models.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
export 'address.dart';
export 'auto_complete.dart';
export 'menu_tab_category.dart';
export 'place_details.dart';

0 comments on commit f4e9bdf

Please sign in to comment.