add card_item_template_component
This commit is contained in:
parent
72237ae168
commit
9bb271f1a3
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,13 @@
|
||||||
|
import '/flutter_flow/flutter_flow_util.dart';
|
||||||
|
import 'card_item_template_component_widget.dart'
|
||||||
|
show CardItemTemplateComponentWidget;
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class CardItemTemplateComponentModel
|
||||||
|
extends FlutterFlowModel<CardItemTemplateComponentWidget> {
|
||||||
|
@override
|
||||||
|
void initState(BuildContext context) {}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {}
|
||||||
|
}
|
|
@ -0,0 +1,235 @@
|
||||||
|
import 'dart:collection';
|
||||||
|
|
||||||
|
import '/flutter_flow/flutter_flow_theme.dart';
|
||||||
|
import '/flutter_flow/flutter_flow_util.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 'card_item_template_component_model.dart';
|
||||||
|
export 'card_item_template_component_model.dart';
|
||||||
|
|
||||||
|
class CardItemTemplateComponentWidget extends StatefulWidget {
|
||||||
|
const CardItemTemplateComponentWidget({
|
||||||
|
super.key,
|
||||||
|
required this.labelsHashMap,
|
||||||
|
required this.statusHashMap,
|
||||||
|
required this.imageHashMap,
|
||||||
|
required this.onTapCardItemAction,
|
||||||
|
});
|
||||||
|
|
||||||
|
final Map<String, String>? labelsHashMap;
|
||||||
|
final Map<String, Color>? statusHashMap;
|
||||||
|
final Map<String, String> imageHashMap; //document/vteID and type
|
||||||
|
final Future Function()? onTapCardItemAction;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CardItemTemplateComponentWidget> createState() =>
|
||||||
|
_CardItemTemplateComponentWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CardItemTemplateComponentWidgetState
|
||||||
|
extends State<CardItemTemplateComponentWidget> {
|
||||||
|
late CardItemTemplateComponentModel _model;
|
||||||
|
LinkedHashMap<String, String> get labelsLinkedHashMap =>
|
||||||
|
LinkedHashMap.from(widget.labelsHashMap ?? {});
|
||||||
|
|
||||||
|
LinkedHashMap<String, Color> get statusLinkedHashMap =>
|
||||||
|
LinkedHashMap.from(widget.statusHashMap ?? {});
|
||||||
|
|
||||||
|
@override
|
||||||
|
void setState(VoidCallback callback) {
|
||||||
|
super.setState(callback);
|
||||||
|
_model.onUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_model = createModel(context, () => CardItemTemplateComponentModel());
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_model.maybeDispose();
|
||||||
|
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
Color _getColorForStatus(String status) {
|
||||||
|
if (status.length % 3 == 0) {
|
||||||
|
return FlutterFlowTheme.of(context).success;
|
||||||
|
} else if (status.length % 3 == 1) {
|
||||||
|
return FlutterFlowTheme.of(context).error;
|
||||||
|
} else {
|
||||||
|
return FlutterFlowTheme.of(context).primary;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
context.watch<FFAppState>();
|
||||||
|
|
||||||
|
return InkWell(
|
||||||
|
splashColor: Colors.transparent,
|
||||||
|
focusColor: Colors.transparent,
|
||||||
|
hoverColor: Colors.transparent,
|
||||||
|
highlightColor: Colors.transparent,
|
||||||
|
onTap: () async {
|
||||||
|
await widget.onTapCardItemAction?.call();
|
||||||
|
},
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
|
||||||
|
child: Card(
|
||||||
|
clipBehavior: Clip.antiAliasWithSaveLayer,
|
||||||
|
color: FlutterFlowTheme.of(context).secondaryBackground,
|
||||||
|
elevation: 5.0,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
|
),
|
||||||
|
child: Container(
|
||||||
|
width: 350.0,
|
||||||
|
height: 115.0,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: FlutterFlowTheme.of(context).secondaryBackground,
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
width: 100.0,
|
||||||
|
height: 100.0,
|
||||||
|
decoration: const BoxDecoration(),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: ListView.builder(
|
||||||
|
shrinkWrap: true,
|
||||||
|
itemCount: labelsLinkedHashMap.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
String key =
|
||||||
|
labelsLinkedHashMap.keys.elementAt(index);
|
||||||
|
String value = labelsLinkedHashMap[key]!;
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 5.0),
|
||||||
|
child: Padding(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.fromLTRB(20, 0, 0, 0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
key,
|
||||||
|
style: FlutterFlowTheme.of(context)
|
||||||
|
.bodyMedium
|
||||||
|
.override(
|
||||||
|
fontFamily:
|
||||||
|
FlutterFlowTheme.of(context)
|
||||||
|
.bodyMediumFamily,
|
||||||
|
fontSize: 12.5,
|
||||||
|
letterSpacing: 0.0,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
useGoogleFonts: GoogleFonts
|
||||||
|
.asMap()
|
||||||
|
.containsKey(
|
||||||
|
FlutterFlowTheme.of(
|
||||||
|
context)
|
||||||
|
.bodyMediumFamily),
|
||||||
|
color:
|
||||||
|
FlutterFlowTheme.of(context)
|
||||||
|
.primaryText,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width:
|
||||||
|
5.0), // Espaçamento entre o label e o valor
|
||||||
|
Text(
|
||||||
|
value,
|
||||||
|
style: FlutterFlowTheme.of(context)
|
||||||
|
.bodyMedium
|
||||||
|
.override(
|
||||||
|
fontFamily:
|
||||||
|
FlutterFlowTheme.of(context)
|
||||||
|
.bodyMediumFamily,
|
||||||
|
fontSize: 12.5,
|
||||||
|
letterSpacing: 0.0,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
useGoogleFonts: GoogleFonts
|
||||||
|
.asMap()
|
||||||
|
.containsKey(
|
||||||
|
FlutterFlowTheme.of(
|
||||||
|
context)
|
||||||
|
.bodyMediumFamily),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.symmetric(vertical: 3.0),
|
||||||
|
child: Container(
|
||||||
|
width: 200.0,
|
||||||
|
height: 27.0,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: statusLinkedHashMap.values.first,
|
||||||
|
borderRadius: BorderRadius.circular(5.0),
|
||||||
|
),
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: Text(
|
||||||
|
statusLinkedHashMap.keys
|
||||||
|
.first, // Acessa diretamente a chave como texto do status
|
||||||
|
style: TextStyle(
|
||||||
|
// Substitua por seu tema ou estilo de texto
|
||||||
|
color: FlutterFlowTheme.of(context)
|
||||||
|
.info, // Cor do texto, ajuste conforme necessário
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.fromSTEB(
|
||||||
|
10.0, 10.0, 10.0, 10.0),
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(22.0),
|
||||||
|
child: CachedNetworkImage(
|
||||||
|
fadeInDuration: const Duration(milliseconds: 500),
|
||||||
|
fadeOutDuration: const Duration(milliseconds: 500),
|
||||||
|
imageUrl: valueOrDefault<String>(
|
||||||
|
'https://freaccess.com.br/freaccess/getImage.php?devUUID=${FFAppState().devUUID}&userUUID=${FFAppState().userUUID}&cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${widget.imageHashMap['key']}&tipo=${widget.imageHashMap['value']}',
|
||||||
|
'https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/flutter-freaccess-hub-0xgz9q/assets/7ftdetkzc3s0/360_F_64676383_LdbmhiNM6Ypzb3FM4PPuFP9rHe7ri8Ju.jpg',
|
||||||
|
),
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ import 'dart:async';
|
||||||
|
|
||||||
import 'package:f_r_e_hub/pages/acess_history_page/acess_history_page_widget.dart';
|
import 'package:f_r_e_hub/pages/acess_history_page/acess_history_page_widget.dart';
|
||||||
import 'package:f_r_e_hub/pages/fast_pass_page/fast_pass_page_widget.dart';
|
import 'package:f_r_e_hub/pages/fast_pass_page/fast_pass_page_widget.dart';
|
||||||
|
import 'package:f_r_e_hub/pages/test_page/test_page.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
@ -64,7 +65,7 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) => GoRouter(
|
||||||
name: '_initialize',
|
name: '_initialize',
|
||||||
path: '/',
|
path: '/',
|
||||||
builder: (context, _) => FFAppState().isLogged
|
builder: (context, _) => FFAppState().isLogged
|
||||||
? const HomePageWidget()
|
? const TestPage()
|
||||||
: const WelcomePageWidget(),
|
: const WelcomePageWidget(),
|
||||||
),
|
),
|
||||||
FFRoute(
|
FFRoute(
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
import 'package:f_r_e_hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart';
|
||||||
|
import 'package:f_r_e_hub/flutter_flow/flutter_flow_theme.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class TestPage extends StatelessWidget {
|
||||||
|
const TestPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
// Exemplo de dados para os HashMaps
|
||||||
|
final Map<String, String> labelsHashMap = {
|
||||||
|
'Nome:': 'Gabriel da Silva',
|
||||||
|
'Entrada:': '08:00 AM 01/01/2022',
|
||||||
|
'Saída:': '17:00 PM 01/01/2022',
|
||||||
|
};
|
||||||
|
|
||||||
|
// Ajuste para o novo tipo esperado pelo componente
|
||||||
|
final Map<String, Color> statusHashMap = {
|
||||||
|
'Ativo': FlutterFlowTheme.of(context).success,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Ajuste para passar os valores corretos para a URL da imagem
|
||||||
|
final Map<String, String> imageKeyValue = {
|
||||||
|
'key': 'docID',
|
||||||
|
'value': 'imageType',
|
||||||
|
};
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Test Page'),
|
||||||
|
),
|
||||||
|
body: Center(
|
||||||
|
child: ListView.builder(
|
||||||
|
itemCount: 10,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return CardItemTemplateComponentWidget(
|
||||||
|
labelsHashMap: labelsHashMap,
|
||||||
|
statusHashMap: statusHashMap,
|
||||||
|
imageHashMap: imageKeyValue,
|
||||||
|
onTapCardItemAction: () async {
|
||||||
|
// Ação ao tocar no card
|
||||||
|
print('Card tapped');
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue