305 lines
13 KiB
Dart
305 lines
13 KiB
Dart
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<String, String> labelsHashMap;
|
|
final List<Map<String, Color>?> statusHashMap;
|
|
final Map<String, String> imageHashMap;
|
|
final Future Function()? onTapCardItemAction;
|
|
final List<Widget> buttons;
|
|
|
|
// final Future Function(
|
|
// BuildContext context,
|
|
// int idDestino,
|
|
// int idVisita,
|
|
// String AccessKey,
|
|
// )? changeStatusAction;
|
|
|
|
@override
|
|
State<VisitRequestTemplateComponentWidget> createState() =>
|
|
_VisitRequestTemplateComponentWidgetState();
|
|
}
|
|
|
|
class _VisitRequestTemplateComponentWidgetState
|
|
extends State<VisitRequestTemplateComponentWidget> {
|
|
late VisitRequestTemplateComponentModel _model;
|
|
|
|
LinkedHashMap<String, String> get labelsLinkedHashMap =>
|
|
LinkedHashMap.from(widget.labelsHashMap ?? {});
|
|
|
|
List<LinkedHashMap<String, Color>> get statusLinkedHashMap =>
|
|
widget.statusHashMap
|
|
.map((map) => LinkedHashMap<String, Color>.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<FFAppState>();
|
|
|
|
// 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 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<String, Color> 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,
|
|
fontWeight: FontWeight.bold,
|
|
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).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),
|
|
),
|
|
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 Flexible(child: SizedBox(height: 20.0)))
|
|
.addToEnd(const Flexible(child: SizedBox(height: 20.0)))
|
|
.addToStart(const Flexible(child: SizedBox(height: 20.0))),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|