|
|
|
|
@ -3,9 +3,7 @@ import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/localization/localization.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/device_transfer_provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
|
|
|
|
import 'package:test_sa/models/device/device_transfer.dart';
|
|
|
|
|
import 'package:test_sa/models/device/device_transfer_info.dart';
|
|
|
|
|
import 'package:test_sa/models/subtitle.dart';
|
|
|
|
|
import 'package:test_sa/views/app_style/colors.dart';
|
|
|
|
|
import 'package:test_sa/views/app_style/sizing.dart';
|
|
|
|
|
@ -54,171 +52,152 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
|
|
|
|
|
key: _scaffoldKey,
|
|
|
|
|
body: SafeArea(
|
|
|
|
|
child: FutureBuilder(
|
|
|
|
|
future: _getDeviceTransfer(),
|
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
|
|
|
|
return const ALoading();
|
|
|
|
|
} else {
|
|
|
|
|
_subtitle = AppLocalization
|
|
|
|
|
.of(context)
|
|
|
|
|
.subtitle;
|
|
|
|
|
_userProvider = Provider.of<UserProvider>(context);
|
|
|
|
|
_settingProvider = Provider.of<SettingProvider>(context);
|
|
|
|
|
_deviceTransferProvider = Provider.of<DeviceTransferProvider>(context);
|
|
|
|
|
_isSender = _userProvider.user.userID == _model.sender?.userId;
|
|
|
|
|
_isReceiver = _userProvider.user.userID == _model.receiver?.userId;
|
|
|
|
|
return Form(
|
|
|
|
|
key: _formKey,
|
|
|
|
|
child: LoadingManager(
|
|
|
|
|
isLoading: _isLoading,
|
|
|
|
|
isFailedLoading: false,
|
|
|
|
|
stateCode: 200,
|
|
|
|
|
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(
|
|
|
|
|
_subtitle.details,
|
|
|
|
|
style: Theme
|
|
|
|
|
.of(context)
|
|
|
|
|
.textTheme
|
|
|
|
|
.headline6
|
|
|
|
|
.copyWith(color: AColors.white, fontStyle: FontStyle.italic),
|
|
|
|
|
),
|
|
|
|
|
future: _getDeviceTransfer(),
|
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
|
|
|
|
return const ALoading();
|
|
|
|
|
} else {
|
|
|
|
|
_subtitle = AppLocalization.of(context).subtitle;
|
|
|
|
|
_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(
|
|
|
|
|
isLoading: _isLoading,
|
|
|
|
|
isFailedLoading: false,
|
|
|
|
|
stateCode: 200,
|
|
|
|
|
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(
|
|
|
|
|
_subtitle.details,
|
|
|
|
|
style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontStyle: FontStyle.italic),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 58),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 58),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
padding: EdgeInsets.all(16 * AppStyle.getScaleFactor(context)),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: "Transfer Id",
|
|
|
|
|
info: _model.title?.toString(),
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: _subtitle.assetName,
|
|
|
|
|
info: _model.device.assetName,
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: _subtitle.assetSN,
|
|
|
|
|
info: _model.device.serialNumber,
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: _subtitle.assetNumber,
|
|
|
|
|
info: _model.device.number,
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: _subtitle.destinationSite,
|
|
|
|
|
info: _model.device.destSiteName,
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: _subtitle.building,
|
|
|
|
|
info: _model.device.destBuildingName,
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: _subtitle.floor,
|
|
|
|
|
info: _model.device.destFloor,
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: _subtitle.department,
|
|
|
|
|
info: _model.device.destDepartmentName,
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: _subtitle.room,
|
|
|
|
|
info: _model.device.destRoom,
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: _subtitle.actions,
|
|
|
|
|
info: "",
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Text("Sender", style: Theme
|
|
|
|
|
.of(context)
|
|
|
|
|
.textTheme
|
|
|
|
|
.headline6),
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
padding: EdgeInsets.all(16 * AppStyle.getScaleFactor(context)),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: "Transfer Id",
|
|
|
|
|
info: _model.title?.toString(),
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: _subtitle.assetName,
|
|
|
|
|
info: _model.device.assetName,
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: _subtitle.assetSN,
|
|
|
|
|
info: _model.device.serialNumber,
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: _subtitle.assetNumber,
|
|
|
|
|
info: _model.device.number,
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: _subtitle.destinationSite,
|
|
|
|
|
info: _model.device.destSiteName,
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: _subtitle.building,
|
|
|
|
|
info: _model.device.destBuildingName,
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: _subtitle.floor,
|
|
|
|
|
info: _model.device.destFloor,
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: _subtitle.department,
|
|
|
|
|
info: _model.device.destDepartmentName,
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: _subtitle.room,
|
|
|
|
|
info: _model.device.destRoom,
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: _subtitle.actions,
|
|
|
|
|
info: "",
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Text("Sender", style: Theme.of(context).textTheme.headline6),
|
|
|
|
|
),
|
|
|
|
|
if (_userProvider.user?.type == UsersTypes.engineer)
|
|
|
|
|
ASmallButton(
|
|
|
|
|
text: _subtitle.edit,
|
|
|
|
|
onPressed: (_isSender || _isReceiver || false)
|
|
|
|
|
? () {
|
|
|
|
|
Navigator.of(context).push(MaterialPageRoute(
|
|
|
|
|
builder: (_) => UpdateDeviceTransfer(
|
|
|
|
|
model: _model,
|
|
|
|
|
isSender: true,
|
|
|
|
|
)));
|
|
|
|
|
}
|
|
|
|
|
: null,
|
|
|
|
|
),
|
|
|
|
|
if (_userProvider.user?.type == UsersTypes.engineer)
|
|
|
|
|
ASmallButton(
|
|
|
|
|
text: _subtitle.edit,
|
|
|
|
|
onPressed: (_isSender || _isReceiver || false)
|
|
|
|
|
? () {
|
|
|
|
|
Navigator.of(context).push(MaterialPageRoute(
|
|
|
|
|
builder: (_) =>
|
|
|
|
|
UpdateDeviceTransfer(
|
|
|
|
|
model: _model,
|
|
|
|
|
isSender: true,
|
|
|
|
|
)));
|
|
|
|
|
}
|
|
|
|
|
: null,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
DeviceTransferInfoSection(
|
|
|
|
|
info: _model.sender,
|
|
|
|
|
isSender: true,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Text("Receiver", style: Theme
|
|
|
|
|
.of(context)
|
|
|
|
|
.textTheme
|
|
|
|
|
.headline6),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
DeviceTransferInfoSection(
|
|
|
|
|
info: _model.sender,
|
|
|
|
|
isSender: true,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Text("Receiver", style: Theme.of(context).textTheme.headline6),
|
|
|
|
|
),
|
|
|
|
|
if (_userProvider.user?.type == UsersTypes.engineer)
|
|
|
|
|
ASmallButton(
|
|
|
|
|
text: _subtitle.edit,
|
|
|
|
|
onPressed: (_isReceiver || false)
|
|
|
|
|
? () {
|
|
|
|
|
Navigator.of(context).push(MaterialPageRoute(
|
|
|
|
|
builder: (_) => UpdateDeviceTransfer(
|
|
|
|
|
model: _model,
|
|
|
|
|
isSender: false,
|
|
|
|
|
)));
|
|
|
|
|
}
|
|
|
|
|
: null,
|
|
|
|
|
),
|
|
|
|
|
if (_userProvider.user?.type == UsersTypes.engineer)
|
|
|
|
|
ASmallButton(
|
|
|
|
|
text: _subtitle.edit,
|
|
|
|
|
onPressed: (_isReceiver || false)
|
|
|
|
|
? () {
|
|
|
|
|
Navigator.of(context).push(MaterialPageRoute(
|
|
|
|
|
builder: (_) =>
|
|
|
|
|
UpdateDeviceTransfer(
|
|
|
|
|
model: _model,
|
|
|
|
|
isSender: false,
|
|
|
|
|
)));
|
|
|
|
|
}
|
|
|
|
|
: null,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
DeviceTransferInfoSection(
|
|
|
|
|
info: _model.receiver,
|
|
|
|
|
isSender: false,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
DeviceTransferInfoSection(
|
|
|
|
|
info: _model.receiver,
|
|
|
|
|
isSender: false,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|