This commit is contained in:
2026-07-08 13:09:20 +03:00
parent b9da1d3064
commit 9eda119527
42 changed files with 830 additions and 279 deletions

View File

@@ -3,13 +3,21 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import '../../core/app_colors.dart';
import '../../di/service_locator.dart';
import '../../domain/entities/payment_card.dart';
import '../../domain/usecase/get_payment_cards_usecase.dart';
import '../../domain/usecase/set_main_payment_card_usecase.dart';
import '../components/app_checkbox.dart';
import '../components/custom_app_bar.dart';
import '../components/gradient_button.dart';
import '../components/payment_option.dart';
import '../components/period_selector.dart';
import '../components/content_parser.dart'; // ✅ Парсер контента
import '../components/sheet/payment_method_sheet.dart';
import '../event/payment_method_sheet_event.dart';
import '../event/subscription_details_event.dart';
import '../state/susbcription_details_state.dart';
import '../viewmodel/payment_method_sheet_bloc.dart';
import '../viewmodel/susbcription_details_bloc.dart';
class SubscriptionDetailsScreen extends StatelessWidget {
@@ -50,11 +58,9 @@ class SubscriptionDetailsScreen extends StatelessWidget {
),
const SizedBox(height: 20),
// 🔹 Контент
Expanded(
child: Stack(
children: [
// Волна снизу
Positioned(
bottom: 0,
left: 0,
@@ -108,10 +114,9 @@ class SubscriptionDetailsScreen extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 🔹 Обёртка для растягивания контента на всю ширину
Column(
crossAxisAlignment: CrossAxisAlignment.stretch, // ✅ Растягивает детей на всю ширину
mainAxisSize: MainAxisSize.min, // ✅ Не занимает лишнее место по вертикали
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: ContentParser.parseContent(
textJson: state.subscription.fullDescriptionJson,
text: state.subscription.fullDescription,
@@ -121,6 +126,14 @@ class SubscriptionDetailsScreen extends StatelessWidget {
if (isAvailableForPurchase) ...[
const SizedBox(height: 30),
_ActionCard(state: state),
const SizedBox(height: 24),
const Text(
'Способ оплаты',
style: TextStyle(color: Colors.white70, fontSize: 14),
),
const SizedBox(height: 12),
_buildCardSelector(state, context),
const SizedBox(height: 30),
GradientButton(
text: state.isAlreadyPurchased ? 'Продлить' : 'Активировать',
@@ -129,7 +142,7 @@ class SubscriptionDetailsScreen extends StatelessWidget {
ActivateSubscriptionPressed(),
);
},
enabled: state.isAgreed,
enabled: state.isAgreed && state.selectedCard != null,
width: double.infinity,
height: 56,
fontSize: 16,
@@ -141,8 +154,77 @@ class SubscriptionDetailsScreen extends StatelessWidget {
),
);
}
Widget _buildCardSelector(DetailsContentState state, BuildContext context) {
if (state.selectedCard != null) {
return PaymentOption(
title: "Карта",
subtitle: state.selectedCard.cardLastNumber,
isSelected: true,
onTap: () async {
final selectedCard = await showModalBottomSheet<PaymentCard>(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (innerContext) => BlocProvider(
create: (context) => PaymentMethodSheetBloc(
getIt<GetPaymentCardsUsecase>(),
getIt<SetMainPaymentCardUsecase>(),
)..add(PaymentMethodSheetStarted()),
child: const PaymentMethodSheet(showBalance: false),
),
);
if (selectedCard != null && context.mounted) {
context.read<SubscriptionDetailsBloc>().add(SelectCardEvent(selectedCard));
}
},
);
}
return Container(
height: 56,
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: () {
context.pushReplacement('/home/payment-method-sheet');
},
borderRadius: BorderRadius.circular(24),
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
'Добавить способ оплаты',
style: TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
const SizedBox(width: 8),
Icon(Icons.arrow_forward_ios, size: 12, color: Colors.white.withOpacity(0.6)),
Icon(Icons.arrow_forward_ios, size: 12, color: Colors.white.withOpacity(0.4)),
Icon(Icons.arrow_forward_ios, size: 12, color: Colors.white.withOpacity(0.2)),
],
),
),
),
),
);
}
}
class _ActionCard extends StatelessWidget {
final DetailsContentState state;
@@ -216,6 +298,7 @@ class _ActionCard extends StatelessWidget {
),
);
}
}
class _PriceRow extends StatelessWidget {