new project stable version

This commit is contained in:
2026-05-10 19:11:31 +03:00
commit 3616f84556
391 changed files with 23857 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
import '../../domain/entities/scooter_order.dart';
enum ActiveRideStatus { initial, loading, success, failure }
class ActiveRideState {
final ActiveRideStatus status;
final ScooterOrder? order;
final String? errorMessage;
final Duration elapsedTime;
final double speed;
final double distance;
final double cost;
final bool isPaused;
final bool inZone;
const ActiveRideState({
this.status = ActiveRideStatus.initial,
this.order,
this.errorMessage,
this.elapsedTime = Duration.zero,
this.speed = 0.0,
this.distance = 0.0,
this.cost = 0.0,
this.isPaused = false,
this.inZone = true,
});
ActiveRideState copyWith({
ActiveRideStatus? status,
ScooterOrder? order,
String? errorMessage,
Duration? elapsedTime,
double? speed,
double? distance,
double? cost,
bool? isPaused,
bool? inZone,
}) {
return ActiveRideState(
status: status ?? this.status,
order: order ?? this.order,
errorMessage: errorMessage ?? this.errorMessage,
elapsedTime: elapsedTime ?? this.elapsedTime,
speed: speed ?? this.speed,
distance: distance ?? this.distance,
cost: cost ?? this.cost,
isPaused: isPaused ?? this.isPaused,
inZone: inZone ?? this.inZone,
);
}
@override
String toString() {
return 'ActiveRideState{status: $status, cost: $cost, isPaused: $isPaused}';
}
}

View File

@@ -0,0 +1,45 @@
enum AddCardStatus { initial, loading, success, failure }
class AddCardState {
final AddCardStatus status;
final String cardNumber;
final String expiryDate;
final String cvv;
final String cardHolder;
final String errorMessage;
const AddCardState({
this.status = AddCardStatus.initial,
this.cardNumber = '',
this.expiryDate = '',
this.cvv = '',
this.cardHolder = '',
this.errorMessage = '',
});
AddCardState copyWith({
AddCardStatus? status,
String? cardNumber,
String? expiryDate,
String? cvv,
String? cardHolder,
String? errorMessage,
}) {
return AddCardState(
status: status ?? this.status,
cardNumber: cardNumber ?? this.cardNumber,
expiryDate: expiryDate ?? this.expiryDate,
cvv: cvv ?? this.cvv,
cardHolder: cardHolder ?? this.cardHolder,
errorMessage: errorMessage ?? this.errorMessage,
);
}
bool get isFormValid {
final cleanCardNumber = cardNumber.replaceAll(' ', '');
return cleanCardNumber.length == 16 &&
expiryDate.length == 5 &&
cvv.length == 3 &&
cardHolder.trim().isNotEmpty;
}
}

View File

@@ -0,0 +1,45 @@
class PhoneAuthState {
final String phone;
final bool isAdult;
final bool privacyAccepted;
final bool isSubmitting;
final bool isSuccess;
final String? error;
PhoneAuthState({
required this.phone,
required this.isAdult,
required this.privacyAccepted,
required this.isSubmitting,
required this.isSuccess,
this.error,
});
factory PhoneAuthState.initial() {
return PhoneAuthState(
phone: '',
isAdult: false,
privacyAccepted: false,
isSubmitting: false,
isSuccess: false,
);
}
PhoneAuthState copyWith({
String? phone,
bool? isAdult,
bool? privacyAccepted,
bool? isSubmitting,
bool? isSuccess,
String? error,
}) {
return PhoneAuthState(
phone: phone ?? this.phone,
isAdult: isAdult ?? this.isAdult,
privacyAccepted: privacyAccepted ?? this.privacyAccepted,
isSubmitting: isSubmitting ?? this.isSubmitting,
isSuccess: isSuccess ?? this.isSuccess,
error: error,
);
}
}

View File

