194 lines
5.6 KiB
Dart
194 lines
5.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import '../../shared/presentation/pages/not_found_page.dart';
|
|
import '../../features/settings/presentation/pages/settings_page.dart';
|
|
import '../../features/settings/presentation/pages/profile_edit_page.dart';
|
|
import '../../features/settings/presentation/pages/help_page.dart';
|
|
import '../../features/auth/presentation/pages/login_page.dart';
|
|
import '../../features/auth/presentation/pages/signup_page.dart';
|
|
import '../../features/dashboard/presentation/pages/student_dashboard_page.dart';
|
|
import '../../features/dashboard/presentation/pages/teacher_dashboard_page.dart';
|
|
import '../../features/ai_tutor/presentation/pages/tutor_chat_page_simple.dart';
|
|
import '../../features/quiz/presentation/pages/quiz_list_page.dart';
|
|
import '../../features/quiz/presentation/pages/quiz_page.dart';
|
|
import '../../features/profile/presentation/pages/profile_page.dart';
|
|
import '../../features/splash/presentation/pages/splash_page.dart';
|
|
import '../../features/auth/presentation/pages/role_selection_page.dart';
|
|
|
|
/// App Router Configuration
|
|
class AppRouter {
|
|
static const String splash = '/splash';
|
|
static const String roleSelection = '/role-selection';
|
|
static const String login = '/login';
|
|
static const String signup = '/signup';
|
|
static const String studentDashboard = '/student-dashboard';
|
|
static const String teacherDashboard = '/teacher-dashboard';
|
|
static const String tutor = '/ai-tutor';
|
|
static const String quizList = '/quiz';
|
|
static const String quiz = '/quiz/:quizId';
|
|
static const String profile = '/profile';
|
|
static const String settings = '/settings';
|
|
|
|
// Nested route paths (without leading slash)
|
|
static const String tutorNested = 'tutor';
|
|
static const String quizListNested = 'quiz';
|
|
static const String quizNested = 'quiz/:quizId';
|
|
|
|
static final GoRouter router = GoRouter(
|
|
initialLocation: splash,
|
|
debugLogDiagnostics: true,
|
|
errorBuilder: (context, state) => const NotFoundPage(),
|
|
|
|
routes: [
|
|
// Splash Screen
|
|
GoRoute(
|
|
path: splash,
|
|
name: 'splash',
|
|
builder: (context, state) => const SplashPage(),
|
|
),
|
|
|
|
// Role Selection
|
|
GoRoute(
|
|
path: roleSelection,
|
|
name: 'roleSelection',
|
|
builder: (context, state) => const RoleSelectionPage(),
|
|
),
|
|
|
|
// Login
|
|
GoRoute(
|
|
path: login,
|
|
name: 'login',
|
|
builder: (context, state) => const LoginPage(),
|
|
),
|
|
|
|
// Signup
|
|
GoRoute(
|
|
path: signup,
|
|
name: 'signup',
|
|
builder: (context, state) => const SignupPage(),
|
|
),
|
|
|
|
// Student Dashboard
|
|
GoRoute(
|
|
path: studentDashboard,
|
|
name: 'studentDashboard',
|
|
builder: (context, state) => const StudentDashboardPage(),
|
|
),
|
|
|
|
// Teacher Dashboard
|
|
GoRoute(
|
|
path: teacherDashboard,
|
|
name: 'teacherDashboard',
|
|
builder: (context, state) => const TeacherDashboardPage(),
|
|
routes: [
|
|
// Nested routes for teacher features
|
|
GoRoute(
|
|
path: tutorNested,
|
|
name: 'teacherTutor',
|
|
builder: (context, state) => const TutorChatPageSimple(),
|
|
),
|
|
GoRoute(
|
|
path: quizListNested,
|
|
name: 'teacherQuizList',
|
|
builder: (context, state) => const QuizListPage(),
|
|
),
|
|
GoRoute(
|
|
path: quizNested,
|
|
name: 'teacherQuiz',
|
|
builder: (context, state) {
|
|
final quizId = state.pathParameters['quizId']!;
|
|
return QuizPage(quizId: quizId);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
|
|
// Profile Route
|
|
GoRoute(
|
|
path: profile,
|
|
name: 'profile',
|
|
builder: (context, state) => const ProfilePage(),
|
|
),
|
|
|
|
// Settings Route
|
|
GoRoute(
|
|
path: settings,
|
|
name: 'settings',
|
|
builder: (context, state) => const SettingsPage(),
|
|
routes: [
|
|
// Profile Edit Route
|
|
GoRoute(
|
|
path: 'profile-edit',
|
|
name: 'profileEdit',
|
|
builder: (context, state) => const ProfileEditPage(),
|
|
),
|
|
// Help Route
|
|
GoRoute(
|
|
path: 'help',
|
|
name: 'help',
|
|
builder: (context, state) => const HelpPage(),
|
|
),
|
|
],
|
|
),
|
|
|
|
// AI Tutor Route (independent)
|
|
GoRoute(
|
|
path: tutor,
|
|
name: 'aiTutor',
|
|
builder: (context, state) => const TutorChatPageSimple(),
|
|
),
|
|
],
|
|
|
|
// Let splash screen handle all navigation logic
|
|
redirect: (context, state) {
|
|
// Allow all routes - splash screen will handle authentication and navigation
|
|
return null;
|
|
},
|
|
);
|
|
|
|
// Navigation helpers
|
|
static void goToLogin(BuildContext context) {
|
|
context.go(login);
|
|
}
|
|
|
|
static void goToSignup(BuildContext context) {
|
|
context.go(signup);
|
|
}
|
|
|
|
static void goToStudentDashboard(BuildContext context) {
|
|
context.go(studentDashboard);
|
|
}
|
|
|
|
static void goToTeacherDashboard(BuildContext context) {
|
|
context.go(teacherDashboard);
|
|
}
|
|
|
|
static void goToTutor(BuildContext context) {
|
|
context.go(tutor);
|
|
}
|
|
|
|
static void goToQuizList(BuildContext context) {
|
|
context.go(quizList);
|
|
}
|
|
|
|
static void goToQuiz(BuildContext context, String quizId) {
|
|
context.go('$quiz/$quizId');
|
|
}
|
|
|
|
static void goToProfile(BuildContext context) {
|
|
context.go(profile);
|
|
}
|
|
|
|
static void goToSettings(BuildContext context) {
|
|
context.go(settings);
|
|
}
|
|
|
|
static void goBack(BuildContext context) {
|
|
context.pop();
|
|
}
|
|
|
|
static void replaceWith(BuildContext context, String location) {
|
|
context.go(location);
|
|
}
|
|
}
|