This commit is contained in:
jantunesmesias 2024-08-26 16:06:58 -03:00
parent ccba14c02d
commit ec6ad2db5c
3 changed files with 131 additions and 150 deletions

View File

@ -1,4 +0,0 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=https://www.google.com/
HostUrl=https://w7.pngwing.com/pngs/144/173/png-transparent-person-icon-illustration-computer-icons-icon-design-symbol-person-symbol-miscellaneous-monochrome-sticker.png

View File

@ -11,16 +11,14 @@ import 'card_item_template_component_model.dart';
export 'card_item_template_component_model.dart'; export 'card_item_template_component_model.dart';
///
class CardItemTemplateComponentWidget extends StatefulWidget { class CardItemTemplateComponentWidget extends StatefulWidget {
const CardItemTemplateComponentWidget({ const CardItemTemplateComponentWidget({
super.key, Key? key,
required this.labelsHashMap, required this.labelsHashMap,
required this.statusHashMap, required this.statusHashMap,
required this.imagePath, required this.imagePath,
required this.onTapCardItemAction, required this.onTapCardItemAction,
}); }) : super(key: key);
final Map<String, String>? labelsHashMap; final Map<String, String>? labelsHashMap;
final List<Map<String, Color>?> statusHashMap; final List<Map<String, Color>?> statusHashMap;
@ -35,23 +33,17 @@ class CardItemTemplateComponentWidget extends StatefulWidget {
class _CardItemTemplateComponentWidgetState class _CardItemTemplateComponentWidgetState
extends State<CardItemTemplateComponentWidget> { extends State<CardItemTemplateComponentWidget> {
late CardItemTemplateComponentModel _model; late CardItemTemplateComponentModel _model;
LinkedHashMap<String, String> get labelsLinkedHashMap => late LinkedHashMap<String, String> labelsLinkedHashMap;
LinkedHashMap.from(widget.labelsHashMap ?? {}); late List<LinkedHashMap<String, Color>> statusLinkedHashMap;
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 @override
void initState() { void initState() {
super.initState(); super.initState();
_model = createModel(context, () => CardItemTemplateComponentModel()); _model = createModel(context, () => CardItemTemplateComponentModel());
labelsLinkedHashMap = LinkedHashMap.from(widget.labelsHashMap ?? {});
statusLinkedHashMap = widget.statusHashMap
.map((map) => LinkedHashMap<String, Color>.from(map ?? {}))
.toList();
} }
@override @override
@ -65,147 +57,147 @@ class _CardItemTemplateComponentWidgetState
} }
List<Widget> _generateLabels() { List<Widget> _generateLabels() {
List<Widget> labels = []; return labelsLinkedHashMap.entries.map((entry) {
double width = MediaQuery.of(context).size.width; final key = entry.key;
final text = entry.value.toString();
for (var key in labelsLinkedHashMap.keys) { return Container(
String text = labelsLinkedHashMap[key].toString(); color: FlutterFlowTheme.of(context).primary,
child: Row(
Widget widget = Row( children: [
children: [ Text(
Text( key,
key,
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),
color: FlutterFlowTheme.of(context).primaryText,
),
),
const SizedBox(width: 2.5),
SizedBox(
width: 225,
child: Text(
text,
overflow: TextOverflow.ellipsis,
style: FlutterFlowTheme.of(context).bodyMedium.override( style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily,
fontSize: 12.5,
letterSpacing: 0.0, letterSpacing: 0.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
useGoogleFonts: GoogleFonts.asMap().containsKey( useGoogleFonts: GoogleFonts.asMap().containsKey(
FlutterFlowTheme.of(context).bodyMediumFamily), FlutterFlowTheme.of(context).bodyMediumFamily),
color: FlutterFlowTheme.of(context).primaryText,
), ),
), ),
) Expanded(
], child: Text(
text,
overflow: TextOverflow.ellipsis,
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),
),
),
)
].divide(const Flexible(child: SizedBox(width: 25))),
),
); );
}).toList();
labels.add(widget);
}
return labels;
} }
Widget _generateImage() { Widget _generateImage() {
return Container( return Flexible(
width: 100, child: SizedBox(
height: 100, width: 100,
decoration: BoxDecoration( height: 100,
color: FlutterFlowTheme.of(context).primaryBackground, child: ClipRRect(
), borderRadius: BorderRadius.circular(20),
child: ClipRRect( child: CachedNetworkImage(
borderRadius: BorderRadius.circular(20), fadeInDuration: const Duration(milliseconds: 500),
child: CachedNetworkImage( fadeOutDuration: const Duration(milliseconds: 500),
fadeInDuration: const Duration(milliseconds: 500), imageUrl: widget.imagePath ?? '',
fadeOutDuration: const Duration(milliseconds: 500), fit: BoxFit.cover,
imageUrl: widget.imagePath ?? '', ),
fit: BoxFit.cover,
), ),
), ),
); );
} }
List<Widget> _generateStatus() { List<Widget> _generateStatus() {
List<Widget> status = []; return statusLinkedHashMap.expand((statusLinked) {
return statusLinked.entries.map((entry) {
final text = entry.key;
final color = entry.value;
statusLinkedHashMap.expand((statusLinked) { return Container(
statusLinked.forEach((text, color) {
Widget widget = Container(
padding: const EdgeInsets.all(5), padding: const EdgeInsets.all(5),
decoration: BoxDecoration( decoration: BoxDecoration(
color: color, borderRadius: BorderRadius.circular(5)), color: color,
borderRadius: BorderRadius.circular(5),
),
child: Text( child: Text(
text, text,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
color: FlutterFlowTheme.of(context).info, color: FlutterFlowTheme.of(context).info,
fontSize: 12, fontSize: 12,
fontWeight: FontWeight.bold), fontWeight: FontWeight.bold,
),
), ),
); );
}).toList();
status.add(widget);
});
return [];
}).toList(); }).toList();
return status;
} }
Widget _smallScreen() { Widget _buildContent() {
return Column( final screenWidth = MediaQuery.of(context).size.width;
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
_generateImage(),
const SizedBox(height: 5),
Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
..._generateLabels(),
const SizedBox(height: 5),
Wrap(
spacing: 8,
runSpacing: 8,
children: _generateStatus(),
)
]),
],
);
}
Widget _largeScreen() { if (screenWidth > 360) {
return Row( return Row(
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Column( Expanded(
mainAxisSize: MainAxisSize.max, child: Container(
crossAxisAlignment: CrossAxisAlignment.start, color: FlutterFlowTheme.of(context).error,
children: [ child: Column(
..._generateLabels(), mainAxisSize: MainAxisSize.max,
const SizedBox(height: 5), crossAxisAlignment: CrossAxisAlignment.start,
Wrap( children: [
spacing: 8, ..._generateLabels(),
runSpacing: 8, const SizedBox(height: 5),
children: _generateStatus(), Wrap(
) spacing: 8,
]), runSpacing: 8,
_generateImage() children: _generateStatus(),
], ),
); ],
),
),
),
_generateImage(),
],
);
} else {
return Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
_generateImage(),
const SizedBox(height: 5),
Expanded(
child: Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
..._generateLabels(),
const SizedBox(height: 5),
Wrap(
spacing: 8,
runSpacing: 8,
children: _generateStatus(),
),
],
),
),
],
);
}
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
double screenWidth = MediaQuery.of(context).size.width;
double screenHeight = MediaQuery.of(context).size.height;
context.watch<AppState>(); context.watch<AppState>();
return InkWell( return InkWell(
@ -226,16 +218,10 @@ class _CardItemTemplateComponentWidgetState
child: Container( child: Container(
width: double.infinity, width: double.infinity,
decoration: BoxDecoration( decoration: BoxDecoration(
color: FlutterFlowTheme.of(context).primaryBackground, color: FlutterFlowTheme.of(context).warning,
), ),
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
child: Column( child: _buildContent(),
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
screenWidth > 360 ? _largeScreen() : _smallScreen(),
],
),
), ),
), ),
), ),

View File

@ -166,12 +166,24 @@ class _HomePageWidgetState extends State<HomePageWidget> {
color: Color(0xFF1AAB5F), color: Color(0xFF1AAB5F),
), ),
child: Align( child: Align(
alignment: AlignmentDirectional.bottomCenter, alignment: AlignmentDirectional.center,
child: Row( child: Row(
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
const SizedBox(), Padding(
padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0),
child: IconButton(
icon: const Icon(
Icons.menu_rounded,
color: Colors.white,
size: 28.0,
),
onPressed: () async {
scaffoldKey.currentState!.openEndDrawer();
},
),
),
Row( Row(
children: [ children: [
ClipRRect( ClipRRect(
@ -196,20 +208,7 @@ class _HomePageWidgetState extends State<HomePageWidget> {
), ),
], ],
), ),
Padding( const SizedBox(),
padding:
const EdgeInsetsDirectional.fromSTEB(10.0, 0.0, 0.0, 0.0),
child: IconButton(
icon: const Icon(
Icons.menu_rounded,
color: Colors.white,
size: 28.0,
),
onPressed: () async {
scaffoldKey.currentState!.openEndDrawer();
},
),
),
], ],
), ),
), ),