bug fixes

This commit is contained in:
2026-08-29 00:00:09 +03:00
parent 6513a004d9
commit a556dc5736
15 changed files with 361 additions and 271 deletions

View File

@@ -498,6 +498,35 @@ class ApiService {
}
}
Future<ZonesResponse?> getAllZones({
int page = 1,
int pageSize = 500,
}) async {
const path = "$baseUrl/zone/available2";
final queryParams = {
'readAll': 'true',
'page': page,
'pageSize': pageSize,
};
try {
final response = await _dio.get(
path,
queryParameters: queryParams,
options: await _getAuthOptions(),
);
if (response.statusCode == 200) {
return ZonesResponse.fromJson(response.data);
}
return null;
} catch (e) {
print("ERROR: getZones failed: $e");
return null;
}
}
Future<TariffsResponse?> getAvailableTariffs({required int scooterId}) async {
final url = "$baseUrl/scooterplan/$scooterId/available";

View File

@@ -10,60 +10,60 @@ class ZoneRepositoryImpl extends ZoneRepository {
ZoneRepositoryImpl(this._apiService);
@override
Future<List<Zone>> getZones(List<double> area,
int page,
int pageSize,) async {
Future<List<Zone>> getZones(List<double> area, int page, int pageSize) async {
final List<Point> list = [];
final List<Point> list2 = [];
/*list.add(Point(55.182372,30.203347));
list.add(Point(55.173746,30.200257));
list.add(Point(55.172153,30.212531));
list.add(Point(55.179946,30.215964));
list2.add(Point(55.178304,30.227380));
list2.add(Point(55.178059,30.229654));
list2.add(Point(55.191339,30.234718));
list2.add(Point(55.194352,30.234890));
list2.add(Point(55.194377,30.231972));
list2.add(Point(55.192123,30.232744));
final zone = Zone(id: 123,
title: "Zone 01",
description: "description",
type: "Finish",
isActive: true,
shapeType: "polygon",
points: list,
speedLimit: "speedLimit");
final zone2 = Zone(id: 124,
title: "Zone 02",
description: "description",
type: "NotDrive",
isActive: true,
shapeType: "polygon",
points: list2,
speedLimit: "speedLimit");
*/
final responce = await _apiService.getZones(
area: area,
page: page,
pageSize: pageSize,
);
final List<Zone>? zones = responce?.zones;
// zones?.add(zone);
// zones?.add(zone2);
print("Scooters: ${zones?.first.title}");
if (responce != null) {
return zones ?? List.empty();
if (responce == null) {
throw Exception(
'Failed to load zones for area: empty response from server',
);
}
return List.empty();
final zones = responce.zones;
print("Zones: ${zones.length}");
return zones;
}
@override
Future<List<Zone>> getAllZones(int page, int pageSize) async {
final List<Point> list = [];
final List<Point> list2 = [];
final responce = await _apiService.getAllZones(
page: page,
pageSize: pageSize,
);
// apiService.getAllZones ловит свои ошибки (сеть/401/5xx) и в этом
// случае возвращает null. Раньше это тихо превращалось в "зон нет" —
// из-за чего сбой запроса выглядел как легитимный пустой ответ и
// (в связке с кешем на уровне MapBloc) навсегда "прятал" зоны на
// время сессии. Бросаем исключение, чтобы вызывающий код (usecase/bloc)
// мог отличить реальный сбой от честного "зон действительно нет"
// и, при необходимости, повторить запрос.
if (responce == null) {
throw Exception('Failed to load zones: empty response from server');
}
final zones = responce.zones;
print(zones.map((z) => '${z.type}:${z.id}'));
for (final z in zones) {
print("Zone ${z.type}:${z.id} geometry.length=${z.geometry.length}");
}
print("Zones: ${zones.length}");
return zones;
}
}

View File

@@ -18,6 +18,7 @@ import 'package:be_happy/domain/repositories/zone_repository.dart';
import 'package:be_happy/domain/service/security_service.dart';
import 'package:be_happy/domain/usecase/add_payment_card_usecase.dart'; // ← новый
import 'package:be_happy/domain/usecase/delete_profile_usecase.dart';
import 'package:be_happy/domain/usecase/get_all_zones_usecase.dart';
import 'package:be_happy/domain/usecase/get_certificates_usecase.dart';
import 'package:be_happy/domain/usecase/get_scooter_order_route_history_usecase.dart';
import 'package:be_happy/domain/usecase/is_pin_set_usecase.dart';
@@ -239,6 +240,9 @@ Future<void> setupDependencies() async {
getIt.registerSingleton<GetAvailableZonesUsecase>(
GetAvailableZonesUsecase(getIt()),
);
getIt.registerSingleton<GetAllZonesUsecase>(
GetAllZonesUsecase(getIt()),
);
getIt.registerSingleton<GetMapSettingsUsecase>(
GetMapSettingsUsecase(getIt()),
);

View File

@@ -2,7 +2,6 @@ class Tariff {
final int id;
final String title;
final String description;
final String descriptionJson;
final bool isActive;
final String currency;
final double holdPrice; // Старт / бронь
@@ -16,7 +15,6 @@ class Tariff {
required this.id,
required this.title,
required this.description,
required this.descriptionJson,
required this.isActive,
required this.currency,
required this.holdPrice,
@@ -35,7 +33,6 @@ class Tariff {
id: json['id'] ?? 0,
title: json['title'] ?? 'Unknown',
description: json['description'] ?? '',
descriptionJson: json['descriptionJson'] ?? '',
isActive: json['isActive'] ?? false,
currency: currency['currency'] ?? 'BYN',
holdPrice: (planPrice['hold'] as num?)?.toDouble() ?? 0.0,

View File

@@ -1,4 +1,6 @@
import 'dart:convert';
import 'package:be_happy/domain/entities/point.dart';
class Zone {
@@ -8,9 +10,6 @@ class Zone {
final String type;
final bool isActive;
final String shapeType;
// Трехмерная структура для поддержки MultiPolygon и дыр (holes):
// geometry[индекс_полигона][индекс_кольца][индекс_точки]
// индекс_кольца == 0 — внешняя граница, > 0 — внутренние вырезы (дыры)
final List<List<List<Point>>> geometry;
final String speedLimit;
@@ -25,7 +24,6 @@ class Zone {
required this.speedLimit,
});
// Геттер для обратной совместимости (возвращает внешнее кольцо первого полигона)
List<Point> get points {
if (geometry.isNotEmpty && geometry[0].isNotEmpty) {
return geometry[0][0];
@@ -45,77 +43,64 @@ class Zone {
if (decoded is List && decoded.isNotEmpty) {
if (shapeType == 'Polygon') {
// Структура: [[[lon, lat], [lon, lat], ...], [hole1], ...]
List<List<Point>> polygonRings = [];
for (var ring in decoded) {
if (ring is List) {
List<Point> ringPoints = [];
for (var coord in ring) {
if (coord is List && coord.length >= 2) {
// В GeoJSON сначала идет Longitude, затем Latitude
ringPoints.add(Point(
(coord[1] as num).toDouble(),
(coord[0] as num).toDouble(),
));
}
}
if (ringPoints.isNotEmpty) polygonRings.add(ringPoints);
}
}
final polygonRings = _parseRings(decoded);
if (polygonRings.isNotEmpty) parsedGeometry.add(polygonRings);
} else if (shapeType == 'MultiPolygon') {
// Структура: [[[[lon, lat], ...]], [[[lon, lat], ...]]]
for (var poly in decoded) {
if (poly is List) {
List<List<Point>> polygonRings = [];
for (var ring in poly) {
if (ring is List) {
List<Point> ringPoints = [];
for (var coord in ring) {
if (coord is List && coord.length >= 2) {
ringPoints.add(Point(
(coord[1] as num).toDouble(),
(coord[0] as num).toDouble(),
));
}
}
if (ringPoints.isNotEmpty) polygonRings.add(ringPoints);
}
}
final polygonRings = _parseRings(poly);
if (polygonRings.isNotEmpty) parsedGeometry.add(polygonRings);
}
}
} else {
// Fallback для LineString или плоских списков
List<Point> ringPoints = [];
for (var coord in decoded) {
if (coord is List && coord.length >= 2) {
ringPoints.add(Point(
(coord[1] as num).toDouble(),
(coord[0] as num).toDouble(),
));
}
}
if (ringPoints.isNotEmpty) parsedGeometry.add([ringPoints]);
final singleRing = _parseCoordinateList(decoded);
if (singleRing.isNotEmpty) parsedGeometry.add([singleRing]);
}
}
} catch (e) {
print("PARSE ERROR for Zone ID ${json['id']}: $e");
} catch (e, stackTrace) {
// Replace with your project logger (e.g., debugPrint or Logger)
assert(() {
print("PARSE ERROR for Zone ID ${json['id']}: $e\n$stackTrace");
return true;
}());
}
return Zone(
id: json['id'] ?? 0,
title: json['title'] ?? 'Unknown',
description: json['description'] ?? '',
type: json['type'] ?? '',
isActive: json['isActive'] ?? false,
speedLimit: json['speedLimit'] ?? '',
id: json['id'] as int? ?? 0,
title: json['title'] as String? ?? 'Unknown',
description: json['description'] as String? ?? '',
type: json['type'] as String? ?? '',
isActive: json['isActive'] as bool? ?? false,
speedLimit: json['speedLimit'] as String? ?? '',
shapeType: shapeType,
geometry: parsedGeometry,
);
}
static List<List<Point>> _parseRings(List rawRings) {
List<List<Point>> polygonRings = [];
for (var ring in rawRings) {
if (ring is List) {
final ringPoints = _parseCoordinateList(ring);
if (ringPoints.isNotEmpty) polygonRings.add(ringPoints);
}
}
return polygonRings;
}
static List<Point> _parseCoordinateList(List rawCoords) {
List<Point> ringPoints = [];
for (var coord in rawCoords) {
if (coord is List && coord.length >= 2) {
ringPoints.add(Point(
(coord[1] as num).toDouble(),
(coord[0] as num).toDouble(),
));
}
}
return ringPoints;
}
@override
String toString() {
return 'Zone{id: $id, title: $title, type: $type, polygonsCount: ${geometry.length}}';

View File

@@ -2,5 +2,6 @@ import '../entities/zone.dart';
abstract class ZoneRepository {
Future<List<Zone>> getZones(List<double> area, int page, int pageSize);
Future<List<Zone>> getAllZones(int page, int pageSize);
}

View File

@@ -0,0 +1,30 @@
import '../entities/zone.dart';
import '../repositories/zone_repository.dart';
class GetAllZonesUsecase {
final ZoneRepository repository;
GetAllZonesUsecase(this.repository);
static const int _pageSize = 100;
Future<List<Zone>> call() async {
final List<Zone> allZones = [];
int page = 0;
while (true) {
final zones = await repository.getAllZones(page, _pageSize);
if (zones == null || zones.isEmpty) break;
allZones.addAll(zones);
// если пришло меньше, чем размер страницы — это последняя страница
if (zones.length < _pageSize) break;
page++;
}
return allZones;
}
}

View File

@@ -240,7 +240,7 @@ class _ScooterCard extends StatelessWidget {
showArrows: true,
height: 32,
width: double.infinity,
fontSize: 12,
fontSize: 11,
onTap: () {
context.go('/home/scooter/${scooter.id}', extra: [address, scooter.distance]);
},

View File

@@ -123,8 +123,7 @@ class _TariffInfoSheetState extends State<TariffInfoSheet> {
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: ContentParser.parseContent(
textJson: widget.tariff.description,
text: widget.tariff.descriptionJson,
text: widget.tariff.description,
),
),
const SizedBox(height: 30),

View File

@@ -265,7 +265,7 @@ class _TariffSheetState extends State<TariffSheet> {
const SizedBox(height: 20),
SizedBox(
height: 150,
height: 160,
child: ListView.builder(
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.only(left: 20),

View File

@@ -19,7 +19,7 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
},
{
'image': 'assets/onboard_2.jpg',
'title': 'Отсканируйте QR-код или введите номер который указан под козлом',
'title': 'Отсканируйте QR-код или введите номер который указан под кодом',
},
{
'image': 'assets/onboard_3.png',

View File

@@ -37,7 +37,6 @@ class _ProfileScreenState extends State<ProfileScreen> {
context.read<ProfileBloc>().add(
ProfilePhotoUpdated(File(pickedImage.path)),
);
} catch (e) {
print("Error picking or uploading image: $e");
}
@@ -63,9 +62,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
Widget build(BuildContext context) {
return Scaffold(
body: Container(
decoration: const BoxDecoration(
gradient: AppColors.phoneScreenBg,
),
decoration: const BoxDecoration(gradient: AppColors.phoneScreenBg),
child: SafeArea(
child: BlocBuilder<ProfileBloc, ProfileState>(
builder: (context, state) {
@@ -88,82 +85,91 @@ class _ProfileScreenState extends State<ProfileScreen> {
return LayoutBuilder(
builder: (context, constraints) {
return SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: constraints.maxHeight,
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
children: [
const SizedBox(height: 16),
CustomAppBar(title: 'Профиль'),
const SizedBox(height: 32),
return Column(
children: [
Expanded(
child: SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: constraints.maxHeight,
),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20,
),
child: Column(
children: [
const SizedBox(height: 16),
CustomAppBar(title: 'Профиль'),
const SizedBox(height: 32),
Stack(
alignment: Alignment.topRight,
children: [
CircleAvatar(
radius: 60,
backgroundColor: AppColors.checkboxFill,
backgroundImage:
(profile.avatarUrl != null &&
profile.avatarUrl!.isNotEmpty)
? NetworkImage(
"${profile.avatarUrl!}?v=${DateTime.now().minute}",
)
: null,
child:
(profile.avatarUrl == null ||
profile.avatarUrl!.isEmpty)
? Text(
profile.name.isNotEmpty
? profile.name[0].toUpperCase()
: '',
style: const TextStyle(
fontSize: 50,
color: AppColors.darkBlue,
),
)
: null,
),
Stack(
alignment: Alignment.topRight,
children: [
CircleAvatar(
radius: 60,
backgroundColor: AppColors.checkboxFill,
backgroundImage:
(profile.avatarUrl != null &&
profile.avatarUrl!.isNotEmpty)
? NetworkImage(
"${profile.avatarUrl!}?v=${DateTime.now().minute}",
)
: null,
child:
(profile.avatarUrl == null ||
profile.avatarUrl!.isEmpty)
? Text(
profile.name.isNotEmpty
? profile.name[0]
.toUpperCase()
: '',
style: const TextStyle(
fontSize: 50,
color: AppColors.darkBlue,
),
)
: null,
),
GestureDetector(
onTap: _pickImage,
child: Container(
child: Image.asset(
'assets/icons/edit.png',
width: 24,
height: 24,
),
GestureDetector(
onTap: _pickImage,
child: Container(
child: Image.asset(
'assets/icons/edit.png',
width: 24,
height: 24,
),
),
),
],
),
),
],
),
const SizedBox(height: 32),
const SizedBox(height: 32),
_ProfileInfoBlock(
profile: profile,
onEditTap: () => context.go("/home/profile/edit"),
),
Padding(
padding: const EdgeInsets.all(20),
child: GradientButton(
text: 'Удалить учётную запись',
onTap: () => _confirmDeleteAccount(context),
showArrows: true,
height: 56,
width: double.infinity,
fontSize: 16,
_ProfileInfoBlock(
profile: profile,
onEditTap: () =>
context.go("/home/profile/edit"),
),
],
),
),
],
),
),
),
),
Padding(
padding: const EdgeInsets.all(20),
child: GradientButton(
text: 'Удалить учётную запись',
onTap: () => _confirmDeleteAccount(context),
showArrows: true,
height: 56,
width: double.infinity,
fontSize: 16,
),
),
],
);
},
);
@@ -388,4 +394,4 @@ class _SettingsBlock extends StatelessWidget {
),
);
}
}
}

View File

@@ -116,13 +116,19 @@ class _SendPhotoViewState extends State<SendPhotoView> {
@override
Widget build(BuildContext context) {
final isUploading = context.select(
(SendPhotoBloc bloc) => bloc.state.status == SendPhotoStatus.loading,
);
return Scaffold(
body: Container(
width: double.infinity,
decoration: const BoxDecoration(gradient: AppColors.phoneScreenBg),
child: SafeArea(
child: Column(
children: [
body: Stack(
children: [
Container(
width: double.infinity,
decoration: const BoxDecoration(gradient: AppColors.phoneScreenBg),
child: SafeArea(
child: Column(
children: [
const SizedBox(height: 16),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
@@ -190,7 +196,8 @@ class _SendPhotoViewState extends State<SendPhotoView> {
},
builder: (context, state) {
final photoCount = state.selectedImages.length;
final isEnabled = photoCount >= 2;
final isEnabled = photoCount >= 2 &&
state.status != SendPhotoStatus.loading;
return GradientButton(
text: 'Отправить',
@@ -210,9 +217,40 @@ class _SendPhotoViewState extends State<SendPhotoView> {
),
),
),
],
],
),
),
),
),
// Оверлей загрузки: показывается, пока фото отправляются на сервер
if (isUploading)
Positioned.fill(
child: AbsorbPointer(
absorbing: true,
child: Container(
color: Colors.black.withOpacity(0.45),
child: const Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
CircularProgressIndicator(
color: Color(0xFF8BFFAA),
),
SizedBox(height: 16),
Text(
'Загружаем фото...',
style: TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
],
),
),
),
),
),
],
),
);
}

View File

@@ -4,7 +4,7 @@ import 'package:be_happy/core/result.dart';
import 'package:be_happy/domain/entities/client_notification.dart';
import 'package:be_happy/domain/entities/map_settings.dart';
import 'package:be_happy/domain/usecase/check_user_usecase.dart';
import 'package:be_happy/domain/usecase/get_available_zones_usecase.dart';
import 'package:be_happy/domain/usecase/get_all_zones_usecase.dart';
import 'package:be_happy/domain/usecase/get_client_orders_usecase.dart';
import 'package:be_happy/domain/usecase/get_map_settings_usecase.dart';
import 'package:be_happy/domain/usecase/get_notifications_stream_usecase.dart';
@@ -26,7 +26,7 @@ import 'package:maps_toolkit/maps_toolkit.dart' as mt;
class MapBloc extends Bloc<ScooterEvent, ScooterState> {
final GetAvailableScootersUsecase getScootersUsecase;
final GetClientOrdersUsecase getClientOrdersUsecase;
final GetAvailableZonesUsecase getAvailableZonesUsecase;
final GetAllZonesUsecase getAllZonesUsecase;
final GetMapSettingsUsecase getMapSettingsUsecase;
final GetNotificationsStreamUseCase getNotificationsStreamUseCase;
final GetProfileUseCase getProfileUseCase;
@@ -35,17 +35,19 @@ class MapBloc extends Bloc<ScooterEvent, ScooterState> {
final SplashBloc splashBloc;
StreamSubscription<ClientNotification>? _notificationSubscription;
Future<List<Zone>>? _zonesFuture;
MapBloc(
this.getAvailableZonesUsecase,
this.getScootersUsecase,
this.getClientOrdersUsecase,
this.getMapSettingsUsecase,
this.getNotificationsStreamUseCase,
this.getProfileUseCase,
this.checkUserUseCase,
this.logoutUseCase,
this.splashBloc,
) : super(ScooterState(isGeomarksShowed: true)) {
this.getAllZonesUsecase,
this.getScootersUsecase,
this.getClientOrdersUsecase,
this.getMapSettingsUsecase,
this.getNotificationsStreamUseCase,
this.getProfileUseCase,
this.checkUserUseCase,
this.logoutUseCase,
this.splashBloc,
) : super(ScooterState(isGeomarksShowed: true)) {
on<FetchScooters>(_onFetchScooters);
on<UpdateMap>(_onUpdateMap);
on<UpdateUserLocation>(_onUpdateUserLocation);
@@ -58,11 +60,43 @@ class MapBloc extends Bloc<ScooterEvent, ScooterState> {
on<ClearMapFocus>(_onClearMapFocus);
}
Future<List<Zone>> _getZones() async {
_zonesFuture ??= getAllZonesUsecase();
try {
return await _zonesFuture!;
} catch (e) {
// Не кешируем неудачную попытку — иначе сбой первого запроса
// (сеть/авторизация) навсегда "выключает" зоны до перезапуска
// приложения. Следующий FetchScooters/UpdateMap попробует заново.
_zonesFuture = null;
rethrow;
}
}
List<Zone> _filterZones(List<Zone> zones, MapSettings settings) {
List<Zone> filteredZones = [];
if (settings.all_zones) {
if (settings.parking_zones) {
filteredZones.addAll(zones.where((el) => el.type == "Finish"));
}
if (settings.restricted_parking_zones) {
filteredZones.addAll(zones.where((el) => el.type == "Drive"));
}
if (settings.restricted_driving_zones) {
filteredZones.addAll(zones.where((el) => el.type == "NotDrive"));
}
}
return filteredZones;
}
void startNotificationStream() {
_notificationSubscription?.cancel();
_notificationSubscription = getNotificationsStreamUseCase().listen(
(notification) {
(notification) {
add(NotificationReceived(notification));
},
onError: (error) {
@@ -94,15 +128,15 @@ class MapBloc extends Bloc<ScooterEvent, ScooterState> {
}
Future<void> _onFetchScooters(
FetchScooters event,
Emitter<ScooterState> emit,
) async {
FetchScooters event,
Emitter<ScooterState> emit,
) async {
emit(state.copyWith(status: ScooterStatus.loading));
try {
final results = await Future.wait([
getScootersUsecase(event.areaScooters, 0, 100),
getAvailableZonesUsecase(event.area, 0, 100),
_getZones(),
getMapSettingsUsecase(),
getClientOrdersUsecase(),
]);
@@ -112,23 +146,7 @@ class MapBloc extends Bloc<ScooterEvent, ScooterState> {
final settings = results[2] as MapSettings;
final orders = results[3];
zones.forEach(print);
List<Zone> filteredZones = [];
if (settings.all_zones) {
if (settings.parking_zones) {
filteredZones.addAll(zones.where((el) => el.type == "Finish"));
}
if (settings.restricted_parking_zones) {
filteredZones.addAll(zones.where((el) => el.type == "Drive"));
}
if (settings.restricted_driving_zones) {
filteredZones.addAll(zones.where((el) => el.type == "NotDrive"));
}
}
final filteredZones = _filterZones(zones, settings);
print(
" FETCH: filteredZones.length = ${filteredZones.length}, all_zones=${settings.all_zones}",
@@ -162,7 +180,7 @@ class MapBloc extends Bloc<ScooterEvent, ScooterState> {
try {
final results = await Future.wait([
getScootersUsecase(state.areaScooters, 0, 100),
getAvailableZonesUsecase(state.area, 0, 100),
_getZones(),
getMapSettingsUsecase(),
]);
@@ -170,33 +188,17 @@ class MapBloc extends Bloc<ScooterEvent, ScooterState> {
final zones = results[1] as List<Zone>;
final settings = results[2] as MapSettings;
List<Zone> filteredZones = [];
if (settings.all_zones) {
if (settings.parking_zones) {
filteredZones.addAll(zones.where((el) => el.type == "Finish"));
}
if (settings.restricted_parking_zones) {
filteredZones.addAll(zones.where((el) => el.type == "Drive"));
}
if (settings.restricted_driving_zones) {
filteredZones.addAll(zones.where((el) => el.type == "NotDrive"));
}
}
final filteredZones = _filterZones(zones, settings);
print(
" UPDATE MAP: filteredZones.length = ${filteredZones.length}, all_zones=${settings.all_zones}",
);
final zonesToEmit = filteredZones.isNotEmpty
? filteredZones
: state.zones;
emit(
state.copyWith(
status: ScooterStatus.success,
scooters: scooters,
zones: zonesToEmit,
zones: filteredZones,
isGeomarksShowed: settings.all_placemarks,
),
);
@@ -212,9 +214,9 @@ class MapBloc extends Bloc<ScooterEvent, ScooterState> {
}
FutureOr<void> _onUpdateUserLocation(
UpdateUserLocation event,
Emitter<ScooterState> emit,
) {
UpdateUserLocation event,
Emitter<ScooterState> emit,
) {
print("USER LOCATION UPDATED EVENT start");
state.zones.forEach((z) {
if (checkUserInZone(Point(event.latitude, event.longitude), z.points)) {
@@ -224,9 +226,9 @@ class MapBloc extends Bloc<ScooterEvent, ScooterState> {
}
FutureOr<void> _onNotificationReceived(
NotificationReceived event,
Emitter<ScooterState> emit,
) {
NotificationReceived event,
Emitter<ScooterState> emit,
) {
print("NOTIFICATION RECEIVED: ${event.notification.content}");
emit(state.copyWith(lastNotification: event.notification));
}
@@ -242,9 +244,9 @@ class MapBloc extends Bloc<ScooterEvent, ScooterState> {
}
FutureOr<void> _onFetchProfileData(
FetchProfileData event,
Emitter<ScooterState> emit,
) async {
FetchProfileData event,
Emitter<ScooterState> emit,
) async {
try {
final profile = await getProfileUseCase();
@@ -262,18 +264,19 @@ class MapBloc extends Bloc<ScooterEvent, ScooterState> {
}
FutureOr<void> _onLogoutPressed(
LogoutPressed event,
Emitter<ScooterState> emit,
) async {
LogoutPressed event,
Emitter<ScooterState> emit,
) async {
await logoutUseCase();
stopNotificationStream();
_zonesFuture = null;
splashBloc.add(AuthLogoutRequested());
}
FutureOr<void> _onCheckUser(
CheckUser event,
Emitter<ScooterState> emit,
) async {
CheckUser event,
Emitter<ScooterState> emit,
) async {
try {
final flags = await checkUserUseCase();
@@ -341,6 +344,4 @@ class MapBloc extends Bloc<ScooterEvent, ScooterState> {
selectedScooterForFocus: null,
));
}
}
}