This commit is contained in:
jantunesmessias 2025-02-17 09:57:46 -03:00
parent defe7f3401
commit 65a70cd8de
10 changed files with 32 additions and 31 deletions

15
.vscode/launch.json vendored
View File

@ -9,20 +9,29 @@
"request": "launch",
"type": "dart",
"args": [
"--no-enable-impeller"
"--no-enable-impeller",
" --enable-experiment=macros"
]
},
{
"name": "flutter-freaccesss-hub (profile mode)",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
"flutterMode": "profile",
"args": [
"--no-enable-impeller",
" --enable-experiment=macros"
]
},
{
"name": "flutter-freaccesss-hub (release mode)",
"request": "launch",
"type": "dart",
"flutterMode": "release"
"flutterMode": "release",
"args": [
"--no-enable-impeller",
" --enable-experiment=macros"
]
}
]
}

View File

@ -15,10 +15,7 @@ class DocumentPageBloc extends Bloc<DocumentPageEvent, DocumentPageState> {
}
static DocumentPageBloc create(DocumentPageModel model) {
final initialState = DocumentPageState(
categories: [],
documents: [],
);
final initialState = DocumentPageState();
return DocumentPageBloc._(model, initialState);
}
@ -66,15 +63,15 @@ class DocumentPageBloc extends Bloc<DocumentPageEvent, DocumentPageState> {
Future<void> _unselectDocument(
UnselectDocumentEvent event, Emitter<DocumentPageState> emit) async {
final docs = await model.generateDocuments(state.page, state.query);
final cats = await model.generateCategories();
// final docs = await model.generateDocuments(state.page, state.query);
// final cats = await model.generateCategories();
emit(
state.copyWith(
currentDocument: null,
isDocumentSelected: false,
documents: docs.$2,
categories: cats,
// documents: docs.$2,
// categories: cats,
),
);
}
@ -113,18 +110,14 @@ class DocumentPageState {
final int? count;
final dynamic page;
final Query? query;
final List<Document?> documents;
final List<Category?> categories;
const DocumentPageState({
this.query,
this.count,
this.page,
this.uri,
required this.documents,
this.currentDocument,
this.isCategorySelected = false,
required this.categories,
this.currentCategory,
this.isDocumentSelected = false,
});
@ -147,11 +140,9 @@ class DocumentPageState {
count: count ?? this.count,
page: page ?? this.page,
//
documents: documents ?? this.documents,
currentDocument: currentDocument ?? this.currentDocument,
isDocumentSelected: isDocumentSelected ?? this.isDocumentSelected,
//
categories: categories ?? this.categories,
currentCategory: currentCategory ?? this.currentCategory,
isCategorySelected: isCategorySelected ?? this.isCategorySelected,
);

View File

@ -36,6 +36,7 @@ class DocumentPageModel extends FlutterFlowModel<DocumentPage> {
/// [documentItemBuilder]
DocumentItem documentItemBuilder<T extends Document>(
BuildContext context, T item, int index) {
print('ItemBuilder -> $index');
return DocumentItem(
document: item,
onPressed: onView,

View File

@ -17,7 +17,9 @@ class DocumentViewScreen extends StatefulScreen {
class _DocumentViewScreenState extends ScreenState<DocumentViewScreen> {
@override
Widget build(BuildContext context) {
action() => context.read<DocumentPageBloc>().add(UnselectDocumentEvent());
action() {
context.read<DocumentPageBloc>().add(UnselectDocumentEvent());
}
final String title = widget.doc.description;
final theme = FlutterFlowTheme.of(context);
@ -35,7 +37,7 @@ class _DocumentViewScreenState extends ScreenState<DocumentViewScreen> {
Widget buildBody(BuildContext context) {
// final PDFViewerKey _viewerKey = PDFViewerKey();
return PDFViewer(
return ReadView(
// search: _viewerKey,
title: widget.doc.description,
url: widget.uri.toString(),

View File

@ -14,9 +14,9 @@ import 'package:hub/shared/widgets/widgets.dart';
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
import 'package:share_plus/share_plus.dart';
part 'document_manager_screen.dart';
part 'document_page_widget.dart';
part 'document_viewer_screen.dart';
part 'document_screen_manager.dart';
part 'document_screen_viewer.dart';
part 'document_page_model.dart';
part 'document_item_component.dart';
part 'document_page_bloc.dart';

View File

@ -1,4 +1,4 @@
part of '../widgets.dart';
part of 'widgets.dart';
// typedef PDFViewerKey = GlobalKey<SfPdfViewerState>;
@ -18,21 +18,21 @@ abstract interface class Viewer extends StatelessComponent {
Widget buildViewer(BuildContext context);
}
class PDFViewer extends StatefulWidget {
class ReadView extends StatefulWidget {
final String url;
final String title;
const PDFViewer({
const ReadView({
super.key,
required this.url,
required this.title,
});
@override
State<PDFViewer> createState() => PDFViewerState();
State<ReadView> createState() => ReadViewState();
}
class PDFViewerState extends State<PDFViewer> {
class ReadViewState extends State<ReadView> {
late PdfController _pdfController;
Future<PdfController> _initializePdf() async {

View File

@ -22,10 +22,8 @@ part 'model.dart';
part 'entity.dart';
/// [View]'s
part 'view/list_view.dart';
part 'view/carousel_view.dart';
/// [Viewer]
part 'viewer/viewer.dart';
part 'list_view.dart';
part 'carousel_view.dart';
part 'read_view.dart';
part 'text.dart';