Files
ReelShort/lib/pages/account/account_entry_card.dart

128 lines
3.5 KiB
Dart

// Author: fruit.com.cn
import 'package:flutter/material.dart';
import '../../core/theme/app_colors.dart';
import '../../core/theme/app_dimens.dart';
import '../../l10n/app_localizations.dart';
import 'account_deactivate_page.dart';
import 'account_devices_page.dart';
import 'account_export_page.dart';
import 'account_profile_page.dart';
/// 设置页账号入口,登录后按列表展示。
class AccountEntryCard extends StatelessWidget {
const AccountEntryCard({super.key});
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
final rows = <_AccountRow>[
_AccountRow(
key: const Key('mine-account-profile'),
icon: Icons.person_outline_rounded,
title: l10n.accountProfile,
page: const AccountProfilePage(),
),
_AccountRow(
key: const Key('mine-account-devices'),
icon: Icons.devices_other_rounded,
title: l10n.accountDevices,
page: const AccountDevicesPage(),
),
_AccountRow(
key: const Key('mine-account-export'),
icon: Icons.file_download_outlined,
title: l10n.accountDataExport,
page: const AccountExportPage(),
),
_AccountRow(
key: const Key('mine-account-deactivate'),
icon: Icons.person_remove_outlined,
title: l10n.accountDeactivate,
page: const AccountDeactivatePage(),
),
];
return Material(
key: const Key('mine-account-card'),
color: AppColors.contentSurface,
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.contentBorder,
),
_AccountListTile(row: rows[index]),
],
],
),
);
}
}
class _AccountRow {
const _AccountRow({
required this.key,
required this.icon,
required this.title,
required this.page,
});
final Key key;
final IconData icon;
final String title;
final Widget page;
}
class _AccountListTile extends StatelessWidget {
const _AccountListTile({required this.row});
final _AccountRow row;
@override
Widget build(BuildContext context) {
return InkWell(
key: row.key,
onTap: () => Navigator.of(
context,
).push<void>(MaterialPageRoute(builder: (_) => row.page)),
child: SizedBox(
height: AppDimens.mineMoreRowHeight,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: AppDimens.spaceLg),
child: Row(
children: [
Icon(
row.icon,
color: AppColors.blueSoft,
size: AppDimens.accountIcon,
),
const SizedBox(width: AppDimens.spaceMd),
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,
),
],
),
),
),
);
}
}