WIP
This commit is contained in:
parent
e1772649ec
commit
23a6b6d1d9
|
@ -64,7 +64,9 @@ class _DetailsComponentWidgetState extends State<DetailsComponentWidget> {
|
||||||
// CachedNetworkImage.evictFromCache(widget.imagePath ?? '');
|
// CachedNetworkImage.evictFromCache(widget.imagePath ?? '');
|
||||||
final double limitedBodyFontSize =
|
final double limitedBodyFontSize =
|
||||||
LimitedFontSizeUtil.getBodyFontSize(context);
|
LimitedFontSizeUtil.getBodyFontSize(context);
|
||||||
return Container(
|
return Material(
|
||||||
|
type: MaterialType.transparency,
|
||||||
|
child: Container(
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
maxWidth: MediaQuery.of(context).size.width,
|
maxWidth: MediaQuery.of(context).size.width,
|
||||||
maxHeight: MediaQuery.of(context).size.height,
|
maxHeight: MediaQuery.of(context).size.height,
|
||||||
|
@ -129,7 +131,8 @@ class _DetailsComponentWidgetState extends State<DetailsComponentWidget> {
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: FlutterFlowTheme.of(context).info,
|
color: FlutterFlowTheme.of(context).info,
|
||||||
letterSpacing: 0.0,
|
letterSpacing: 0.0,
|
||||||
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
useGoogleFonts:
|
||||||
|
GoogleFonts.asMap().containsKey(
|
||||||
FlutterFlowTheme.of(context)
|
FlutterFlowTheme.of(context)
|
||||||
.labelMediumFamily,
|
.labelMediumFamily,
|
||||||
),
|
),
|
||||||
|
@ -142,7 +145,8 @@ class _DetailsComponentWidgetState extends State<DetailsComponentWidget> {
|
||||||
.labelMediumFamily,
|
.labelMediumFamily,
|
||||||
color: FlutterFlowTheme.of(context).info,
|
color: FlutterFlowTheme.of(context).info,
|
||||||
letterSpacing: 0.0,
|
letterSpacing: 0.0,
|
||||||
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
useGoogleFonts:
|
||||||
|
GoogleFonts.asMap().containsKey(
|
||||||
FlutterFlowTheme.of(context)
|
FlutterFlowTheme.of(context)
|
||||||
.labelMediumFamily,
|
.labelMediumFamily,
|
||||||
),
|
),
|
||||||
|
@ -156,9 +160,11 @@ class _DetailsComponentWidgetState extends State<DetailsComponentWidget> {
|
||||||
color: FlutterFlowTheme.of(context).info,
|
color: FlutterFlowTheme.of(context).info,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
style: FlutterFlowTheme.of(context)
|
||||||
fontFamily:
|
.bodyMedium
|
||||||
FlutterFlowTheme.of(context).bodyMediumFamily,
|
.override(
|
||||||
|
fontFamily: FlutterFlowTheme.of(context)
|
||||||
|
.bodyMediumFamily,
|
||||||
color: FlutterFlowTheme.of(context).info,
|
color: FlutterFlowTheme.of(context).info,
|
||||||
letterSpacing: 0.0,
|
letterSpacing: 0.0,
|
||||||
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
||||||
|
@ -278,6 +284,7 @@ class _DetailsComponentWidgetState extends State<DetailsComponentWidget> {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,15 @@ part 'documents.rxb.g.dart';
|
||||||
|
|
||||||
typedef DocumentKey = GlobalKey<DocumentPageState>;
|
typedef DocumentKey = GlobalKey<DocumentPageState>;
|
||||||
|
|
||||||
|
/// -----------------------------------------------
|
||||||
|
/// [Extensions] ---------------------------------
|
||||||
|
/// -----------------------------------------------
|
||||||
|
|
||||||
|
extension ExplicitRxdartStartWithExtension<T> on Stream<T?> {
|
||||||
|
Stream<T?> rxdartStartWith(T? value) =>
|
||||||
|
rx.StartWithExtension(this).startWith(value);
|
||||||
|
}
|
||||||
|
|
||||||
/// -----------------------------------------------
|
/// -----------------------------------------------
|
||||||
/// [Pages] ---------------------------------------
|
/// [Pages] ---------------------------------------
|
||||||
/// -----------------------------------------------
|
/// -----------------------------------------------
|
||||||
|
@ -146,33 +155,42 @@ class DocumentViewerScreen extends StatefulScreen {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DocumentViewerScreenState extends ScreenState<DocumentViewerScreen> {
|
class _DocumentViewerScreenState extends ScreenState<DocumentViewerScreen> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final String title = widget.doc.$1.description;
|
final String title = widget.doc.$1.description;
|
||||||
final theme = FlutterFlowTheme.of(context);
|
final theme = FlutterFlowTheme.of(context);
|
||||||
final locale = FFLocalizations.of(context);
|
final locale = FFLocalizations.of(context);
|
||||||
|
final Color color = widget.doc.$1.category.color;
|
||||||
|
;
|
||||||
|
|
||||||
backAction() => widget.bloc.events.unselectDocument();
|
backAction() => widget.bloc.events.unselectDocument();
|
||||||
infoAction() => DetailsComponentWidget(
|
infoAction() => DetailsComponentWidget(
|
||||||
buttons: [],
|
buttons: [],
|
||||||
statusHashMap: [],
|
statusHashMap: [
|
||||||
|
Map<String, Color>.from({
|
||||||
|
widget.doc.$1.description: widget.doc.$1.category.color,
|
||||||
|
})
|
||||||
|
],
|
||||||
labelsHashMap: Map<String, String>.from({
|
labelsHashMap: Map<String, String>.from({
|
||||||
locale.getVariableText(
|
locale.getVariableText(
|
||||||
enText: 'Description',
|
enText: 'Description',
|
||||||
ptText: 'Descrição',
|
ptText: 'Descrição',
|
||||||
): widget.doc.$1.description,
|
): widget.doc.$1.description,
|
||||||
locale.getVariableText(
|
|
||||||
enText: 'Type',
|
|
||||||
ptText: 'Tipo',
|
|
||||||
): widget.doc.$1.type,
|
|
||||||
locale.getVariableText(
|
locale.getVariableText(
|
||||||
enText: 'Category',
|
enText: 'Category',
|
||||||
ptText: 'Categoria',
|
ptText: 'Categoria',
|
||||||
): widget.doc.$1.category.title,
|
): widget.doc.$1.category.title,
|
||||||
|
if (widget.doc.$1.person.isNotEmpty)
|
||||||
locale.getVariableText(
|
locale.getVariableText(
|
||||||
enText: 'Person',
|
enText: 'Person',
|
||||||
ptText: 'Pessoa',
|
ptText: 'Pessoa',
|
||||||
): widget.doc.$1.person,
|
): widget.doc.$1.person,
|
||||||
|
if (widget.doc.$1.property.isNotEmpty)
|
||||||
locale.getVariableText(
|
locale.getVariableText(
|
||||||
enText: 'Property',
|
enText: 'Property',
|
||||||
ptText: 'Propriedade',
|
ptText: 'Propriedade',
|
||||||
|
@ -180,11 +198,13 @@ class _DocumentViewerScreenState extends ScreenState<DocumentViewerScreen> {
|
||||||
locale.getVariableText(
|
locale.getVariableText(
|
||||||
enText: 'Created At',
|
enText: 'Created At',
|
||||||
ptText: 'Criado em',
|
ptText: 'Criado em',
|
||||||
): widget.doc.$1.createdAt,
|
): ValidatorUtil.toLocalDateTime(
|
||||||
|
'yyyy-MM-dd', widget.doc.$1.createdAt),
|
||||||
locale.getVariableText(
|
locale.getVariableText(
|
||||||
enText: 'Updated At',
|
enText: 'Updated At',
|
||||||
ptText: 'Atualizado em',
|
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) {
|
Widget buildBody(BuildContext context) {
|
||||||
// final PDFViewerKey _viewerKey = PDFViewerKey();
|
|
||||||
|
|
||||||
return ReadView(
|
return ReadView(
|
||||||
// search: _viewerKey,
|
|
||||||
title: widget.doc.$1.description,
|
title: widget.doc.$1.description,
|
||||||
url: widget.doc.$2.toString(),
|
url: widget.doc.$2.toString(),
|
||||||
);
|
);
|
||||||
|
@ -256,7 +273,7 @@ class DocumentModel extends FlutterFlowModel<DocumentPage> {
|
||||||
BuildContext context, T item, int index) {
|
BuildContext context, T item, int index) {
|
||||||
log('ItemBuilder -> $index');
|
log('ItemBuilder -> $index');
|
||||||
|
|
||||||
return DocumentItem(
|
return DocumentComponent(
|
||||||
document: item,
|
document: item,
|
||||||
onPressed: onView,
|
onPressed: onView,
|
||||||
);
|
);
|
||||||
|
@ -311,8 +328,8 @@ class DocumentModel extends FlutterFlowModel<DocumentPage> {
|
||||||
|
|
||||||
/// [Footer]
|
/// [Footer]
|
||||||
|
|
||||||
CategoryItem categoryItemBuilder<T>(T? item) {
|
CategoryComponent categoryItemBuilder<T>(T? item) {
|
||||||
return CategoryItem(category: item! as Category);
|
return CategoryComponent(category: item! as Category);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget itemFooterBuilder<T>(Future<List<T?>> Function() gen) =>
|
Widget itemFooterBuilder<T>(Future<List<T?>> Function() gen) =>
|
||||||
|
@ -479,11 +496,6 @@ class DocumentModel extends FlutterFlowModel<DocumentPage> {
|
||||||
/// [BLoCs] ---------------------------------------
|
/// [BLoCs] ---------------------------------------
|
||||||
/// -----------------------------------------------
|
/// -----------------------------------------------
|
||||||
|
|
||||||
extension RxdartStartWithExtension<T> on Stream<T?> {
|
|
||||||
Stream<T?> rxdartStartWith(T? value) =>
|
|
||||||
rx.StartWithExtension(this).startWith(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class DocumentPageBlocEvents {
|
abstract class DocumentPageBlocEvents {
|
||||||
void selectDocument(Document document);
|
void selectDocument(Document document);
|
||||||
void unselectDocument();
|
void unselectDocument();
|
||||||
|
@ -589,11 +601,11 @@ interface class Category extends Archive {
|
||||||
/// -----------------------------------------------
|
/// -----------------------------------------------
|
||||||
|
|
||||||
// ignore: must_be_immutable
|
// ignore: must_be_immutable
|
||||||
class DocumentItem extends StatelessComponent {
|
class DocumentComponent extends StatelessComponent {
|
||||||
final Document document;
|
final Document document;
|
||||||
void Function(Document, BuildContext) onPressed;
|
void Function(Document, BuildContext) onPressed;
|
||||||
|
|
||||||
DocumentItem({
|
DocumentComponent({
|
||||||
super.key,
|
super.key,
|
||||||
required this.document,
|
required this.document,
|
||||||
required this.onPressed,
|
required this.onPressed,
|
||||||
|
@ -721,20 +733,20 @@ class DocumentItem extends StatelessComponent {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
DocumentItem copyWith({
|
DocumentComponent copyWith({
|
||||||
Document? document,
|
Document? document,
|
||||||
}) {
|
}) {
|
||||||
return DocumentItem(
|
return DocumentComponent(
|
||||||
document: document ?? this.document,
|
document: document ?? this.document,
|
||||||
onPressed: onPressed,
|
onPressed: onPressed,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CategoryItem extends StatelessComponent {
|
class CategoryComponent extends StatelessComponent {
|
||||||
final Category category;
|
final Category category;
|
||||||
|
|
||||||
const CategoryItem({
|
const CategoryComponent({
|
||||||
super.key,
|
super.key,
|
||||||
required this.category,
|
required this.category,
|
||||||
});
|
});
|
||||||
|
|
|
@ -38,7 +38,7 @@ mixin Template {
|
||||||
if (action == null) return [];
|
if (action == null) return [];
|
||||||
return [
|
return [
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () async => await showDialog(
|
onPressed: () async => await showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => action(),
|
builder: (context) => action(),
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
part of 'widgets.dart';
|
part of 'widgets.dart';
|
||||||
|
|
||||||
// typedef PDFViewerKey = GlobalKey<SfPdfViewerState>;
|
// typedef PDFViewerKey = GlobalKey<SfPdfViewerState>;
|
||||||
|
typedef ReadViewController = PdfController;
|
||||||
|
typedef Document = PdfDocument;
|
||||||
|
|
||||||
abstract interface class Viewer extends StatelessComponent {
|
abstract interface class Viewer extends StatelessComponent {
|
||||||
final String src;
|
final String src;
|
||||||
|
@ -33,12 +35,10 @@ class ReadView extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ReadViewState extends State<ReadView> {
|
class ReadViewState extends State<ReadView> {
|
||||||
late PdfController _pdfController;
|
Future<ReadViewController> _initializePdf() async {
|
||||||
|
|
||||||
Future<PdfController> _initializePdf() async {
|
|
||||||
final file = await downloadPdf(widget.url);
|
final file = await downloadPdf(widget.url);
|
||||||
final Future<PdfDocument> document = PdfDocument.openFile(file.path);
|
final Future<Document> document = Document.openFile(file.path);
|
||||||
return PdfController(document: document);
|
return ReadViewController(document: document);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<File> downloadPdf(String url) async {
|
Future<File> downloadPdf(String url) async {
|
||||||
|
@ -106,11 +106,10 @@ class ReadViewState extends State<ReadView> {
|
||||||
|
|
||||||
Widget _buildPDFViewer() => Padding(
|
Widget _buildPDFViewer() => Padding(
|
||||||
padding: EdgeInsets.all(10),
|
padding: EdgeInsets.all(10),
|
||||||
child: FutureBuilder<PdfController>(
|
child: FutureBuilder<ReadViewController>(
|
||||||
future: _initializePdf(),
|
future: _initializePdf(),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (!snapshot.hasData) return buildLoadingIndicator(context);
|
if (!snapshot.hasData) return buildLoadingIndicator(context);
|
||||||
|
|
||||||
return PdfView(
|
return PdfView(
|
||||||
controller: snapshot.data!,
|
controller: snapshot.data!,
|
||||||
renderer: (PdfPage page) => page.render(
|
renderer: (PdfPage page) => page.render(
|
||||||
|
@ -120,7 +119,6 @@ class ReadViewState extends State<ReadView> {
|
||||||
10.0, 10.0, page.width * 2, page.height * 2),
|
10.0, 10.0, page.width * 2, page.height * 2),
|
||||||
forPrint: false,
|
forPrint: false,
|
||||||
quality: 100,
|
quality: 100,
|
||||||
removeTempFile: true,
|
|
||||||
format: PdfPageImageFormat.jpeg,
|
format: PdfPageImageFormat.jpeg,
|
||||||
backgroundColor: '#ffffff',
|
backgroundColor: '#ffffff',
|
||||||
),
|
),
|
||||||
|
@ -130,10 +128,4 @@ class ReadViewState extends State<ReadView> {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Widget get progressIndicator => LoadingUtil.buildLoadingIndicator(context);
|
// Widget get progressIndicator => LoadingUtil.buildLoadingIndicator(context);
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_pdfController.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue