4a93bd1c44
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
113 lines
3.3 KiB
Dart
113 lines
3.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../features/auth/application/auth_controller.dart';
|
|
import '../../features/auth/presentation/login_screen.dart';
|
|
import '../../features/dashboard/presentation/dashboard_screen.dart';
|
|
import '../../features/profile/presentation/profile_screen.dart';
|
|
import '../../features/review/presentation/review_entry_screen.dart';
|
|
import '../../features/review_history/presentation/review_history_screen.dart';
|
|
import '../../shared/storage/session_store.dart';
|
|
|
|
class AiContractAppShell extends StatefulWidget {
|
|
const AiContractAppShell({super.key});
|
|
|
|
@override
|
|
State<AiContractAppShell> createState() => _AiContractAppShellState();
|
|
}
|
|
|
|
class _AiContractAppShellState extends State<AiContractAppShell> {
|
|
int _currentIndex = 0;
|
|
late final AuthController _authController;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_authController = AuthController();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ValueListenableBuilder(
|
|
valueListenable: SessionStore.listenable,
|
|
builder: (context, session, _) {
|
|
final destinations = const [
|
|
_ShellDestination(
|
|
label: '工作台',
|
|
icon: Icons.space_dashboard_outlined,
|
|
screen: DashboardScreen(),
|
|
),
|
|
_ShellDestination(
|
|
label: '发起审查',
|
|
icon: Icons.description_outlined,
|
|
screen: ReviewEntryScreen(),
|
|
),
|
|
_ShellDestination(
|
|
label: '审查记录',
|
|
icon: Icons.history_outlined,
|
|
screen: ReviewHistoryScreen(),
|
|
),
|
|
_ShellDestination(
|
|
label: '我的',
|
|
icon: Icons.person_outline,
|
|
screen: ProfileScreen(),
|
|
),
|
|
];
|
|
|
|
final destination = destinations[_currentIndex];
|
|
final isAuthenticated = session?.isAuthenticated ?? false;
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(destination.label),
|
|
Text(
|
|
isAuthenticated ? '已登录 · ${session!.userDisplayName}' : 'AI 合同平台 · Android First',
|
|
style: Theme.of(context).textTheme.labelSmall,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
body: SafeArea(
|
|
child: isAuthenticated
|
|
? AnimatedSwitcher(
|
|
duration: const Duration(milliseconds: 240),
|
|
child: destination.screen,
|
|
)
|
|
: LoginScreen(controller: _authController),
|
|
),
|
|
bottomNavigationBar: NavigationBar(
|
|
selectedIndex: _currentIndex,
|
|
onDestinationSelected: (index) {
|
|
setState(() {
|
|
_currentIndex = index;
|
|
});
|
|
},
|
|
destinations: destinations
|
|
.map(
|
|
(item) => NavigationDestination(
|
|
icon: Icon(item.icon),
|
|
label: item.label,
|
|
),
|
|
)
|
|
.toList(),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|
|
|
|
class _ShellDestination {
|
|
const _ShellDestination({
|
|
required this.label,
|
|
required this.icon,
|
|
required this.screen,
|
|
});
|
|
|
|
final String label;
|
|
final IconData icon;
|
|
final Widget screen;
|
|
}
|