diff --git a/lib/features/purchase/third_party_payment_sheet.dart b/lib/features/purchase/third_party_payment_sheet.dart index 8212d28..47a06e8 100644 --- a/lib/features/purchase/third_party_payment_sheet.dart +++ b/lib/features/purchase/third_party_payment_sheet.dart @@ -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 showThirdPartyPaymentMethodSheet( BuildContext context, { required List 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,15 +456,44 @@ class _PaymentMethodOptionCard extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - Text( - title, - style: GoogleFonts.inter( - fontSize: 16, - fontWeight: FontWeight.w700, - color: PencilTheme.stone900, - ), - maxLines: 2, - overflow: TextOverflow.ellipsis, + Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + child: Text( + title, + style: GoogleFonts.inter( + fontSize: 16, + fontWeight: FontWeight.w700, + color: PencilTheme.stone900, + ), + 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), @@ -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, - ), - ), - ), ], ), ), diff --git a/pubspec.yaml b/pubspec.yaml index fd262e7..b9f1106 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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