import 'package:flutter/material.dart'; import 'package:test_sa/controllers/api_routes/urls.dart'; import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/models/device/asset.dart'; class AssetItemListView extends StatelessWidget { final Asset device; final Function(Asset) onPressed; const AssetItemListView({Key key, this.device, this.onPressed}) : super(key: key); @override Widget build(BuildContext context) { return Container( padding: const EdgeInsets.all(16), decoration: ShapeDecoration( color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20), ), shadows: const [BoxShadow(color: Color(0x07000000), blurRadius: 14, offset: Offset(0, 0), spreadRadius: 0)], ), child: Row( children: [ Container( width: 95, height: 95, decoration: ShapeDecoration( color: const Color(0xFFEAF1F4), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), image: DecorationImage( fit: BoxFit.cover, image: NetworkImage(device.assetPhoto != null ? URLs.getFileUrl(device.assetPhoto) : "https://www.lasteelcraft.com/images/no-image-available.png"), )), ), 15.width, Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ Text( device.modelDefinition.assetName, maxLines: 2, style: AppTextStyles.heading5.copyWith(color: Color(0xFF3B3D4A)), ), Text( "${context.translation.assetNumber} : ${device.assetNumber}", style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)), ), Text( "${context.translation.model} : ${device.modelDefinition.modelDefCode}", style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)), ), ], ), Row( crossAxisAlignment: CrossAxisAlignment.end, children: [ Text( "${context.translation.serialNo} : ${device.assetSerialNo}", maxLines: 2, style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)), ).expanded, Row( mainAxisSize: MainAxisSize.min, children: [ Text( context.translation.viewDetails, style: AppTextStyles.bodyText.copyWith(color: const Color(0xFF4A8DB7)), ), 4.width, const Icon( Icons.arrow_forward, color: Color(0xFF4A8DB7), size: 14, ) ], ), ], ) ], ).expanded ], ), ).onPress(() => onPressed(device)); } }