122 lines
4.2 KiB
Dart
122 lines
4.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
|
|
import '../routing/app_routes.dart';
|
|
import '../data/providers.dart';
|
|
import '../theme/app_icons.dart';
|
|
import '../theme/wise_tokens.dart';
|
|
import '../widgets/mini_player.dart';
|
|
|
|
class ShellPage extends ConsumerWidget {
|
|
const ShellPage({required this.child, required this.currentPath, super.key});
|
|
|
|
final Widget child;
|
|
final String currentPath;
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final player = ref.watch(audioPlayerControllerProvider);
|
|
final controller = ref.read(audioPlayerControllerProvider.notifier);
|
|
final selectedIndex = _tabs.indexWhere((tab) => tab.path == currentPath);
|
|
final safeIndex = selectedIndex < 0 ? 0 : selectedIndex;
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text('研听'),
|
|
Text(
|
|
'全球机构研报中文解读',
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: WiseColors.textSecondary,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
body: ColoredBox(
|
|
color: WiseColors.canvas,
|
|
child: Stack(children: [Positioned.fill(child: child)]),
|
|
),
|
|
bottomNavigationBar: SafeArea(
|
|
top: false,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
MiniPlayer(player: player, onToggle: controller.toggleAudio),
|
|
Container(
|
|
height: 64,
|
|
padding: const EdgeInsets.fromLTRB(12, 8, 12, 8),
|
|
decoration: const BoxDecoration(
|
|
color: WiseColors.canvas,
|
|
border: Border(
|
|
top: BorderSide(color: Color(0x11000000), width: 0.5),
|
|
),
|
|
),
|
|
child: Row(
|
|
children: List.generate(_tabs.length, (index) {
|
|
final tab = _tabs[index];
|
|
final active = index == safeIndex;
|
|
return Expanded(
|
|
child: InkWell(
|
|
onTap: () => context.go(tab.path),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Icon(
|
|
tab.icon,
|
|
size: 20,
|
|
color: active
|
|
? WiseColors.ink
|
|
: WiseColors.textTertiary,
|
|
),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
tab.label,
|
|
style:
|
|
(Theme.of(context).textTheme.labelLarge ??
|
|
const TextStyle())
|
|
.copyWith(
|
|
color: active
|
|
? WiseColors.ink
|
|
: WiseColors.textTertiary,
|
|
fontFamily: 'Inter',
|
|
fontSize: 12,
|
|
letterSpacing: 0.72,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _TabItem {
|
|
const _TabItem({required this.label, required this.path, required this.icon});
|
|
|
|
final String label;
|
|
final String path;
|
|
final IconData icon;
|
|
}
|
|
|
|
const List<_TabItem> _tabs = [
|
|
_TabItem(label: '推荐', path: AppRoutes.home, icon: AppIcons.sparkle),
|
|
_TabItem(label: '研报', path: AppRoutes.reports, icon: AppIcons.article),
|
|
_TabItem(label: '机构', path: AppRoutes.institutions, icon: AppIcons.bank),
|
|
_TabItem(label: '听单', path: AppRoutes.listen, icon: AppIcons.headphones),
|
|
_TabItem(label: '我的', path: AppRoutes.profile, icon: AppIcons.user),
|
|
];
|