@@ -0,0 +1,27 @@
import '../../domain/entities/scooter_order.dart';
enum CurrentRidesStatus { initial, loading, success, failure }
class CurrentRidesState {
final CurrentRidesStatus status;
final List<ScooterOrder> orders;
final String? errorMessage;
const CurrentRidesState({
this.status = CurrentRidesStatus.initial,
this.orders = const [],
this.errorMessage,
});
CurrentRidesState copyWith({
CurrentRidesStatus? status,
List<ScooterOrder>? orders,
String? errorMessage,
}) {
return CurrentRidesState(
status: status ?? this.status,
orders: orders ?? this.orders,
errorMessage: errorMessage ?? this.errorMessage,
);
}
}

View File

@@ -0,0 +1,42 @@
import '../../domain/entities/user_profile.dart';
class EditProfileState {
final bool isSaving;
final bool isSuccess;
final bool isLoading;
final UserProfile? profile;
final String? error;
const EditProfileState({
required this.isSaving,
required this.isSuccess,
required this.isLoading,
this.profile,
this.error,
});
factory EditProfileState.initial() {
return const EditProfileState(
isSaving: false,
isSuccess: false,
isLoading: false,
);
}
EditProfileState copyWith({
bool? isSaving,
bool? isSuccess,
bool? isLoading,
UserProfile? profile,
String? error,
}) {
return EditProfileState(
isSaving: isSaving ?? this.isSaving,
isSuccess: isSuccess ?? this.isSuccess,
isLoading: isLoading ?? this.isLoading,
profile: profile ?? this.profile,
error: error,
);
}
}

View File

@@ -0,0 +1,29 @@
class MapSettingsModalState {
final bool isAllGeomarksActive;
final bool isAllGeozonesActive;
final bool isRestrictedDrivingZoneActive;
final bool isParkingZoneActive;
final bool isRestrictedParkingZoneActive;
MapSettingsModalState({
required this.isAllGeomarksActive,
required this.isAllGeozonesActive,
required this.isRestrictedDrivingZoneActive,
required this.isParkingZoneActive,
required this.isRestrictedParkingZoneActive,
});
MapSettingsModalState copyWith({
bool? isGeomarksActive,
bool? isAllGeozonesActive,
bool? isRestrictedDrivingZoneActive,
bool? isParkingZoneActive,
bool? isRestrictedParkingZoneActive,
}) => MapSettingsModalState(
isAllGeomarksActive: isGeomarksActive ?? this.isAllGeomarksActive,
isAllGeozonesActive: isAllGeozonesActive ?? this.isAllGeozonesActive,
isRestrictedDrivingZoneActive: isRestrictedDrivingZoneActive ?? this.isRestrictedDrivingZoneActive,
isParkingZoneActive: isParkingZoneActive ?? this.isParkingZoneActive,
isRestrictedParkingZoneActive: isRestrictedParkingZoneActive ?? this.isRestrictedParkingZoneActive,
);
}

View File

@@ -0,0 +1,68 @@
import 'package:be_happy/domain/entities/user_check_flags.dart';
import '../../domain/entities/point.dart';
import '../../domain/entities/scooter.dart';
import '../../domain/entities/zone.dart';
import '../../domain/entities/client_notification.dart';
enum ScooterStatus { initial, loading, success, failure }
class ScooterState {
final List<Scooter> scooters;
final List<Zone> zones;
final List<double> area;
final List<double> areaScooters;
final ScooterStatus status;
final bool isGeomarksShowed;
final String? address;
final String? errorMessage;
final String phoneNumber;
final int balance;
final UserCheckFlags flags;
final ClientNotification? lastNotification;
ScooterState({
this.scooters = const [],
this.zones = const [],
this.area = const [],
this.areaScooters = const [],
this.status = ScooterStatus.initial,
required this.isGeomarksShowed,
this.address,
this.errorMessage,
this.phoneNumber = "+375XXXXXXXXX",
this.balance = 999,
this.flags = const UserCheckFlags(hasFine: false, hasUnpaidOrder: false, hasCard: false),
this.lastNotification,
});
ScooterState copyWith({
List<Scooter>? scooters,
List<Zone>? zones,
List<double>? area,
List<double>? areaScooters,
ScooterStatus? status,
bool? isGeomarksShowed,
String? address,
String? errorMessage,
String? phoneNumber,
int? balance,
UserCheckFlags? flags,
ClientNotification? lastNotification,
}) {
return ScooterState(
scooters: scooters ?? this.scooters,
zones: zones ?? this.zones,
area: area ?? this.area,
areaScooters: areaScooters ?? this.areaScooters,
status: status ?? this.status,
address: address ?? this.address,
isGeomarksShowed: isGeomarksShowed?? this.isGeomarksShowed,
errorMessage: errorMessage ?? this.errorMessage,
phoneNumber: phoneNumber ?? this.phoneNumber,
balance: balance ?? this.balance,
flags: flags ?? this.flags,
lastNotification: lastNotification ?? this.lastNotification,
);
}
}

