refactor(architecture): centralize bloc files into dedicated folder

This commit is contained in:
anhtunz
2025-01-05 18:56:39 +07:00
parent fb12c44505
commit c2c685da86
37 changed files with 87 additions and 87 deletions

View File

@@ -1,80 +0,0 @@
// ignore_for_file: use_build_context_synchronously
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import '../../product/services/map_services.dart';
import '../../product/shared/shared_snack_bar.dart';
import '../devices/device_model.dart';
import '../../product/base/bloc/base_bloc.dart';
import '../../product/services/api_services.dart';
class MapBloc extends BlocBase {
APIServices apiServices = APIServices();
MapServices mapServices = MapServices();
@override
void dispose() {}
final mapTheme = StreamController<String>.broadcast();
StreamSink<String> get sinkMapTheme => mapTheme.sink;
Stream<String> get streamMapTheme => mapTheme.stream;
final mapType = StreamController<MapType>.broadcast();
StreamSink<MapType> get sinkMapType => mapType.sink;
Stream<MapType> get streamMapType => mapType.stream;
final mapController = StreamController<GoogleMapController>.broadcast();
StreamSink<GoogleMapController> get sinkmapController => mapController.sink;
Stream<GoogleMapController> get streammapController => mapController.stream;
final allDevices = StreamController<List<Device>>.broadcast();
StreamSink<List<Device>> get sinkAllDevices => allDevices.sink;
Stream<List<Device>> get streamAllDevices => allDevices.stream;
final allMarker = StreamController<Set<Marker>>.broadcast();
StreamSink<Set<Marker>> get sinkAllMarker => allMarker.sink;
Stream<Set<Marker>> get streamAllMarker => allMarker.stream;
final polylines = StreamController<List<LatLng>>.broadcast();
StreamSink<List<LatLng>> get sinkPolylines => polylines.sink;
Stream<List<LatLng>> get streamPolylines => polylines.stream;
Future<void> updateCameraPosition(
Completer<GoogleMapController> controller,
double latitude,
double longitude,
double zoom,
) async {
final CameraPosition cameraPosition =
CameraPosition(target: LatLng(latitude, longitude), zoom: zoom);
final GoogleMapController mapController = await controller.future;
mapController.animateCamera(CameraUpdate.newCameraPosition(cameraPosition));
}
Future<void> findTheWay(
BuildContext context,
Completer<GoogleMapController> controller,
LatLng origin,
LatLng destination,
) async {
List<LatLng> polylines = [];
final polylineCoordinates =
await mapServices.findTheWay(origin, destination);
if (polylineCoordinates.isNotEmpty) {
polylines = polylineCoordinates;
sinkPolylines.add(polylines);
await updateCameraPosition(
controller,
destination.latitude,
destination.longitude,
13.0,
);
} else {
showNoIconTopSnackBar(
context, "Không tìm thấy đường", Colors.orange, Colors.white);
}
}
}

View File

@@ -7,7 +7,7 @@ import 'package:geolocator/geolocator.dart';
import 'package:google_maps_cluster_manager_2/google_maps_cluster_manager_2.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:sfm_app/feature/devices/device_model.dart';
import 'package:sfm_app/feature/map/map_bloc.dart';
import 'package:sfm_app/bloc/map_bloc.dart';
import 'package:sfm_app/feature/map/widget/on_tap_marker_widget.dart';
import 'package:sfm_app/product/base/bloc/base_bloc.dart';
import 'package:sfm_app/product/constant/icon/icon_constants.dart';

View File

@@ -7,7 +7,7 @@ import 'show_direction_widget.dart';
import 'show_nearest_place.dart';
import '../../../product/constant/icon/icon_constants.dart';
import '../../../product/extention/context_extention.dart';
import '../map_bloc.dart';
import '../../../bloc/map_bloc.dart';
import '../../../product/services/api_services.dart';
import '../../../product/services/language_services.dart';
import '../../../product/utils/device_utils.dart';

View File

@@ -7,7 +7,7 @@ import 'package:sfm_app/product/constant/icon/icon_constants.dart';
import 'package:sfm_app/product/extention/context_extention.dart';
import 'package:sfm_app/product/services/language_services.dart';
import '../map_bloc.dart';
import '../../../bloc/map_bloc.dart';
showDirections(
BuildContext context,

View File

@@ -4,7 +4,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import '../map_bloc.dart';
import '../../../bloc/map_bloc.dart';
import 'show_direction_widget.dart';
import '../../../product/constant/icon/icon_constants.dart';
import '../../../product/extention/context_extention.dart';