142 lines
4.3 KiB
Dart
142 lines
4.3 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';
|
|
|
|
const _accountTitleWidth = 64.0;
|
|
|
|
/// 我的页账号入口卡;只在登录态由父页面展示。
|
|
class AccountEntryCard extends StatelessWidget {
|
|
const AccountEntryCard({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final l10n = AppLocalizations.of(context)!;
|
|
return Material(
|
|
key: const Key('mine-account-card'),
|
|
color: AppColors.card,
|
|
borderRadius: BorderRadius.circular(16),
|
|
clipBehavior: Clip.antiAlias,
|
|
child: SizedBox(
|
|
height: AppDimens.accountCardHeight,
|
|
child: Row(
|
|
children: [
|
|
SizedBox(
|
|
width: _accountTitleWidth,
|
|
child: Padding(
|
|
padding: const EdgeInsets.only(left: 12),
|
|
child: Text(
|
|
l10n.accountCenter,
|
|
style: const TextStyle(
|
|
fontSize: AppDimens.caption,
|
|
fontWeight: FontWeight.w800,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const VerticalDivider(
|
|
width: 1,
|
|
color: AppColors.outlineVariantDark,
|
|
),
|
|
Expanded(
|
|
child: Row(
|
|
children: [
|
|
_entry(
|
|
context,
|
|
key: const Key('mine-account-profile'),
|
|
icon: Icons.person_outline_rounded,
|
|
title: l10n.accountProfile,
|
|
page: const AccountProfilePage(),
|
|
divider: true,
|
|
),
|
|
_entry(
|
|
context,
|
|
key: const Key('mine-account-devices'),
|
|
icon: Icons.devices_other_rounded,
|
|
title: l10n.accountDevices,
|
|
page: const AccountDevicesPage(),
|
|
divider: true,
|
|
),
|
|
_entry(
|
|
context,
|
|
key: const Key('mine-account-export'),
|
|
icon: Icons.file_download_outlined,
|
|
title: l10n.accountDataExport,
|
|
page: const AccountExportPage(),
|
|
divider: true,
|
|
),
|
|
_entry(
|
|
context,
|
|
key: const Key('mine-account-deactivate'),
|
|
icon: Icons.person_remove_outlined,
|
|
title: l10n.accountDeactivate,
|
|
page: const AccountDeactivatePage(),
|
|
divider: false,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _entry(
|
|
BuildContext context, {
|
|
required Key key,
|
|
required IconData icon,
|
|
required String title,
|
|
required Widget page,
|
|
required bool divider,
|
|
}) {
|
|
return Expanded(
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: InkWell(
|
|
key: key,
|
|
onTap: () => Navigator.of(
|
|
context,
|
|
).push<void>(MaterialPageRoute(builder: (_) => page)),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Icon(
|
|
icon,
|
|
color: AppColors.blueSoft,
|
|
size: AppDimens.accountIcon,
|
|
),
|
|
const SizedBox(height: 2),
|
|
Text(
|
|
title,
|
|
maxLines: 2,
|
|
overflow: TextOverflow.ellipsis,
|
|
textAlign: TextAlign.center,
|
|
style: const TextStyle(
|
|
fontSize: AppDimens.accountLabel,
|
|
height: 1.15,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
if (divider)
|
|
const VerticalDivider(
|
|
width: 1,
|
|
color: AppColors.outlineVariantDark,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|