View File

@@ -0,0 +1,31 @@
import '../../../domain/entities/news.dart';
enum NewsStatus { initial, loading, success, failure }
class NewsState {
final NewsStatus status;
final List<NewsEntity> news;
final String? errorMessage;
const NewsState({
required this.status,
this.news = const [],
this.errorMessage,
});
NewsState copyWith({
NewsStatus? status,
List<NewsEntity>? news,
String? errorMessage,
}) {
return NewsState(
status: status ?? this.status,
news: news ?? this.news,
errorMessage: errorMessage ?? this.errorMessage,
);
}
bool get isLoading => status == NewsStatus.loading;
bool get isSuccess => status == NewsStatus.success;
bool get isFailure => status == NewsStatus.failure;
}

View File

@@ -0,0 +1,45 @@
import 'package:be_happy/domain/entities/payment_card.dart';
import '../../domain/entities/scooter_order.dart';
enum PaymentConfirmStatus { initial, loading, success, failure }
class PaymentConfirmState {
final PaymentConfirmStatus status;
final PaymentCard? selectedCard;
final String? errorMessage;
final bool paymentCompleted;
final ScooterOrder? order;
final bool useBalance;
final int userBalance;
const PaymentConfirmState({
this.status = PaymentConfirmStatus.initial,
this.errorMessage,
this.selectedCard,
this.paymentCompleted = false,
this.order,
this.useBalance = false,
this.userBalance = 0,
});
PaymentConfirmState copyWith({
PaymentConfirmStatus? status,
String? errorMessage,
PaymentCard? selectedCard,
bool? paymentCompleted,
ScooterOrder? order,
bool? useBalance,
int? userBalance,
}) {
return PaymentConfirmState(
status: status ?? this.status,
errorMessage: errorMessage ?? this.errorMessage,
selectedCard: selectedCard ?? this.selectedCard,
paymentCompleted: paymentCompleted ?? this.paymentCompleted,
order: order ?? this.order,
useBalance: useBalance ?? this.useBalance,
userBalance: userBalance ?? this.userBalance,
);
}
}

View File

@@ -0,0 +1,30 @@
import '../../domain/entities/payment_card.dart';
enum PaymentMethodSheetStatus { initial, loading, success, failure }
class PaymentMethodSheetState {
final PaymentMethodSheetStatus status;
final List<PaymentCard> cards;
final double balance;
final String? errorMessage;
PaymentMethodSheetState({
this.status = PaymentMethodSheetStatus.initial,
this.cards = const [],
this.balance = 0.0,
this.errorMessage,
});
PaymentMethodSheetState copyWith({
PaymentMethodSheetStatus? status,
List<PaymentCard>? cards,
double? balance,
String? errorMessage,
}) =>
PaymentMethodSheetState(
status: status ?? this.status,
cards: cards ?? this.cards,
balance: balance ?? this.balance,
errorMessage: errorMessage ?? this.errorMessage,
);
}

View File

