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,218 +64,225 @@ 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(
constraints: BoxConstraints( type: MaterialType.transparency,
maxWidth: MediaQuery.of(context).size.width, child: Container(
maxHeight: MediaQuery.of(context).size.height, constraints: BoxConstraints(
), maxWidth: MediaQuery.of(context).size.width,
decoration: BoxDecoration( maxHeight: MediaQuery.of(context).size.height,
color: FlutterFlowTheme.of(context).primaryBackground, ),
borderRadius: const BorderRadius.all(Radius.circular(25.0)), decoration: BoxDecoration(
), color: FlutterFlowTheme.of(context).primaryBackground,
child: SingleChildScrollView( borderRadius: const BorderRadius.all(Radius.circular(25.0)),
child: Column( ),
mainAxisSize: MainAxisSize.max, child: SingleChildScrollView(
mainAxisAlignment: MainAxisAlignment.start, child: Column(
children: [ mainAxisSize: MainAxisSize.max,
SizedBox(height: MediaQuery.of(context).size.height * 0.02), mainAxisAlignment: MainAxisAlignment.start,
if (widget.imagePath != null && widget.imagePath != '') children: [
Container( SizedBox(height: MediaQuery.of(context).size.height * 0.02),
width: MediaQuery.of(context).size.width * 0.3, if (widget.imagePath != null && widget.imagePath != '')
height: MediaQuery.of(context).size.width * 0.3, Container(
clipBehavior: Clip.antiAlias, width: MediaQuery.of(context).size.width * 0.3,
decoration: const BoxDecoration( height: MediaQuery.of(context).size.width * 0.3,
shape: BoxShape.circle, clipBehavior: Clip.antiAlias,
decoration: const BoxDecoration(
shape: BoxShape.circle,
),
child: CachedNetworkImage(
fadeInDuration: const Duration(milliseconds: 100),
fadeOutDuration: const Duration(milliseconds: 100),
imageUrl: widget.imagePath!,
fit: BoxFit.cover,
useOldImageOnUrlChange: true,
),
), ),
child: CachedNetworkImage( SizedBox(height: MediaQuery.of(context).size.height * 0.03),
fadeInDuration: const Duration(milliseconds: 100), Row(
fadeOutDuration: const Duration(milliseconds: 100), children: statusLinkedHashMap.expand((linkedHashMap) {
imageUrl: widget.imagePath!, return linkedHashMap.entries
fit: BoxFit.cover, .map((MapEntry<String, Color> item) {
useOldImageOnUrlChange: true, return Expanded(
), child: Padding(
), padding: EdgeInsets.symmetric(
SizedBox(height: MediaQuery.of(context).size.height * 0.03), horizontal: MediaQuery.of(context).size.width * 0.05,
Row(
children: statusLinkedHashMap.expand((linkedHashMap) {
return linkedHashMap.entries
.map((MapEntry<String, Color> item) {
return Expanded(
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: MediaQuery.of(context).size.width * 0.05,
),
child: TextFormField(
autofocus: false,
canRequestFocus: false,
readOnly: true,
obscureText: false,
decoration: InputDecoration(
isDense: true,
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
borderSide: BorderSide(
color: item.value,
),
),
filled: true,
fillColor: item.value,
labelText: item.key,
labelStyle: FlutterFlowTheme.of(context)
.labelMedium
.override(
fontFamily: FlutterFlowTheme.of(context)
.labelMediumFamily,
fontWeight: FontWeight.bold,
color: FlutterFlowTheme.of(context).info,
letterSpacing: 0.0,
useGoogleFonts: GoogleFonts.asMap().containsKey(
FlutterFlowTheme.of(context)
.labelMediumFamily,
),
fontSize: limitedBodyFontSize,
),
hintStyle: FlutterFlowTheme.of(context)
.labelMedium
.override(
fontFamily: FlutterFlowTheme.of(context)
.labelMediumFamily,
color: FlutterFlowTheme.of(context).info,
letterSpacing: 0.0,
useGoogleFonts: GoogleFonts.asMap().containsKey(
FlutterFlowTheme.of(context)
.labelMediumFamily,
),
fontSize: limitedBodyFontSize,
),
focusedBorder: InputBorder.none,
errorBorder: InputBorder.none,
focusedErrorBorder: InputBorder.none,
suffixIcon: Icon(
Icons.info,
color: FlutterFlowTheme.of(context).info,
),
), ),
style: FlutterFlowTheme.of(context).bodyMedium.override( child: TextFormField(
fontFamily: autofocus: false,
FlutterFlowTheme.of(context).bodyMediumFamily, canRequestFocus: false,
color: FlutterFlowTheme.of(context).info, readOnly: true,
letterSpacing: 0.0, obscureText: false,
useGoogleFonts: GoogleFonts.asMap().containsKey( decoration: InputDecoration(
FlutterFlowTheme.of(context).bodyMediumFamily, isDense: true,
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
borderSide: BorderSide(
color: item.value,
), ),
fontSize: limitedBodyFontSize,
), ),
textAlign: TextAlign.center, filled: true,
maxLines: null, fillColor: item.value,
keyboardType: TextInputType.name, labelText: item.key,
validator: _model.textController1Validator labelStyle: FlutterFlowTheme.of(context)
.asValidator(context), .labelMedium
.override(
fontFamily: FlutterFlowTheme.of(context)
.labelMediumFamily,
fontWeight: FontWeight.bold,
color: FlutterFlowTheme.of(context).info,
letterSpacing: 0.0,
useGoogleFonts:
GoogleFonts.asMap().containsKey(
FlutterFlowTheme.of(context)
.labelMediumFamily,
),
fontSize: limitedBodyFontSize,
),
hintStyle: FlutterFlowTheme.of(context)
.labelMedium
.override(
fontFamily: FlutterFlowTheme.of(context)
.labelMediumFamily,
color: FlutterFlowTheme.of(context).info,
letterSpacing: 0.0,
useGoogleFonts:
GoogleFonts.asMap().containsKey(
FlutterFlowTheme.of(context)
.labelMediumFamily,
),
fontSize: limitedBodyFontSize,
),
focusedBorder: InputBorder.none,
errorBorder: InputBorder.none,
focusedErrorBorder: InputBorder.none,
suffixIcon: Icon(
Icons.info,
color: FlutterFlowTheme.of(context).info,
),
),
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily: FlutterFlowTheme.of(context)
.bodyMediumFamily,
color: FlutterFlowTheme.of(context).info,
letterSpacing: 0.0,
useGoogleFonts: GoogleFonts.asMap().containsKey(
FlutterFlowTheme.of(context).bodyMediumFamily,
),
fontSize: limitedBodyFontSize,
),
textAlign: TextAlign.center,
maxLines: null,
keyboardType: TextInputType.name,
validator: _model.textController1Validator
.asValidator(context),
),
),
);
}).toList();
}).toList(),
),
SizedBox(height: MediaQuery.of(context).size.height * 0.03),
ListView.builder(
shrinkWrap: true,
itemCount: labelsLinkedHashMap.length,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
String key = labelsLinkedHashMap.keys.elementAt(index);
String value = labelsLinkedHashMap[key]!;
// return Text('key: $key, value: $value');
return TextFormField(
readOnly: true,
initialValue: value,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily:
FlutterFlowTheme.of(context).bodyMediumFamily,
color: FlutterFlowTheme.of(context).primaryText,
letterSpacing: 0.0,
useGoogleFonts: GoogleFonts.asMap().containsKey(
FlutterFlowTheme.of(context).bodyMediumFamily,
),
fontSize: limitedBodyFontSize,
),
decoration: InputDecoration(
labelText: key,
filled: true,
fillColor: FlutterFlowTheme.of(context).primaryBackground,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
borderSide: BorderSide(
color: FlutterFlowTheme.of(context)
.primaryBackground, // Change border color here
),
),
labelStyle: FlutterFlowTheme.of(context)
.labelMedium
.override(
fontFamily:
FlutterFlowTheme.of(context).labelMediumFamily,
color: FlutterFlowTheme.of(context).primaryText,
letterSpacing: 0.0,
useGoogleFonts: GoogleFonts.asMap().containsKey(
FlutterFlowTheme.of(context).labelMediumFamily,
),
),
hintStyle: FlutterFlowTheme.of(context)
.labelMedium
.override(
fontFamily:
FlutterFlowTheme.of(context).labelMediumFamily,
color: FlutterFlowTheme.of(context).primaryText,
letterSpacing: 0.0,
useGoogleFonts: GoogleFonts.asMap().containsKey(
FlutterFlowTheme.of(context).labelMediumFamily,
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
borderSide: BorderSide(
color: FlutterFlowTheme.of(context)
.primaryBackground, // Change border color here
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
borderSide: BorderSide(
color: FlutterFlowTheme.of(context)
.primaryBackground, // Change border color here
),
),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
borderSide: BorderSide(
color: FlutterFlowTheme.of(context)
.primaryBackground, // Change border color here
),
),
focusedErrorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
borderSide: BorderSide(
color: FlutterFlowTheme.of(context)
.primaryBackground, // Change border color here
),
), ),
), ),
); );
}).toList(); },
}).toList(),
),
SizedBox(height: MediaQuery.of(context).size.height * 0.03),
ListView.builder(
shrinkWrap: true,
itemCount: labelsLinkedHashMap.length,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
String key = labelsLinkedHashMap.keys.elementAt(index);
String value = labelsLinkedHashMap[key]!;
// return Text('key: $key, value: $value');
return TextFormField(
readOnly: true,
initialValue: value,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily:
FlutterFlowTheme.of(context).bodyMediumFamily,
color: FlutterFlowTheme.of(context).primaryText,
letterSpacing: 0.0,
useGoogleFonts: GoogleFonts.asMap().containsKey(
FlutterFlowTheme.of(context).bodyMediumFamily,
),
fontSize: limitedBodyFontSize,
),
decoration: InputDecoration(
labelText: key,
filled: true,
fillColor: FlutterFlowTheme.of(context).primaryBackground,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
borderSide: BorderSide(
color: FlutterFlowTheme.of(context)
.primaryBackground, // Change border color here
),
),
labelStyle: FlutterFlowTheme.of(context)
.labelMedium
.override(
fontFamily:
FlutterFlowTheme.of(context).labelMediumFamily,
color: FlutterFlowTheme.of(context).primaryText,
letterSpacing: 0.0,
useGoogleFonts: GoogleFonts.asMap().containsKey(
FlutterFlowTheme.of(context).labelMediumFamily,
),
),
hintStyle: FlutterFlowTheme.of(context)
.labelMedium
.override(
fontFamily:
FlutterFlowTheme.of(context).labelMediumFamily,
color: FlutterFlowTheme.of(context).primaryText,
letterSpacing: 0.0,
useGoogleFonts: GoogleFonts.asMap().containsKey(
FlutterFlowTheme.of(context).labelMediumFamily,
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
borderSide: BorderSide(
color: FlutterFlowTheme.of(context)
.primaryBackground, // Change border color here
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
borderSide: BorderSide(
color: FlutterFlowTheme.of(context)
.primaryBackground, // Change border color here
),
),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
borderSide: BorderSide(
color: FlutterFlowTheme.of(context)
.primaryBackground, // Change border color here
),
),
focusedErrorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
borderSide: BorderSide(
color: FlutterFlowTheme.of(context)
.primaryBackground, // Change border color here
),
),
),
);
},
),
SizedBox(height: MediaQuery.of(context).size.height * 0.02),
if (widget.buttons!.isNotEmpty || widget.buttons != null)
OverflowBar(
overflowAlignment: OverflowBarAlignment.center,
alignment: MainAxisAlignment.center,
overflowSpacing: 2,
spacing: 2,
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: widget.buttons!,
), ),
SizedBox(height: MediaQuery.of(context).size.height * 0.02), SizedBox(height: MediaQuery.of(context).size.height * 0.02),
], if (widget.buttons!.isNotEmpty || widget.buttons != null)
OverflowBar(
overflowAlignment: OverflowBarAlignment.center,
alignment: MainAxisAlignment.center,
overflowSpacing: 2,
spacing: 2,
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: widget.buttons!,
),
SizedBox(height: MediaQuery.of(context).size.height * 0.02),
],
),
), ),
), ),
); );

View File

@ -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,45 +155,56 @@ 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,
locale.getVariableText( if (widget.doc.$1.person.isNotEmpty)
enText: 'Person', locale.getVariableText(
ptText: 'Pessoa', enText: 'Person',
): widget.doc.$1.person, ptText: 'Pessoa',
locale.getVariableText( ): widget.doc.$1.person,
enText: 'Property', if (widget.doc.$1.property.isNotEmpty)
ptText: 'Propriedade', locale.getVariableText(
): widget.doc.$1.property, enText: 'Property',
ptText: 'Propriedade',
): widget.doc.$1.property,
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,
}); });

View File

@ -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(),
), ),

View File

@ -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();
}
} }