You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
157 lines
6.4 KiB
Dart
157 lines
6.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:test_sa/controllers/localization/localization.dart';
|
|
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
import 'package:test_sa/models/device/device_transfer.dart';
|
|
import 'package:test_sa/models/subtitle.dart';
|
|
import 'package:test_sa/models/user.dart';
|
|
import 'package:test_sa/views/app_style/colors.dart';
|
|
import 'package:test_sa/views/app_style/sizing.dart';
|
|
import 'package:test_sa/views/widgets/requests/request_status.dart';
|
|
|
|
class DeviceTransferItem extends StatelessWidget {
|
|
final int index;
|
|
final DeviceTransfer item;
|
|
final Function(DeviceTransfer) onPressed;
|
|
|
|
const DeviceTransferItem({Key key, this.item, this.onPressed, this.index}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
User _user = Provider.of<UserProvider>(context, listen: false).user;
|
|
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: 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.headline6.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold),
|
|
),
|
|
Divider(
|
|
color: onItemColor,
|
|
),
|
|
Text(
|
|
item.device?.number ?? "-----",
|
|
style: Theme.of(context).textTheme.headline6.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold),
|
|
),
|
|
Divider(
|
|
color: onItemColor,
|
|
),
|
|
Text(
|
|
item.device.assetName ?? "",
|
|
style: Theme.of(context).textTheme.headline6.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold),
|
|
),
|
|
Divider(
|
|
color: onItemColor,
|
|
),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: Text(
|
|
context.translation.from,
|
|
style: Theme.of(context).textTheme.subtitle2.copyWith(
|
|
color: onItemColor,
|
|
),
|
|
),
|
|
),
|
|
StatusLabel(
|
|
backgroundColor: AColors.getRequestStatusColor(item.sender.status?.id),
|
|
label: item.sender.status?.name,
|
|
)
|
|
],
|
|
),
|
|
//const SizedBox(height: 8,),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: Text(
|
|
item.sender.client.name,
|
|
style: Theme.of(context).textTheme.subtitle2.copyWith(
|
|
color: onItemColor,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
if (item.sender.department.id != null)
|
|
Text(
|
|
item.sender.department.name,
|
|
style: Theme.of(context).textTheme.bodySmall.copyWith(
|
|
color: onItemColor,
|
|
),
|
|
),
|
|
Divider(
|
|
color: onItemColor,
|
|
),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: Text(
|
|
context.translation.to,
|
|
style: Theme.of(context).textTheme.subtitle2.copyWith(
|
|
color: onItemColor,
|
|
),
|
|
),
|
|
),
|
|
StatusLabel(
|
|
backgroundColor: AColors.getRequestStatusColor(item.receiver.status?.id),
|
|
label: item.receiver.status?.name,
|
|
)
|
|
],
|
|
),
|
|
//const SizedBox(height: 8,),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: Text(
|
|
item.receiver.client.name,
|
|
style: Theme.of(context).textTheme.subtitle2.copyWith(
|
|
color: onItemColor,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
if (item.receiver.department.id != null)
|
|
Text(
|
|
item.receiver.department.name,
|
|
style: Theme.of(context).textTheme.bodySmall.copyWith(
|
|
color: onItemColor,
|
|
),
|
|
),
|
|
//Divider(color: onItemColor,),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|