@@ -0,0 +1,38 @@
import '../../domain/entities/payment_card.dart';
enum PaymentMethodsStatus { initial, loading, success, failure }
class PaymentMethodsState {
final PaymentMethodsStatus status;
final List<PaymentCard> cards;
final int balance;
final String? errorMessage;
final bool isDeleting;
final bool isSettingMain;
PaymentMethodsState({
this.status = PaymentMethodsStatus.initial,
this.cards = const [],
this.balance = 99,
this.errorMessage,
this.isDeleting = false,
this.isSettingMain = false,
});
PaymentMethodsState copyWith({
PaymentMethodsStatus? status,
List<PaymentCard>? cards,
int? balance,
String? errorMessage,
bool? isDeleting,
bool? isSettingMain,
}) =>
PaymentMethodsState(
status: status ?? this.status,
cards: cards ?? this.cards,
balance: balance ?? this.balance,
errorMessage: errorMessage ?? this.errorMessage,
isDeleting: isDeleting ?? this.isDeleting,
isSettingMain: isSettingMain ?? this.isSettingMain,
);
}

View File

@@ -0,0 +1,27 @@
sealed class PinState {
final String pin;
final String? error;
const PinState({required this.pin, this.error});
}
// Состояние создания нового ПИН-кода
class PinCreateInProgress extends PinState {
const PinCreateInProgress({required String pin, String? error})
: super(pin: pin, error: error);
}
// Состояние ввода существующего ПИН-кода для входа
class PinLoginInProgress extends PinState {
const PinLoginInProgress({required String pin, String? error})
: super(pin: pin, error: error);
}
// Технические состояния
class PinLoading extends PinState {
const PinLoading() : super(pin: '');
}
class PinSuccess extends PinState {
const PinSuccess() : super(pin: '');
}

View File

@@ -0,0 +1,29 @@
import '../../domain/entities/user_profile.dart';
class ProfileState {
final bool isLoading;
final UserProfile? profile;
final String? error;
const ProfileState({
required this.isLoading,
this.profile,
this.error,
});
factory ProfileState.initial() {
return const ProfileState(isLoading: true);
}
ProfileState copyWith({
bool? isLoading,
UserProfile? profile,
String? error,
}) {
return ProfileState(
isLoading: isLoading ?? this.isLoading,
profile: profile ?? this.profile,
error: error,
);
}
}

View File

@@ -0,0 +1,29 @@
enum ReservedRideStatus { initial, loading, success, failure }
class ReservedRideState {
final ReservedRideStatus status;
final String? errorMessage;
final bool rideStarted;
final bool rideCancelled;
const ReservedRideState({
this.status = ReservedRideStatus.initial,
this.errorMessage,
this.rideStarted = false,
this.rideCancelled = false,
});
ReservedRideState copyWith({
ReservedRideStatus? status,
String? errorMessage,
bool? rideStarted,
bool? rideCancelled,
}) {
return ReservedRideState(
status: status ?? this.status,
errorMessage: errorMessage ?? this.errorMessage,
rideStarted: rideStarted ?? this.rideStarted,
rideCancelled: rideCancelled ?? this.rideCancelled,
);
}
}

View File

@@ -0,0 +1,18 @@
// route_state.dart
import '../../domain/entities/point.dart';
abstract class RouteState {}
class RouteInitial extends RouteState {}
class RouteLoading extends RouteState {}
class RouteLoaded extends RouteState {
final List<Point> points;
RouteLoaded(this.points);
}
class RouteError extends RouteState {
final String message;
RouteError(this.message);
}

View File

@@ -0,0 +1,23 @@
abstract class ScooterCodeState {
final String code;
final String? error;
const ScooterCodeState({this.code = '', this.error});
}
class ScooterCodeInitial extends ScooterCodeState {
const ScooterCodeInitial({super.code, super.error});
}
class ScooterCodeLoading extends ScooterCodeState {
const ScooterCodeLoading({super.code});
}
class ScooterCodeSuccess extends ScooterCodeState {
final dynamic scooter; // Замените dynamic на вашу модель Scooter
const ScooterCodeSuccess(this.scooter, {super.code});
}
class ScooterCodeFailure extends ScooterCodeState {
const ScooterCodeFailure(String error, {super.code}) : super(error: error);
}

View File

@@ -0,0 +1,32 @@
import '../../domain/entities/scooter.dart';
enum ScooterDetailModalStatus { initial, loading, success, failure }
class ScooterDetailModalState {
final ScooterDetailModalStatus status;
final String? address;
final String? errorMessage;
final List<Scooter>? scooters;
ScooterDetailModalState({
this.status = ScooterDetailModalStatus.initial,
this.address,
this.errorMessage,
this.scooters,
});
ScooterDetailModalState copyWith({
ScooterDetailModalStatus? status,
double? distance,
String? address,
String? errorMessage,
List<Scooter>? scooters,
}) => ScooterDetailModalState(
status: status ?? this.status,
address: address ?? this.address,
errorMessage: errorMessage ?? this.errorMessage,
scooters: scooters ?? this.scooters,
);
}

View File

@@ -0,0 +1,27 @@
import '../../domain/entities/scooter.dart';
enum ScooterStatus { initial, loading, success, failure }
class ScooterDetailState {
final ScooterStatus status;
final Scooter? scooter;
final String? errorMessage;
const ScooterDetailState({
this.status = ScooterStatus.initial,
this.scooter,
this.errorMessage,
});
ScooterDetailState copyWith({
ScooterStatus? status,
Scooter? scooter,
String? errorMessage,
}) {
return ScooterDetailState(
status: status ?? this.status,
scooter: scooter ?? this.scooter,
errorMessage: errorMessage ?? this.errorMessage,
);
}
}

View File

@@ -0,0 +1,31 @@
enum SendPhotoStatus { initial, loading, success, failure }
class SendPhotoState {
final SendPhotoStatus status;
final List<String> selectedImages;
final List<int> recievedPhotoIds;
final String errorMessage;
const SendPhotoState({
this.status = SendPhotoStatus.initial,
this.selectedImages = const [],
this.recievedPhotoIds = const [],
this.errorMessage = '',
});
SendPhotoState copyWith({
SendPhotoStatus? status,
List<String>? selectedImages,
List<int>? recievedPhotoIds,
String? errorMessage,
}) {
return SendPhotoState(
status: status ?? this.status,
selectedImages: selectedImages ?? this.selectedImages,
recievedPhotoIds: recievedPhotoIds ?? this.recievedPhotoIds,
errorMessage: errorMessage ?? this.errorMessage,
);
}
bool get hasSelectedImages => selectedImages.isNotEmpty;
}

View File

@@ -0,0 +1,25 @@
import 'package:equatable/equatable.dart';
abstract class SplashState extends Equatable {
const SplashState();
@override
List<Object> get props => [];
}
// Начальное состояние, когда мы еще не знаем, авторизован ли пользователь
class AuthInitial extends SplashState {}
class AuthInProgress extends SplashState {}
// Пользователь успешно авторизован (токен обновлен)
class AuthAuthenticated extends SplashState {}
// Пользователь не авторизован (нет токена или его не удалось обновить)
class AuthUnauthenticated extends SplashState {}
// успешно ввел пин код
class AuthPinVerified extends SplashState {}
// Специальное состояние для первого запуска приложения
class AuthFirstLaunch extends SplashState {}

View File

@@ -0,0 +1,20 @@
import '../../domain/entities/subscription.dart';
abstract class SubscriptionState {}
class SubscriptionsLoading extends SubscriptionState {}
class SubscriptionsLoaded extends SubscriptionState {
final List<Subscription> subscriptions;
final List<Subscription> activeSubscriptions;
SubscriptionsLoaded({
required this.subscriptions,
required this.activeSubscriptions,
});
}
class SubscriptionsError extends SubscriptionState {
final String message;
SubscriptionsError(this.message);
}

View File

@@ -0,0 +1,35 @@
import 'package:be_happy/domain/entities/subscription.dart';
import '../../domain/entities/subscription_period.dart';
abstract class SubscriptionDetailsState {}
class DetailsLoading extends SubscriptionDetailsState {}
class DetailsError extends SubscriptionDetailsState {
final String message;
DetailsError(this.message);
}
class DetailsContentState extends SubscriptionDetailsState {
final Subscription subscription;
final SubscriptionPeriod selectedPeriod;
final bool isAgreed;
DetailsContentState({
required this.subscription,
required this.selectedPeriod,
this.isAgreed = false,
});
DetailsContentState copyWith({
SubscriptionPeriod? selectedPeriod,
bool? isAgreed,
}) {
return DetailsContentState(
subscription: this.subscription,
selectedPeriod: selectedPeriod ?? this.selectedPeriod,
isAgreed: isAgreed ?? this.isAgreed,
);
}
}

