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,104 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../core/legal/legal_opener.dart';
|
||||
import '../../core/legal/legal_page.dart';
|
||||
import '../../core/theme/app_colors.dart';
|
||||
import '../../core/theme/app_dimens.dart';
|
||||
import '../../l10n/app_localizations.dart';
|
||||
|
||||
/// 设置页里的服务条款和隐私协议。点一行就打开当前语言的公开页。
|
||||
class LegalLinksCard extends StatelessWidget {
|
||||
const LegalLinksCard({super.key, this.open});
|
||||
|
||||
final Future<void> Function(String url)? open;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
final rows = <_LegalRow>[
|
||||
_LegalRow(
|
||||
key: const Key('settings-terms'),
|
||||
title: l10n.legalTerms,
|
||||
path: legalTermsPath,
|
||||
),
|
||||
_LegalRow(
|
||||
key: const Key('settings-privacy'),
|
||||
title: l10n.legalPrivacy,
|
||||
path: legalPrivacyPath,
|
||||
),
|
||||
];
|
||||
return Material(
|
||||
color: AppColors.card,
|
||||
borderRadius: BorderRadius.circular(AppDimens.cardRadius),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: Column(
|
||||
children: [
|
||||
for (var index = 0; index < rows.length; index++) ...[
|
||||
if (index > 0)
|
||||
const Divider(
|
||||
height: AppDimens.mineGridDividerWidth,
|
||||
thickness: AppDimens.mineGridDividerWidth,
|
||||
color: AppColors.outlineVariantDark,
|
||||
),
|
||||
_tile(context, rows[index]),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _tile(BuildContext context, _LegalRow row) {
|
||||
return InkWell(
|
||||
key: row.key,
|
||||
onTap: () => _open(context, row.path),
|
||||
child: SizedBox(
|
||||
height: AppDimens.mineMoreRowHeight,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: AppDimens.spaceLg),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
row.title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
color: AppColors.textPrimary,
|
||||
fontSize: AppDimens.listTitle,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
Icons.chevron_right_rounded,
|
||||
color: AppColors.textSecondary,
|
||||
size: AppDimens.accountIcon,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _open(BuildContext context, String path) {
|
||||
final url = legalPageUrl(path, Localizations.localeOf(context));
|
||||
final custom = open;
|
||||
if (custom != null) {
|
||||
unawaited(custom(url));
|
||||
return;
|
||||
}
|
||||
unawaited(openLegalUrlOrNotify(context, url));
|
||||
}
|
||||
}
|
||||
|
||||
class _LegalRow {
|
||||
const _LegalRow({required this.key, required this.title, required this.path});
|
||||
|
||||
final Key key;
|
||||
final String title;
|
||||
final String path;
|
||||
}
|
||||
@@ -6,16 +6,15 @@ import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../core/data/services/auth_controller.dart';
|
||||
import '../../core/theme/app_colors.dart';
|
||||
import '../../core/theme/app_dimens.dart';
|
||||
import '../../core/theme/app_theme.dart';
|
||||
import '../../core/widgets/auth_gate.dart';
|
||||
import '../../core/widgets/plain_page_scaffold.dart';
|
||||
import '../../l10n/app_localizations.dart';
|
||||
import '../account/account_entry_card.dart';
|
||||
import '../notices/notices_page.dart';
|
||||
import 'legal_links_card.dart';
|
||||
|
||||
/// 设置页:收纳账号、通知与登录态,不提供手动语言切换。
|
||||
/// 设置页:账号入口按列表展示,不提供通知和手动语言切换。
|
||||
class SettingsPage extends StatelessWidget {
|
||||
const SettingsPage({super.key});
|
||||
|
||||
@@ -34,10 +33,10 @@ class SettingsPage extends StatelessWidget {
|
||||
children: [
|
||||
if (auth.isSignedIn) ...[
|
||||
const AccountEntryCard(),
|
||||
const SizedBox(height: 12),
|
||||
const SizedBox(height: AppDimens.spaceXl),
|
||||
],
|
||||
_noticesTile(context, l10n),
|
||||
const SizedBox(height: 24),
|
||||
const LegalLinksCard(),
|
||||
const SizedBox(height: AppDimens.spaceXl),
|
||||
_authAction(context, l10n, auth),
|
||||
],
|
||||
),
|
||||
@@ -45,29 +44,6 @@ class SettingsPage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _noticesTile(BuildContext context, AppLocalizations l10n) {
|
||||
return Material(
|
||||
color: AppColors.card,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(AppDimens.cardRadius),
|
||||
side: const BorderSide(color: AppColors.border),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: ListTile(
|
||||
key: const Key('settings-notices'),
|
||||
leading: const Icon(
|
||||
Icons.notifications_none_rounded,
|
||||
color: AppColors.blueSoft,
|
||||
),
|
||||
title: Text(l10n.notices),
|
||||
trailing: const Icon(Icons.chevron_right_rounded),
|
||||
onTap: () => Navigator.of(
|
||||
context,
|
||||
).push<void>(MaterialPageRoute(builder: (_) => const NoticesPage())),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _authAction(
|
||||
BuildContext context,
|
||||
AppLocalizations l10n,
|
||||
|
||||
Reference in new issue
Block a user