purchase_legal_notes.dart
6.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
import 'package:doublefeel_flutter/app/modules/purchase/widgets/purchase_colors.dart';
import 'package:doublefeel_flutter/l10n/l10n_extensions.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
/// OHOS subscription terms shown on the purchase and membership pages.
class OhosPurchaseLegalNotes extends StatelessWidget {
const OhosPurchaseLegalNotes({
super.key,
required this.onContactUsTap,
required this.onSupportEmailTap,
});
final VoidCallback onContactUsTap;
final VoidCallback onSupportEmailTap;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
context.l10n.purchaseNotesTitle,
style: const TextStyle(
color: Colors.black,
fontSize: 18,
fontWeight: FontWeight.w600,
height: 1.2,
),
),
const SizedBox(height: 24),
const _LegalText(
prefix: '1. ',
spans: [
_LegalTextSpan(
text: '本服务为自动续费订阅服务,¥68/年或¥16/月,到期后将按所选订阅周期自动续费并扣款。',
),
],
),
const SizedBox(height: 12),
const _LegalText(
prefix: '2. ',
spans: [
_LegalTextSpan(
text:
'如需取消自动续费,请前往支付宝 > 我的 > 设置 > 支付设置 > 免密支付/自动扣款 > 关闭对应服务。取消后,当前会员权益可使用至本周期结束,下个周期将不再扣费。',
),
],
),
const SizedBox(height: 12),
const _LegalText(
prefix: '3. ',
spans: [
_LegalTextSpan(
text: '确认支付成功后,会员权益立即生效。如支付成功后会员未生效,请尝试重新登录账号。',
),
],
),
const SizedBox(height: 12),
const _LegalText(
prefix: '4. ',
spans: [
_LegalTextSpan(
text: 'DoubleFeel Pro 属于虚拟服务商品,购买后除法律法规另有规定外,通常不支持退款。',
),
],
),
const SizedBox(height: 12),
_LegalText(
prefix: '5. ',
spans: const [
_LegalTextSpan(text: '如有其他问题,请'),
_LegalTextSpan(text: '联系我们', isLink: true),
_LegalTextSpan(text: ',或发送邮件至'),
_LegalTextSpan(text: 'support@doublefeel.cn', isLink: true),
_LegalTextSpan(text: '。'),
],
onLinkTaps: [onContactUsTap, onSupportEmailTap],
),
],
),
);
}
}
/// iOS subscription terms shown on the purchase and membership pages.
class IosPurchaseLegalNotes extends StatelessWidget {
const IosPurchaseLegalNotes({
required this.onRefundExplanationTap,
required this.onContactUsTap,
});
final VoidCallback onRefundExplanationTap;
final VoidCallback onContactUsTap;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
context.l10n.purchaseNotesTitle,
style: const TextStyle(
color: Colors.black,
fontSize: 18,
fontWeight: FontWeight.w600,
height: 1.2,
),
),
const SizedBox(height: 24),
_LegalText(
prefix: '1. ',
spans: [
_LegalTextSpan(text: context.l10n.purchaseNoteSubscription),
_LegalTextSpan(
text: context.l10n.purchaseLinkLearnMore,
isLink: true,
),
const _LegalTextSpan(text: '。'),
],
onLinkTaps: [onRefundExplanationTap],
),
const SizedBox(height: 12),
_LegalText(
prefix: '2. ',
spans: [
_LegalTextSpan(text: context.l10n.purchaseNoteContact),
_LegalTextSpan(
text: context.l10n.purchaseLinkContactUs,
isLink: true,
),
const _LegalTextSpan(text: '。'),
],
onLinkTaps: [onContactUsTap],
),
],
),
);
}
}
class _LegalTextSpan {
const _LegalTextSpan({required this.text, this.isLink = false});
final String text;
final bool isLink;
}
class _LegalText extends StatefulWidget {
const _LegalText({
required this.prefix,
required this.spans,
this.onLinkTaps = const [],
});
final String prefix;
final List<_LegalTextSpan> spans;
final List<VoidCallback> onLinkTaps;
@override
State<_LegalText> createState() => _LegalTextState();
}
class _LegalTextState extends State<_LegalText> {
late List<TapGestureRecognizer> _linkRecognizers;
@override
void initState() {
super.initState();
_linkRecognizers = _createRecognizers();
}
@override
void didUpdateWidget(covariant _LegalText oldWidget) {
super.didUpdateWidget(oldWidget);
for (var index = 0; index < _linkRecognizers.length; index++) {
_linkRecognizers[index].onTap = widget.onLinkTaps[index];
}
}
List<TapGestureRecognizer> _createRecognizers() => [
for (final onTap in widget.onLinkTaps)
TapGestureRecognizer()..onTap = onTap,
];
@override
void dispose() {
for (final recognizer in _linkRecognizers) {
recognizer.dispose();
}
super.dispose();
}
static const _baseStyle = TextStyle(
color: PurchaseColors.subtitle,
fontSize: 12,
height: 1.4,
);
static const _linkStyle = TextStyle(
color: Color(0xFF845EEE),
fontWeight: FontWeight.w500,
decoration: TextDecoration.underline,
decorationColor: Color(0xFF845EEE),
);
@override
Widget build(BuildContext context) {
var linkIndex = 0;
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(widget.prefix, style: _baseStyle),
Expanded(
child: Text.rich(
TextSpan(
style: _baseStyle,
children: [
for (final span in widget.spans)
TextSpan(
text: span.text,
style: span.isLink ? _linkStyle : null,
recognizer:
span.isLink ? _linkRecognizers[linkIndex++] : null,
),
],
),
textScaler: MediaQuery.textScalerOf(context),
),
),
],
);
}
}