import 'dart:collection'; import 'dart:developer'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:hub/components/templates_components/details_component/details_component_model.dart'; import 'package:hub/flutter_flow/flutter_flow_icon_button.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/internationalization.dart'; import 'package:provider/provider.dart'; class VisitRequestTemplateComponentWidget extends StatefulWidget { const VisitRequestTemplateComponentWidget({ Key? key, required this.labelsHashMap, required this.statusHashMap, required this.imageHashMap, this.onTapCardItemAction, required this.buttons, }); final Map labelsHashMap; final List?> statusHashMap; final Map imageHashMap; final Future Function()? onTapCardItemAction; final List buttons; // final Future Function( // BuildContext context, // int idDestino, // int idVisita, // String AccessKey, // )? changeStatusAction; @override State createState() => _VisitRequestTemplateComponentWidgetState(); } class _VisitRequestTemplateComponentWidgetState extends State { late VisitRequestTemplateComponentModel _model; LinkedHashMap get labelsLinkedHashMap => LinkedHashMap.from(widget.labelsHashMap ?? {}); List> get statusLinkedHashMap => widget.statusHashMap .map((map) => LinkedHashMap.from(map ?? {})) .toList(); @override void setState(VoidCallback callback) { super.setState(callback); _model.onUpdate(); } @override void initState() { super.initState(); _model = createModel(context, () => VisitRequestTemplateComponentModel()); _model.textFieldFocusNodeStatus ??= FocusNode(); } @override void dispose() { _model.maybeDispose(); super.dispose(); } @override Widget build(BuildContext context) { context.watch(); // bool isLoaded = false; // final pending = FFLocalizations.of(context).getVariableText( // enText: 'Pending', // ptText: 'Pendente', // ); // final active = FFLocalizations.of(context).getVariableText( // enText: 'Ativo', // ptText: 'Ativo', // ); // final canceled = FFLocalizations.of(context).getVariableText( // enText: 'Canceled', // ptText: 'Cancelado', // ); return LayoutBuilder( builder: (context, constraints) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 10.0), child: Container( width: constraints.maxWidth, decoration: BoxDecoration( color: FlutterFlowTheme.of(context).primaryBackground, borderRadius: const BorderRadius.all(Radius.circular(25.0)), ), child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.start, children: [ Container( width: 150.0, height: 150.0, clipBehavior: Clip.antiAlias, decoration: const BoxDecoration( shape: BoxShape.circle, ), child: CachedNetworkImage( fadeInDuration: const Duration(milliseconds: 100), fadeOutDuration: const Duration(milliseconds: 100), imageUrl: 'https://freaccess.com.br/freaccess/getImage.php?cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${widget.imageHashMap['key']}&tipo=${widget.imageHashMap['value']}', fit: BoxFit.cover, ), ), Row( children: statusLinkedHashMap.expand((linkedHashMap) { return linkedHashMap.entries .map((MapEntry item) { return Expanded( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 24.0), child: TextFormField( // controller: _model.textControllerStatus, // focusNode: _model.textFieldFocusNodeStatus, 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, color: FlutterFlowTheme.of(context).info, 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).info, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() .containsKey( FlutterFlowTheme.of(context) .labelMediumFamily), ), focusedBorder: InputBorder.none, errorBorder: InputBorder.none, focusedErrorBorder: InputBorder.none, suffixIcon: Icon( Icons.info, color: FlutterFlowTheme.of(context).accent1, ), ), 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), ), textAlign: TextAlign.start, maxLines: null, keyboardType: TextInputType.name, validator: _model.textController1Validator .asValidator(context), ), ), ); }).toList(); }).toList(), ), 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 Padding( padding: const EdgeInsets.symmetric( horizontal: 10.0, vertical: 3.0), child: 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, ), ), 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 ), ), ), ), ); }, ), if (widget.buttons.isNotEmpty) Padding( padding: const EdgeInsets.symmetric(horizontal: 10.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: widget.buttons, ), ), ] .divide(const SizedBox(height: 20.0)) .addToEnd(const SizedBox(height: 20.0)) .addToStart(const SizedBox(height: 20.0)), ), ), ); }, ); } }