refactor: create separate BLoCs for each screen with comprehensive tests
- Created 8 separate BLoCs (Home, Library, BookDetails, AddBook, Scanner, Categories, Wishlist, Settings) - Each BLoC has its own event, state, and bloc files - Added 70 comprehensive tests covering all BLoC functionality - All tests passing (70/70) - Fixed linting issues and updated deprecated APIs - Improved code organization and maintainability
This commit is contained in:
320
bookshelf_flutter/lib/screens/add_book_screen.dart
Normal file
320
bookshelf_flutter/lib/screens/add_book_screen.dart
Normal file
@@ -0,0 +1,320 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import '../bloc/app_bloc.dart';
|
||||
import '../bloc/app_event.dart';
|
||||
import '../models/models.dart';
|
||||
|
||||
class AddBookScreen extends StatefulWidget {
|
||||
final dynamic initialData;
|
||||
|
||||
const AddBookScreen({super.key, this.initialData});
|
||||
|
||||
@override
|
||||
State<AddBookScreen> createState() => _AddBookScreenState();
|
||||
}
|
||||
|
||||
class _AddBookScreenState extends State<AddBookScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
late TextEditingController _titleController;
|
||||
late TextEditingController _authorController;
|
||||
late TextEditingController _genreController;
|
||||
late TextEditingController _annotationController;
|
||||
String? _coverUrl;
|
||||
BookStatus _selectedStatus = BookStatus.wantToRead;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_titleController = TextEditingController();
|
||||
_authorController = TextEditingController();
|
||||
_genreController = TextEditingController();
|
||||
_annotationController = TextEditingController();
|
||||
|
||||
if (widget.initialData is Book) {
|
||||
final book = widget.initialData as Book;
|
||||
_titleController.text = book.title;
|
||||
_authorController.text = book.author;
|
||||
_genreController.text = book.genre;
|
||||
_annotationController.text = book.annotation;
|
||||
_coverUrl = book.coverUrl;
|
||||
_selectedStatus = book.status;
|
||||
} else if (widget.initialData is Map) {
|
||||
final data = widget.initialData as Map<String, dynamic>;
|
||||
_titleController.text = data['title']?.toString() ?? '';
|
||||
_authorController.text = data['author']?.toString() ?? '';
|
||||
_genreController.text = data['genre']?.toString() ?? '';
|
||||
_annotationController.text = data['annotation']?.toString() ?? '';
|
||||
_coverUrl = data['coverUrl']?.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_titleController.dispose();
|
||||
_authorController.dispose();
|
||||
_genreController.dispose();
|
||||
_annotationController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _pickImage() async {
|
||||
final picker = ImagePicker();
|
||||
final XFile? image = await picker.pickImage(source: ImageSource.gallery);
|
||||
if (image != null) {
|
||||
setState(() {
|
||||
_coverUrl = image.path;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void _saveBook() {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
context.read<AppBloc>().add(
|
||||
BookSaved({
|
||||
'title': _titleController.text,
|
||||
'author': _authorController.text,
|
||||
'genre': _genreController.text,
|
||||
'annotation': _annotationController.text,
|
||||
'coverUrl': _coverUrl,
|
||||
'status': _selectedStatus,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFF112116),
|
||||
appBar: AppBar(
|
||||
backgroundColor: const Color(0xFF112116).withValues(alpha: 0.9),
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back_ios_new, color: Colors.white),
|
||||
onPressed: () {
|
||||
context.read<AppBloc>().add(
|
||||
widget.initialData is Book
|
||||
? const ScreenChanged(AppScreen.details)
|
||||
: const ScreenChanged(AppScreen.library),
|
||||
);
|
||||
},
|
||||
),
|
||||
title: const Text('Добавить книгу'),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: Form(
|
||||
key: _formKey,
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16),
|
||||
children: [
|
||||
Center(
|
||||
child: GestureDetector(
|
||||
onTap: _pickImage,
|
||||
child: Container(
|
||||
width: 160,
|
||||
height: 240,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: const Color(0xFF346544),
|
||||
width: 2,
|
||||
),
|
||||
color: const Color(0xFF1A3222),
|
||||
),
|
||||
child: _coverUrl != null
|
||||
? ClipRRect(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: _coverUrl!.startsWith('http')
|
||||
? CachedNetworkImage(
|
||||
imageUrl: _coverUrl!,
|
||||
fit: BoxFit.cover,
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
)
|
||||
: Image.network(_coverUrl!, fit: BoxFit.cover),
|
||||
)
|
||||
: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF17CF54).withValues(alpha: 0.1),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.add_a_photo,
|
||||
color: Color(0xFF17CF54),
|
||||
size: 28,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
const Text(
|
||||
'Загрузить',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xFF93C8A5),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
_buildTextField(
|
||||
controller: _titleController,
|
||||
label: 'Название',
|
||||
validator: (value) =>
|
||||
value?.isEmpty ?? true ? 'Введите название' : null,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildTextField(
|
||||
controller: _authorController,
|
||||
label: 'Автор',
|
||||
validator: (value) =>
|
||||
value?.isEmpty ?? true ? 'Введите автора' : null,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildTextField(
|
||||
controller: _genreController,
|
||||
label: 'Жанр',
|
||||
validator: (value) =>
|
||||
value?.isEmpty ?? true ? 'Введите жанр' : null,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildTextField(
|
||||
controller: _annotationController,
|
||||
label: 'Аннотация',
|
||||
maxLines: 4,
|
||||
validator: (value) =>
|
||||
value?.isEmpty ?? true ? 'Введите аннотацию' : null,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
DropdownButtonFormField<BookStatus>(
|
||||
initialValue: _selectedStatus,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Статус',
|
||||
labelStyle: const TextStyle(
|
||||
color: Color(0xFFE0E0E0),
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
filled: true,
|
||||
fillColor: const Color(0xFF1A3222),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(color: Color(0xFF346544)),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(color: Color(0xFF346544)),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(color: Color(0xFF17CF54)),
|
||||
),
|
||||
),
|
||||
dropdownColor: const Color(0xFF1A3222),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
items: BookStatus.values.map((status) {
|
||||
return DropdownMenuItem(
|
||||
value: status,
|
||||
child: Text(status.displayName),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
setState(() {
|
||||
_selectedStatus = value;
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 120),
|
||||
],
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF112116).withValues(alpha: 0.95),
|
||||
border: Border(
|
||||
top: BorderSide(color: Colors.white.withValues(alpha: 0.05), width: 1),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: OutlinedButton(
|
||||
onPressed: () {
|
||||
context.read<AppBloc>().add(
|
||||
widget.initialData is Book
|
||||
? const ScreenChanged(AppScreen.details)
|
||||
: const ScreenChanged(AppScreen.library),
|
||||
);
|
||||
},
|
||||
style: OutlinedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
side: const BorderSide(color: Colors.transparent),
|
||||
),
|
||||
child: const Text('Отмена'),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: _saveBook,
|
||||
icon: const Icon(Icons.save),
|
||||
label: const Text('Сохранить'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF17CF54),
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTextField({
|
||||
required TextEditingController controller,
|
||||
required String label,
|
||||
int maxLines = 1,
|
||||
String? Function(String?)? validator,
|
||||
}) {
|
||||
return TextFormField(
|
||||
controller: controller,
|
||||
maxLines: maxLines,
|
||||
validator: validator,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 16),
|
||||
decoration: InputDecoration(
|
||||
labelText: label,
|
||||
labelStyle: const TextStyle(
|
||||
color: Color(0xFFE0E0E0),
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
filled: true,
|
||||
fillColor: const Color(0xFF1A3222),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(color: Color(0xFF346544)),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(color: Color(0xFF346544)),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(color: Color(0xFF17CF54)),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
288
bookshelf_flutter/lib/screens/book_details_screen.dart
Normal file
288
bookshelf_flutter/lib/screens/book_details_screen.dart
Normal file
@@ -0,0 +1,288 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import '../bloc/app_bloc.dart';
|
||||
import '../bloc/app_event.dart';
|
||||
import '../models/models.dart';
|
||||
|
||||
class BookDetailsScreen extends StatelessWidget {
|
||||
final Book book;
|
||||
|
||||
const BookDetailsScreen({super.key, required this.book});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFF112116),
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
SliverAppBar(
|
||||
expandedHeight: 460,
|
||||
pinned: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back_ios_new, color: Colors.white),
|
||||
onPressed: () {
|
||||
context.read<AppBloc>().add(const ScreenChanged(AppScreen.library));
|
||||
},
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.more_horiz, color: Colors.white),
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
background: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
CachedNetworkImage(
|
||||
imageUrl: book.coverUrl ??
|
||||
'https://picsum.photos/seed/placeholder/400/600',
|
||||
fit: BoxFit.cover,
|
||||
width: double.infinity,
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Colors.transparent,
|
||||
const Color(0xFF112116),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 6,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withValues(alpha: 0.4),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(
|
||||
color: Colors.white.withValues(alpha: 0.1),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
book.status.displayName,
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF17CF54),
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
letterSpacing: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
book.title,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
book.author,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
color: Color(0xFF93C8A5),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: book.genre.split(',').map((genre) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 8,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF244730),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
genre.trim(),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
context.read<AppBloc>().add(const ScreenChanged(AppScreen.addBook));
|
||||
},
|
||||
icon: const Icon(Icons.edit_square),
|
||||
label: const Text('Edit Details'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF17CF54),
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
context.read<AppBloc>().add(BookDeleted(book.id));
|
||||
},
|
||||
icon: const Icon(Icons.delete),
|
||||
label: const Text('Delete'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.white.withValues(alpha: 0.05),
|
||||
foregroundColor: Colors.white,
|
||||
side: BorderSide(
|
||||
color: Colors.white.withValues(alpha: 0.1),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
const Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
'About',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withValues(alpha: 0.05),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(
|
||||
color: Colors.white.withValues(alpha: 0.05),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
book.annotation,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
color: Color(0xFF93C8A5),
|
||||
height: 1.5,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
GridView.count(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
crossAxisCount: 2,
|
||||
crossAxisSpacing: 12,
|
||||
mainAxisSpacing: 12,
|
||||
childAspectRatio: 1.2,
|
||||
children: [
|
||||
_buildInfoCard(
|
||||
Icons.menu_book,
|
||||
'Pages',
|
||||
book.pages?.toString() ?? 'N/A',
|
||||
Colors.blue,
|
||||
),
|
||||
_buildInfoCard(
|
||||
Icons.language,
|
||||
'Language',
|
||||
book.language ?? 'Russian',
|
||||
Colors.purple,
|
||||
),
|
||||
_buildInfoCard(
|
||||
Icons.calendar_month,
|
||||
'Published',
|
||||
book.publishedYear?.toString() ?? 'N/A',
|
||||
Colors.orange,
|
||||
),
|
||||
_buildInfoCard(
|
||||
Icons.star,
|
||||
'Rating',
|
||||
'${book.rating ?? 0}/5',
|
||||
Colors.amber,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInfoCard(IconData icon, String label, String value, Color color) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withValues(alpha: 0.05),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: Colors.white.withValues(alpha: 0.05),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(6),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withValues(alpha: 0.2),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Icon(icon, color: color, size: 18),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.grey.shade500,
|
||||
letterSpacing: 0.5,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
value,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
224
bookshelf_flutter/lib/screens/categories_screen.dart
Normal file
224
bookshelf_flutter/lib/screens/categories_screen.dart
Normal file
@@ -0,0 +1,224 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../models/models.dart';
|
||||
|
||||
class CategoriesScreen extends StatelessWidget {
|
||||
const CategoriesScreen({super.key});
|
||||
|
||||
static const List<Category> categories = [
|
||||
(
|
||||
id: 'fiction',
|
||||
name: 'Фантастика',
|
||||
count: 24,
|
||||
icon: Icons.rocket_launch,
|
||||
colorClass: 'bg-indigo-500/20 text-indigo-300',
|
||||
),
|
||||
(
|
||||
id: 'fantasy',
|
||||
name: 'Фэнтези',
|
||||
count: 18,
|
||||
icon: Icons.auto_fix_high,
|
||||
colorClass: 'bg-purple-500/20 text-purple-300',
|
||||
),
|
||||
(
|
||||
id: 'nonfiction',
|
||||
name: 'Научпоп',
|
||||
count: 7,
|
||||
icon: Icons.psychology,
|
||||
colorClass: 'bg-teal-500/20 text-teal-300',
|
||||
),
|
||||
(
|
||||
id: 'business',
|
||||
name: 'Бизнес',
|
||||
count: 3,
|
||||
icon: Icons.business_center,
|
||||
colorClass: 'bg-blue-500/20 text-blue-300',
|
||||
),
|
||||
(
|
||||
id: 'education',
|
||||
name: 'Учебная',
|
||||
count: 0,
|
||||
icon: Icons.school,
|
||||
colorClass: 'bg-orange-500/20 text-orange-300',
|
||||
),
|
||||
(
|
||||
id: 'classics',
|
||||
name: 'Классика',
|
||||
count: 15,
|
||||
icon: Icons.history_edu,
|
||||
colorClass: 'bg-amber-500/20 text-amber-300',
|
||||
),
|
||||
];
|
||||
|
||||
Color _getCategoryColor(String colorClass) {
|
||||
if (colorClass.contains('indigo')) return Colors.indigo.shade400;
|
||||
if (colorClass.contains('purple')) return Colors.purple.shade400;
|
||||
if (colorClass.contains('teal')) return Colors.teal.shade400;
|
||||
if (colorClass.contains('blue')) return Colors.blue.shade400;
|
||||
if (colorClass.contains('orange')) return Colors.orange.shade400;
|
||||
if (colorClass.contains('amber')) return Colors.amber.shade400;
|
||||
return Colors.grey.shade400;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFF112116),
|
||||
body: Column(
|
||||
children: [
|
||||
_buildHeader(),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemCount: categories.length,
|
||||
itemBuilder: (context, index) {
|
||||
final category = categories[index];
|
||||
return _buildCategoryCard(category);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildHeader() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF112116).withValues(alpha: 0.95),
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Colors.white.withValues(alpha: 0.05), width: 1),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Изменить',
|
||||
style: TextStyle(
|
||||
color: Colors.white.withValues(alpha: 0.6),
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF17CF54).withValues(alpha: 0.1),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.add,
|
||||
color: Color(0xFF17CF54),
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
'Категории',
|
||||
style: TextStyle(
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Container(
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF1A3023),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: TextField(
|
||||
style: const TextStyle(color: Colors.white, fontSize: 16),
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Поиск жанра...',
|
||||
hintStyle: TextStyle(
|
||||
color: Colors.white.withValues(alpha: 0.4),
|
||||
),
|
||||
prefixIcon: Icon(
|
||||
Icons.search,
|
||||
color: Colors.white.withValues(alpha: 0.4),
|
||||
size: 20,
|
||||
),
|
||||
border: InputBorder.none,
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCategoryCard(Category category) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
// Navigate to category details
|
||||
},
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF1A3023),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: Colors.white.withValues(alpha: 0.05)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 48,
|
||||
height: 48,
|
||||
decoration: BoxDecoration(
|
||||
color: _getCategoryColor(category.colorClass).withValues(alpha: 0.2),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Icon(
|
||||
category.icon,
|
||||
color: _getCategoryColor(category.colorClass),
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
category.name,
|
||||
style: const TextStyle(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
category.count > 0
|
||||
? '${category.count} книги'
|
||||
: 'Нет книг',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white.withValues(alpha: 0.5),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
Icons.chevron_right,
|
||||
color: Colors.white.withValues(alpha: 0.2),
|
||||
size: 24,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
68
bookshelf_flutter/lib/screens/home_screen.dart
Normal file
68
bookshelf_flutter/lib/screens/home_screen.dart
Normal file
@@ -0,0 +1,68 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../bloc/app_bloc.dart';
|
||||
import '../bloc/app_state.dart';
|
||||
import '../models/models.dart';
|
||||
import 'library_screen.dart';
|
||||
import 'categories_screen.dart';
|
||||
import 'book_details_screen.dart';
|
||||
import 'add_book_screen.dart';
|
||||
import 'scanner_screen.dart';
|
||||
import 'wishlist_screen.dart';
|
||||
import 'settings_screen.dart';
|
||||
import '../widgets/bottom_nav.dart';
|
||||
|
||||
class HomeScreen extends StatelessWidget {
|
||||
const HomeScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: BlocBuilder<AppBloc, AppState>(
|
||||
builder: (context, state) {
|
||||
final currentScreen = state.currentScreen;
|
||||
final hideNav = [
|
||||
AppScreen.scanner,
|
||||
AppScreen.details,
|
||||
AppScreen.addBook,
|
||||
].contains(currentScreen);
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
_buildScreen(context, state),
|
||||
if (!hideNav)
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: BottomNav(currentScreen: currentScreen),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildScreen(BuildContext context, AppState state) {
|
||||
switch (state.currentScreen) {
|
||||
case AppScreen.library:
|
||||
return const LibraryScreen();
|
||||
case AppScreen.categories:
|
||||
return const CategoriesScreen();
|
||||
case AppScreen.wishlist:
|
||||
return const WishlistScreen();
|
||||
case AppScreen.settings:
|
||||
return const SettingsScreen();
|
||||
case AppScreen.details:
|
||||
if (state.selectedBook == null) return const SizedBox();
|
||||
return BookDetailsScreen(book: state.selectedBook!);
|
||||
case AppScreen.addBook:
|
||||
return AddBookScreen(
|
||||
initialData: state.selectedBook ?? state.prefilledData,
|
||||
);
|
||||
case AppScreen.scanner:
|
||||
return const ScannerScreen();
|
||||
}
|
||||
}
|
||||
}
|
||||
288
bookshelf_flutter/lib/screens/library_screen.dart
Normal file
288
bookshelf_flutter/lib/screens/library_screen.dart
Normal file
@@ -0,0 +1,288 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import '../bloc/app_bloc.dart';
|
||||
import '../bloc/app_event.dart';
|
||||
import '../bloc/app_state.dart';
|
||||
import '../models/models.dart';
|
||||
|
||||
class LibraryScreen extends StatefulWidget {
|
||||
const LibraryScreen({super.key});
|
||||
|
||||
@override
|
||||
State<LibraryScreen> createState() => _LibraryScreenState();
|
||||
}
|
||||
|
||||
class _LibraryScreenState extends State<LibraryScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFF112116),
|
||||
body: Column(
|
||||
children: [
|
||||
_buildHeader(context),
|
||||
Expanded(child: _buildBookGrid(context)),
|
||||
],
|
||||
),
|
||||
floatingActionButton: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 80),
|
||||
child: FloatingActionButton(
|
||||
onPressed: () {
|
||||
context.read<AppBloc>().add(const AddBookClicked());
|
||||
},
|
||||
backgroundColor: const Color(0xFF17CF54),
|
||||
elevation: 8,
|
||||
child: const Icon(Icons.add, size: 28),
|
||||
),
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildHeader(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF112116).withValues(alpha: 0.95),
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Colors.white.withValues(alpha: 0.05), width: 1),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const SizedBox(width: 40),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Книжная полка',
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 40,
|
||||
child: Icon(
|
||||
Icons.notifications_outlined,
|
||||
color: Colors.white,
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
BlocBuilder<AppBloc, AppState>(
|
||||
buildWhen: (previous, current) =>
|
||||
previous.searchQuery != current.searchQuery,
|
||||
builder: (context, state) {
|
||||
return Container(
|
||||
height: 48,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF244730),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: Colors.white.withValues(alpha: 0.05)),
|
||||
),
|
||||
child: TextField(
|
||||
onChanged: (value) {
|
||||
context.read<AppBloc>().add(SearchChanged(value));
|
||||
},
|
||||
style: const TextStyle(color: Colors.white, fontSize: 16),
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Поиск по названию или автору...',
|
||||
hintStyle: const TextStyle(
|
||||
color: Color(0xFF93C8A5),
|
||||
),
|
||||
prefixIcon: const Icon(
|
||||
Icons.search,
|
||||
color: Color(0xFF93C8A5),
|
||||
size: 20,
|
||||
),
|
||||
border: InputBorder.none,
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBookGrid(BuildContext context) {
|
||||
return BlocBuilder<AppBloc, AppState>(
|
||||
builder: (context, state) {
|
||||
final filteredBooks = state.books.where((book) {
|
||||
final query = state.searchQuery.toLowerCase();
|
||||
return book.title.toLowerCase().contains(query) ||
|
||||
book.author.toLowerCase().contains(query);
|
||||
}).toList();
|
||||
|
||||
if (filteredBooks.isEmpty) {
|
||||
return Center(
|
||||
child: Text(
|
||||
'Книги не найдены',
|
||||
style: TextStyle(
|
||||
color: const Color(0xFF93C8A5),
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return GridView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
crossAxisSpacing: 16,
|
||||
mainAxisSpacing: 16,
|
||||
childAspectRatio: 0.67,
|
||||
),
|
||||
itemCount: filteredBooks.length,
|
||||
itemBuilder: (context, index) {
|
||||
final book = filteredBooks[index];
|
||||
return _buildBookCard(context, book);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBookCard(BuildContext context, Book book) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
context.read<AppBloc>().add(BookClicked(book));
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
color: const Color(0xFF1A3222),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.3),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: book.coverUrl ??
|
||||
'https://picsum.photos/seed/placeholder/400/600',
|
||||
fit: BoxFit.cover,
|
||||
width: double.infinity,
|
||||
placeholder: (context, url) => const Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Color(0xFF17CF54),
|
||||
),
|
||||
),
|
||||
errorWidget: (context, url, error) => Container(
|
||||
color: const Color(0xFF1A3222),
|
||||
child: const Icon(
|
||||
Icons.book_outlined,
|
||||
size: 48,
|
||||
color: Color(0xFF93C8A5),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (book.status == BookStatus.reading && book.progress != null)
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: Container(
|
||||
height: 4,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withValues(alpha: 0.5),
|
||||
),
|
||||
child: FractionallySizedBox(
|
||||
widthFactor: book.progress! / 100,
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Container(
|
||||
color: const Color(0xFF17CF54),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (book.status == BookStatus.done)
|
||||
Positioned(
|
||||
top: 8,
|
||||
left: 8,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF17CF54),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Text(
|
||||
'DONE',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (book.isFavorite)
|
||||
Positioned(
|
||||
top: 8,
|
||||
right: 8,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withValues(alpha: 0.6),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.favorite,
|
||||
size: 14,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
book.title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
book.author,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF93C8A5),
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
270
bookshelf_flutter/lib/screens/scanner_screen.dart
Normal file
270
bookshelf_flutter/lib/screens/scanner_screen.dart
Normal file
@@ -0,0 +1,270 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../bloc/app_bloc.dart';
|
||||
import '../bloc/app_event.dart';
|
||||
import '../models/models.dart';
|
||||
|
||||
class ScannerScreen extends StatelessWidget {
|
||||
const ScannerScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.black,
|
||||
body: Stack(
|
||||
children: [
|
||||
// Camera placeholder
|
||||
Container(
|
||||
color: Colors.black87,
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
),
|
||||
// Header
|
||||
Positioned(
|
||||
top: 48,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
context
|
||||
.read<AppBloc>()
|
||||
.add(const ScreenChanged(AppScreen.addBook));
|
||||
},
|
||||
icon: Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withValues(alpha: 0.4),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(Icons.close, color: Colors.white, size: 24),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 6,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withValues(alpha: 0.4),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(
|
||||
color: Colors.white.withValues(alpha: 0.1),
|
||||
),
|
||||
),
|
||||
child: const Text(
|
||||
'СКАНЕР',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500,
|
||||
letterSpacing: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 40),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
// Scanner frame
|
||||
Center(
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width * 0.75,
|
||||
height: MediaQuery.of(context).size.width * 0.75 * 1.5,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(
|
||||
color: Colors.white.withValues(alpha: 0.2),
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
// Corner accents - top left
|
||||
Positioned(
|
||||
top: -2,
|
||||
left: -2,
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(8),
|
||||
),
|
||||
child: Container(
|
||||
width: 32,
|
||||
height: 32,
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
left: const BorderSide(color: Color(0xFF17CF54), width: 4),
|
||||
top: const BorderSide(color: Color(0xFF17CF54), width: 4),
|
||||
right: const BorderSide(color: Colors.transparent, width: 4),
|
||||
bottom: const BorderSide(color: Colors.transparent, width: 4),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Corner accents - top right
|
||||
Positioned(
|
||||
top: -2,
|
||||
right: -2,
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topRight: Radius.circular(8),
|
||||
),
|
||||
child: Container(
|
||||
width: 32,
|
||||
height: 32,
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
right: const BorderSide(color: Color(0xFF17CF54), width: 4),
|
||||
top: const BorderSide(color: Color(0xFF17CF54), width: 4),
|
||||
left: const BorderSide(color: Colors.transparent, width: 4),
|
||||
bottom: const BorderSide(color: Colors.transparent, width: 4),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Corner accents - bottom left
|
||||
Positioned(
|
||||
bottom: -2,
|
||||
left: -2,
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.only(
|
||||
bottomLeft: Radius.circular(8),
|
||||
),
|
||||
child: Container(
|
||||
width: 32,
|
||||
height: 32,
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
left: const BorderSide(color: Color(0xFF17CF54), width: 4),
|
||||
bottom: const BorderSide(color: Color(0xFF17CF54), width: 4),
|
||||
right: const BorderSide(color: Colors.transparent, width: 4),
|
||||
top: const BorderSide(color: Colors.transparent, width: 4),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Corner accents - bottom right
|
||||
Positioned(
|
||||
bottom: -2,
|
||||
right: -2,
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.only(
|
||||
bottomRight: Radius.circular(8),
|
||||
),
|
||||
child: Container(
|
||||
width: 32,
|
||||
height: 32,
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
right: const BorderSide(color: Color(0xFF17CF54), width: 4),
|
||||
bottom: const BorderSide(color: Color(0xFF17CF54), width: 4),
|
||||
left: const BorderSide(color: Colors.transparent, width: 4),
|
||||
top: const BorderSide(color: Colors.transparent, width: 4),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Scan line animation
|
||||
Center(
|
||||
child: Container(
|
||||
height: 2,
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF17CF54),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: const Color(0xFF17CF54).withValues(alpha: 0.8),
|
||||
blurRadius: 15,
|
||||
spreadRadius: 2,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
// Instructions
|
||||
Positioned(
|
||||
bottom: 120,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Column(
|
||||
children: [
|
||||
const Text(
|
||||
'Поместите обложку в рамку',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
'Камера будет добавлена в будущих обновлениях',
|
||||
style: TextStyle(
|
||||
color: Color(0xFF17CF54),
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Capture button
|
||||
Positioned(
|
||||
bottom: 40,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Center(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
// Simulate detection
|
||||
context.read<AppBloc>().add(
|
||||
BookDetected({
|
||||
'title': 'Новая книга',
|
||||
'author': 'Неизвестный автор',
|
||||
'genre': 'Неизвестный жанр',
|
||||
'annotation': 'Добавьте описание книги',
|
||||
}),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
width: 80,
|
||||
height: 80,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: Colors.white.withValues(alpha: 0.3),
|
||||
width: 4,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.white.withValues(alpha: 0.3),
|
||||
blurRadius: 20,
|
||||
spreadRadius: 2,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
39
bookshelf_flutter/lib/screens/settings_screen.dart
Normal file
39
bookshelf_flutter/lib/screens/settings_screen.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SettingsScreen extends StatelessWidget {
|
||||
const SettingsScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFF112116),
|
||||
body: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(40),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Text(
|
||||
'Настройки',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Персонализируйте ваше приложение.',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: const Color(0xFF93C8A5),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
39
bookshelf_flutter/lib/screens/wishlist_screen.dart
Normal file
39
bookshelf_flutter/lib/screens/wishlist_screen.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class WishlistScreen extends StatelessWidget {
|
||||
const WishlistScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFF112116),
|
||||
body: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(40),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Text(
|
||||
'Вишлист',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Здесь будут книги, которые вы хотите прочитать.',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: const Color(0xFF93C8A5),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user