chore: bootstrap flutter reader app skeleton
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../core/theme/app_theme.dart';
|
||||
import 'router/app_router.dart';
|
||||
|
||||
class ReaderApp extends ConsumerWidget {
|
||||
const ReaderApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final router = ref.watch(appRouterProvider);
|
||||
|
||||
return MaterialApp.router(
|
||||
title: 'Reader App',
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: AppTheme.lightTheme,
|
||||
routerConfig: router,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../features/auth/presentation/login_screen.dart';
|
||||
import '../../features/bookshelf/presentation/bookshelf_screen.dart';
|
||||
import '../../features/comments/presentation/comments_screen.dart';
|
||||
import '../../features/genres/presentation/genres_screen.dart';
|
||||
import '../../features/home/presentation/home_screen.dart';
|
||||
import '../../features/novel/presentation/novel_detail_screen.dart';
|
||||
import '../../features/profile/presentation/profile_screen.dart';
|
||||
import '../../features/reader/presentation/reader_screen.dart';
|
||||
import '../../features/search/presentation/search_screen.dart';
|
||||
import '../../features/settings/presentation/settings_screen.dart';
|
||||
import '../../features/splash/presentation/splash_screen.dart';
|
||||
import '../../shared/widgets/app_shell.dart';
|
||||
import 'route_names.dart';
|
||||
|
||||
final appRouterProvider = Provider<GoRouter>((ref) {
|
||||
return GoRouter(
|
||||
initialLocation: RouteNames.splash,
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: RouteNames.splash,
|
||||
builder: (context, state) => const SplashScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: RouteNames.login,
|
||||
builder: (context, state) => const LoginScreen(),
|
||||
),
|
||||
ShellRoute(
|
||||
builder: (context, state, child) => AppShell(child: child),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: RouteNames.home,
|
||||
builder: (context, state) => const HomeScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: RouteNames.search,
|
||||
builder: (context, state) => const SearchScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: RouteNames.genres,
|
||||
builder: (context, state) => const GenresScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: RouteNames.bookshelf,
|
||||
builder: (context, state) => const BookshelfScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: RouteNames.profile,
|
||||
builder: (context, state) => const ProfileScreen(),
|
||||
),
|
||||
],
|
||||
),
|
||||
GoRoute(
|
||||
path: RouteNames.novelDetail,
|
||||
builder: (_, state) => NovelDetailScreen(
|
||||
novelId: state.uri.queryParameters['id'] ?? '',
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: RouteNames.reader,
|
||||
builder: (_, state) => ReaderScreen(
|
||||
chapterId: state.uri.queryParameters['chapterId'] ?? '',
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: RouteNames.comments,
|
||||
builder: (_, state) => CommentsScreen(
|
||||
novelId: state.uri.queryParameters['novelId'] ?? '',
|
||||
chapterId: state.uri.queryParameters['chapterId'],
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: RouteNames.settings,
|
||||
builder: (context, state) => const SettingsScreen(),
|
||||
),
|
||||
],
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
class RouteNames {
|
||||
RouteNames._();
|
||||
|
||||
static const splash = '/';
|
||||
static const home = '/home';
|
||||
static const login = '/login';
|
||||
static const search = '/search';
|
||||
static const genres = '/genres';
|
||||
static const novelDetail = '/novel';
|
||||
static const reader = '/reader';
|
||||
static const bookshelf = '/bookshelf';
|
||||
static const comments = '/comments';
|
||||
static const profile = '/profile';
|
||||
static const settings = '/settings';
|
||||
}
|
||||
Reference in New Issue
Block a user