This commit is contained in:
jantunesmessias 2025-02-19 09:53:26 -03:00
parent e1772649ec
commit 23a6b6d1d9
4 changed files with 262 additions and 251 deletions

View File

@ -64,7 +64,9 @@ class _DetailsComponentWidgetState extends State<DetailsComponentWidget> {
// CachedNetworkImage.evictFromCache(widget.imagePath ?? '');
final double limitedBodyFontSize =
LimitedFontSizeUtil.getBodyFontSize(context);
return Container(
return Material(
type: MaterialType.transparency,
child: Container(
constraints: BoxConstraints(
maxWidth: MediaQuery.of(context).size.width,
maxHeight: MediaQuery.of(context).size.height,
@ -129,7 +131,8 @@ class _DetailsComponentWidgetState extends State<DetailsComponentWidget> {
fontWeight: FontWeight.bold,
color: FlutterFlowTheme.of(context).info,
letterSpacing: 0.0,
useGoogleFonts: GoogleFonts.asMap().containsKey(
useGoogleFonts:
GoogleFonts.asMap().containsKey(
FlutterFlowTheme.of(context)
.labelMediumFamily,
),
@ -142,7 +145,8 @@ class _DetailsComponentWidgetState extends State<DetailsComponentWidget> {
.labelMediumFamily,
color: FlutterFlowTheme.of(context).info,
letterSpacing: 0.0,
useGoogleFonts: GoogleFonts.asMap().containsKey(
useGoogleFonts:
GoogleFonts.asMap().containsKey(
FlutterFlowTheme.of(context)
.labelMediumFamily,
),
@ -156,9 +160,11 @@ class _DetailsComponentWidgetState extends State<DetailsComponentWidget> {
color: FlutterFlowTheme.of(context).info,
),
),
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily:
FlutterFlowTheme.of(context).bodyMediumFamily,
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily: FlutterFlowTheme.of(context)
.bodyMediumFamily,
color: FlutterFlowTheme.of(context).info,
letterSpacing: 0.0,
useGoogleFonts: GoogleFonts.asMap().containsKey(
@ -278,6 +284,7 @@ class _DetailsComponentWidgetState extends State<DetailsComponentWidget> {
],
),
),
),
);
}
}

View File

@ -23,6 +23,15 @@ part 'documents.rxb.g.dart';
typedef DocumentKey = GlobalKey<DocumentPageState>;
/// -----------------------------------------------
/// [Extensions] ---------------------------------
/// -----------------------------------------------
extension ExplicitRxdartStartWithExtension<T> on Stream<T?> {
Stream<T?> rxdartStartWith(T? value) =>
rx.StartWithExtension(this).startWith(value);
}
/// -----------------------------------------------
/// [Pages] ---------------------------------------
/// -----------------------------------------------
@ -146,33 +155,42 @@ class DocumentViewerScreen extends StatefulScreen {
}
class _DocumentViewerScreenState extends ScreenState<DocumentViewerScreen> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
final String title = widget.doc.$1.description;
final theme = FlutterFlowTheme.of(context);
final locale = FFLocalizations.of(context);
final Color color = widget.doc.$1.category.color;
;
backAction() => widget.bloc.events.unselectDocument();
infoAction() => DetailsComponentWidget(
buttons: [],
statusHashMap: [],
statusHashMap: [
Map<String, Color>.from({
widget.doc.$1.description: widget.doc.$1.category.color,
})
],
labelsHashMap: Map<String, String>.from({
locale.getVariableText(
enText: 'Description',
ptText: 'Descrição',
): widget.doc.$1.description,
locale.getVariableText(
enText: 'Type',
ptText: 'Tipo',
): widget.doc.$1.type,
locale.getVariableText(
enText: 'Category',
ptText: 'Categoria',
): widget.doc.$1.category.title,
if (widget.doc.$1.person.isNotEmpty)
locale.getVariableText(
enText: 'Person',
ptText: 'Pessoa',
): widget.doc.$1.person,
if (widget.doc.$1.property.isNotEmpty)
locale.getVariableText(
enText: 'Property',
ptText: 'Propriedade',
@ -180,11 +198,13 @@ class _DocumentViewerScreenState extends ScreenState<DocumentViewerScreen> {
locale.getVariableText(
enText: 'Created At',
ptText: 'Criado em',
): widget.doc.$1.createdAt,
): ValidatorUtil.toLocalDateTime(
'yyyy-MM-dd', widget.doc.$1.createdAt),
locale.getVariableText(
enText: 'Updated At',
ptText: 'Atualizado em',
): widget.doc.$1.updatedAt,
): ValidatorUtil.toLocalDateTime(
'yyyy-MM-dd', widget.doc.$1.updatedAt),
}),
);
@ -200,10 +220,7 @@ class _DocumentViewerScreenState extends ScreenState<DocumentViewerScreen> {
}
Widget buildBody(BuildContext context) {
// final PDFViewerKey _viewerKey = PDFViewerKey();
return ReadView(
// search: _viewerKey,
title: widget.doc.$1.description,
url: widget.doc.$2.toString(),
);
@ -256,7 +273,7 @@ class DocumentModel extends FlutterFlowModel<DocumentPage> {
BuildContext context, T item, int index) {
log('ItemBuilder -> $index');
return DocumentItem(
return DocumentComponent(
document: item,
onPressed: onView,
);
@ -311,8 +328,8 @@ class DocumentModel extends FlutterFlowModel<DocumentPage> {
/// [Footer]
CategoryItem categoryItemBuilder<T>(T? item) {
return CategoryItem(category: item! as Category);
CategoryComponent categoryItemBuilder<T>(T? item) {
return CategoryComponent(category: item! as Category);
}
Widget itemFooterBuilder<T>(Future<List<T?>> Function() gen) =>
@ -479,11 +496,6 @@ class DocumentModel extends FlutterFlowModel<DocumentPage> {
/// [BLoCs] ---------------------------------------
/// -----------------------------------------------
extension RxdartStartWithExtension<T> on Stream<T?> {
Stream<T?> rxdartStartWith(T? value) =>
rx.StartWithExtension(this).startWith(value);
}
abstract class DocumentPageBlocEvents {
void selectDocument(Document document);
void unselectDocument();
@ -589,11 +601,11 @@ interface class Category extends Archive {
/// -----------------------------------------------
// ignore: must_be_immutable
class DocumentItem extends StatelessComponent {
class DocumentComponent extends StatelessComponent {
final Document document;
void Function(Document, BuildContext) onPressed;
DocumentItem({
DocumentComponent({
super.key,
required this.document,
required this.onPressed,
@ -721,20 +733,20 @@ class DocumentItem extends StatelessComponent {
);
}
DocumentItem copyWith({
DocumentComponent copyWith({
Document? document,
}) {
return DocumentItem(
return DocumentComponent(
document: document ?? this.document,
onPressed: onPressed,
);
}
}
class CategoryItem extends StatelessComponent {
class CategoryComponent extends StatelessComponent {
final Category category;
const CategoryItem({
const CategoryComponent({
super.key,
required this.category,
});

View File

@ -38,7 +38,7 @@ mixin Template {
if (action == null) return [];
return [
IconButton(
onPressed: () async => await showDialog(
onPressed: () async => await showModalBottomSheet(
context: context,
builder: (context) => action(),
),

View File

@ -1,6 +1,8 @@
part of 'widgets.dart';
// typedef PDFViewerKey = GlobalKey<SfPdfViewerState>;
typedef ReadViewController = PdfController;
typedef Document = PdfDocument;
abstract interface class Viewer extends StatelessComponent {
final String src;
@ -33,12 +35,10 @@ class ReadView extends StatefulWidget {
}
class ReadViewState extends State<ReadView> {
late PdfController _pdfController;
Future<PdfController> _initializePdf() async {
Future<ReadViewController> _initializePdf() async {
final file = await downloadPdf(widget.url);
final Future<PdfDocument> document = PdfDocument.openFile(file.path);
return PdfController(document: document);
final Future<Document> document = Document.openFile(file.path);
return ReadViewController(document: document);
}
Future<File> downloadPdf(String url) async {
@ -106,11 +106,10 @@ class ReadViewState extends State<ReadView> {
Widget _buildPDFViewer() => Padding(
padding: EdgeInsets.all(10),
child: FutureBuilder<PdfController>(
child: FutureBuilder<ReadViewController>(
future: _initializePdf(),
builder: (context, snapshot) {
if (!snapshot.hasData) return buildLoadingIndicator(context);
return PdfView(
controller: snapshot.data!,
renderer: (PdfPage page) => page.render(
@ -120,7 +119,6 @@ class ReadViewState extends State<ReadView> {
10.0, 10.0, page.width * 2, page.height * 2),
forPrint: false,
quality: 100,
removeTempFile: true,
format: PdfPageImageFormat.jpeg,
backgroundColor: '#ffffff',
),
@ -130,10 +128,4 @@ class ReadViewState extends State<ReadView> {
);
// Widget get progressIndicator => LoadingUtil.buildLoadingIndicator(context);
@override
void dispose() {
_pdfController.dispose();
super.dispose();
}
}