fix functional bugs
This commit is contained in:
@@ -1,141 +0,0 @@
|
||||
import 'dart:ui';
|
||||
import 'package:be_happy/presentation/event/map_event.dart';
|
||||
import 'package:be_happy/presentation/event/map_settings_modal_event.dart';
|
||||
import 'package:be_happy/presentation/state/map_settings_modal_state.dart';
|
||||
import 'package:be_happy/presentation/viewmodel/map_settings_modal_bloc.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../viewmodel/map_bloc.dart';
|
||||
|
||||
class MapSettingsSheet extends StatelessWidget {
|
||||
final VoidCallback? onClose;
|
||||
|
||||
const MapSettingsSheet({super.key, this.onClose});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<MapSettingsModalBloc, MapSettingsModalState>(
|
||||
builder: (context, state) {
|
||||
final List<_SettingItemData> items = [
|
||||
_SettingItemData(
|
||||
label: 'Геоточки',
|
||||
icon: Icons.location_on_outlined,
|
||||
color: const Color(0xFF66E3C4),
|
||||
isActive: state.isAllGeomarksActive,
|
||||
onChanged: (val) => context.read<MapSettingsModalBloc>().add(AllGeomarksToggled(val)),
|
||||
),
|
||||
_SettingItemData(
|
||||
label: 'Геозоны',
|
||||
icon: Icons.gps_fixed_outlined,
|
||||
color: const Color(0xFF86EFAC),
|
||||
isActive: state.isAllGeozonesActive,
|
||||
onChanged: (val) => context.read<MapSettingsModalBloc>().add(AllGeozonesToggled(val)),
|
||||
),
|
||||
_SettingItemData(
|
||||
label: 'Парковка',
|
||||
icon: Icons.home_outlined,
|
||||
color: const Color(0xFFA78BFA),
|
||||
isActive: state.isParkingZoneActive,
|
||||
onChanged: (val) => context.read<MapSettingsModalBloc>().add(ParkingZonesToggled(val)),
|
||||
),
|
||||
_SettingItemData(
|
||||
label: 'Парковка запрещена',
|
||||
icon: Icons.block_outlined,
|
||||
color: const Color(0xFFF59E0B),
|
||||
isActive: state.isRestrictedParkingZoneActive,
|
||||
onChanged: (val) => context.read<MapSettingsModalBloc>().add(RestrictedParkingZonesToggled(val)),
|
||||
),
|
||||
_SettingItemData(
|
||||
label: 'Запрещено кататься',
|
||||
icon: Icons.warning_amber_outlined,
|
||||
color: const Color(0xFFEF4444),
|
||||
isActive: state.isRestrictedDrivingZoneActive,
|
||||
onChanged: (val) => context.read<MapSettingsModalBloc>().add(RestrictedDrivingZonesToggled(val)),
|
||||
),
|
||||
];
|
||||
|
||||
return Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(30)),
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 20, sigmaY: 20),
|
||||
child: Container(
|
||||
height: 365,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF000032).withOpacity(0.88),
|
||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(30)),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text(
|
||||
'Параметры карты',
|
||||
style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w600),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
context.read<MapSettingsModalBloc>().add(ApllyButtonClick());
|
||||
context.read<MapBloc>().add(UpdateMap());
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: const Text(
|
||||
'Готово',
|
||||
style: TextStyle(color: Color(0xFF66E3C4), fontSize: 16, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
itemCount: items.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = items[index];
|
||||
return ListTile(
|
||||
leading: Icon(item.icon, color: item.color),
|
||||
title: Text(item.label, style: const TextStyle(color: Colors.white)),
|
||||
trailing: Switch.adaptive(
|
||||
value: item.isActive,
|
||||
onChanged: item.onChanged,
|
||||
activeTrackColor: const Color(0xFF66E3C4),
|
||||
inactiveThumbColor: Colors.white,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Вспомогательный класс для описания строк
|
||||
class _SettingItemData {
|
||||
final String label;
|
||||
final IconData icon;
|
||||
final Color color;
|
||||
final bool isActive;
|
||||
final ValueChanged<bool> onChanged;
|
||||
|
||||
_SettingItemData({
|
||||
required this.label,
|
||||
required this.icon,
|
||||
required this.color,
|
||||
required this.isActive,
|
||||
required this.onChanged,
|
||||
});
|
||||
}
|
||||
@@ -1,13 +1,16 @@
|
||||
import 'dart:async';
|
||||
import 'dart:ui';
|
||||
import 'package:be_happy/domain/entities/scooter.dart';
|
||||
import 'package:bot_toast/bot_toast.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../../../di/service_locator.dart';
|
||||
import '../../event/active_ride_event.dart';
|
||||
import '../../event/map_event.dart';
|
||||
import '../../state/active_ride_state.dart';
|
||||
import '../../viewmodel/active_ride_bloc.dart';
|
||||
import '../../viewmodel/map_bloc.dart';
|
||||
import '../dialog/finish_ride_confirmation_dialog.dart';
|
||||
import '../notification_toast.dart';
|
||||
|
||||
@@ -56,7 +59,7 @@ class _ActiveRideSheetState extends State<ActiveRideSheet> {
|
||||
return BlocProvider.value(
|
||||
value: _bloc,
|
||||
child: BlocConsumer<ActiveRideBloc, ActiveRideState>(
|
||||
listenWhen: (previous, current) => previous.inZone != current.inZone,
|
||||
listenWhen: (previous, current) => previous.inZone != current.inZone || previous.status != current.status,
|
||||
listener: (context, state) {
|
||||
if (!state.inZone) {
|
||||
BotToast.showCustomNotification(
|
||||
@@ -71,6 +74,15 @@ class _ActiveRideSheetState extends State<ActiveRideSheet> {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
if (state.status == ActiveRideStatus.success && state.order != null) {
|
||||
final scooter = state.order!.scooter;
|
||||
context.read<MapBloc>().add(FocusOnScooter(Scooter(id: scooter.id,
|
||||
title: scooter.title, status: scooter.status,
|
||||
latitude: state.longitude, longitude: state.latitude,
|
||||
batteryLevel: scooter.batteryLevel, isOnline: scooter.isOnline,
|
||||
maxSpeed: scooter.maxSpeed, number: scooter.number)));
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
// Логика отображения загрузки и ошибок остается прежней
|
||||
@@ -203,8 +215,8 @@ class _ActiveRideSheetState extends State<ActiveRideSheet> {
|
||||
color: Colors.white,
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontFeatures: [FontFeature.tabularFigures()],
|
||||
fontFamily: 'Digital Numbers',
|
||||
fontFeatures: const [FontFeature.tabularFigures()],
|
||||
fontFamily: 'DigitalNumbers',
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
@@ -306,10 +318,27 @@ class _ActiveRideSheetState extends State<ActiveRideSheet> {
|
||||
}
|
||||
// 🔹 Если отменил — ничего не делаем, диалог уже закрылся
|
||||
},
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: Column( // ✅ Вернули Column с иконкой и текстом
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.stop,
|
||||
color: Colors.white,
|
||||
size: 24,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
const Text(
|
||||
'ЗАВЕРШИТЬ',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -219,11 +219,11 @@ class _RideCardState extends State<_RideCard> {
|
||||
displayTime = _elapsedTime;
|
||||
}
|
||||
final timeString = _formatDuration(displayTime);
|
||||
final statusText = _getStatusText(widget.order.status);
|
||||
final statusColor = _getStatusColor(widget.order.status);
|
||||
final statusText = widget.order.status == 'Booking' ? 'Забронирован' : "Активный";
|
||||
final statusColor = widget.order.status == 'Booking' ? Color(0xFFFFCC00) : Color(0xFF8bffaa);
|
||||
|
||||
final scooterNumber =
|
||||
widget.order.scooter?.number ?? widget.order.scooterId.toString();
|
||||
widget.order.scooter.number ?? widget.order.scooterId.toString();
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
@@ -261,7 +261,7 @@ class _RideCardState extends State<_RideCard> {
|
||||
Text(
|
||||
statusText,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
color: statusColor,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
@@ -269,22 +269,51 @@ class _RideCardState extends State<_RideCard> {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
scooterNumber,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
_getLocationText(),
|
||||
style: TextStyle(
|
||||
color: Colors.white.withOpacity(0.6),
|
||||
fontSize: 13,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Image.asset("assets/icons/qr_icon_order.png"),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
scooterNumber,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
if (isReserved)
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
"Тариф",
|
||||
style: TextStyle(
|
||||
color: Color(0xFF8bffaa),
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Image.asset("assets/icons/timer.png", width: 14,),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
widget.order.plan?.title ?? "Название тарифа",
|
||||
style: TextStyle(
|
||||
color: Color(0xFF8bffaa),
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -301,10 +330,10 @@ class _RideCardState extends State<_RideCard> {
|
||||
timeString,
|
||||
style: TextStyle(
|
||||
color: statusColor,
|
||||
fontSize: 26,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontFeatures: const [FontFeature.tabularFigures()],
|
||||
fontFamily: 'Digital Numbers',
|
||||
fontFamily: 'DigitalNumbers',
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -360,7 +389,7 @@ class _RideCardState extends State<_RideCard> {
|
||||
switch (status.toLowerCase()) {
|
||||
case 'reserved':
|
||||
case 'holding':
|
||||
return 'Забронировано';
|
||||
return 'Забронирован';
|
||||
case 'active':
|
||||
case 'in_progress':
|
||||
return 'Активно';
|
||||
|
||||
@@ -5,8 +5,6 @@ import 'package:be_happy/presentation/state/map_settings_modal_state.dart';
|
||||
import 'package:be_happy/presentation/viewmodel/map_settings_modal_bloc.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../viewmodel/map_bloc.dart';
|
||||
|
||||
class MapSettingsSheet extends StatelessWidget {
|
||||
@@ -19,13 +17,6 @@ class MapSettingsSheet extends StatelessWidget {
|
||||
return BlocBuilder<MapSettingsModalBloc, MapSettingsModalState>(
|
||||
builder: (context, state) {
|
||||
final List<_SettingItemData> items = [
|
||||
_SettingItemData(
|
||||
label: 'Геоточки',
|
||||
icon: Icons.location_on_outlined,
|
||||
color: const Color(0xFF66E3C4),
|
||||
isActive: state.isAllGeomarksActive,
|
||||
onChanged: (val) => context.read<MapSettingsModalBloc>().add(AllGeomarksToggled(val)),
|
||||
),
|
||||
_SettingItemData(
|
||||
label: 'Геозоны',
|
||||
icon: Icons.gps_fixed_outlined,
|
||||
@@ -41,9 +32,9 @@ class MapSettingsSheet extends StatelessWidget {
|
||||
onChanged: (val) => context.read<MapSettingsModalBloc>().add(ParkingZonesToggled(val)),
|
||||
),
|
||||
_SettingItemData(
|
||||
label: 'Разрешено кататься',
|
||||
label: 'Парковка запрещена',
|
||||
icon: Icons.block_outlined,
|
||||
color: const Color(0xFF5ECD4C),
|
||||
color: const Color(0xFFF59E0B),
|
||||
isActive: state.isRestrictedParkingZoneActive,
|
||||
onChanged: (val) => context.read<MapSettingsModalBloc>().add(RestrictedParkingZonesToggled(val)),
|
||||
),
|
||||
|
||||
@@ -12,11 +12,13 @@ import '../../state/payment_method_sheet_state.dart';
|
||||
import '../../viewmodel/payment_method_sheet_bloc.dart';
|
||||
|
||||
class PaymentMethodSheet extends StatefulWidget {
|
||||
final PaymentCard? initialSelectedCard; // Добавляем это поле
|
||||
final PaymentCard? initialSelectedCard;
|
||||
final bool showBalance;
|
||||
|
||||
const PaymentMethodSheet({
|
||||
super.key,
|
||||
this.initialSelectedCard, // Инициализируем в конструкторе
|
||||
this.initialSelectedCard,
|
||||
this.showBalance = true,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -92,7 +94,7 @@ class _PaymentMethodSheetState extends State<PaymentMethodSheet> {
|
||||
_selectedPaymentMethod = initialIndex != -1 ? initialIndex : -1;
|
||||
} else {
|
||||
final mainCardIndex = state.cards.indexWhere((card) => card.isMain);
|
||||
_selectedPaymentMethod = mainCardIndex != -1 ? mainCardIndex : -1;
|
||||
_selectedPaymentMethod = mainCardIndex != -1 ? mainCardIndex : (widget.showBalance ? -1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,19 +171,20 @@ class _PaymentMethodSheetState extends State<PaymentMethodSheet> {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Column(
|
||||
children: [
|
||||
PaymentOption(
|
||||
title: 'Баланс',
|
||||
subtitle: '${state.balance.toStringAsFixed(2)} BYN',
|
||||
isSelected: _selectedPaymentMethod == -1,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_selectedPaymentMethod = -1;
|
||||
});
|
||||
Navigator.pop(context, 'balance');
|
||||
},
|
||||
),
|
||||
|
||||
const SizedBox(height: 12),
|
||||
if (widget.showBalance) ...[
|
||||
PaymentOption(
|
||||
title: 'Баланс',
|
||||
subtitle: '${state.balance.toStringAsFixed(2)} BYN',
|
||||
isSelected: _selectedPaymentMethod == -1,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_selectedPaymentMethod = -1;
|
||||
});
|
||||
Navigator.pop(context, 'balance');
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
|
||||
...state.cards.asMap().entries.map((entry) {
|
||||
final index = entry.key;
|
||||
|
||||
@@ -14,7 +14,7 @@ class ReservedRideSheet extends StatefulWidget {
|
||||
final String scooterNumber;
|
||||
final int orderId;
|
||||
final Duration initialReservationTime;
|
||||
|
||||
|
||||
const ReservedRideSheet({
|
||||
super.key,
|
||||
required this.scooterNumber,
|
||||
@@ -60,264 +60,286 @@ class _ReservedRideSheetState extends State<ReservedRideSheet> {
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider.value(
|
||||
value: _bloc,
|
||||
child: Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(30)),
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 20, sigmaY: 20),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.only(top: 20, bottom: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF000032).withOpacity(0.5),
|
||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(30)),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// HEADER
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Row(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () => Navigator.pop(context),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.arrow_back_ios_sharp,
|
||||
color: const Color(0x99FFFFFF),
|
||||
size: 20,
|
||||
),
|
||||
Icon(
|
||||
Icons.arrow_back_ios_sharp,
|
||||
color: const Color(0x66FFFFFF),
|
||||
size: 20,
|
||||
),
|
||||
Icon(
|
||||
Icons.arrow_back_ios_sharp,
|
||||
color: const Color(0x22FFFFFF),
|
||||
size: 20,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Бесплатное бронирование',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(30)),
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 20, sigmaY: 20),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.only(top: 20, bottom: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF000032).withOpacity(0.5),
|
||||
borderRadius: const BorderRadius.vertical(
|
||||
top: Radius.circular(30),
|
||||
),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// ТАЙМЕР + ИНФО О САМОКАТЕ (КОМПАКТНЫЙ)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Row(
|
||||
children: [
|
||||
// Таймер
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text(
|
||||
_formatDuration(_reservationTime),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontFeatures: [FontFeature.tabularFigures()],
|
||||
fontFamily: 'Digital Numbers',
|
||||
),
|
||||
),
|
||||
),
|
||||
// Иконка и информация (ВЫСОКИЙ БЛОК)
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// HEADER
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Row(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () => Navigator.pop(context),
|
||||
child: Row(
|
||||
children: [
|
||||
// Иконка самоката (ВЫШЕ)
|
||||
SizedBox(
|
||||
width: 44,
|
||||
height: 56,
|
||||
child: Image.asset(
|
||||
'assets/icons/e6a5dcb6a3e2ec2362c25ea49509ab10d2312b19-reverse.png',
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
Icon(
|
||||
Icons.arrow_back_ios_sharp,
|
||||
color: const Color(0x99FFFFFF),
|
||||
size: 20,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
// Инфо
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 8,
|
||||
height: 8,
|
||||
decoration: const BoxDecoration(
|
||||
color: Color(0xFFFFB800),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
const Text(
|
||||
'Забронирован',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'№${widget.scooterNumber}',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Icon(
|
||||
Icons.arrow_back_ios_sharp,
|
||||
color: const Color(0x66FFFFFF),
|
||||
size: 20,
|
||||
),
|
||||
Icon(
|
||||
Icons.arrow_back_ios_sharp,
|
||||
color: const Color(0x22FFFFFF),
|
||||
size: 20,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// КНОПКА "НАЧАТЬ ПОЕЗДКУ"
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: BlocListener<ReservedRideBloc, ReservedRideState>(
|
||||
listener: (context, state) {
|
||||
if (state.rideStarted) {
|
||||
Navigator.pop(context);
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
builder: (context) => ActiveRideSheet(
|
||||
scooterNumber: widget.scooterNumber,
|
||||
initialElapsedTime: Duration.zero,
|
||||
orderId: widget.orderId,
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Бесплатное бронирование',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
);
|
||||
} else if (state.status == ReservedRideStatus.failure) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(state.errorMessage ?? 'Ошибка')),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: GradientButton(
|
||||
text: 'Начать поездку',
|
||||
showArrows: true,
|
||||
height: 48,
|
||||
width: double.infinity,
|
||||
fontSize: 15,
|
||||
onTap: () {
|
||||
_bloc.add(StartRide(widget.orderId));
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 12),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// КНОПКА "ОТМЕНИТЬ БРОНИРОВАНИЕ"
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: BlocListener<ReservedRideBloc, ReservedRideState>(
|
||||
listener: (context, state) {
|
||||
if (state.rideCancelled) {
|
||||
Navigator.pop(context);
|
||||
} else if (state.status == ReservedRideStatus.failure) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(state.errorMessage ?? 'Ошибка')),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
height: 48,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
border: Border.all(
|
||||
color: Colors.white.withOpacity(0.4),
|
||||
width: 1,
|
||||
// ТАЙМЕР + ИНФО О САМОКАТЕ (КОМПАКТНЫЙ)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Row(
|
||||
children: [
|
||||
// Таймер
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text(
|
||||
_formatDuration(_reservationTime),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontFeatures: [FontFeature.tabularFigures()],
|
||||
fontFamily: 'Digital Numbers',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
final result = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => const CancelBookingDialog(),
|
||||
);
|
||||
if (result != null && result) {
|
||||
_bloc.add(CancelRide(widget.orderId));
|
||||
}
|
||||
},
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
child: BlocBuilder<ReservedRideBloc, ReservedRideState>(
|
||||
builder: (context, state) {
|
||||
if (state.status == ReservedRideStatus.loading) {
|
||||
return const Center(
|
||||
child: SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
strokeWidth: 2,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return const Center(
|
||||
child: Text(
|
||||
'Отменить бронирование',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
// Иконка и информация (ВЫСОКИЙ БЛОК)
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 16,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
// Иконка самоката (ВЫШЕ)
|
||||
SizedBox(
|
||||
width: 44,
|
||||
height: 56,
|
||||
child: Image.asset(
|
||||
'assets/icons/e6a5dcb6a3e2ec2362c25ea49509ab10d2312b19-reverse.png',
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
// Инфо
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 8,
|
||||
height: 8,
|
||||
decoration: const BoxDecoration(
|
||||
color: Color(0xFFFFB800),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
const Text(
|
||||
'Забронирован',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'№${widget.scooterNumber}',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// КНОПКА "НАЧАТЬ ПОЕЗДКУ"
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: BlocListener<ReservedRideBloc, ReservedRideState>(
|
||||
listener: (context, state) {
|
||||
if (state.rideStarted) {
|
||||
Navigator.pop(context);
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
builder: (context) => ActiveRideSheet(
|
||||
scooterNumber: widget.scooterNumber,
|
||||
initialElapsedTime: Duration.zero,
|
||||
orderId: widget.orderId,
|
||||
),
|
||||
);
|
||||
} else if (state.status ==
|
||||
ReservedRideStatus.failure) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(state.errorMessage ?? 'Ошибка'),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: GradientButton(
|
||||
text: 'Начать поездку',
|
||||
showArrows: true,
|
||||
height: 48,
|
||||
width: double.infinity,
|
||||
fontSize: 15,
|
||||
onTap: () {
|
||||
_bloc.add(StartRide(widget.orderId));
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// КНОПКА "ОТМЕНИТЬ БРОНИРОВАНИЕ"
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: BlocListener<ReservedRideBloc, ReservedRideState>(
|
||||
listener: (context, state) {
|
||||
if (state.rideCancelled) {
|
||||
Navigator.pop(context);
|
||||
} else if (state.status ==
|
||||
ReservedRideStatus.failure) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(state.errorMessage ?? 'Ошибка'),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
height: 48,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
border: Border.all(
|
||||
color: Colors.white.withOpacity(0.4),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
final result = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) =>
|
||||
const CancelBookingDialog(),
|
||||
);
|
||||
if (result != null && result) {
|
||||
_bloc.add(CancelRide(widget.orderId));
|
||||
}
|
||||
},
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
child:
|
||||
BlocBuilder<
|
||||
ReservedRideBloc,
|
||||
ReservedRideState
|
||||
>(
|
||||
builder: (context, state) {
|
||||
if (state.status ==
|
||||
ReservedRideStatus.loading) {
|
||||
return const Center(
|
||||
child: SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
strokeWidth: 2,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return const Center(
|
||||
child: Text(
|
||||
'Отменить бронирование',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
import 'package:be_happy/presentation/components/gradient_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../domain/entities/subscription.dart';
|
||||
import '../event/subscription_list_event.dart';
|
||||
|
||||
class SubscriptionCard extends StatelessWidget {
|
||||
final Subscription subscription;
|
||||
final bool isActive;
|
||||
final DateTime? expiredAt;
|
||||
final VoidCallback? onRefresh;
|
||||
|
||||
const SubscriptionCard({super.key, required this.subscription, required this.isActive});
|
||||
const SubscriptionCard({super.key, required this.subscription, required this.isActive, this.expiredAt, this.onRefresh});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -15,9 +20,9 @@ class SubscriptionCard extends StatelessWidget {
|
||||
? subscription.options.reduce((a, b) => a.price < b.price ? a : b)
|
||||
: null;
|
||||
|
||||
final maxDaysOption = subscription.options.isNotEmpty
|
||||
/*final maxDaysOption = subscription.options.isNotEmpty
|
||||
? subscription.options.reduce((a, b) => a.days > b.days ? a : b)
|
||||
: null;
|
||||
: null;*/
|
||||
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
@@ -43,7 +48,7 @@ class SubscriptionCard extends StatelessWidget {
|
||||
padding: EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.3),
|
||||
borderRadius: BorderRadius.circular(12), // Опционально: скругление углов
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
"АКТИВНА",
|
||||
@@ -64,12 +69,19 @@ class SubscriptionCard extends StatelessWidget {
|
||||
subscription.shortDescription,
|
||||
style: TextStyle(color: Colors.white.withOpacity(0.7), fontSize: 14),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
if (maxDaysOption != null) ...[
|
||||
if (isActive && expiredAt != null) ...[
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
"Период действия: до ${maxDaysOption.days} дней",
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14),
|
||||
Builder(
|
||||
builder: (context) {
|
||||
final day = expiredAt!.day.toString().padLeft(2, '0');
|
||||
final month = expiredAt!.month.toString().padLeft(2, '0');
|
||||
final year = expiredAt!.year;
|
||||
|
||||
return Text(
|
||||
"Период действия: до $day.$month.$year",
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 20),
|
||||
@@ -83,15 +95,17 @@ class SubscriptionCard extends StatelessWidget {
|
||||
)
|
||||
else
|
||||
const SizedBox.shrink(),
|
||||
ElevatedButton(
|
||||
onPressed: () => context.push("/home/subscriptions/${subscription.id}"),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF80FFD1),
|
||||
foregroundColor: Colors.black,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
|
||||
),
|
||||
child: const Text("Подробнее", style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
GradientButton(
|
||||
onTap: () async {
|
||||
final isSubscribed = await context.push<bool>("/home/subscriptions/${subscription.id}");
|
||||
if (isSubscribed == true && onRefresh != null) {
|
||||
onRefresh!();
|
||||
}
|
||||
},
|
||||
text: "Подробнее",
|
||||
enabled: true,
|
||||
width: 120,
|
||||
height: 40,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -30,4 +30,14 @@ class NotificationReceived extends ScooterEvent {
|
||||
NotificationReceived(this.notification);
|
||||
}
|
||||
|
||||
class FocusOnScooter extends ScooterEvent {
|
||||
final Scooter scooter;
|
||||
FocusOnScooter(this.scooter);
|
||||
}
|
||||
|
||||
class ClearMapPlacemarks extends ScooterEvent {}
|
||||
class ClearMapFocus extends ScooterEvent {}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -58,9 +58,9 @@ import '../../domain/usecase/remove_payment_card_usecase.dart';
|
||||
import '../../domain/usecase/save_map_settings_usecase.dart';
|
||||
import '../../domain/usecase/set_main_payment_card_usecase.dart';
|
||||
import '../../domain/usecase/verify_pin_usecase.dart';
|
||||
import '../components/map_settings_sheet.dart';
|
||||
import '../components/scooter_bottom_sheet.dart';
|
||||
import '../components/sheet/current_rides_sheet.dart';
|
||||
import '../components/sheet/map_settings_sheet.dart';
|
||||
import '../components/sheet/payment_method_sheet.dart';
|
||||
import '../components/sheet/reserved_ride_sheet.dart';
|
||||
import '../components/sheet/tariff_sheet.dart';
|
||||
@@ -372,6 +372,7 @@ class AppRouter {
|
||||
SubscriptionDetailsBloc(
|
||||
getIt<GetSubscriptionByIdUsecase>(),
|
||||
getIt<ActivateSubscriptionUsecase>(),
|
||||
getIt<GetClientSubscriptionsUsecase>(),
|
||||
)
|
||||
..add(
|
||||
LoadDetailsEvent(
|
||||
|
||||
@@ -19,11 +19,14 @@ class AddCardScreen extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: BlocListener<AddCardBloc, AddCardState>(
|
||||
listenWhen: (previous, current) =>
|
||||
previous.status != current.status &&
|
||||
current.status == AddCardStatus.success,
|
||||
listenWhen: (previous, current) {
|
||||
print(
|
||||
'Смена статуса: ${previous.status} -> ${current.status} ${current.errorMessage}');
|
||||
return previous.status != current.status &&
|
||||
current.status == AddCardStatus.success;
|
||||
},
|
||||
listener: (context, state) {
|
||||
context.pop();
|
||||
context.pop(true);
|
||||
},
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(gradient: AppColors.phoneScreenBg),
|
||||
@@ -149,10 +152,7 @@ class AddCardScreen extends StatelessWidget {
|
||||
child: InkWell(
|
||||
onTap: state.isFormValid
|
||||
? () => {
|
||||
context.read<AddCardBloc>().add(
|
||||
AddCardSubmitted()),
|
||||
context.read<PaymentMethodsBloc>()..add(PaymentMethodsStarted()),
|
||||
context.pop()
|
||||
context.read<AddCardBloc>().add(AddCardSubmitted()),
|
||||
}
|
||||
: null,
|
||||
borderRadius: BorderRadius.circular(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import '../../core/app_colors.dart';
|
||||
import '../components/custom_app_bar.dart';
|
||||
@@ -17,12 +18,10 @@ class DocumentsScreen extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Column(
|
||||
children: [
|
||||
// ✅ Используем общий AppBar
|
||||
const SizedBox(height: 16),
|
||||
CustomAppBar(title: 'Документы'),
|
||||
const SizedBox(height: 32),
|
||||
|
||||
// Список ссылок
|
||||
LinkRow(
|
||||
icon: 'assets/icons/doc.png',
|
||||
title: 'Договор аренды',
|
||||
@@ -33,14 +32,14 @@ class DocumentsScreen extends StatelessWidget {
|
||||
LinkRow(
|
||||
icon: 'assets/icons/doc.png',
|
||||
title: 'Политика конфиденциальности',
|
||||
onTap: () => openLink('https://...'),
|
||||
onTap: () => context.push('/privacy-policy')
|
||||
),
|
||||
const Divider(height: 1, color: Colors.white24),
|
||||
const SizedBox(height: 12),
|
||||
LinkRow(
|
||||
icon: 'assets/icons/doc.png',
|
||||
title: 'Правила вождения',
|
||||
onTap: () => openLink('https://...'),
|
||||
onTap: () => openLink('https://behappybel.by/#rule'),
|
||||
),
|
||||
const Divider(height: 1, color: Colors.white24),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
@@ -93,7 +93,9 @@ class _MapScreenState extends State<MapScreen> {
|
||||
listenWhen: (previous, current) {
|
||||
return current.lastNotification !=
|
||||
previous.lastNotification ||
|
||||
current.flags != previous.flags;
|
||||
current.flags != previous.flags ||
|
||||
previous.selectedScooterForFocus?.id
|
||||
!= current.selectedScooterForFocus?.id;
|
||||
},
|
||||
|
||||
listener: (context, state) {
|
||||
@@ -164,14 +166,39 @@ class _MapScreenState extends State<MapScreen> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (state.selectedScooterForFocus != null) {
|
||||
final targetScooter = state.selectedScooterForFocus!;
|
||||
|
||||
print("RESERVED SCOOTER: $targetScooter");
|
||||
|
||||
_moveCameraToPoint(
|
||||
targetScooter.longitude,
|
||||
targetScooter.latitude,
|
||||
zoom: 17,
|
||||
);
|
||||
|
||||
context.read<MapBloc>().add(ClearMapFocus());
|
||||
}
|
||||
},
|
||||
buildWhen: (previous, current) =>
|
||||
previous.scooters != current.scooters ||
|
||||
previous.zones != current.zones,
|
||||
buildWhen: (previous, current) {
|
||||
return previous.scooters != current.scooters ||
|
||||
previous.reservedScooters != current.reservedScooters ||
|
||||
previous.zones != current.zones ||
|
||||
previous.status != current.status;
|
||||
},
|
||||
|
||||
builder: (context, state) {
|
||||
final scooters = _buildScooterPlacemarks(
|
||||
state.scooters,
|
||||
state.address ?? "Unknown address",
|
||||
final freeScooters = _buildScooterPlacemarks(
|
||||
scooters: state.scooters,
|
||||
iconAsset: 'assets/icons/scooter_placemark_fill.png',
|
||||
isClickable: true,
|
||||
);
|
||||
|
||||
final reservedScooters = _buildScooterPlacemarks(
|
||||
scooters: state.reservedScooters ?? [],
|
||||
iconAsset: 'assets/icons/scooter_reserved_placemark_fill.png',
|
||||
isClickable: false,
|
||||
);
|
||||
|
||||
final zonePolygons = _buildZonePolygons(state.zones);
|
||||
@@ -193,9 +220,10 @@ class _MapScreenState extends State<MapScreen> {
|
||||
},
|
||||
mapObjects: [
|
||||
...zonePolygons,
|
||||
...reservedScooters,
|
||||
ClusterizedPlacemarkCollection(
|
||||
mapId: const MapObjectId('scooters_cluster'),
|
||||
placemarks: scooters,
|
||||
placemarks: freeScooters,
|
||||
radius: 30,
|
||||
minZoom: 15,
|
||||
consumeTapEvents: true,
|
||||
@@ -232,7 +260,6 @@ class _MapScreenState extends State<MapScreen> {
|
||||
},
|
||||
),
|
||||
|
||||
// Индикатор загрузки (отдельный строитель для статуса)
|
||||
BlocBuilder<MapBloc, ScooterState>(
|
||||
buildWhen: (previous, current) =>
|
||||
previous.status != current.status,
|
||||
@@ -378,6 +405,7 @@ class _MapScreenState extends State<MapScreen> {
|
||||
}
|
||||
|
||||
void _onMarkerTap(List<Scooter> scooters) async {
|
||||
context.read<MapBloc>().add(CheckUser());
|
||||
final flags = context.read<MapBloc>().state.flags;
|
||||
|
||||
if (!flags.hasCard) {
|
||||
@@ -553,26 +581,26 @@ class _MapScreenState extends State<MapScreen> {
|
||||
await ClusterIconPainter.initImage('assets/icons/scooter_placemark.png');
|
||||
}
|
||||
|
||||
List<PlacemarkMapObject> _buildScooterPlacemarks(
|
||||
List<Scooter> scooters,
|
||||
String address,
|
||||
) {
|
||||
List<PlacemarkMapObject> _buildScooterPlacemarks({
|
||||
required List<Scooter> scooters,
|
||||
required String iconAsset,
|
||||
required bool isClickable,
|
||||
}) {
|
||||
return scooters.map((scooter) {
|
||||
return PlacemarkMapObject(
|
||||
mapId: MapObjectId('${scooter.id}'),
|
||||
mapId: MapObjectId('${isClickable ? "" : "reserved_"}${scooter.id}'), // уникальный ID для карты
|
||||
point: Point(latitude: scooter.longitude, longitude: scooter.latitude),
|
||||
icon: PlacemarkIcon.single(
|
||||
PlacemarkIconStyle(
|
||||
image: BitmapDescriptor.fromAssetImage(
|
||||
'assets/icons/scooter_placemark_fill.png',
|
||||
),
|
||||
image: BitmapDescriptor.fromAssetImage(iconAsset),
|
||||
scale: 0.2,
|
||||
),
|
||||
),
|
||||
opacity: 1.0,
|
||||
onTap: (object, point) async => {
|
||||
_onMarkerTap([scooter]),
|
||||
},
|
||||
consumeTapEvents: isClickable,
|
||||
onTap: isClickable
|
||||
? (object, point) async => _onMarkerTap([scooter])
|
||||
: null,
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
@@ -9,9 +9,11 @@ import '../components/custom_app_bar.dart';
|
||||
import '../components/gradient_button.dart';
|
||||
import '../components/payment_option.dart';
|
||||
import '../components/sheet/payment_method_sheet.dart';
|
||||
import '../event/map_event.dart';
|
||||
import '../event/payment_confirm_event.dart';
|
||||
import '../event/payment_method_sheet_event.dart';
|
||||
import '../state/payment_confirm_state.dart';
|
||||
import '../viewmodel/map_bloc.dart';
|
||||
import '../viewmodel/payment_confirm_bloc.dart';
|
||||
import '../viewmodel/payment_method_sheet_bloc.dart';
|
||||
|
||||
@@ -78,6 +80,7 @@ class _PaymentConfirmScreenContent extends StatelessWidget {
|
||||
|
||||
listener: (context, state) {
|
||||
if (state.status == PaymentConfirmStatus.success && state.paymentCompleted) {
|
||||
context.read<MapBloc>().add(ClearMapPlacemarks());
|
||||
context.go('/home');
|
||||
} else if (state.status == PaymentConfirmStatus.failure) {
|
||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||
|
||||
@@ -17,43 +17,63 @@ class PaymentMethodsScreen extends StatelessWidget {
|
||||
body: Container(
|
||||
decoration: const BoxDecoration(gradient: AppColors.phoneScreenBg),
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 16),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
child: CustomAppBar(title: 'Способы оплаты'),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Expanded(
|
||||
child: BlocConsumer<PaymentMethodsBloc, PaymentMethodsState>(
|
||||
listener: (context, state) {
|
||||
if (state.status == PaymentMethodsStatus.failure) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(state.errorMessage ?? 'Ошибка')),
|
||||
);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
if (state.status == PaymentMethodsStatus.loading && state.cards.isEmpty) {
|
||||
return const Center(child: CircularProgressIndicator(color: Color(0xFF00D4AA)));
|
||||
}
|
||||
child: BlocConsumer<PaymentMethodsBloc, PaymentMethodsState>(
|
||||
listener: (context, state) {
|
||||
if (state.status == PaymentMethodsStatus.failure) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(state.errorMessage ?? 'Ошибка')),
|
||||
);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
final isNetworkProcessing = state.status == PaymentMethodsStatus.loading ||
|
||||
(state.isDeleting ?? false) ||
|
||||
(state.isSettingMain ?? false);
|
||||
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_buildBalanceCard(context, state.balance),
|
||||
const SizedBox(height: 20),
|
||||
_buildCardsList(context, state),
|
||||
],
|
||||
return Stack(
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
const SizedBox(height: 16),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
child: CustomAppBar(title: 'Способы оплаты'),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 24),
|
||||
Expanded(
|
||||
child: state.cards.isEmpty && state.status == PaymentMethodsStatus.loading
|
||||
? const Center(
|
||||
child: CircularProgressIndicator(color: Color(0xFF00D4AA)),
|
||||
)
|
||||
: SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_buildBalanceCard(context, state.balance),
|
||||
const SizedBox(height: 20),
|
||||
_buildCardsList(context, state),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
if (isNetworkProcessing && state.cards.isNotEmpty)
|
||||
Positioned.fill(
|
||||
child: Container(
|
||||
color: Colors.black.withOpacity(0.4),
|
||||
child: const Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Color(0xFF00D4AA),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -163,7 +183,13 @@ class PaymentMethodsScreen extends StatelessWidget {
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () => context.go('/home/payment-methods/add-card'),
|
||||
onTap: () async {
|
||||
final isCardAdded = await context.push<bool>('/home/payment-methods/add-card');
|
||||
|
||||
if (isCardAdded == true && context.mounted) {
|
||||
context.read<PaymentMethodsBloc>().add(PaymentMethodsStarted());
|
||||
}
|
||||
},
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
|
||||
@@ -50,7 +50,9 @@ 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) {
|
||||
@@ -70,56 +72,82 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
}
|
||||
|
||||
final profile = state.profile!;
|
||||
return SingleChildScrollView(
|
||||
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,
|
||||
), GestureDetector(
|
||||
onTap: _pickImage,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(top: 0, right: 0),
|
||||
child: Image.asset(
|
||||
'assets/icons/edit.png',
|
||||
width: 24,
|
||||
height: 24,
|
||||
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),
|
||||
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 32),
|
||||
|
||||
_ProfileInfoBlock(
|
||||
profile: profile,
|
||||
onEditTap: () => context.go("/home/profile/edit"),
|
||||
),
|
||||
|
||||
// const SizedBox(height: 24),
|
||||
// _SettingsBlock(
|
||||
// notificationsEnabled: notificationsEnabled,
|
||||
// onNotificationsChanged: (v) =>
|
||||
// setState(() => notificationsEnabled = v),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
_ProfileInfoBlock(
|
||||
profile: profile,
|
||||
onEditTap: () => context.go("/home/profile/edit"),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
_SettingsBlock(
|
||||
notificationsEnabled: notificationsEnabled,
|
||||
onNotificationsChanged: (v) =>
|
||||
setState(() => notificationsEnabled = v),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
|
||||
import 'dart:math' as math;
|
||||
import 'package:be_happy/presentation/event/spalsh_event.dart';
|
||||
import 'package:be_happy/presentation/viewmodel/splash_bloc.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
// Подключи сюда свои реальные экраны:
|
||||
import 'phone_screen.dart';
|
||||
import 'pin_login_screen.dart';
|
||||
|
||||
class SplashScreen extends StatefulWidget {
|
||||
const SplashScreen({super.key});
|
||||
@@ -19,35 +14,61 @@ class SplashScreen extends StatefulWidget {
|
||||
class _SplashScreenState extends State<SplashScreen>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late final AnimationController _controller;
|
||||
late final Animation<double> _revealAnimation;
|
||||
|
||||
static const double logoSize = 300;
|
||||
// Фаза 1: Заполнение цветом слева направо (0.0 -> 0.5)
|
||||
late final Animation<double> _fillProgress;
|
||||
|
||||
// Фаза 2: Укатывание вправо (0.6 -> 1.0)
|
||||
late final Animation<double> _rollTranslation;
|
||||
late final Animation<double> _rollRotation;
|
||||
|
||||
// Уменьшенный размер логотипа по вашему запросу
|
||||
static const double logoSize = 130;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
// контроллер анимации
|
||||
_controller = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 2500),
|
||||
duration: const Duration(milliseconds: 3000),
|
||||
);
|
||||
|
||||
// анимация движения "затемняющего" прямоугольника
|
||||
_revealAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
|
||||
CurvedAnimation(parent: _controller, curve: Curves.easeInOut),
|
||||
_fillProgress = Tween<double>(begin: 0.0, end: 1.0).animate(
|
||||
CurvedAnimation(
|
||||
parent: _controller,
|
||||
curve: const Interval(0.0, 0.5, curve: Curves.easeInOut),
|
||||
),
|
||||
);
|
||||
|
||||
// запускаем анимацию
|
||||
_controller.forward().then((_) async {
|
||||
// небольшая пауза после анимации
|
||||
await Future.delayed(const Duration(milliseconds: 800));
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
context.read<SplashBloc>().add(AuthCheckRequested());
|
||||
_rollTranslation = Tween<double>(begin: 0.0, end: 1.0).animate(
|
||||
CurvedAnimation(
|
||||
parent: _controller,
|
||||
curve: const Interval(0.6, 1.0, curve: Curves.easeInCubic),
|
||||
),
|
||||
);
|
||||
|
||||
_rollRotation = Tween<double>(begin: 0.0, end: 2 * math.pi).animate(
|
||||
CurvedAnimation(
|
||||
parent: _controller,
|
||||
curve: const Interval(0.6, 1.0, curve: Curves.easeIn),
|
||||
),
|
||||
);
|
||||
|
||||
// Добавляем задержку перед стартом, чтобы пользователь успел увидеть экран
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
if (!mounted) return;
|
||||
|
||||
// Ждем 500мс после того, как первый кадр отрисовался
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
|
||||
if (!mounted) return;
|
||||
// Запускаем анимацию
|
||||
_controller.forward().then((_) {
|
||||
if (!mounted) return;
|
||||
context.read<SplashBloc>().add(AuthCheckRequested());
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -56,69 +77,102 @@ class _SplashScreenState extends State<SplashScreen>
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final double screenWidth = MediaQuery.of(context).size.width;
|
||||
final double endTranslation = screenWidth / 2 + logoSize;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFF3A3A3A),
|
||||
body: Center(
|
||||
child: AnimatedBuilder(
|
||||
animation: _controller,
|
||||
builder: (context, _) {
|
||||
final double offset = _revealAnimation.value * (logoSize * 1.2);
|
||||
|
||||
return Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
// Цветной логотип (на заднем плане)
|
||||
Image.asset(
|
||||
'assets/logo_color.png',
|
||||
width: logoSize,
|
||||
height: logoSize,
|
||||
fit: BoxFit.contain,
|
||||
body: Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Color(0xFF293A69),
|
||||
Color(0xFF202741),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Прямоугольник, который "уезжает" вправо, открывая логотип
|
||||
ClipRect(
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: FractionallySizedBox(
|
||||
widthFactor: 1,
|
||||
child: Container(
|
||||
width: logoSize,
|
||||
height: logoSize,
|
||||
color: const Color(0xFF3A3A3A),
|
||||
transform: Matrix4.translationValues(offset, 0, 0),
|
||||
),
|
||||
// 2. Волна
|
||||
Positioned(
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Image.asset(
|
||||
'assets/wave.png',
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Image.asset(
|
||||
'assets/splash_map.png',
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
|
||||
Center(
|
||||
child: AnimatedBuilder(
|
||||
animation: _controller,
|
||||
builder: (context, child) {
|
||||
final double translationX = _rollTranslation.value * endTranslation;
|
||||
|
||||
return Transform(
|
||||
transform: Matrix4.translationValues(translationX, 0, 0)
|
||||
..rotateZ(_rollRotation.value),
|
||||
alignment: Alignment.center,
|
||||
// Используем ShaderMask для эффекта заполнения/проявления
|
||||
child: ShaderMask(
|
||||
shaderCallback: (bounds) {
|
||||
return LinearGradient(
|
||||
begin: Alignment.centerLeft,
|
||||
end: Alignment.centerRight,
|
||||
// Используем _fillProgress для сдвига жесткой границы градиента
|
||||
colors: const [Colors.white, Colors.transparent],
|
||||
stops: [_fillProgress.value, _fillProgress.value],
|
||||
).createShader(bounds);
|
||||
},
|
||||
blendMode: BlendMode.dstIn, // Оставляет только ту часть логотипа, где градиент белый
|
||||
child: Image.asset(
|
||||
'assets/splash_logo.png',
|
||||
width: logoSize,
|
||||
height: logoSize,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Обводка логотипа (поверх)
|
||||
Image.asset(
|
||||
'assets/logo_outline.png',
|
||||
width: logoSize * 1.01,
|
||||
height: logoSize * 1.01,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
bottomNavigationBar: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 24),
|
||||
child: Text(
|
||||
'Версия приложения 1.0',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.white.withOpacity(0.8),
|
||||
fontSize: 12,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// 5. Версия приложения
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 24,
|
||||
child: Text(
|
||||
'Версия приложения 1.0',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.white.withOpacity(0.6),
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w300,
|
||||
letterSpacing: 0.5,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -27,15 +27,26 @@ class SubscriptionDetailsScreen extends StatelessWidget {
|
||||
const SizedBox(height: 16),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: BlocBuilder<SubscriptionDetailsBloc, SubscriptionDetailsState>(
|
||||
builder: (context, state) {
|
||||
String title = "Загрузка...";
|
||||
if (state is DetailsContentState) {
|
||||
title = state.subscription.title;
|
||||
}
|
||||
return CustomAppBar(title: title);
|
||||
},
|
||||
),
|
||||
child:
|
||||
BlocConsumer<
|
||||
SubscriptionDetailsBloc,
|
||||
SubscriptionDetailsState
|
||||
>(
|
||||
listenWhen: (previous, current) =>
|
||||
current is DetailsContentState && current.isSuccess,
|
||||
listener: (context, state) {
|
||||
if (state is DetailsContentState && state.isSuccess) {
|
||||
context.pop(true);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
String title = "Загрузка...";
|
||||
if (state is DetailsContentState) {
|
||||
title = state.subscription.title;
|
||||
}
|
||||
return CustomAppBar(title: title);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
@@ -53,11 +64,16 @@ class SubscriptionDetailsScreen extends StatelessWidget {
|
||||
child: Image.asset('assets/wave.png'),
|
||||
),
|
||||
),
|
||||
BlocBuilder<SubscriptionDetailsBloc, SubscriptionDetailsState>(
|
||||
BlocBuilder<
|
||||
SubscriptionDetailsBloc,
|
||||
SubscriptionDetailsState
|
||||
>(
|
||||
builder: (context, state) {
|
||||
if (state is DetailsLoading) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(color: Color(0xFF80FFD1)),
|
||||
child: CircularProgressIndicator(
|
||||
color: Color(0xFF80FFD1),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (state is DetailsError) {
|
||||
@@ -85,6 +101,7 @@ class SubscriptionDetailsScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildContent(BuildContext context, DetailsContentState state) {
|
||||
final bool isAvailableForPurchase = state.subscription.isActive;
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 20),
|
||||
child: Column(
|
||||
@@ -98,22 +115,28 @@ class SubscriptionDetailsScreen extends StatelessWidget {
|
||||
height: 1.5,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
|
||||
_ActionCard(state: state),
|
||||
if (isAvailableForPurchase) ...[
|
||||
const SizedBox(height: 30),
|
||||
|
||||
const SizedBox(height: 30),
|
||||
_ActionCard(state: state),
|
||||
|
||||
GradientButton(
|
||||
text: 'Активировать',
|
||||
onTap: () => context.read<SubscriptionDetailsBloc>().add(
|
||||
ActivateSubscriptionPressed(),
|
||||
const SizedBox(height: 30),
|
||||
|
||||
GradientButton(
|
||||
text: state.isAlreadyPurchased ? 'Продлить' : 'Активировать',
|
||||
onTap: () {
|
||||
context.read<SubscriptionDetailsBloc>().add(
|
||||
ActivateSubscriptionPressed(),
|
||||
);
|
||||
},
|
||||
enabled: state.isAgreed,
|
||||
width: double.infinity,
|
||||
height: 56,
|
||||
fontSize: 16,
|
||||
showArrows: true,
|
||||
),
|
||||
width: double.infinity,
|
||||
height: 56,
|
||||
fontSize: 16,
|
||||
showArrows: true,
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
@@ -232,4 +255,4 @@ class _PriceRow extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:be_happy/presentation/event/subscription_list_event.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
@@ -44,17 +45,26 @@ class SubscriptionsListScreen extends StatelessWidget {
|
||||
if (state is SubscriptionsLoading) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
} else if (state is SubscriptionsLoaded) {
|
||||
final activeIds = state.activeSubscriptions.map((e) => e.id).toSet();
|
||||
final clientSubsMap = {
|
||||
for (var sub in state.activeSubscriptions) sub.subscriptionId: sub
|
||||
};
|
||||
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.only(top: 20),
|
||||
itemCount: state.subscriptions.length,
|
||||
itemBuilder: (context, index) {
|
||||
final subscription = state.subscriptions[index];
|
||||
final bool isActive = activeIds.contains(subscription.id);
|
||||
|
||||
final bool isPurchased = subscription.isCurrent;
|
||||
|
||||
final clientSub = clientSubsMap[subscription.id];
|
||||
final DateTime? expirationDate = isPurchased ? clientSub?.expiredAt : null;
|
||||
|
||||
return SubscriptionCard(
|
||||
subscription: subscription,
|
||||
isActive: isActive,
|
||||
isActive: isPurchased,
|
||||
expiredAt: expirationDate,
|
||||
onRefresh: () { context.read<SubscriptionListBloc>().add(LoadSubscriptionsEvent());},
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -170,7 +170,7 @@ class TopUpScreen extends StatelessWidget {
|
||||
create: (context) =>
|
||||
PaymentMethodSheetBloc(getIt<GetPaymentCardsUsecase>())
|
||||
..add(PaymentMethodSheetStarted()),
|
||||
child: const PaymentMethodSheet(),
|
||||
child: const PaymentMethodSheet(showBalance: false,),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ class ActiveRideState {
|
||||
final double cost;
|
||||
final bool isPaused;
|
||||
final bool inZone;
|
||||
final double latitude;
|
||||
final double longitude;
|
||||
|
||||
const ActiveRideState({
|
||||
this.status = ActiveRideStatus.initial,
|
||||
@@ -20,6 +22,8 @@ class ActiveRideState {
|
||||
this.elapsedTime = Duration.zero,
|
||||
this.speed = 0.0,
|
||||
this.distance = 0.0,
|
||||
this.latitude = 0.0,
|
||||
this.longitude = 0.0,
|
||||
this.cost = 0.0,
|
||||
this.isPaused = false,
|
||||
this.inZone = true,
|
||||
@@ -33,6 +37,8 @@ class ActiveRideState {
|
||||
double? speed,
|
||||
double? distance,
|
||||
double? cost,
|
||||
double? longitude,
|
||||
double? latitude,
|
||||
bool? isPaused,
|
||||
bool? inZone,
|
||||
}) {
|
||||
@@ -44,6 +50,8 @@ class ActiveRideState {
|
||||
speed: speed ?? this.speed,
|
||||
distance: distance ?? this.distance,
|
||||
cost: cost ?? this.cost,
|
||||
latitude: latitude ?? this.latitude,
|
||||
longitude: longitude ?? this.longitude,
|
||||
isPaused: isPaused ?? this.isPaused,
|
||||
inZone: inZone ?? this.inZone,
|
||||
);
|
||||
|
||||
@@ -9,6 +9,8 @@ enum ScooterStatus { initial, loading, success, failure }
|
||||
|
||||
class ScooterState {
|
||||
final List<Scooter> scooters;
|
||||
final List<Scooter> reservedScooters;
|
||||
final Scooter? selectedScooterForFocus;
|
||||
final List<Zone> zones;
|
||||
final List<double> area;
|
||||
final List<double> areaScooters;
|
||||
@@ -23,6 +25,8 @@ class ScooterState {
|
||||
|
||||
ScooterState({
|
||||
this.scooters = const [],
|
||||
this.reservedScooters = const [],
|
||||
this.selectedScooterForFocus,
|
||||
this.zones = const [],
|
||||
this.area = const [],
|
||||
this.areaScooters = const [],
|
||||
@@ -38,6 +42,8 @@ class ScooterState {
|
||||
|
||||
ScooterState copyWith({
|
||||
List<Scooter>? scooters,
|
||||
List<Scooter>? reservedScooters,
|
||||
Scooter? selectedScooterForFocus,
|
||||
List<Zone>? zones,
|
||||
List<double>? area,
|
||||
List<double>? areaScooters,
|
||||
@@ -52,6 +58,8 @@ class ScooterState {
|
||||
}) {
|
||||
return ScooterState(
|
||||
scooters: scooters ?? this.scooters,
|
||||
reservedScooters: reservedScooters ?? this.reservedScooters,
|
||||
selectedScooterForFocus: selectedScooterForFocus ?? this.selectedScooterForFocus,
|
||||
zones: zones ?? this.zones,
|
||||
area: area ?? this.area,
|
||||
areaScooters: areaScooters ?? this.areaScooters,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'package:be_happy/domain/entities/client_subscription.dart';
|
||||
|
||||
import '../../domain/entities/subscription.dart';
|
||||
|
||||
abstract class SubscriptionState {}
|
||||
@@ -6,7 +8,7 @@ class SubscriptionsLoading extends SubscriptionState {}
|
||||
|
||||
class SubscriptionsLoaded extends SubscriptionState {
|
||||
final List<Subscription> subscriptions;
|
||||
final List<Subscription> activeSubscriptions;
|
||||
final List<ClientSubscription> activeSubscriptions;
|
||||
|
||||
SubscriptionsLoaded({
|
||||
required this.subscriptions,
|
||||
|
||||
@@ -15,21 +15,29 @@ class DetailsContentState extends SubscriptionDetailsState {
|
||||
final Subscription subscription;
|
||||
final SubscriptionPeriod selectedPeriod;
|
||||
final bool isAgreed;
|
||||
final bool isAlreadyPurchased; // ✅ Куплена ли эта подписка сейчас
|
||||
final bool isSuccess; // ✅ Сигнал для навигатора назад
|
||||
|
||||
DetailsContentState({
|
||||
required this.subscription,
|
||||
required this.selectedPeriod,
|
||||
this.isAgreed = false,
|
||||
this.isAlreadyPurchased = false,
|
||||
this.isSuccess = false,
|
||||
});
|
||||
|
||||
DetailsContentState copyWith({
|
||||
SubscriptionPeriod? selectedPeriod,
|
||||
bool? isAgreed,
|
||||
bool? isAlreadyPurchased,
|
||||
bool? isSuccess,
|
||||
}) {
|
||||
return DetailsContentState(
|
||||
subscription: this.subscription,
|
||||
selectedPeriod: selectedPeriod ?? this.selectedPeriod,
|
||||
isAgreed: isAgreed ?? this.isAgreed,
|
||||
isAlreadyPurchased: isAlreadyPurchased ?? this.isAlreadyPurchased,
|
||||
isSuccess: isSuccess ?? this.isSuccess,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -76,6 +76,8 @@ class ActiveRideBloc extends Bloc<ActiveRideEvent, ActiveRideState> {
|
||||
cost: orderData?.price ?? 0.0,
|
||||
isPaused: isPaused,
|
||||
inZone: orderData?.zone,
|
||||
latitude: orderData?.latitude,
|
||||
longitude: orderData?.longitude,
|
||||
));
|
||||
|
||||
_syncTimer?.cancel();
|
||||
@@ -196,6 +198,8 @@ class ActiveRideBloc extends Bloc<ActiveRideEvent, ActiveRideState> {
|
||||
cost: orderData?.price ?? state.cost,
|
||||
isPaused: isPaused,
|
||||
inZone: orderData?.zone,
|
||||
latitude: orderData?.latitude,
|
||||
longitude: orderData?.longitude,
|
||||
));
|
||||
}
|
||||
print("CURRENT STATE $state");
|
||||
|
||||
@@ -5,6 +5,7 @@ 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_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';
|
||||
import 'package:be_happy/domain/usecase/logout_usecase.dart';
|
||||
@@ -13,6 +14,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../domain/entities/point.dart';
|
||||
import '../../domain/entities/scooter.dart';
|
||||
import '../../domain/entities/scooter_order.dart';
|
||||
import '../../domain/entities/zone.dart';
|
||||
import '../../domain/usecase/get_available_scooters_usecase.dart';
|
||||
import '../../domain/usecase/get_profile_usecase.dart';
|
||||
@@ -23,6 +25,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 GetMapSettingsUsecase getMapSettingsUsecase;
|
||||
final GetNotificationsStreamUseCase getNotificationsStreamUseCase;
|
||||
@@ -35,6 +38,7 @@ class MapBloc extends Bloc<ScooterEvent, ScooterState> {
|
||||
MapBloc(
|
||||
this.getAvailableZonesUsecase,
|
||||
this.getScootersUsecase,
|
||||
this.getClientOrdersUsecase,
|
||||
this.getMapSettingsUsecase,
|
||||
this.getNotificationsStreamUseCase,
|
||||
this.getProfileUseCase,
|
||||
@@ -49,6 +53,9 @@ class MapBloc extends Bloc<ScooterEvent, ScooterState> {
|
||||
on<FetchProfileData>(_onFetchProfileData);
|
||||
on<CheckUser>(_onCheckUser);
|
||||
on<LogoutPressed>(_onLogoutPressed);
|
||||
on<FocusOnScooter>(_onFocusOnScooter);
|
||||
on<ClearMapPlacemarks>(_onClearMapPlacemarks);
|
||||
on<ClearMapFocus>(_onClearMapFocus);
|
||||
}
|
||||
|
||||
void startNotificationStream() {
|
||||
@@ -97,11 +104,15 @@ class MapBloc extends Bloc<ScooterEvent, ScooterState> {
|
||||
getScootersUsecase(event.areaScooters, 0, 100),
|
||||
getAvailableZonesUsecase(event.area, 0, 100),
|
||||
getMapSettingsUsecase(),
|
||||
getClientOrdersUsecase(),
|
||||
]);
|
||||
|
||||
final scooters = results[0] as List<Scooter>;
|
||||
final zones = results[1] as List<Zone>;
|
||||
final settings = results[2] as MapSettings;
|
||||
final orders = results[3];
|
||||
|
||||
|
||||
|
||||
zones.forEach(print);
|
||||
|
||||
@@ -127,6 +138,7 @@ class MapBloc extends Bloc<ScooterEvent, ScooterState> {
|
||||
state.copyWith(
|
||||
status: ScooterStatus.success,
|
||||
scooters: scooters,
|
||||
// reservedScooters: reservedScooters,
|
||||
zones: filteredZones,
|
||||
area: event.area,
|
||||
areaScooters: event.areaScooters,
|
||||
@@ -236,7 +248,9 @@ class MapBloc extends Bloc<ScooterEvent, ScooterState> {
|
||||
try {
|
||||
final profile = await getProfileUseCase();
|
||||
|
||||
emit(state.copyWith(phoneNumber: profile.phone, balance: profile.balance));
|
||||
emit(
|
||||
state.copyWith(phoneNumber: profile.phone, balance: profile.balance),
|
||||
);
|
||||
} catch (e) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
@@ -280,4 +294,52 @@ class MapBloc extends Bloc<ScooterEvent, ScooterState> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _onFocusOnScooter(FocusOnScooter event, Emitter<ScooterState> emit) {
|
||||
final updatedReserved = List<Scooter>.from(state.reservedScooters ?? []);
|
||||
if (!updatedReserved.any((s) => s.id == event.scooter.id)) {
|
||||
updatedReserved.add(event.scooter);
|
||||
}
|
||||
|
||||
emit(state.copyWith(
|
||||
selectedScooterForFocus: event.scooter,
|
||||
reservedScooters: updatedReserved,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
||||
FutureOr<void> _onClearMapPlacemarks(ClearMapPlacemarks event, Emitter<ScooterState> emit) async {
|
||||
try{
|
||||
final orders = await getClientOrdersUsecase();
|
||||
|
||||
List<Scooter> updatedReservedScooters = [];
|
||||
|
||||
if (orders is Success<List<ScooterOrder>>) {
|
||||
print("FETCH: orders.data.length = ${orders.data?.length}");
|
||||
|
||||
updatedReservedScooters = orders.data?.map((order) {
|
||||
return order.scooter;
|
||||
}).toList() ?? [];
|
||||
}
|
||||
|
||||
emit(state.copyWith(
|
||||
reservedScooters: updatedReservedScooters,
|
||||
));
|
||||
} catch (e) {
|
||||
print("Error in _onClearMapPlacemarks: $e");
|
||||
emit(state.copyWith(
|
||||
status: ScooterStatus.failure,
|
||||
errorMessage: e.toString(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _onClearMapFocus(ClearMapFocus event, Emitter<ScooterState> emit) {
|
||||
emit(state.copyWith(
|
||||
selectedScooterForFocus: null,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'package:be_happy/domain/entities/scooter_order.dart';
|
||||
import 'package:be_happy/domain/usecase/get_scooter_order_history_usecase.dart';
|
||||
import 'package:be_happy/core/result.dart';
|
||||
|
||||
// 🔹 EVENTS
|
||||
abstract class OrderHistoryEvent {}
|
||||
|
||||
class OrderHistoryFetchRequested extends OrderHistoryEvent {
|
||||
@@ -13,7 +12,6 @@ class OrderHistoryFetchRequested extends OrderHistoryEvent {
|
||||
|
||||
class OrderHistoryRefreshRequested extends OrderHistoryEvent {}
|
||||
|
||||
// 🔹 STATES
|
||||
enum OrderHistoryStatus { initial, loading, success, failure, empty }
|
||||
|
||||
class OrderHistoryState {
|
||||
|
||||
@@ -89,12 +89,11 @@ class PaymentConfirmBloc
|
||||
event.isBalance,
|
||||
);
|
||||
|
||||
if (result is Success<ScooterOrder>) {
|
||||
if (result is Success<void>) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
status: PaymentConfirmStatus.success,
|
||||
paymentCompleted: true,
|
||||
|
||||
),
|
||||
);
|
||||
} else if (result is Failure) {
|
||||
|
||||
@@ -70,13 +70,16 @@ class PaymentMethodsBloc extends Bloc<PaymentMethodsEvent, PaymentMethodsState>
|
||||
PaymentMethodsDeleteCard event,
|
||||
Emitter<PaymentMethodsState> emit,
|
||||
) async {
|
||||
emit(state.copyWith(isDeleting: true));
|
||||
emit(state.copyWith(
|
||||
status: PaymentMethodsStatus.loading,
|
||||
isDeleting: true,
|
||||
));
|
||||
|
||||
try {
|
||||
final result = await _removePaymentCardUsecase(event.cardId);
|
||||
|
||||
if (result is Success) {
|
||||
emit(state.copyWith(isDeleting: false));
|
||||
emit(state.copyWith(isDeleting: false, status: PaymentMethodsStatus.success));
|
||||
add(PaymentMethodsStarted());
|
||||
} else if (result is Failure) {
|
||||
String errorMessage = 'Не удалось удалить карту';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:be_happy/core/result.dart';
|
||||
import 'package:be_happy/domain/entities/client_subscription.dart';
|
||||
import 'package:be_happy/domain/entities/subscription.dart';
|
||||
import 'package:be_happy/domain/usecase/get_available_subscriptions_usecase.dart';
|
||||
import 'package:be_happy/domain/usecase/get_client_subscriptions_usecase.dart';
|
||||
@@ -11,6 +12,7 @@ class SubscriptionListBloc extends Bloc<SubscriptionEvent, SubscriptionState> {
|
||||
final GetAvailableSubscriptionsUsecase getAvailableSubscriptionsUsecase;
|
||||
final GetClientSubscriptionsUsecase getClientSubscriptionsUsecase;
|
||||
|
||||
|
||||
SubscriptionListBloc({
|
||||
required this.getAvailableSubscriptionsUsecase,
|
||||
required this.getClientSubscriptionsUsecase,
|
||||
@@ -26,10 +28,25 @@ class SubscriptionListBloc extends Bloc<SubscriptionEvent, SubscriptionState> {
|
||||
final allResult = results[0];
|
||||
final activeResult = results[1] ;
|
||||
|
||||
if (allResult is Success<List<Subscription>> && activeResult is Success<List<Subscription>>) {
|
||||
if (allResult is Success<List<Subscription>> && activeResult is Success<List<ClientSubscription>>) {
|
||||
final availableSubs = allResult.data ?? [];
|
||||
final clientSubs = activeResult.data ?? [];
|
||||
|
||||
final Map<int, Subscription> combinedSubsMap = {};
|
||||
|
||||
for (var clientSub in clientSubs) {
|
||||
if (clientSub.subscription != null) {
|
||||
combinedSubsMap[clientSub.subscriptionId] = clientSub.subscription;
|
||||
}
|
||||
}
|
||||
|
||||
for (var sub in availableSubs) {
|
||||
combinedSubsMap[sub.id] = sub;
|
||||
}
|
||||
|
||||
emit(SubscriptionsLoaded(
|
||||
subscriptions: allResult.data ?? [],
|
||||
activeSubscriptions: activeResult.data ?? [],
|
||||
subscriptions: combinedSubsMap.values.toList(),
|
||||
activeSubscriptions: clientSubs,
|
||||
));
|
||||
} else {
|
||||
emit(SubscriptionsError("Не удалось загрузить данные из API"));
|
||||
|
||||
@@ -4,38 +4,59 @@ import 'package:be_happy/domain/usecase/activate_subscription_usecase.dart';
|
||||
import 'package:be_happy/domain/usecase/get_subscription_by_id_usecase.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../domain/entities/client_subscription.dart';
|
||||
import '../../domain/usecase/get_client_subscriptions_usecase.dart';
|
||||
import '../event/subscription_details_event.dart';
|
||||
import '../state/susbcription_details_state.dart';
|
||||
|
||||
class SubscriptionDetailsBloc extends Bloc<SubscriptionDetailsEvent, SubscriptionDetailsState> {
|
||||
class SubscriptionDetailsBloc
|
||||
extends Bloc<SubscriptionDetailsEvent, SubscriptionDetailsState> {
|
||||
final GetSubscriptionByIdUsecase getSubscriptionByIdUsecase;
|
||||
final ActivateSubscriptionUsecase activateSubscriptionUsecase;
|
||||
final GetClientSubscriptionsUsecase getClientSubscriptionsUsecase;
|
||||
|
||||
SubscriptionDetailsBloc(this.getSubscriptionByIdUsecase,
|
||||
this.activateSubscriptionUsecase) : super(DetailsLoading()) {
|
||||
SubscriptionDetailsBloc(
|
||||
this.getSubscriptionByIdUsecase,
|
||||
this.activateSubscriptionUsecase,
|
||||
this.getClientSubscriptionsUsecase,
|
||||
) : super(DetailsLoading()) {
|
||||
on<LoadDetailsEvent>((event, emit) async {
|
||||
emit(DetailsLoading());
|
||||
try {
|
||||
|
||||
final result = await getSubscriptionByIdUsecase(event.subscriptionId);
|
||||
|
||||
switch (result) {
|
||||
final clientSubsResult = await getClientSubscriptionsUsecase();
|
||||
bool isPurchased = false;
|
||||
|
||||
case Success<Subscription>():
|
||||
final sub = result.data;
|
||||
|
||||
if (sub == null) return;
|
||||
|
||||
emit(DetailsContentState(
|
||||
subscription: sub,
|
||||
selectedPeriod: sub.options.first,
|
||||
));
|
||||
case Failure<Subscription>():
|
||||
emit(DetailsError("Ошибка при запросе данных"));
|
||||
switch (clientSubsResult) {
|
||||
case Success<List<ClientSubscription>>():
|
||||
isPurchased = clientSubsResult.data?.any(
|
||||
(element) => element.subscriptionId == event.subscriptionId,
|
||||
) ?? false;
|
||||
break;
|
||||
|
||||
case Failure<List<ClientSubscription>>():
|
||||
isPurchased = false;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (result) {
|
||||
case Success<Subscription>():
|
||||
final sub = result.data;
|
||||
if (sub == null) return;
|
||||
|
||||
emit(
|
||||
DetailsContentState(
|
||||
subscription: sub,
|
||||
selectedPeriod: sub.options.first,
|
||||
isAlreadyPurchased: isPurchased,
|
||||
),
|
||||
);
|
||||
break;
|
||||
case Failure<Subscription>():
|
||||
emit(DetailsError("Ошибка при запросе данных"));
|
||||
break;
|
||||
}
|
||||
} catch (e) {
|
||||
emit(DetailsError("Не удалось загрузить данные"));
|
||||
}
|
||||
@@ -43,7 +64,9 @@ class SubscriptionDetailsBloc extends Bloc<SubscriptionDetailsEvent, Subscriptio
|
||||
|
||||
on<SelectPeriodEvent>((event, emit) {
|
||||
if (state is DetailsContentState) {
|
||||
emit((state as DetailsContentState).copyWith(selectedPeriod: event.period));
|
||||
emit(
|
||||
(state as DetailsContentState).copyWith(selectedPeriod: event.period),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -53,14 +76,23 @@ class SubscriptionDetailsBloc extends Bloc<SubscriptionDetailsEvent, Subscriptio
|
||||
}
|
||||
});
|
||||
|
||||
on<ActivateSubscriptionPressed>((event, emit) {
|
||||
switch(state) {
|
||||
on<ActivateSubscriptionPressed>((event, emit) async {
|
||||
switch (state) {
|
||||
case DetailsContentState contentState:
|
||||
activateSubscriptionUsecase(contentState.selectedPeriod.id);
|
||||
if (!contentState.isAgreed) {
|
||||
return;
|
||||
}
|
||||
|
||||
final result = await activateSubscriptionUsecase(contentState.selectedPeriod.id);
|
||||
|
||||
if (result is Success) {
|
||||
emit(contentState.copyWith(isSuccess: true));
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user