diff --git a/lib/features/documents/documents.dart b/lib/features/documents/documents.dart index c1983505..706e17df 100644 --- a/lib/features/documents/documents.dart +++ b/lib/features/documents/documents.dart @@ -68,7 +68,7 @@ class DocumentPageState extends PageState { Widget _buildDocumentViewScreen( AsyncSnapshot<(Document, Uri)?> snapshot, DocumentPageBlocType bloc) { if (snapshot.hasData) { - return DocumentViewScreen( + return DocumentViewerScreen( doc: snapshot.data!, bloc: bloc, ); @@ -83,7 +83,7 @@ class DocumentPageState extends PageState { /// ----------------------------------------------- class DocumentManagerScreen extends StatelessScreen { - final DocumentPageModel model; + final DocumentModel model; final DocumentPageState state; const DocumentManagerScreen({ @@ -130,8 +130,8 @@ class DocumentManagerScreen extends StatelessScreen { } } -class DocumentViewScreen extends StatefulScreen { - const DocumentViewScreen({ +class DocumentViewerScreen extends StatefulScreen { + const DocumentViewerScreen({ super.key, required this.doc, required this.bloc, @@ -141,10 +141,11 @@ class DocumentViewScreen extends StatefulScreen { final DocumentPageBlocType bloc; @override - ScreenState createState() => _DocumentViewScreenState(); + ScreenState createState() => + _DocumentViewerScreenState(); } -class _DocumentViewScreenState extends ScreenState { +class _DocumentViewerScreenState extends ScreenState { @override Widget build(BuildContext context) { final String title = widget.doc.$1.description; @@ -213,9 +214,9 @@ class _DocumentViewScreenState extends ScreenState { /// [Models] -------------------------------------- /// ----------------------------------------------- -class DocumentPageModel extends FlutterFlowModel { +class DocumentModel extends FlutterFlowModel { final DocumentPageBlocType bloc; - DocumentPageModel(this.bloc); + DocumentModel(this.bloc); late EnhancedListViewKey vehicleScreenManager; @@ -495,10 +496,10 @@ abstract class DocumentPageBlocStates { @RxBloc() class DocumentPageBloc extends $DocumentPageBloc { - late final DocumentPageModel model; + late final DocumentModel model; DocumentPageBloc(BuildContext context) { - model = DocumentPageModel(this); + model = DocumentModel(this); model.initState(context); } diff --git a/lib/shared/mixins/template_mixin.dart b/lib/shared/mixins/template_mixin.dart new file mode 100644 index 00000000..f3184e56 --- /dev/null +++ b/lib/shared/mixins/template_mixin.dart @@ -0,0 +1,70 @@ +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'package:hub/flutter_flow/index.dart'; +import 'package:material_symbols_icons/material_symbols_icons.dart'; + +mixin Template { + PreferredSizeWidget buildAppBar( + String title, + BuildContext context, [ + dynamic Function()? backAction, + dynamic Function()? frontAction, + ]) { + final theme = FlutterFlowTheme.of(context); + return AppBar( + backgroundColor: FlutterFlowTheme.of(context).primaryBackground, + automaticallyImplyLeading: false, + title: Text( + title, + style: FlutterFlowTheme.of(context).headlineMedium.override( + fontFamily: FlutterFlowTheme.of(context).headlineMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, + fontSize: 16.0, + fontWeight: FontWeight.bold, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap().containsKey( + FlutterFlowTheme.of(context).headlineMediumFamily), + ), + ), + leading: _backButton(context, theme, backAction), + centerTitle: true, + elevation: 0.0, + actions: _frontButton(context, theme, frontAction), + ); + } + + List _frontButton(BuildContext context, FlutterFlowTheme theme, + dynamic Function()? action) { + if (action == null) return []; + return [ + IconButton( + onPressed: () async => await showDialog( + context: context, + builder: (context) => action(), + ), + icon: Icon( + Symbols.info_i_rounded, + color: Colors.black, + ), + ) + ]; + } + + Widget? _backButton(BuildContext context, FlutterFlowTheme theme, + dynamic Function()? onPressed) { + if (onPressed == null) return null; + return FlutterFlowIconButton( + key: ValueKey('BackNavigationAppBar'), + borderColor: Colors.transparent, + borderRadius: 30.0, + borderWidth: 1.0, + buttonSize: 60.0, + icon: Icon( + Icons.keyboard_arrow_left, + color: theme.primaryText, + size: 30.0, + ), + onPressed: onPressed, + ); + } +} diff --git a/lib/shared/widgets/page.dart b/lib/shared/widgets/page.dart index 2acbca74..8fda7fad 100644 --- a/lib/shared/widgets/page.dart +++ b/lib/shared/widgets/page.dart @@ -1,71 +1,5 @@ part of 'widgets.dart'; -mixin Template { - PreferredSizeWidget buildAppBar( - String title, - BuildContext context, [ - dynamic Function()? backAction, - dynamic Function()? frontAction, - ]) { - final theme = FlutterFlowTheme.of(context); - return AppBar( - backgroundColor: FlutterFlowTheme.of(context).primaryBackground, - automaticallyImplyLeading: false, - title: Text( - title, - style: FlutterFlowTheme.of(context).headlineMedium.override( - fontFamily: FlutterFlowTheme.of(context).headlineMediumFamily, - color: FlutterFlowTheme.of(context).primaryText, - fontSize: 16.0, - fontWeight: FontWeight.bold, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).headlineMediumFamily), - ), - ), - leading: _backButton(context, theme, backAction), - centerTitle: true, - elevation: 0.0, - actions: _frontButton(context, theme, frontAction), - ); - } - - List _frontButton(BuildContext context, FlutterFlowTheme theme, - dynamic Function()? action) { - if (action == null) return []; - return [ - IconButton( - onPressed: () async => await showDialog( - context: context, - builder: (context) => action(), - ), - icon: Icon( - Symbols.info_i_rounded, - color: Colors.black, - ), - ) - ]; - } - - Widget? _backButton(BuildContext context, FlutterFlowTheme theme, - dynamic Function()? onPressed) { - if (onPressed == null) return null; - return FlutterFlowIconButton( - key: ValueKey('BackNavigationAppBar'), - borderColor: Colors.transparent, - borderRadius: 30.0, - borderWidth: 1.0, - buttonSize: 60.0, - icon: Icon( - Icons.keyboard_arrow_left, - color: theme.primaryText, - size: 30.0, - ), - onPressed: onPressed, - ); - } -} - /// [PageWidget] abstract class PageWidget extends Widget { diff --git a/lib/shared/widgets/widgets.dart b/lib/shared/widgets/widgets.dart index 05fb8a12..ae0c5ff7 100644 --- a/lib/shared/widgets/widgets.dart +++ b/lib/shared/widgets/widgets.dart @@ -3,11 +3,9 @@ import 'dart:io'; import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_pdfview/flutter_pdfview.dart'; -import 'package:google_fonts/google_fonts.dart'; import 'package:http/http.dart' as http; import 'package:hub/flutter_flow/index.dart'; -import 'package:material_symbols_icons/symbols.dart'; +import 'package:hub/shared/mixins/template_mixin.dart'; import 'package:path_provider/path_provider.dart'; import 'package:pdfx/pdfx.dart'; import 'package:share_plus/share_plus.dart';