sync changes
This commit is contained in:
@@ -36,7 +36,6 @@ class _ActiveRideSheetState extends State<ActiveRideSheet> {
|
||||
_bloc = getIt<ActiveRideBloc>();
|
||||
_bloc.add(LoadScooterOrder(widget.orderId));
|
||||
|
||||
// Локальный таймер для обновления UI каждую секунду
|
||||
_localTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||
if (mounted && !_bloc.state.isPaused) {
|
||||
setState(() {});
|
||||
@@ -60,7 +59,6 @@ class _ActiveRideSheetState extends State<ActiveRideSheet> {
|
||||
listener: (context, state) {
|
||||
if (!state.inZone) {
|
||||
BotToast.showCustomNotification(
|
||||
// duration: const Duration(seconds: 4),
|
||||
|
||||
toastBuilder: (_) {
|
||||
return NotificationToast(
|
||||
@@ -125,8 +123,7 @@ class _ActiveRideSheetState extends State<ActiveRideSheet> {
|
||||
? state.elapsedTime
|
||||
: state.elapsedTime + (DateTime.now().difference(DateTime.now().subtract(const Duration(seconds: 1))));
|
||||
|
||||
// Для отображения текущего времени в реальном времени
|
||||
final effectiveElapsedTime = state.isPaused
|
||||
final effectiveElapsedTime = state.isPaused
|
||||
? state.elapsedTime
|
||||
: DateTime.now().difference(state.order?.startAt ?? state.order?.createdAt ?? DateTime.now());
|
||||
|
||||
@@ -189,7 +186,6 @@ class _ActiveRideSheetState extends State<ActiveRideSheet> {
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// 🔹 ТАЙМЕР
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.symmetric(horizontal: 20),
|
||||
|
||||
@@ -5,15 +5,23 @@ import 'package:flutter/cupertino.dart';
|
||||
|
||||
class TariffInfoSheet extends StatefulWidget {
|
||||
final Tariff tariff;
|
||||
final bool isInsurance;
|
||||
final Function(bool) onChanged;
|
||||
|
||||
const TariffInfoSheet({super.key, required this.tariff});
|
||||
const TariffInfoSheet({super.key, required this.tariff, required this.isInsurance, required this.onChanged});
|
||||
|
||||
@override
|
||||
State<TariffInfoSheet> createState() => _TariffInfoSheetState();
|
||||
}
|
||||
|
||||
class _TariffInfoSheetState extends State<TariffInfoSheet> {
|
||||
bool _isInsuranceEnabled = true;
|
||||
late bool _isInsuranceEnabled;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_isInsuranceEnabled = widget.isInsurance;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -80,7 +88,6 @@ class _TariffInfoSheetState extends State<TariffInfoSheet> {
|
||||
|
||||
const Divider(color: Colors.white24, height: 40),
|
||||
|
||||
// Страховка
|
||||
Row(
|
||||
children: [
|
||||
const Text(
|
||||
@@ -100,7 +107,10 @@ class _TariffInfoSheetState extends State<TariffInfoSheet> {
|
||||
child: CupertinoSwitch(
|
||||
value: _isInsuranceEnabled,
|
||||
activeColor: const Color(0xFF66E3C4),
|
||||
onChanged: (val) => setState(() => _isInsuranceEnabled = val),
|
||||
onChanged: (val) {
|
||||
setState(() => _isInsuranceEnabled = val);
|
||||
widget.onChanged(val);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -108,7 +118,6 @@ class _TariffInfoSheetState extends State<TariffInfoSheet> {
|
||||
|
||||
const Divider(color: Colors.white24, height: 40),
|
||||
|
||||
// Список правил (Bullet points)
|
||||
_buildInfoBullet('Оплата страховки осуществляется только по банковской карте отдельным платежом'),
|
||||
_buildInfoBullet('В режиме паузы время тарифа приостанавливается'),
|
||||
_buildInfoBullet('При старте заказа будет заблокирована сумма в размере 7 рублей для проверки платежеспособности. Сумма разблокируется по факту списания средств за поездку.'),
|
||||
|
||||
@@ -30,7 +30,6 @@ class TariffSheet extends StatefulWidget {
|
||||
|
||||
class _TariffSheetState extends State<TariffSheet> {
|
||||
int? _selectedTariffIndex;
|
||||
bool _hasPaymentCard = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -40,7 +39,27 @@ class _TariffSheetState extends State<TariffSheet> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<TariffSheetBloc, TariffSheetState>(
|
||||
return BlocConsumer<TariffSheetBloc, TariffSheetState>(
|
||||
listener: (context, state) {
|
||||
if (state.status == TariffSheetStatus.failure && state.errorMessage != null) {
|
||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
state.errorMessage!,
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
backgroundColor: Colors.redAccent.withOpacity(0.9),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
margin: const EdgeInsets.all(20),
|
||||
duration: const Duration(seconds: 3),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
if (state.status == TariffSheetStatus.loading) {
|
||||
return Align(
|
||||
@@ -193,7 +212,7 @@ class _TariffSheetState extends State<TariffSheet> {
|
||||
bottom: 0,
|
||||
child: Center(
|
||||
child: Text(
|
||||
'${widget.scooter.batteryLevel.toInt()}%', // ✅ Цифры
|
||||
'${widget.scooter.batteryLevel.toInt()}%',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 10,
|
||||
@@ -245,6 +264,7 @@ class _TariffSheetState extends State<TariffSheet> {
|
||||
'Минута на паузе ${tariff.pausePrice.toStringAsFixed(0)} ${tariff.currency}',
|
||||
],
|
||||
isSelected: _selectedTariffIndex == index,
|
||||
isInsurance: state.isInsurance,
|
||||
tariff: tariff,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
@@ -380,7 +400,7 @@ class _TariffSheetState extends State<TariffSheet> {
|
||||
0,
|
||||
state.useBalance ? null : state.selectedCard?.id,
|
||||
state.useBalance,
|
||||
false
|
||||
state.isInsurance
|
||||
)
|
||||
);
|
||||
context.pushReplacement('/home/current-rides-sheet');
|
||||
@@ -421,6 +441,7 @@ class _TariffCard extends StatelessWidget {
|
||||
final String currency;
|
||||
final String subtitle;
|
||||
final List<String> details;
|
||||
final bool isInsurance;
|
||||
final bool isSelected;
|
||||
final VoidCallback onTap;
|
||||
|
||||
@@ -432,6 +453,7 @@ class _TariffCard extends StatelessWidget {
|
||||
required this.subtitle,
|
||||
required this.details,
|
||||
required this.isSelected,
|
||||
required this.isInsurance,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@@ -448,14 +470,11 @@ class _TariffCard extends StatelessWidget {
|
||||
: Colors.white.withOpacity(0.19),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
// Используем Stack, чтобы наложить кнопку поверх контента
|
||||
child: Stack(
|
||||
children: [
|
||||
// Основной контент карточки
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Заголовок с иконкой часов
|
||||
Row(
|
||||
children: [
|
||||
const Icon(
|
||||
@@ -531,8 +550,16 @@ class _TariffCard extends StatelessWidget {
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
builder: (context) => TariffInfoSheet(tariff: tariff),
|
||||
builder: (context) => TariffInfoSheet(
|
||||
tariff: tariff,
|
||||
isInsurance: isInsurance,
|
||||
onChanged: (val) {
|
||||
context.read<TariffSheetBloc>().add(InsuranceToggled(val));
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
|
||||
print('Info pressed for $title');
|
||||
},
|
||||
child: Image.asset(
|
||||
|
||||
@@ -14,6 +14,11 @@ class PaymentCardChanged extends TariffSheetEvent {
|
||||
PaymentCardChanged(this.card);
|
||||
}
|
||||
|
||||
class InsuranceToggled extends TariffSheetEvent {
|
||||
final bool isEnabled;
|
||||
InsuranceToggled(this.isEnabled);
|
||||
}
|
||||
|
||||
class SelectBalancePressed extends TariffSheetEvent {}
|
||||
|
||||
class BookScooterPressed extends TariffSheetEvent {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:be_happy/presentation/viewmodel/payment_methods_bloc.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
@@ -6,6 +7,7 @@ import '../../core/app_colors.dart';
|
||||
import '../components/custom_app_bar.dart';
|
||||
import '../components/card_input_field.dart'; // ← новый импорт
|
||||
import '../components/utils/card_formatter.dart';
|
||||
import '../event/payment_methods_event.dart';
|
||||
import '../viewmodel/add_card_bloc.dart';
|
||||
import '../event/add_card_event.dart';
|
||||
import '../state/add_card_state.dart';
|
||||
@@ -28,7 +30,6 @@ class AddCardScreen extends StatelessWidget {
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
// 🔹 ВЕРХНЯЯ ЧАСТЬ (шапка + форма)
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
@@ -37,7 +38,6 @@ class AddCardScreen extends StatelessWidget {
|
||||
const CustomAppBar(title: 'Добавление карты'),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// 🔹 ОСНОВНОЙ КОНТЕЙНЕР С ПОЛЯМИ
|
||||
Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
@@ -46,7 +46,6 @@ class AddCardScreen extends StatelessWidget {
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
// Номер карты
|
||||
BlocBuilder<AddCardBloc, AddCardState>(
|
||||
builder: (context, state) {
|
||||
return CardInputField(
|
||||
@@ -60,7 +59,6 @@ class AddCardScreen extends StatelessWidget {
|
||||
],
|
||||
letterSpacing: 2,
|
||||
onChanged: (value) {
|
||||
// Очищаем от пробелов перед отправкой в BLoC
|
||||
final cleanValue = value.replaceAll(' ', '');
|
||||
context.read<AddCardBloc>().add(CardNumberChanged(cleanValue));
|
||||
},
|
||||
@@ -137,7 +135,6 @@ class AddCardScreen extends StatelessWidget {
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// 🔹 КНОПКА "ДОБАВИТЬ КАРТУ"
|
||||
BlocBuilder<AddCardBloc, AddCardState>(
|
||||
builder: (context, state) {
|
||||
return Container(
|
||||
@@ -153,7 +150,8 @@ class AddCardScreen extends StatelessWidget {
|
||||
? () => {
|
||||
context.read<AddCardBloc>().add(
|
||||
AddCardSubmitted()),
|
||||
context.go("/home/payment-methods")
|
||||
context.read<PaymentMethodsBloc>()..add(PaymentMethodsStarted()),
|
||||
context.pop()
|
||||
}
|
||||
: null,
|
||||
borderRadius: BorderRadius.circular(
|
||||
@@ -205,7 +203,6 @@ class AddCardScreen extends StatelessWidget {
|
||||
horizontal: 20, vertical: 24),
|
||||
child: Column(
|
||||
children: [
|
||||
// Текст о безопасности
|
||||
const Text(
|
||||
'Мы не сохраняем данные карты у себя. Оплата происходит '
|
||||
'через сертифицированный провайдер Беларуси bePaid. '
|
||||
@@ -221,10 +218,6 @@ class AddCardScreen extends StatelessWidget {
|
||||
),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Логотипы платёжных систем
|
||||
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -178,7 +178,7 @@ class OrderHistoryDetailScreen extends StatelessWidget {
|
||||
padding: EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.3),
|
||||
borderRadius: BorderRadius.circular(12), // Опционально: скругление углов
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
order.status == 'Paid' ? 'ОПЛАЧЕН' : 'НЕ ОПЛАЧЕН',
|
||||
@@ -262,7 +262,7 @@ class OrderHistoryDetailScreen extends StatelessWidget {
|
||||
const SizedBox(height: 12),
|
||||
_DetailRow(
|
||||
label: 'Страховка',
|
||||
value: order.isInsurance ? '1 руб' : '—',
|
||||
value: order.isInsurance ? "${order.insurancePrice} руб." : '—',
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -3,7 +3,9 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../../core/app_colors.dart';
|
||||
import '../components/code_dots.dart';
|
||||
import '../event/map_event.dart';
|
||||
import '../event/spalsh_event.dart';
|
||||
import '../viewmodel/map_bloc.dart';
|
||||
import '../viewmodel/pin_bloc.dart';
|
||||
import '../event/pin_event.dart';
|
||||
import '../state/pin_state.dart';
|
||||
@@ -143,6 +145,24 @@ class _PinLoginScreenState extends State<PinLoginScreen> {
|
||||
style: const TextStyle(color: AppColors.white70),
|
||||
),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
if (state is! PinCreateInProgress)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
context.read<MapBloc>().add(LogoutPressed());
|
||||
context.read<SplashBloc>().add(AuthCheckRequested());
|
||||
},
|
||||
child: const Text(
|
||||
"Забыли PIN-код?",
|
||||
style: TextStyle(
|
||||
color: AppColors.whiteText,
|
||||
decoration: TextDecoration.underline,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 40),
|
||||
|
||||
],
|
||||
|
||||
@@ -2,9 +2,11 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../core/app_colors.dart';
|
||||
import '../../di/service_locator.dart';
|
||||
import '../../domain/entities/payment_card.dart';
|
||||
import '../../domain/usecase/get_payment_cards_usecase.dart';
|
||||
import '../components/app_checkbox.dart';
|
||||
import '../components/custom_app_bar.dart'; // ✅ Уже есть
|
||||
import '../components/gradient_button.dart';
|
||||
import '../components/payment_option.dart';
|
||||
@@ -51,7 +53,6 @@ class TopUpScreen extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
_buildCardSelector(state, context),
|
||||
_buildAddCardButton(() => context.push("/home/payment-methods/add-card")),
|
||||
const SizedBox(height: 20),
|
||||
_buildAgreement(state, context),
|
||||
const Spacer(),
|
||||
@@ -159,7 +160,6 @@ class TopUpScreen extends StatelessWidget {
|
||||
subtitle: '****${state.selectedCard!.cardLastNumber}',
|
||||
isSelected: true,
|
||||
onTap: () async {
|
||||
// Открываем модалку как вложенную, не закрывая текущую
|
||||
final selectedCard = await showModalBottomSheet<PaymentCard>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
@@ -236,18 +236,22 @@ class TopUpScreen extends StatelessWidget {
|
||||
|
||||
Widget _buildAgreement(TopUpState state, BuildContext context) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Checkbox(
|
||||
AppCheckbox(
|
||||
value: state.isAgreed,
|
||||
onChanged: (v) =>
|
||||
context.read<TopUpBloc>().add(ToggleAgreement(v ?? false)),
|
||||
side: const BorderSide(color: Colors.white54),
|
||||
),
|
||||
const Expanded(
|
||||
child: Text(
|
||||
'Я принимаю условия покупки бонусного пакета, при котором денежные средства не подлежат возврату...',
|
||||
style: TextStyle(color: Colors.white54, fontSize: 12),
|
||||
const SizedBox(width: 12),
|
||||
Flexible(
|
||||
child: Text.rich(
|
||||
TextSpan(
|
||||
text: 'Я принимаю условия покупки бонусного пакета, при котором денежные средства не подлежат возврату... ',
|
||||
style: const TextStyle(
|
||||
color: AppColors.white70,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -266,23 +270,4 @@ class TopUpScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAddCardButton(VoidCallback onPressed) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: onPressed,
|
||||
icon: const Icon(Icons.add, color: Colors.white),
|
||||
label: const Text(
|
||||
'Добавить платежную карту',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
style: OutlinedButton.styleFrom(
|
||||
side: const BorderSide(color: Colors.white54),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ class TariffSheetState {
|
||||
final List<Tariff> tariffs;
|
||||
final String? errorMessage;
|
||||
final PaymentCard? selectedCard;
|
||||
final bool isInsurance;
|
||||
final int userBalance;
|
||||
final bool useBalance ;
|
||||
|
||||
@@ -16,6 +17,7 @@ class TariffSheetState {
|
||||
this.status = TariffSheetStatus.initial,
|
||||
this.tariffs = const [],
|
||||
this.selectedCard,
|
||||
this.isInsurance = false,
|
||||
this.errorMessage,
|
||||
this.userBalance = 0,
|
||||
this.useBalance = false,
|
||||
@@ -26,6 +28,7 @@ class TariffSheetState {
|
||||
List<Tariff>? tariffs,
|
||||
PaymentCard? selectedCard,
|
||||
String? errorMessage,
|
||||
bool? isInsurance,
|
||||
int? userBalance,
|
||||
bool? useBalance,
|
||||
|
||||
@@ -35,6 +38,7 @@ class TariffSheetState {
|
||||
selectedCard: selectedCard ?? this.selectedCard,
|
||||
useBalance: useBalance ?? this.useBalance,
|
||||
userBalance: userBalance ?? this.userBalance,
|
||||
isInsurance: isInsurance ?? this.isInsurance,
|
||||
errorMessage: errorMessage ?? this.errorMessage,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -57,8 +57,6 @@ class ActiveRideBloc extends Bloc<ActiveRideEvent, ActiveRideState> {
|
||||
if (orderResult is Success<ScooterOrder>) {
|
||||
final order = orderResult.data;
|
||||
|
||||
|
||||
// Пытаемся достать доп. данные, если они Success
|
||||
final orderData = activeOrderData is Success<ActiveScooterOrder>
|
||||
? activeOrderData.data
|
||||
: null;
|
||||
@@ -80,7 +78,6 @@ class ActiveRideBloc extends Bloc<ActiveRideEvent, ActiveRideState> {
|
||||
inZone: orderData?.zone,
|
||||
));
|
||||
|
||||
//synchronize
|
||||
_syncTimer?.cancel();
|
||||
_syncTimer = Timer.periodic(const Duration(seconds: 5), (timer) {
|
||||
add(SyncScooterOrder(event.orderId));
|
||||
|
||||
@@ -20,6 +20,8 @@ class CurrentRidesBloc extends Bloc<CurrentRidesEvent, CurrentRidesState> {
|
||||
) async {
|
||||
emit(state.copyWith(status: CurrentRidesStatus.loading));
|
||||
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
|
||||
final result = await _getClientOrdersUsecase();
|
||||
|
||||
if (result is Success<List<ScooterOrder>>) {
|
||||
|
||||
@@ -55,10 +55,11 @@ class ScooterDetailModalBloc
|
||||
|
||||
final routes = await _getPedestrianRoutesUsecase(
|
||||
Point(latitude: event.userLatitude, longitude: event.userLongitude),
|
||||
Point(latitude: scooter.latitude, longitude: scooter.longitude),
|
||||
Point(latitude: scooter.longitude, longitude: scooter.latitude),
|
||||
);
|
||||
|
||||
final distance = routes?.firstOrNull?.metadata.weight.walkingDistance.value;
|
||||
print("Distance is: $distance");
|
||||
final time = routes?.firstOrNull?.metadata.weight.time.value;
|
||||
|
||||
if (result is Success<Scooter>) {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'package:be_happy/core/failures.dart';
|
||||
import 'package:be_happy/domain/entities/scooter_order.dart';
|
||||
import 'package:be_happy/domain/usecase/get_profile_usecase.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
@@ -29,6 +31,7 @@ class TariffSheetBloc extends Bloc<TariffSheetEvent, TariffSheetState> {
|
||||
on<PaymentCardChanged>(_onPaymentCardChanged);
|
||||
on<BookScooterPressed>(_onBookScooterPressed);
|
||||
on<SelectBalancePressed>(_onSelectBalancePressed);
|
||||
on<InsuranceToggled>(_onInsuranceToggled);
|
||||
}
|
||||
|
||||
Future<void> _onStarted(
|
||||
@@ -92,12 +95,12 @@ class TariffSheetBloc extends Bloc<TariffSheetEvent, TariffSheetState> {
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _onBookScooterPressed(
|
||||
FutureOr<void> _onBookScooterPressed (
|
||||
BookScooterPressed event,
|
||||
Emitter<TariffSheetState> emit,
|
||||
) {
|
||||
) async {
|
||||
try {
|
||||
_bookScooterUsecase(
|
||||
final result = await _bookScooterUsecase(
|
||||
scooterId: event.scooterId,
|
||||
planId: event.planId,
|
||||
cardId: event.cardId,
|
||||
@@ -105,7 +108,23 @@ class TariffSheetBloc extends Bloc<TariffSheetEvent, TariffSheetState> {
|
||||
isBalance: event.isBalance,
|
||||
isInsurance: event.isInsurance,
|
||||
);
|
||||
Future.delayed(const Duration(milliseconds: 300));
|
||||
|
||||
switch (result) {
|
||||
|
||||
case Success<ScooterOrder>():
|
||||
// TODO: Handle this case.
|
||||
throw UnimplementedError();
|
||||
case Failure<ScooterOrder>():
|
||||
if (result is WrongZoneFailure) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
status: TariffSheetStatus.failure,
|
||||
errorMessage: result.failure.message,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
@@ -125,4 +144,8 @@ class TariffSheetBloc extends Bloc<TariffSheetEvent, TariffSheetState> {
|
||||
selectedCard: null,
|
||||
));
|
||||
}
|
||||
|
||||
FutureOr<void> _onInsuranceToggled(InsuranceToggled event, Emitter<TariffSheetState> emit) async {
|
||||
emit(state.copyWith(isInsurance: event.isEnabled));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user