import 'package:flutter/material.dart'; import '../../../controllers/localization/localization.dart'; import '../../../models/device/device_transfer.dart'; import '../../../models/subtitle.dart'; import '../../app_style/colors.dart'; import '../../app_style/sizing.dart'; import '../requests/request_status.dart'; class DeviceTransferItem extends StatelessWidget { final int index; final DeviceTransfer item; final Function(DeviceTransfer)? onPressed; const DeviceTransferItem({Key? key, required this.item, this.onPressed, required this.index}) : super(key: key); @override Widget build(BuildContext context) { Subtitle? subtitle = AppLocalization.of(context)?.subtitle; Color itemColor = index % 2 == 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary; Color onItemColor = index % 2 != 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary; return Padding( padding: const EdgeInsets.symmetric(vertical: 4), child: ElevatedButton( style: ElevatedButton.styleFrom( padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8), backgroundColor: itemColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), ), ), //padding: EdgeInsets.symmetric(vertical: 8,horizontal: 8), onPressed: () { onPressed!(item); }, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( item.title ?? "-----", style: Theme.of(context).textTheme.titleLarge?.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold), ), Divider( color: onItemColor, ), Row( children: [ Expanded( child: Text( subtitle?.from ?? "", style: Theme.of(context).textTheme.titleSmall?.copyWith( color: onItemColor, ), ), ), StatusLabel( color: AColors.getRequestStatusColor(item.sender?.status?.id ?? 0), label: item.sender!.status!.label, ) ], ), //const SizedBox(height: 8,), Row( children: [ Expanded( child: Text( item.sender?.client?.name ?? "", style: Theme.of(context).textTheme.titleSmall?.copyWith( color: onItemColor, ), ), ), ], ), Text( item.sender?.department?.name ?? "", style: Theme.of(context).textTheme.bodySmall?.copyWith( color: onItemColor, ), ), Divider( color: onItemColor, ), Row( children: [ Expanded( child: Text( subtitle?.to ?? "", style: Theme.of(context).textTheme.titleSmall?.copyWith( color: onItemColor, ), ), ), StatusLabel( color: AColors.getRequestStatusColor(item.receiver?.status?.id ?? 0), label: item.receiver!.status!.label, ) ], ), //const SizedBox(height: 8,), Row( children: [ Expanded( child: Text( item.receiver?.client?.name ?? "", style: Theme.of(context).textTheme.titleSmall?.copyWith( color: onItemColor, ), ), ), ], ), Text( item.receiver?.department?.name ?? "", style: Theme.of(context).textTheme.bodySmall?.copyWith( color: onItemColor, ), ), //Divider(color: onItemColor,), ], ), ), ], ), ], ), ), ); } }