|
|
|
|
@ -1,19 +1,28 @@
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_svg/svg.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/localization/localization.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/asset_transfer_provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:test_sa/models/device/asset_transfer.dart';
|
|
|
|
|
import 'package:test_sa/views/app_style/colors.dart';
|
|
|
|
|
import 'package:test_sa/views/app_style/sizing.dart';
|
|
|
|
|
import 'package:test_sa/views/pages/device_transfer/update_device_transfer.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/buttons/app_back_button.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/buttons/app_small_button.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/loaders/app_loading.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/requests/info_row.dart';
|
|
|
|
|
|
|
|
|
|
import '../../../extensions/text_extensions.dart';
|
|
|
|
|
import '../../../models/enums/user_types.dart';
|
|
|
|
|
import '../../../new_views/app_style/app_color.dart';
|
|
|
|
|
import '../../../new_views/common_widgets/default_app_bar.dart';
|
|
|
|
|
import '../../widgets/requests/request_status.dart';
|
|
|
|
|
|
|
|
|
|
class DeviceTransferDetails extends StatefulWidget {
|
|
|
|
|
final AssetTransfer model;
|
|
|
|
|
@ -26,8 +35,6 @@ class DeviceTransferDetails extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
|
|
|
|
|
AssetTransfer _model;
|
|
|
|
|
bool _isSender = false;
|
|
|
|
|
bool _isReceiver = false;
|
|
|
|
|
UserProvider _userProvider;
|
|
|
|
|
bool _isLoading = false;
|
|
|
|
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
|
|
|
@ -46,6 +53,7 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: DefaultAppBar(title: context.translation.deviceTransferDetails),
|
|
|
|
|
key: _scaffoldKey,
|
|
|
|
|
body: SafeArea(
|
|
|
|
|
child: FutureBuilder(
|
|
|
|
|
@ -55,8 +63,6 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
|
|
|
|
|
return const ALoading();
|
|
|
|
|
} else {
|
|
|
|
|
_userProvider = Provider.of<UserProvider>(context);
|
|
|
|
|
// _isSender = _userProvider.user.userID == _model.sender?.userId;
|
|
|
|
|
// _isReceiver = _userProvider.user.userID == _model.receiver?.userId;
|
|
|
|
|
return Form(
|
|
|
|
|
key: _formKey,
|
|
|
|
|
child: LoadingManager(
|
|
|
|
|
@ -66,129 +72,74 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
|
|
|
|
|
onRefresh: () async {},
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
color: Theme.of(context).colorScheme.primary,
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
const ABackButton(),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Center(
|
|
|
|
|
child: Text(
|
|
|
|
|
context.translation.details,
|
|
|
|
|
style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontStyle: FontStyle.italic),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 58),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
padding: EdgeInsets.all(16 * AppStyle.getScaleFactor(context)),
|
|
|
|
|
child: Column(
|
|
|
|
|
_buildDetailsCard(
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: "Transfer Id",
|
|
|
|
|
info: "_model.title?.toString()",
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: context.translation.assetName,
|
|
|
|
|
info: "_model.device.assetName",
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: context.translation.assetSN,
|
|
|
|
|
info: "_model.device.serialNumber",
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: context.translation.assetNumber,
|
|
|
|
|
info: "_model.device.number",
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: context.translation.destinationSite,
|
|
|
|
|
info: "_model.device.destSiteName",
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: context.translation.building,
|
|
|
|
|
info: " _model.device.destBuildingName",
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: context.translation.floor,
|
|
|
|
|
info: "_model.device.destFloor",
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: context.translation.department,
|
|
|
|
|
info: "_model.device.destDepartmentName",
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: context.translation.room,
|
|
|
|
|
info: "_model.device.destRoom",
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: context.translation.actions,
|
|
|
|
|
info: "",
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Text("Sender", style: Theme.of(context).textTheme.headline6),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
/// TBD
|
|
|
|
|
StatusLabel(
|
|
|
|
|
label: "",
|
|
|
|
|
id: 0,
|
|
|
|
|
textColor: AColors.getPriorityStatusTextColor(0),
|
|
|
|
|
backgroundColor: AColors.getPriorityStatusColor(0)),
|
|
|
|
|
8.width,
|
|
|
|
|
/// TBD
|
|
|
|
|
StatusLabel(label: '', textColor: AColors.getRequestStatusTextColor(0), backgroundColor: AColors.getRequestStatusColor(0)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
if (_userProvider.user?.type == UsersTypes.engineer)
|
|
|
|
|
ASmallButton(
|
|
|
|
|
text: context.translation.edit,
|
|
|
|
|
// onPressed: (_isSender)
|
|
|
|
|
// ? (_model.sender.status?.name == "Closed"
|
|
|
|
|
// ? null
|
|
|
|
|
// : () {
|
|
|
|
|
// Navigator.of(context).push(MaterialPageRoute(
|
|
|
|
|
// builder: (_) => UpdateDeviceTransfer(
|
|
|
|
|
// model: _model,
|
|
|
|
|
// isSender: true,
|
|
|
|
|
// )));
|
|
|
|
|
// })
|
|
|
|
|
// : null,
|
|
|
|
|
),
|
|
|
|
|
1.width.expanded,
|
|
|
|
|
Text(widget.model.createdOn != null ?widget.model.createdOn.toServiceRequestCardFormat:"", textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: const Color(0xFF3B3D4A))),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
// DeviceTransferInfoSection(
|
|
|
|
|
// info: _model.sender,
|
|
|
|
|
// isSender: true,
|
|
|
|
|
// ),
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
Row(
|
|
|
|
|
8.height,
|
|
|
|
|
Text(context.translation.transferDetails, style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))),
|
|
|
|
|
8.height,
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Text("Receiver", style: Theme.of(context).textTheme.headline6),
|
|
|
|
|
),
|
|
|
|
|
if (_userProvider.user?.type == UsersTypes.engineer)
|
|
|
|
|
ASmallButton(
|
|
|
|
|
text: context.translation.edit,
|
|
|
|
|
// onPressed: (_isReceiver)
|
|
|
|
|
// ? (_model.receiver.status?.name == "Closed"
|
|
|
|
|
// ? null
|
|
|
|
|
// : () {
|
|
|
|
|
// Navigator.of(context).push(MaterialPageRoute(
|
|
|
|
|
// builder: (_) => UpdateDeviceTransfer(
|
|
|
|
|
// model: _model,
|
|
|
|
|
// isSender: false,
|
|
|
|
|
// )));
|
|
|
|
|
// })
|
|
|
|
|
// : null,
|
|
|
|
|
),
|
|
|
|
|
_buildTextWidget('${context.translation.assetName} : ${_model.assetName}'),
|
|
|
|
|
_buildTextWidget('${context.translation.assetNumber} : ${_model.assetNumber}'),
|
|
|
|
|
_buildTextWidget('${context.translation.model} : ${_model.modelName}'),
|
|
|
|
|
_buildTextWidget('${context.translation.sn} : ${_model.assetSerialNo}'),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
// DeviceTransferInfoSection(
|
|
|
|
|
// info: _model.receiver,
|
|
|
|
|
// isSender: false,
|
|
|
|
|
// ),
|
|
|
|
|
8.height,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
).paddingAll(14)
|
|
|
|
|
),
|
|
|
|
|
// sender card
|
|
|
|
|
_buildCard(
|
|
|
|
|
isSender: true,
|
|
|
|
|
site: _model.senderSiteName??"",
|
|
|
|
|
/// TBD
|
|
|
|
|
unit: _model.senderDepartmentName??"",
|
|
|
|
|
comment: _model.senderComment??"",
|
|
|
|
|
/// TBD
|
|
|
|
|
statusLabel: StatusLabel(
|
|
|
|
|
label: _model.senderMachineStatusName??"",
|
|
|
|
|
id: _model.senderMachineStatusId,
|
|
|
|
|
textColor: AColors.getRequestStatusTextColor(_model.senderMachineStatusId),
|
|
|
|
|
backgroundColor: AColors.getRequestStatusColor(_model.senderMachineStatusId)),
|
|
|
|
|
),
|
|
|
|
|
// receiver card
|
|
|
|
|
_buildCard(
|
|
|
|
|
isSender: false,
|
|
|
|
|
site: _model.destSiteName??"",
|
|
|
|
|
/// TBD
|
|
|
|
|
unit: _model.destDepartmentName??"",
|
|
|
|
|
comment: _model.receiverComment??"",
|
|
|
|
|
/// TBD
|
|
|
|
|
statusLabel: StatusLabel(
|
|
|
|
|
label: _model.receiverMachineStatusName??"",
|
|
|
|
|
id: _model.receiverMachineStatusId,
|
|
|
|
|
textColor: AColors.getRequestStatusTextColor(_model.receiverMachineStatusId),
|
|
|
|
|
backgroundColor: AColors.getRequestStatusColor(_model.receiverMachineStatusId)),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
@ -200,4 +151,93 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_buildDetailsCard(Widget widget){
|
|
|
|
|
return Container(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)),
|
|
|
|
|
),
|
|
|
|
|
child: widget,
|
|
|
|
|
).paddingOnly(top: 14, start: 14, end: 14);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_buildTextWidget(String text){
|
|
|
|
|
return Text(
|
|
|
|
|
text, style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_buildCard({@required String site, @required String unit, @required String comment, @required bool isSender, StatusLabel statusLabel}){
|
|
|
|
|
return Container(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)),
|
|
|
|
|
),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
statusLabel??Container(),
|
|
|
|
|
8.height,
|
|
|
|
|
Text(isSender?context.translation.senderDetails:context.translation.receiverDetails,
|
|
|
|
|
style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
if (_userProvider.user?.type == UsersTypes.engineer)
|
|
|
|
|
CircleAvatar(
|
|
|
|
|
radius: 25,
|
|
|
|
|
backgroundColor: AppColor.neutral30,
|
|
|
|
|
child: CircleAvatar(
|
|
|
|
|
radius: 24,
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.only(left: 3.0),
|
|
|
|
|
child: SvgPicture.asset('assets/images/update.svg'),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
).onPress(
|
|
|
|
|
isSender ? _model.senderMachineStatusName == "Closed"
|
|
|
|
|
? null
|
|
|
|
|
: () {
|
|
|
|
|
Navigator.of(context).push(MaterialPageRoute(
|
|
|
|
|
builder: (_) => UpdateDeviceTransfer(
|
|
|
|
|
model: _model,
|
|
|
|
|
isSender: isSender,
|
|
|
|
|
)));
|
|
|
|
|
}
|
|
|
|
|
: _model.receiverMachineStatusName == "Closed"
|
|
|
|
|
? null
|
|
|
|
|
: () {
|
|
|
|
|
Navigator.of(context).push(MaterialPageRoute(
|
|
|
|
|
builder: (_) => UpdateDeviceTransfer(
|
|
|
|
|
model: _model,
|
|
|
|
|
isSender: isSender,
|
|
|
|
|
)));
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
_buildTextWidget('${context.translation.site} : $site'),
|
|
|
|
|
_buildTextWidget('${context.translation.unite} : $unit'),
|
|
|
|
|
8.height,
|
|
|
|
|
const Divider(color: Color(0xFFEAF1F4), height: 1, thickness: 1),
|
|
|
|
|
8.height,
|
|
|
|
|
_buildTextWidget(comment),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
],
|
|
|
|
|
).paddingAll(14),
|
|
|
|
|
).paddingOnly(top: 14, start: 14, end: 14);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|