openai service
This commit is contained in:
@@ -1,15 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'bloc/book_bloc.dart';
|
||||
import 'bloc/navigation_bloc.dart';
|
||||
import 'models/models.dart';
|
||||
import 'widgets/layout.dart';
|
||||
import 'screens/library_screen.dart';
|
||||
import 'screens/categories_screen.dart';
|
||||
import 'screens/book_details_screen.dart';
|
||||
import 'screens/add_book_screen.dart';
|
||||
import 'screens/scanner_screen.dart';
|
||||
import 'bloc/book/book_bloc.dart';
|
||||
import 'widgets/bottom_nav_shell.dart';
|
||||
import 'theme/app_theme.dart';
|
||||
|
||||
void main() async {
|
||||
@@ -23,101 +16,15 @@ class BookshelfApp extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MultiBlocProvider(
|
||||
providers: [
|
||||
BlocProvider(create: (_) => BookBloc()),
|
||||
BlocProvider(create: (_) => NavigationBloc()),
|
||||
],
|
||||
return BlocProvider(
|
||||
create: (_) => BookBloc(),
|
||||
child: MaterialApp(
|
||||
title: 'Книжная полка',
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: AppTheme.lightTheme(),
|
||||
themeMode: ThemeMode.light,
|
||||
home: const _AppShell(),
|
||||
home: const BottomNavShell(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _AppShell extends StatelessWidget {
|
||||
const _AppShell();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<NavigationBloc, NavigationState>(
|
||||
builder: (context, state) {
|
||||
final showNav = switch (state.screen) {
|
||||
AppScreen.library ||
|
||||
AppScreen.categories ||
|
||||
AppScreen.wishlist ||
|
||||
AppScreen.settings => true,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
final screen = switch (state.screen) {
|
||||
AppScreen.library => _libraryWithFab(context),
|
||||
AppScreen.categories => const CategoriesScreen(),
|
||||
AppScreen.wishlist => _placeholder(
|
||||
'Здесь будут книги, которые вы хотите прочитать.',
|
||||
),
|
||||
AppScreen.settings => _placeholder(
|
||||
'Персонализируйте ваше приложение.',
|
||||
),
|
||||
AppScreen.details => const BookDetailsScreen(),
|
||||
AppScreen.addBook => const AddBookScreen(),
|
||||
AppScreen.scanner => const ScannerScreen(),
|
||||
};
|
||||
|
||||
if (state.screen == AppScreen.scanner) {
|
||||
return screen;
|
||||
}
|
||||
|
||||
return AppLayout(showBottomNav: showNav, child: screen);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _libraryWithFab(BuildContext context) {
|
||||
return Stack(
|
||||
children: [
|
||||
const LibraryScreen(),
|
||||
Positioned(
|
||||
bottom: 16,
|
||||
right: 20,
|
||||
child: FloatingActionButton(
|
||||
onPressed: () {
|
||||
context.read<NavigationBloc>().add(
|
||||
NavigateTo(
|
||||
AppScreen.addBook,
|
||||
selectedBook: null,
|
||||
prefilledData: null,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: const Icon(Icons.add),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _placeholder(String message) {
|
||||
return Builder(
|
||||
builder: (context) {
|
||||
final theme = Theme.of(context);
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(48),
|
||||
child: Text(
|
||||
message,
|
||||
textAlign: TextAlign.center,
|
||||
style: theme.textTheme.bodyLarge?.copyWith(
|
||||
color: theme.colorScheme.onSurface.withValues(alpha: 0.5),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user