Telas de login e dashboard de estudante feito
This commit is contained in:
177
lib/core/routing/app_router.dart
Normal file
177
lib/core/routing/app_router.dart
Normal file
@@ -0,0 +1,177 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.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/tutor/presentation/pages/tutor_chat_page.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';
|
||||
import '../../shared/presentation/pages/not_found_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 = '/tutor';
|
||||
static const String quizList = '/quiz';
|
||||
static const String quiz = '/quiz/:quizId';
|
||||
static const String profile = '/profile';
|
||||
|
||||
// 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(),
|
||||
),
|
||||
|
||||
// Authentication Routes
|
||||
GoRoute(
|
||||
path: login,
|
||||
name: 'login',
|
||||
builder: (context, state) => const LoginPage(),
|
||||
),
|
||||
|
||||
GoRoute(
|
||||
path: signup,
|
||||
name: 'signup',
|
||||
builder: (context, state) => const SignupPage(),
|
||||
),
|
||||
|
||||
// Dashboard Routes
|
||||
GoRoute(
|
||||
path: studentDashboard,
|
||||
name: 'studentDashboard',
|
||||
builder: (context, state) => const StudentDashboardPage(),
|
||||
routes: [
|
||||
// Nested routes for student features
|
||||
GoRoute(
|
||||
path: tutorNested,
|
||||
name: 'studentTutor',
|
||||
builder: (context, state) => const TutorChatPage(),
|
||||
),
|
||||
GoRoute(
|
||||
path: quizListNested,
|
||||
name: 'quizList',
|
||||
builder: (context, state) => const QuizListPage(),
|
||||
),
|
||||
GoRoute(
|
||||
path: quizNested,
|
||||
name: 'quiz',
|
||||
builder: (context, state) {
|
||||
final quizId = state.pathParameters['quizId']!;
|
||||
return QuizPage(quizId: quizId);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
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 TutorChatPage(),
|
||||
),
|
||||
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(),
|
||||
),
|
||||
],
|
||||
|
||||
// Redirect unauthenticated users to login
|
||||
redirect: (context, state) {
|
||||
// TODO: Implement authentication check
|
||||
// For now, allow all routes
|
||||
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 goBack(BuildContext context) {
|
||||
context.pop();
|
||||
}
|
||||
|
||||
static void replaceWith(BuildContext context, String location) {
|
||||
context.go(location);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user