feat(app): 完善播放协议搜索与空状态
This commit is contained in:
1 parent
671e0ce143
commit
ef29fc5f15
85 files changed
+2976
-768
No files matched your search
@@ -0,0 +1,75 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../core/legal/legal_opener.dart';
|
||||
import '../../core/legal/legal_page.dart';
|
||||
import '../../core/theme/app_colors.dart';
|
||||
import '../../l10n/app_localizations.dart';
|
||||
|
||||
const double _legalFontSize = 12;
|
||||
|
||||
/// 登录页底部的协议入口。点用户协议或隐私政策会打开对应语言的页面。
|
||||
class AuthLegalLinks extends StatefulWidget {
|
||||
const AuthLegalLinks({super.key, this.open});
|
||||
|
||||
/// 测试时可替换真正的跳转。
|
||||
final Future<void> Function(String url)? open;
|
||||
|
||||
@override
|
||||
State<AuthLegalLinks> createState() => _AuthLegalLinksState();
|
||||
}
|
||||
|
||||
class _AuthLegalLinksState extends State<AuthLegalLinks> {
|
||||
late final TapGestureRecognizer _termsTap = TapGestureRecognizer()
|
||||
..onTap = () => _open(legalTermsPath);
|
||||
late final TapGestureRecognizer _privacyTap = TapGestureRecognizer()
|
||||
..onTap = () => _open(legalPrivacyPath);
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_termsTap.dispose();
|
||||
_privacyTap.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _open(String path) {
|
||||
final url = legalPageUrl(path, Localizations.localeOf(context));
|
||||
final custom = widget.open;
|
||||
if (custom != null) {
|
||||
unawaited(custom(url));
|
||||
return;
|
||||
}
|
||||
unawaited(openLegalUrlOrNotify(context, url));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
final muted = TextStyle(color: AppColors.muted, fontSize: _legalFontSize, height: 1.6);
|
||||
final link = muted.copyWith(color: AppColors.blue);
|
||||
return Text.rich(
|
||||
TextSpan(
|
||||
style: muted,
|
||||
children: [
|
||||
TextSpan(text: l10n.authLegalLead),
|
||||
const TextSpan(text: ' '),
|
||||
TextSpan(text: l10n.authTerms, style: link, recognizer: _termsTap),
|
||||
const TextSpan(text: ' '),
|
||||
TextSpan(text: l10n.authLegalJoin),
|
||||
const TextSpan(text: ' '),
|
||||
TextSpan(
|
||||
text: l10n.authPrivacy,
|
||||
style: link,
|
||||
recognizer: _privacyTap,
|
||||
),
|
||||
],
|
||||
),
|
||||
key: const Key('auth-legal'),
|
||||
textAlign: TextAlign.center,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user