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.
cloudsolutions-atoms/lib/views/widgets/gas_refill/gas_refill_item.dart

114 lines
5.1 KiB
Dart

3 years ago
import 'package:flutter/material.dart';
3 years ago
import 'package:test_sa/controllers/localization/localization.dart';
import 'package:test_sa/extensions/context_extension.dart';
3 years ago
import 'package:test_sa/models/gas_refill/gas_refill_model.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';
3 years ago
class GasRefillItem extends StatelessWidget {
final int index;
final GasRefillModel item;
final Function(GasRefillModel) onPressed;
2 years ago
3 years ago
const GasRefillItem({Key key, this.item, this.onPressed, this.index}) : super(key: key);
@override
Widget build(BuildContext context) {
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;
3 years ago
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)),
),
),
3 years ago
//padding: EdgeInsets.symmetric(vertical: 8,horizontal: 8),
onPressed: () {
3 years ago
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),
3 years ago
),
Row(
children: [
Expanded(
child: Text(
context.translation.hospital,
style: Theme.of(context).textTheme.titleSmall.copyWith(
color: onItemColor,
),
3 years ago
),
),
if (item.clientName != null)
Text(
item.clientName,
style: Theme.of(context).textTheme.titleSmall.copyWith(
color: onItemColor,
),
3 years ago
),
],
),
Divider(color: onItemColor),
3 years ago
Row(
children: [
Expanded(
child: Text(context.translation.status, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
3 years ago
),
if (item.status?.id != null) StatusLabel(label: item.status.name, backgroundColor: AColors.getGasStatusColor(item.status.id)),
3 years ago
],
),
if (item?.expectedDate != null) Divider(color: onItemColor),
if (item?.expectedDate != null)
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
2 years ago
Text("Expected Date", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
Text(item.expectedDate.toIso8601String().split("T").first, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
],
),
if (item?.details?.isNotEmpty ?? false) Divider(color: onItemColor),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (item?.details?.isNotEmpty ?? false) Text("Gas Type", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: item.details
.map(
(gas) => gas?.type?.name?.isNotEmpty ?? false
? Text(gas?.type?.name, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor))
: const SizedBox.shrink(),
)
.toList(),
)
],
),
3 years ago
],
),
),
],
),
],
),
),
);
}
}