import 'package:easy_debounce/easy_debounce.dart'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:hub/components/atomic_components/shared_components_atoms/tabview.dart'; import 'package:hub/flutter_flow/flutter_flow_icon_button.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/flutter_flow_widgets.dart'; import 'package:hub/flutter_flow/internationalization.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/flutter_flow/upload_data.dart'; import 'package:hub/pages/pets_page/pets_page_model.dart'; class PetsPageWidget extends StatefulWidget { PetsPageWidget({super.key}); @override State createState() => _PetsPageWidgetState(); } class _PetsPageWidgetState extends State with SingleTickerProviderStateMixin { late PetsPageModel _model; @override void initState() { super.initState(); _model = PetsPageModel(); _model.tabBarController = TabController(length: 2, vsync: this); } @override void dispose() { _model.tabBarController.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( appBar: appBarPets(context), body: tabViewPets(context, _model, _model.tabBarController)); } } PreferredSizeWidget appBarPets(BuildContext context) { return AppBar( backgroundColor: FlutterFlowTheme.of(context).primaryBackground, automaticallyImplyLeading: false, forceMaterialTransparency: true, elevation: 0.0, leading: FlutterFlowIconButton( borderColor: Colors.transparent, borderRadius: 30.0, borderWidth: 1.0, buttonSize: 60.0, icon: Icon( Icons.keyboard_arrow_left, color: FlutterFlowTheme.of(context).primaryText, size: 30.0, ), onPressed: () async { context.pop(); }, ), title: Text( FFLocalizations.of(context) .getVariableText(ptText: 'Pets', enText: 'Pets'), style: FlutterFlowTheme.of(context).headlineMedium.override( fontFamily: 'Nunito', color: FlutterFlowTheme.of(context).primaryText, fontSize: 15.0, letterSpacing: 0.0, fontWeight: FontWeight.bold, useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'), ), ), actions: const [], centerTitle: true, ); } Widget tabViewPets(BuildContext context, PetsPageModel _model, controller) { return TabViewUtil( context: context, model: _model, labelTab1: 'Cadastrar', labelTab2: 'Consultar', controller: controller, widget1: formAddPets(context), widget2: Center(child: Text('Consultar')), ); } Widget formAddPets(BuildContext context) { return SingleChildScrollView( child: Column( mainAxisSize: MainAxisSize.max, children: [ Form( autovalidateMode: AutovalidateMode.onUserInteraction, child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Padding( padding: const EdgeInsetsDirectional.fromSTEB( 24.0, 0.0, 24.0, 0.0), child: Builder( builder: (context) { if ((_model.uploadedLocalFile.bytes?.isNotEmpty ?? false)) { return InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, hoverColor: Colors.transparent, highlightColor: Colors.transparent, onTap: () async { setState(() { _model.isDataUploading = false; _model.uploadedLocalFile = FFUploadedFile( bytes: Uint8List.fromList([])); }); }, child: ClipRRect( borderRadius: BorderRadius.circular(8.0), child: Image.memory( _model.uploadedLocalFile.bytes ?? Uint8List.fromList([]), width: 300.0, height: 200.0, fit: BoxFit.cover, ), ), ); } else { return Stack( children: [ Align( alignment: const AlignmentDirectional(0.0, 0.0), child: FFButtonWidget( onPressed: () async { final selectedMedia = await selectMediaWithSourceBottomSheet( context: context, // maxWidth: 300.00, // maxHeight: 300.00, imageQuality: 100, allowPhoto: true, includeDimensions: true, ); if (selectedMedia != null) { // && // selectedMedia.every((m) => // validateFileFormat( // m.storagePath, context))) { setState( () => _model.isDataUploading = true); var selectedUploadedFiles = []; try { showUploadMessage( context, 'Uploading file...', showLoading: true, ); selectedUploadedFiles = selectedMedia .map((m) => FFUploadedFile( name: m.storagePath .split('/') .last, bytes: m.bytes, height: m.dimensions?.height, width: m.dimensions?.width, // blurHash: m.blurHash, )) .toList(); } finally { ScaffoldMessenger.of(context) .hideCurrentSnackBar(); _model.isDataUploading = false; } if (selectedUploadedFiles.length == selectedMedia.length) { setState(() { _model.uploadedLocalFile = selectedUploadedFiles.first; }); showUploadMessage(context, 'Success!'); } else { setState(() {}); showUploadMessage( context, 'Failed to upload data'); return; } } }, text: '', icon: Icon( Icons.photo_camera, color: FlutterFlowTheme.of(context).accent1, size: 30.0, ), options: FFButtonOptions( width: double.infinity, height: 120.0, padding: const EdgeInsetsDirectional.fromSTEB( 0.0, 0.0, 0.0, 20.0), iconPadding: const EdgeInsetsDirectional.fromSTEB( 14.0, 0.0, 0.0, 20.0), color: FlutterFlowTheme.of(context) .primaryBackground, textStyle: FlutterFlowTheme.of(context) .titleSmall .override( fontFamily: FlutterFlowTheme.of(context) .titleSmallFamily, color: FlutterFlowTheme.of(context) .primaryText, fontSize: 16.0, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() .containsKey( FlutterFlowTheme.of(context) .titleSmallFamily), ), borderSide: BorderSide( color: FlutterFlowTheme.of(context).accent1, width: 0.2, ), borderRadius: BorderRadius.circular(8.0), ), ), ), Align( alignment: const AlignmentDirectional(0.0, 0.0), child: Padding( padding: const EdgeInsetsDirectional.fromSTEB( 10.0, 65.0, 10.0, 0.0), child: Text( FFLocalizations.of(context).getText( 'p4ftwxcy' /* Clique para adicionar a foto p... */, ), 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), ), ), ), ), ], ); } }, ), ), Padding( padding: const EdgeInsetsDirectional.fromSTEB( 24.0, 0.0, 24.0, 0.0), child: TextFormField( // controller: _model.textController1, autovalidateMode: AutovalidateMode.onUserInteraction, // focusNode: _model.textFieldFocusNode1, // onChanged: (_) => EasyDebounce.debounce( // '_model.textFieldFocusNode1', // const Duration(milliseconds: 500), // () => setState(() {}), // ), autofocus: false, textInputAction: TextInputAction.next, obscureText: false, decoration: InputDecoration( isDense: true, labelText: FFLocalizations.of(context).getText( 'v7g73yik' /* Nome */, ), 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( borderSide: BorderSide( color: FlutterFlowTheme.of(context).customColor6, width: 0.5, ), borderRadius: BorderRadius.circular(10.0), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide( color: FlutterFlowTheme.of(context).primary, width: 0.5, ), borderRadius: BorderRadius.circular(10.0), ), errorBorder: OutlineInputBorder( borderSide: BorderSide( color: FlutterFlowTheme.of(context).error, width: 0.5, ), borderRadius: BorderRadius.circular(10.0), ), focusedErrorBorder: OutlineInputBorder( borderSide: BorderSide( color: FlutterFlowTheme.of(context).error, width: 0.5, ), borderRadius: BorderRadius.circular(10.0), ), suffixIcon: Icon( Icons.person, color: FlutterFlowTheme.of(context).accent1, ), ), 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), ), maxLines: null, maxLength: 80, keyboardType: TextInputType.name, inputFormatters: [LengthLimitingTextInputFormatter(80)], // validator: // _model.textController1Validator.asValidator(context), ), ), ])), ], ), ); }