Registration pipeline chenged - fill profile step added. Order payment fixed

This commit is contained in:
2026-09-14 19:20:31 +03:00
parent 7460408784
commit 153a763b6f
8 changed files with 1023 additions and 905 deletions

View File

@@ -115,6 +115,8 @@ class _PaymentConfirmScreenContent extends StatelessWidget {
);
}
final hasNoDebt = (order?.unpayTotalPrice ?? 0) == 0;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -141,7 +143,7 @@ class _PaymentConfirmScreenContent extends StatelessWidget {
Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
CrossAxisAlignment.start,
children: [
_buildInfoLabel('Стоимость поездки:'),
_buildValueRow(
@@ -154,7 +156,7 @@ class _PaymentConfirmScreenContent extends StatelessWidget {
Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
CrossAxisAlignment.start,
children: [
_buildInfoLabel('Оплачено:'),
_buildValueRow(
@@ -183,7 +185,7 @@ class _PaymentConfirmScreenContent extends StatelessWidget {
const SizedBox(height: 12),
Row(
mainAxisAlignment:
MainAxisAlignment.center,
MainAxisAlignment.center,
children: [
Image.asset(
'assets/icons/money_icon.png',
@@ -204,114 +206,115 @@ class _PaymentConfirmScreenContent extends StatelessWidget {
),
),
const SizedBox(height: 40),
// 🔹 КАРТА ОПЛАТЫ
(state.useBalance || state.selectedCard != null)
? Padding(padding: const EdgeInsets.symmetric(horizontal: 20),
child: PaymentOption(
title: state.useBalance ? 'Баланс' : "",
subtitle: state.useBalance
? '${state.userBalance.toStringAsFixed(2)} BYN'
: '${state.selectedCard!.cardLastNumber}',
isSelected: true,
onTap: () async {
final result = await showModalBottomSheet<dynamic>(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (innerContext) => BlocProvider(
create: (context) => PaymentMethodSheetBloc(
getIt<GetPaymentCardsUsecase>(),
getIt<SetMainPaymentCardUsecase>(),
getIt<GetProfileUseCase>(),
getIt<AddPaymentCardUsecase>(),
)..add(PaymentMethodSheetStarted()),
child: PaymentMethodSheet(
initialSelectedCard: state.useBalance ? null : state.selectedCard,
),
),
);
if (result != null) {
if (result is PaymentCard) {
context.read<PaymentConfirmBloc>().add(PaymentCardChanged(result));
} else if (result == 'balance') {
context.read<PaymentConfirmBloc>().add(SelectBalancePressed());
}
}
},
),
)
: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20,
),
child: Container(
height: 56,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(
24,
),
border: Border.all(
color: Colors.white.withOpacity(
0.4,
),
width: 1,
// 🔹 КАРТА ОПЛАТЫ (Отображается только если есть долг)
if (!hasNoDebt) ...[
const SizedBox(height: 40),
(state.useBalance || state.selectedCard != null)
? Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: PaymentOption(
title: state.useBalance ? 'Баланс' : "",
subtitle: state.useBalance
? '${state.userBalance.toStringAsFixed(2)} BYN'
: '${state.selectedCard!.cardLastNumber}',
isSelected: true,
onTap: () async {
final result = await showModalBottomSheet<dynamic>(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (innerContext) => BlocProvider(
create: (context) => PaymentMethodSheetBloc(
getIt<GetPaymentCardsUsecase>(),
getIt<SetMainPaymentCardUsecase>(),
getIt<GetProfileUseCase>(),
getIt<AddPaymentCardUsecase>(),
)..add(PaymentMethodSheetStarted()),
child: PaymentMethodSheet(
initialSelectedCard: state.useBalance ? null : state.selectedCard,
),
),
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),
),
],
if (result != null) {
if (result is PaymentCard) {
context.read<PaymentConfirmBloc>().add(PaymentCardChanged(result));
} else if (result == 'balance') {
context.read<PaymentConfirmBloc>().add(SelectBalancePressed());
}
}
},
),
)
: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20,
),
child: 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),
),
],
),
),
),
),
),
),
],
],
);
},
@@ -322,45 +325,53 @@ class _PaymentConfirmScreenContent extends StatelessWidget {
Padding(
padding: const EdgeInsets.all(24.0),
child:
BlocConsumer<PaymentConfirmBloc, PaymentConfirmState>(
listener: (context, state) {
if (state.status == PaymentConfirmStatus.success &&
state.paymentCompleted) {
BlocConsumer<PaymentConfirmBloc, PaymentConfirmState>(
listener: (context, state) {
if (state.status == PaymentConfirmStatus.success &&
state.paymentCompleted) {
context.go('/home');
} else if (state.status ==
PaymentConfirmStatus.failure) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
state.errorMessage ?? 'Ошибка оплаты',
),
),
);
}
},
builder: (context, state) {
final hasNoDebt = (state.order?.unpayTotalPrice ?? 0) == 0;
return GradientButton(
text: state.status == PaymentConfirmStatus.loading
? 'Обработка...'
: (hasNoDebt ? 'Продолжить' : 'Оплатить'),
showArrows: true,
height: 56,
width: double.infinity,
onTap: (state.status == PaymentConfirmStatus.loading ||
(!hasNoDebt && !state.useBalance && state.selectedCard == null))
? null
: () {
if (hasNoDebt) {
context.read<MapBloc>().add(ClearMapPlacemarks());
context.go('/home');
} else if (state.status ==
PaymentConfirmStatus.failure) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
state.errorMessage ?? 'Ошибка оплаты',
),
} else {
context.read<PaymentConfirmBloc>().add(
PayRide(
cardId: state.useBalance ? null : state.selectedCard?.id,
isBalance: state.useBalance,
orderId: orderId,
photoIds: photoIds,
),
);
}
},
builder: (context, state) {
return GradientButton(
text: state.status == PaymentConfirmStatus.loading
? 'Обработка...'
: 'Оплатить',
showArrows: true,
height: 56,
width: double.infinity,
onTap: (state.status == PaymentConfirmStatus.loading || (!state.useBalance && state.selectedCard == null))
? null
: () {
context.read<PaymentConfirmBloc>().add(
PayRide(
cardId: state.useBalance ? null : state.selectedCard?.id,
isBalance: state.useBalance,
orderId: orderId,
photoIds: photoIds,
),
);
},
);
},
),
);
},
),
),
],
),
@@ -371,7 +382,6 @@ class _PaymentConfirmScreenContent extends StatelessWidget {
);
}
// Вспомогательный метод для подзаголовков
Widget _buildInfoLabel(String text) {
return Padding(
padding: const EdgeInsets.only(bottom: 8),
@@ -382,7 +392,6 @@ class _PaymentConfirmScreenContent extends StatelessWidget {
);
}
// Вспомогательный метод для строк со значениями и иконками
Widget _buildValueRow(String iconName, String value) {
return Row(
children: [
@@ -405,4 +414,4 @@ class _PaymentConfirmScreenContent extends StatelessWidget {
final m = minutes % 60;
return '${h.toString().padLeft(2, '0')}:${m.toString().padLeft(2, '0')}';
}
}
}