Compare commits
No commits in common. "df6788bbcd80215d9ca5221dbb95cdf356d04465" and "1242f2b3fe0e8425d9898c58b567b482442c2e6b" have entirely different histories.
df6788bbcd
...
1242f2b3fe
1
.gitignore
vendored
1
.gitignore
vendored
@ -41,7 +41,6 @@ pubspec.lock
|
|||||||
**/android/**/GeneratedPluginRegistrant.java
|
**/android/**/GeneratedPluginRegistrant.java
|
||||||
|
|
||||||
# iOS
|
# iOS
|
||||||
**/Pods/
|
|
||||||
**/ios/**/*.mode1v3
|
**/ios/**/*.mode1v3
|
||||||
**/ios/**/*.mode2v3
|
**/ios/**/*.mode2v3
|
||||||
**/ios/**/*.moved-aside
|
**/ios/**/*.moved-aside
|
||||||
|
|||||||
@ -6,8 +6,6 @@ class PaymentMethodItem {
|
|||||||
this.name,
|
this.name,
|
||||||
this.icon,
|
this.icon,
|
||||||
this.recommend = false,
|
this.recommend = false,
|
||||||
this.bonusCredits = 0,
|
|
||||||
this.bonusRatio = 0,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
final String paymentMethod; // resource,如 GOOGLEPAY/APPLEPAY
|
final String paymentMethod; // resource,如 GOOGLEPAY/APPLEPAY
|
||||||
@ -15,10 +13,6 @@ class PaymentMethodItem {
|
|||||||
final String? name; // brigade 展示名称
|
final String? name; // brigade 展示名称
|
||||||
final String? icon; // greylist 图标 URL
|
final String? icon; // greylist 图标 URL
|
||||||
final bool recommend; // deny 为 true 时显示 Recommended
|
final bool recommend; // deny 为 true 时显示 Recommended
|
||||||
/// conjure — 该支付方式额外赠送的积分
|
|
||||||
final int bonusCredits;
|
|
||||||
/// enchant — 赠送比例(若服务端仅返回比例、无积分时可展示)
|
|
||||||
final double bonusRatio;
|
|
||||||
|
|
||||||
factory PaymentMethodItem.fromJson(Map<String, dynamic> json) {
|
factory PaymentMethodItem.fromJson(Map<String, dynamic> json) {
|
||||||
return PaymentMethodItem(
|
return PaymentMethodItem(
|
||||||
@ -27,38 +21,8 @@ class PaymentMethodItem {
|
|||||||
name: json['brigade']?.toString(),
|
name: json['brigade']?.toString(),
|
||||||
icon: json['greylist']?.toString(),
|
icon: json['greylist']?.toString(),
|
||||||
recommend: json['deny'] == true,
|
recommend: json['deny'] == true,
|
||||||
bonusCredits: _parseInt(json['conjure']) ?? 0,
|
|
||||||
bonusRatio: _parseDouble(json['enchant']) ?? 0,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int? _parseInt(dynamic v) {
|
|
||||||
if (v == null) return null;
|
|
||||||
if (v is int) return v;
|
|
||||||
if (v is num) return v.toInt();
|
|
||||||
return int.tryParse(v.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
static double? _parseDouble(dynamic v) {
|
|
||||||
if (v == null) return null;
|
|
||||||
if (v is double) return v;
|
|
||||||
if (v is num) return v.toDouble();
|
|
||||||
return double.tryParse(v.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
String get displayName => name?.isNotEmpty == true ? name! : paymentMethod;
|
String get displayName => name?.isNotEmpty == true ? name! : paymentMethod;
|
||||||
|
|
||||||
/// 用于列表副标题:优先展示赠送积分,否则展示赠送比例
|
|
||||||
String? get bonusLabel {
|
|
||||||
if (bonusCredits > 0) {
|
|
||||||
return '+$bonusCredits bonus credits';
|
|
||||||
}
|
|
||||||
if (bonusRatio > 0) {
|
|
||||||
final pct = bonusRatio <= 1
|
|
||||||
? (bonusRatio * 100).round()
|
|
||||||
: bonusRatio.round();
|
|
||||||
return '+$pct% bonus credits';
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -787,7 +787,7 @@ class _PaymentMethodItem extends StatelessWidget {
|
|||||||
child: AnimatedContainer(
|
child: AnimatedContainer(
|
||||||
duration: const Duration(milliseconds: 150),
|
duration: const Duration(milliseconds: 150),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
constraints: const BoxConstraints(minHeight: 64),
|
height: 64,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: isSelected ? const Color(0x158B5CF6) : AppColors.surface,
|
color: isSelected ? const Color(0x158B5CF6) : AppColors.surface,
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
@ -804,12 +804,7 @@ class _PaymentMethodItem extends StatelessWidget {
|
|||||||
_PaymentIcon(iconUrl: item.icon),
|
_PaymentIcon(iconUrl: item.icon),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
children: [
|
children: [
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Text(
|
child: Text(
|
||||||
@ -835,21 +830,6 @@ class _PaymentMethodItem extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (item.bonusLabel != null) ...[
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
Text(
|
|
||||||
item.bonusLabel!,
|
|
||||||
style: AppTypography.caption.copyWith(
|
|
||||||
color: AppColors.primary,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
fontSize: 12,
|
|
||||||
),
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user