import 'package:hub/commons/actions/api_calls.dart'; import 'package:hub/commons/components/templates/exception/widget.dart'; import 'package:hub/modals/selection/bottom_arrow_linked_locals/widget.dart'; import '/commons/widgets/flutter_flow_icon_button.dart'; import '/commons/widgets/flutter_flow_theme.dart'; import '/commons/widgets/flutter_flow_util.dart'; import '/commons/widgets/flutter_flow_widgets.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import 'model.dart'; export 'model.dart'; class ScheduleProvisionalVisitPageWidget extends StatefulWidget { const ScheduleProvisionalVisitPageWidget({super.key}); @override State createState() => _ScheduleProvisionalVisitPageWidgetState(); } class _ScheduleProvisionalVisitPageWidgetState extends State { late ScheduleProvisionalVisitPageModel _model; final scaffoldKey = GlobalKey(); @override void initState() { super.initState(); _model = createModel(context, () => ScheduleProvisionalVisitPageModel()); _model.textController1 ??= TextEditingController(); _model.textFieldFocusNode1 ??= FocusNode(); _model.textController2 ??= TextEditingController(); _model.textFieldFocusNode2 ??= FocusNode(); _model.textController3 ??= TextEditingController(); _model.textFieldFocusNode3 ??= FocusNode(); } @override void dispose() { _model.dispose(); super.dispose(); } @override Widget build(BuildContext context) { context.watch(); return GestureDetector( onTap: () => _model.unfocusNode.canRequestFocus ? FocusScope.of(context).requestFocus(_model.unfocusNode) : FocusScope.of(context).unfocus(), child: Scaffold( key: scaffoldKey, backgroundColor: FlutterFlowTheme.of(context).primaryBackground, appBar: AppBar( automaticallyImplyLeading: false, forceMaterialTransparency: true, 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).getText( 'cifgwfxs' /* Agendamento Provisório */, ), style: FlutterFlowTheme.of(context).headlineMedium.override( fontFamily: 'Nunito', color: FlutterFlowTheme.of(context).primaryText, fontSize: 16.0, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'), ), ), actions: const [], centerTitle: true, elevation: 0.0, ), body: SingleChildScrollView( child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.start, children: [ Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( decoration: const BoxDecoration(), child: SingleChildScrollView( child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Column( mainAxisSize: MainAxisSize.max, children: [ Align( alignment: const AlignmentDirectional(-1.0, 0.0), child: Padding( padding: const EdgeInsetsDirectional.fromSTEB( 20.0, 30.0, 0.0, 30.0), child: Text( FFLocalizations.of(context).getText( 'x7at46ur' /* Quais visitantes você deseja c... */, ), textAlign: TextAlign.start, style: FlutterFlowTheme.of(context) .bodyMedium .override( fontFamily: FlutterFlowTheme.of(context) .bodyMediumFamily, letterSpacing: 0.0, fontWeight: FontWeight.bold, useGoogleFonts: GoogleFonts.asMap() .containsKey( FlutterFlowTheme.of(context) .bodyMediumFamily), ), ), ), ), Stack( children: [ FFButtonWidget( onPressed: () async { await showModalBottomSheet( isScrollControlled: true, backgroundColor: Colors.transparent, enableDrag: false, context: context, builder: (context) { return GestureDetector( onTap: () => _model .unfocusNode.canRequestFocus ? FocusScope.of(context) .requestFocus( _model.unfocusNode) : FocusScope.of(context) .unfocus(), child: Padding( padding: MediaQuery.viewInsetsOf( context), child: const BottomArrowLinkedLocalsComponentWidget(), ), ); }, ).then((value) => safeSetState(() {})); }, text: FFAppState().local, options: FFButtonOptions( width: 320.0, height: 51.0, padding: const EdgeInsetsDirectional.fromSTEB( 24.0, 0.0, 24.0, 0.0), iconPadding: const EdgeInsetsDirectional.fromSTEB( 0.0, 0.0, 0.0, 0.0), color: FlutterFlowTheme.of(context) .primaryBackground, textStyle: FlutterFlowTheme.of(context) .titleSmall .override( fontFamily: FlutterFlowTheme.of(context) .titleSmallFamily, color: FlutterFlowTheme.of(context) .primaryText, fontSize: 14.0, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() .containsKey( FlutterFlowTheme.of(context) .titleSmallFamily), ), borderSide: BorderSide( color: FlutterFlowTheme.of(context) .primaryText, width: 0.3, ), borderRadius: BorderRadius.circular(24.0), ), ), Padding( padding: const EdgeInsetsDirectional.fromSTEB( 20.0, 10.0, 0.0, 0.0), child: Container( width: 35.0, height: 35.0, clipBehavior: Clip.antiAlias, decoration: const BoxDecoration( shape: BoxShape.circle, ), child: CachedNetworkImage( fadeInDuration: const Duration(milliseconds: 100), fadeOutDuration: const Duration(milliseconds: 100), imageUrl: valueOrDefault( 'https://freaccess.com.br/freaccess/Images/Clients/${FFAppState().cliUUID}.png', 'https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/flutter-freaccess-hub-0xgz9q/assets/7ftdetkzc3s0/360_F_64676383_LdbmhiNM6Ypzb3FM4PPuFP9rHe7ri8Ju.jpg', ), fit: BoxFit.cover, ), ), ), ], ), ].addToEnd(const SizedBox(height: 20.0)), ), Column( mainAxisSize: MainAxisSize.max, children: [ Align( alignment: const AlignmentDirectional(-1.0, 0.0), child: Padding( padding: const EdgeInsetsDirectional.fromSTEB( 20.0, 30.0, 0.0, 0.0), child: Text( FFLocalizations.of(context).getText( 'shj19b2o' /* Qual o período de validade da ... */, ), textAlign: TextAlign.start, style: FlutterFlowTheme.of(context) .bodyMedium .override( fontFamily: FlutterFlowTheme.of(context) .bodyMediumFamily, letterSpacing: 0.0, fontWeight: FontWeight.bold, useGoogleFonts: GoogleFonts.asMap() .containsKey( FlutterFlowTheme.of(context) .bodyMediumFamily), ), ), ), ), Stack( children: [ Padding( padding: const EdgeInsetsDirectional.fromSTEB( 24.0, 50.0, 24.0, 0.0), child: TextFormField( controller: _model.textController1, focusNode: _model.textFieldFocusNode1, autofocus: false, obscureText: false, decoration: InputDecoration( isDense: true, labelText: FFLocalizations.of(context).getText( '8zgsw5so' /* Ínicio da Visita */, ), 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), ), hintText: FFLocalizations.of(context).getText( 'p16wm7kp' /* Quando a visitas se inicia? */, ), 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) .accent1, width: 0.5, ), borderRadius: BorderRadius.circular(8.0), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide( color: FlutterFlowTheme.of(context) .primary, width: 0.5, ), borderRadius: BorderRadius.circular(8.0), ), errorBorder: OutlineInputBorder( borderSide: BorderSide( color: FlutterFlowTheme.of(context) .error, width: 0.5, ), borderRadius: BorderRadius.circular(8.0), ), focusedErrorBorder: OutlineInputBorder( borderSide: BorderSide( color: FlutterFlowTheme.of(context) .error, width: 0.5, ), borderRadius: BorderRadius.circular(8.0), ), suffixIcon: Icon( Icons.date_range, color: FlutterFlowTheme.of(context) .accent1, ), ), style: FlutterFlowTheme.of(context) .bodyMedium .override( fontFamily: FlutterFlowTheme.of(context) .bodyMediumFamily, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() .containsKey( FlutterFlowTheme.of(context) .bodyMediumFamily), ), textAlign: TextAlign.center, validator: _model.textController1Validator .asValidator(context), ), ), Padding( padding: const EdgeInsetsDirectional.fromSTEB( 24.0, 50.0, 24.0, 0.0), child: InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, hoverColor: Colors.transparent, highlightColor: Colors.transparent, onTap: () async { final datePickedDate = await showDatePicker( context: context, initialDate: getCurrentTimestamp, firstDate: DateTime(1900), lastDate: DateTime(2050), builder: (context, child) { return wrapInMaterialDatePickerTheme( context, child!, headerBackgroundColor: FlutterFlowTheme.of(context) .primary, headerForegroundColor: FlutterFlowTheme.of(context) .info, headerTextStyle: FlutterFlowTheme.of(context) .headlineLarge .override( fontFamily: FlutterFlowTheme.of( context) .headlineLargeFamily, fontSize: 32.0, letterSpacing: 0.0, fontWeight: FontWeight.w600, useGoogleFonts: GoogleFonts .asMap() .containsKey( FlutterFlowTheme.of( context) .headlineLargeFamily), ), pickerBackgroundColor: FlutterFlowTheme.of(context) .secondaryBackground, pickerForegroundColor: FlutterFlowTheme.of(context) .primaryText, selectedDateTimeBackgroundColor: FlutterFlowTheme.of(context) .primary, selectedDateTimeForegroundColor: FlutterFlowTheme.of(context) .info, actionButtonForegroundColor: FlutterFlowTheme.of(context) .primaryText, iconSize: 24.0, ); }, ); if (datePickedDate != null) { safeSetState(() { _model.datePicked = DateTime( datePickedDate.year, datePickedDate.month, datePickedDate.day, ); }); } setState(() { _model.textController1?.text = dateTimeFormat( 'd/M/y', _model.datePicked, locale: FFLocalizations.of(context) .languageCode, ); _model.textController1?.selection = TextSelection.collapsed( offset: _model .textController1! .text .length); }); }, child: Container( width: double.infinity, height: 50.0, decoration: BoxDecoration( borderRadius: BorderRadius.circular(8.0), ), ), ), ), ], ), ], ), Column( mainAxisSize: MainAxisSize.max, children: [ Align( alignment: const AlignmentDirectional(-1.0, 0.0), child: Padding( padding: const EdgeInsetsDirectional.fromSTEB( 20.0, 30.0, 0.0, 30.0), child: Text( FFLocalizations.of(context).getText( '3zfd7uf9' /* Qual o nome do visitante? */, ), textAlign: TextAlign.start, style: FlutterFlowTheme.of(context) .bodyMedium .override( fontFamily: FlutterFlowTheme.of(context) .bodyMediumFamily, letterSpacing: 0.0, fontWeight: FontWeight.bold, useGoogleFonts: GoogleFonts.asMap() .containsKey( FlutterFlowTheme.of(context) .bodyMediumFamily), ), ), ), ), Container( height: 93.0, decoration: const BoxDecoration(), alignment: const AlignmentDirectional(0.0, 0.0), child: Padding( padding: const EdgeInsetsDirectional.fromSTEB( 24.0, 0.0, 24.0, 20.0), child: SizedBox( width: double.infinity, child: TextFormField( controller: _model.textController2, focusNode: _model.textFieldFocusNode2, autofocus: false, textInputAction: TextInputAction.next, obscureText: false, decoration: InputDecoration( isDense: true, labelText: FFLocalizations.of(context).getText( 'wehvxbz4' /* Nome do Visitante */, ), 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), ), hintText: FFLocalizations.of(context).getText( 'juh7f24w' /* Escreva o nome do visitante aq... */, ), 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) .accent1, 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), ), textAlign: TextAlign.start, maxLines: null, validator: _model.textController2Validator .asValidator(context), ), ), ), ), ], ), Column( mainAxisSize: MainAxisSize.max, children: [ Align( alignment: const AlignmentDirectional(-1.0, 0.0), child: Padding( padding: const EdgeInsetsDirectional.fromSTEB( 20.0, 30.0, 0.0, 30.0), child: Text( FFLocalizations.of(context).getText( 'jhss056s' /* Você tem alguma observação sob... */, ), textAlign: TextAlign.start, style: FlutterFlowTheme.of(context) .bodyMedium .override( fontFamily: FlutterFlowTheme.of(context) .bodyMediumFamily, letterSpacing: 0.0, fontWeight: FontWeight.bold, useGoogleFonts: GoogleFonts.asMap() .containsKey( FlutterFlowTheme.of(context) .bodyMediumFamily), ), ), ), ), Padding( padding: const EdgeInsetsDirectional.fromSTEB( 24.0, 0.0, 24.0, 20.0), child: SizedBox( width: double.infinity, child: TextFormField( controller: _model.textController3, focusNode: _model.textFieldFocusNode3, autofocus: false, textInputAction: TextInputAction.next, obscureText: false, decoration: InputDecoration( isDense: true, labelText: FFLocalizations.of(context).getText( 'cw8b3tbb' /* Observações da Visita */, ), 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), ), hintText: FFLocalizations.of(context).getText( 'k4qkbv1f' /* Escreva as suas observações aq... */, ), 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) .accent1, 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.text_fields, 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), ), textAlign: TextAlign.start, maxLines: null, maxLength: 100, validator: _model.textController3Validator .asValidator(context), ), ), ), ], ), ], ), ), ), InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, hoverColor: Colors.transparent, highlightColor: Colors.transparent, onTap: () async { _model.provisionalVisitScheduling = await PhpGroup.postProvVisitSchedulingCall.call( devUUID: FFAppState().devUUID, userUUID: FFAppState().userUUID, cliID: FFAppState().cliUUID, atividade: 'putAgendamentoProv', data: _model.textController1.text, motivo: _model.textController3.text, nome: _model.textController2.text, proID: FFAppState().ownerUUID, ); if (PhpGroup.postProvVisitSchedulingCall.error( (_model.provisionalVisitScheduling?.jsonBody ?? ''), ) == false) { setState(() { _model.textController1?.clear(); _model.textController2?.clear(); _model.textController3?.clear(); }); } else { await showModalBottomSheet( isScrollControlled: true, backgroundColor: Colors.transparent, enableDrag: false, context: context, builder: (context) { return GestureDetector( onTap: () => _model.unfocusNode.canRequestFocus ? FocusScope.of(context) .requestFocus(_model.unfocusNode) : FocusScope.of(context).unfocus(), child: Padding( padding: MediaQuery.viewInsetsOf(context), child: ThrowExceptionWidget( msg: PhpGroup.postProvVisitSchedulingCall.msg( (_model.provisionalVisitScheduling ?.jsonBody ?? ''), )!, ), ), ); }, ).then((value) => safeSetState(() {})); } setState(() {}); }, child: Container( width: 100.0, height: 40.0, decoration: BoxDecoration( color: FlutterFlowTheme.of(context).primary, borderRadius: const BorderRadius.only( bottomLeft: Radius.circular(15.0), bottomRight: Radius.circular(15.0), topLeft: Radius.circular(15.0), topRight: Radius.circular(15.0), ), ), alignment: const AlignmentDirectional(0.0, 1.0), child: Align( alignment: const AlignmentDirectional(0.0, 0.0), child: Icon( Icons.save_alt, color: FlutterFlowTheme.of(context).info, size: 24.0, ), ), ), ), ], ), ] .addToStart(const SizedBox(height: 4.0)) .addToEnd(const SizedBox(height: 40.0)), ), ), ), ); } }