View File

@@ -0,0 +1,40 @@
import 'package:be_happy/domain/entities/payment_card.dart';
import '../../domain/entities/tariff.dart';
enum TariffSheetStatus { initial, loading, success, failure }
class TariffSheetState {
final TariffSheetStatus status;
final List<Tariff> tariffs;
final String? errorMessage;
final PaymentCard? selectedCard;
final int userBalance;
final bool useBalance ;
TariffSheetState({
this.status = TariffSheetStatus.initial,
this.tariffs = const [],
this.selectedCard,
this.errorMessage,
this.userBalance = 0,
this.useBalance = false,
});
TariffSheetState copyWith({
TariffSheetStatus? status,
List<Tariff>? tariffs,
PaymentCard? selectedCard,
String? errorMessage,
int? userBalance,
bool? useBalance,
}) => TariffSheetState(
status: status ?? this.status,
tariffs: tariffs ?? this.tariffs,
selectedCard: selectedCard ?? this.selectedCard,
useBalance: useBalance ?? this.useBalance,
userBalance: userBalance ?? this.userBalance,
errorMessage: errorMessage ?? this.errorMessage,
);
}

View File

@@ -0,0 +1,40 @@
import 'package:be_happy/domain/entities/certificate.dart';
import 'package:be_happy/domain/entities/payment_card.dart';
import '../../domain/entities/top_up_tariff.dart';
class TopUpState {
final List<Certificate> certificates;
final List<PaymentCard> cards;
final Certificate? selectedTariff;
final PaymentCard? selectedCard;
final bool isLoading;
final bool isAgreed;
TopUpState({
this.certificates = const [],
this.cards = const [],
this.selectedTariff,
this.selectedCard,
this.isLoading = false,
this.isAgreed = false,
});
TopUpState copyWith({
List<Certificate>? certificates,
List<PaymentCard>? cards,
Certificate? selectedTariff,
PaymentCard? selectedCard,
bool? isLoading,
bool? isAgreed,
}) {
return TopUpState(
certificates: certificates ?? this.certificates,
cards: cards ?? this.cards,
selectedTariff: selectedTariff ?? this.selectedTariff,
selectedCard: selectedCard ?? this.selectedCard,
isLoading: isLoading ?? this.isLoading,
isAgreed: isAgreed ?? this.isAgreed,
);
}
}

View File

@@ -0,0 +1,60 @@
class VerifyCodeState {
final String phoneNumber;
final String tempToken;
final String code;
final int secondsLeft;
final int attemptsLeft;
final bool isSubmitting;
final bool isSuccess;
final bool isBlocked;
final String? error;
VerifyCodeState({
required this.phoneNumber,
required this.tempToken,
required this.code,
required this.secondsLeft,
required this.attemptsLeft,
required this.isSubmitting,
required this.isSuccess,
required this.isBlocked,
this.error,
});
factory VerifyCodeState.initial() {
return VerifyCodeState(
phoneNumber: '',
tempToken: '',
code: '',
secondsLeft: 60,
attemptsLeft: 3,
isSubmitting: false,
isSuccess: false,
isBlocked: false,
);
}
VerifyCodeState copyWith({
String? phoneNumber,
String? tempToken,
String? code,
int? secondsLeft,
int? attemptsLeft,
bool? isSubmitting,
bool? isSuccess,
bool? isBlocked,
String? error,
}) {
return VerifyCodeState(
phoneNumber: phoneNumber ?? this.phoneNumber,
tempToken: tempToken ?? this.tempToken,
code: code ?? this.code,
secondsLeft: secondsLeft ?? this.secondsLeft,
attemptsLeft: attemptsLeft ?? this.attemptsLeft,
isSubmitting: isSubmitting ?? this.isSubmitting,
isSuccess: isSuccess ?? this.isSuccess,
isBlocked: isBlocked ?? this.isBlocked,
error: error,
);
}
}