优化:三方支付显示赠送比例优化

This commit is contained in:
ivan 2026-04-23 16:37:44 +08:00
parent faed1ab448
commit fef2606e66
2 changed files with 56 additions and 54 deletions

View File

@ -10,8 +10,8 @@ const double _paymentSheetIconScale = 1.5;
/// `funymee_home.pen` **zL8hY / p7kQm**
/// **Pay** `btnPayPrimary`
///
/// [summaryTierCredits] / [summaryTierBonus] +
/// `null` [product]
/// [summaryTierCredits] / [summaryTierBonus] +
/// `null` [product] [PaymentMethodItem.bonusRatio]
Future<PaymentMethodItem?> showThirdPartyPaymentMethodSheet(
BuildContext context, {
required List<PaymentMethodItem> methods,
@ -181,10 +181,6 @@ class _ThirdPartyPaymentSheetBodyState
if (i > 0) const SizedBox(height: 12),
_PaymentMethodOptionCard(
method: widget.methods[i],
tierCreditsForChannelPercent:
widget.summaryTierCredits ??
widget.product.credits ??
0,
selected: _selectedIndex == i,
iconColor: _iconAccent(widget.methods[i]),
onSelect: () => setState(() => _selectedIndex = i),
@ -225,16 +221,19 @@ String _formatProductPrice(PaymentProductItem p) {
return '\$$a';
}
/// [PaymentMethodItem.bonusCredits] [tierCredits] `+N% More Credits` `+<1% More Credits`
String? _channelBonusCreditsPercentLine(
int tierCredits,
int? channelBonusCredits,
) {
if (channelBonusCredits == null || channelBonusCredits <= 0) return null;
if (tierCredits <= 0) return null;
final rounded = ((channelBonusCredits * 100.0) / tierCredits).round();
if (rounded > 0) return '+$rounded% More Credits';
return '+<1% More Credits';
/// **** [PaymentMethodItem.bonusRatio]`1`
/// `bonusCredits / ` `bonusRatio` [PaymentMethodItem.bonusCredits]
String? _thirdPartyChannelBonusSubtitle(PaymentMethodItem method) {
final br = method.bonusRatio;
if (br != null && br > 0) {
final pct = br <= 1 ? (br * 100).round() : br.round();
return '+$pct% More Credits';
}
final bc = method.bonusCredits;
if (bc != null && bc > 0) {
return '+$bc More Credits';
}
return null;
}
class _PaymentSummaryCard extends StatelessWidget {
@ -360,16 +359,12 @@ class _PayCtaButton extends StatelessWidget {
class _PaymentMethodOptionCard extends StatelessWidget {
const _PaymentMethodOptionCard({
required this.method,
required this.tierCreditsForChannelPercent,
required this.selected,
required this.iconColor,
required this.onSelect,
});
final PaymentMethodItem method;
///
final int tierCreditsForChannelPercent;
final bool selected;
final Color iconColor;
final VoidCallback onSelect;
@ -382,10 +377,7 @@ class _PaymentMethodOptionCard extends StatelessWidget {
final title = method.displayName.isNotEmpty
? method.displayName
: (method.paymentMethod ?? 'Payment');
final channelBonusLine = _channelBonusCreditsPercentLine(
tierCreditsForChannelPercent,
method.bonusCredits,
);
final channelBonusLine = _thirdPartyChannelBonusSubtitle(method);
return Material(
color: Colors.white,
@ -464,7 +456,11 @@ class _PaymentMethodOptionCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Text(
title,
style: GoogleFonts.inter(
fontSize: 16,
@ -474,6 +470,31 @@ class _PaymentMethodOptionCard extends StatelessWidget {
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
if (method.recommend == true) ...[
const SizedBox(width: 6),
Container(
padding: const EdgeInsets.symmetric(
horizontal: 6,
vertical: 2,
),
decoration: BoxDecoration(
color: PencilTheme.cardThumbBg,
borderRadius: BorderRadius.circular(6),
),
child: Text(
'Recommend',
style: GoogleFonts.inter(
fontSize: 9,
fontWeight: FontWeight.w600,
height: 1.1,
color: PencilTheme.stone700,
),
),
),
],
],
),
if (channelBonusLine != null) ...[
const SizedBox(height: 4),
Text(
@ -483,32 +504,13 @@ class _PaymentMethodOptionCard extends StatelessWidget {
fontWeight: FontWeight.w600,
color: PencilTheme.profileCredits,
),
maxLines: 2,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
],
),
),
if (method.recommend == true)
Container(
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 5,
),
decoration: BoxDecoration(
color: PencilTheme.cardThumbBg,
borderRadius: BorderRadius.circular(8),
),
child: Text(
'Recommend',
style: GoogleFonts.inter(
fontSize: 11,
fontWeight: FontWeight.w600,
color: PencilTheme.stone700,
),
),
),
],
),
),

View File

@ -2,7 +2,7 @@ name: funymee_ai
description: "FunyMee AI Application."
publish_to: 'none'
version: 1.0.18+18
version: 1.0.19+19
environment:
sdk: ^3.11.1