Files
yanting/lib/features/shell_page.dart
T
2026-06-05 11:12:55 +08:00

76 lines
2.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/wise_tokens.dart';
import '../widgets/bottom_tab_bar.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: Theme.of(context).scaffoldBackgroundColor,
child: Stack(children: [Positioned.fill(child: child)]),
),
bottomNavigationBar: SafeArea(
top: false,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
MiniPlayer(player: player, onToggle: controller.toggleAudio),
BottomTabBar(
items: yantingBottomTabItems,
selectedIndex: safeIndex,
onSelected: (index) => context.go(_tabs[index].path),
),
],
),
),
);
}
}
class _TabItem {
const _TabItem({required this.path});
final String path;
}
const List<_TabItem> _tabs = [
_TabItem(path: AppRoutes.home),
_TabItem(path: AppRoutes.reports),
_TabItem(path: AppRoutes.institutions),
_TabItem(path: AppRoutes.listen),
_TabItem(path: AppRoutes.profile),
];