|
...
|
...
|
@@ -7,8 +7,10 @@ import 'package:doublefeel_flutter/core/theme/app_theme.dart'; |
|
|
|
import 'package:doublefeel_flutter/data/local/user_preferences_storage.dart';
|
|
|
|
import 'package:doublefeel_flutter/data/models/local/user_preferences.dart';
|
|
|
|
import 'package:doublefeel_flutter/l10n/l10n_extensions.dart';
|
|
|
|
import 'package:doublefeel_flutter/l10n/l10n_extensions.dart' as context;
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
|
|
|
|
class MembershipDetailView extends GetView<MembershipDetailController> {
|
|
|
|
const MembershipDetailView({super.key});
|
|
...
|
...
|
@@ -115,7 +117,7 @@ class MembershipDetailView extends GetView<MembershipDetailController> { |
|
|
|
final preferences = userPrefs.preferences.value;
|
|
|
|
final vipInfo = preferences.vipInfo;
|
|
|
|
return Text(
|
|
|
|
_vipSubtitle(vipInfo),
|
|
|
|
_vipSubtitle(vipInfo, context),
|
|
|
|
style: TextStyle(
|
|
|
|
color: context.colors.textPrimary,
|
|
|
|
fontSize: 14,
|
|
...
|
...
|
@@ -140,7 +142,7 @@ class MembershipDetailView extends GetView<MembershipDetailController> { |
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
top: 28, left: 16, right: 16, bottom: 16),
|
|
|
|
child: Text(
|
|
|
|
'畅享全部高级权益',
|
|
|
|
context.l10n.enjoyAllPremiumBenefits,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.black,
|
|
|
|
fontSize: 18,
|
|
...
|
...
|
@@ -164,7 +166,7 @@ class MembershipDetailView extends GetView<MembershipDetailController> { |
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
top: 28, left: 16, right: 16),
|
|
|
|
child: Text(
|
|
|
|
'会员管理',
|
|
|
|
context.l10n.membershipManagement,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.black,
|
|
|
|
fontSize: 18,
|
|
...
|
...
|
@@ -189,7 +191,7 @@ class MembershipDetailView extends GetView<MembershipDetailController> { |
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
'会员类型',
|
|
|
|
context.l10n.membershipTypes,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
color: context.colors.textPrimary,
|
|
...
|
...
|
@@ -220,7 +222,7 @@ class MembershipDetailView extends GetView<MembershipDetailController> { |
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
'有效期至',
|
|
|
|
context.l10n.validUntil,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
color: context.colors.textPrimary,
|
|
...
|
...
|
@@ -234,7 +236,7 @@ class MembershipDetailView extends GetView<MembershipDetailController> { |
|
|
|
userPrefs.preferences.value;
|
|
|
|
final vipInfo = preferences.vipInfo;
|
|
|
|
return Text(
|
|
|
|
_vipExprieDate(vipInfo),
|
|
|
|
_vipExprieDate(vipInfo, context),
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
color: context.colors.textPrimary,
|
|
...
|
...
|
@@ -260,7 +262,7 @@ class MembershipDetailView extends GetView<MembershipDetailController> { |
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
'管理订阅',
|
|
|
|
context.l10n.manageSubscriptions,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
color: context.colors.textPrimary,
|
|
...
|
...
|
@@ -294,57 +296,61 @@ class MembershipDetailView extends GetView<MembershipDetailController> { |
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
String _vipSubtitle(UserPreferencesVipInfo? vipInfo) {
|
|
|
|
String _vipSubtitle(UserPreferencesVipInfo? vipInfo, BuildContext context) {
|
|
|
|
final endDate = vipInfo?.vipEndDate ?? 0;
|
|
|
|
if (vipInfo?.isVip != true || endDate <= 0) {
|
|
|
|
return '立即解锁';
|
|
|
|
return l10n.unlockNow;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vipInfo?.isForeverVip ?? false) {
|
|
|
|
return '终身使用,免费更新';
|
|
|
|
return l10n.purchaseLifetimePlan;
|
|
|
|
}
|
|
|
|
|
|
|
|
final milliseconds = endDate > 1000000000000 ? endDate : endDate * 1000;
|
|
|
|
final date = DateTime.fromMillisecondsSinceEpoch(milliseconds);
|
|
|
|
final month = date.month.toString().padLeft(2, '0');
|
|
|
|
final day = date.day.toString().padLeft(2, '0');
|
|
|
|
return '有效期至 ${date.year}-$month-$day';
|
|
|
|
final locale = Localizations.localeOf(context).languageCode;
|
|
|
|
|
|
|
|
final dateStr = DateFormat.yMMMd(locale).format(date);
|
|
|
|
|
|
|
|
return l10n.membershipValidUntilDate(dateStr);
|
|
|
|
}
|
|
|
|
|
|
|
|
String _vipExprieDate(UserPreferencesVipInfo? vipInfo) {
|
|
|
|
String _vipExprieDate(UserPreferencesVipInfo? vipInfo, BuildContext context) {
|
|
|
|
final endDate = vipInfo?.vipEndDate ?? 0;
|
|
|
|
if (vipInfo?.isVip != true || endDate <= 0) {
|
|
|
|
return '立即解锁';
|
|
|
|
return l10n.unlockNow;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vipInfo?.isForeverVip ?? false) {
|
|
|
|
return '永不过期';
|
|
|
|
return l10n.purchaseLifetimePlan;
|
|
|
|
}
|
|
|
|
|
|
|
|
final milliseconds = endDate > 1000000000000 ? endDate : endDate * 1000;
|
|
|
|
final date = DateTime.fromMillisecondsSinceEpoch(milliseconds);
|
|
|
|
final month = date.month.toString().padLeft(2, '0');
|
|
|
|
final day = date.day.toString().padLeft(2, '0');
|
|
|
|
return '${date.year}-$month-$day';
|
|
|
|
final locale = Localizations.localeOf(context).languageCode;
|
|
|
|
|
|
|
|
final dateStr = DateFormat.yMMMd(locale).format(date);
|
|
|
|
|
|
|
|
return l10n.membershipValidUntilDate(dateStr);
|
|
|
|
}
|
|
|
|
|
|
|
|
String _vipType(UserPreferencesVipInfo? vipInfo) {
|
|
|
|
if (vipInfo == null || vipInfo.isVip != true || vipInfo.vipEndDate <= 0) {
|
|
|
|
return '立即解锁';
|
|
|
|
return l10n.unlockNow;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vipInfo.isForeverVip) {
|
|
|
|
return '终身会员';
|
|
|
|
return l10n.purchaseLifetimePlan;
|
|
|
|
}
|
|
|
|
switch (vipInfo.vipType) {
|
|
|
|
case 1:
|
|
|
|
return '月度会员';
|
|
|
|
return context.l10n.monthlyMembership;
|
|
|
|
case 2:
|
|
|
|
return '季度会员';
|
|
|
|
return context.l10n.quarterlyMembership;
|
|
|
|
case 3:
|
|
|
|
return '年度会员';
|
|
|
|
return context.l10n.annualMembership;
|
|
|
|
case 10:
|
|
|
|
return '终身会员';
|
|
|
|
return context.l10n.lifetimeMembership;
|
|
|
|
default:
|
|
|
|
return '';
|
|
|
|
}
|
...
|
...
|
|