|
|
|
|
@ -5,6 +5,8 @@ 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/controllers/providers/settings/setting_provider.dart';
|
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:test_sa/models/device/asset_transfer.dart';
|
|
|
|
|
import 'package:test_sa/models/subtitle.dart';
|
|
|
|
|
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
|
|
|
|
|
@ -14,7 +16,14 @@ import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
|
|
|
|
|
|
|
|
|
|
import '../../../../controllers/localization/localization.dart';
|
|
|
|
|
import '../../../controllers/validator/validator.dart';
|
|
|
|
|
import '../../../extensions/text_extensions.dart';
|
|
|
|
|
import '../../../models/lookup.dart';
|
|
|
|
|
import '../../../new_views/common_widgets/app_text_form_field.dart';
|
|
|
|
|
import '../../../new_views/common_widgets/default_app_bar.dart';
|
|
|
|
|
import '../../../new_views/common_widgets/single_item_drop_down_menu.dart';
|
|
|
|
|
import '../../../providers/gas_request_providers/gas_status_provider.dart';
|
|
|
|
|
import '../../widgets/e_signature/e_signature.dart';
|
|
|
|
|
|
|
|
|
|
class UpdateDeviceTransfer extends StatefulWidget {
|
|
|
|
|
final AssetTransfer model;
|
|
|
|
|
@ -34,7 +43,7 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
|
|
|
|
|
Uint8List _signature;
|
|
|
|
|
AssetTransferProvider _deviceTransferProvider;
|
|
|
|
|
final TextEditingController _requestedQuantityController = TextEditingController();
|
|
|
|
|
// final DeviceTransferInfo _formModel = DeviceTransferInfo(attachments: []);
|
|
|
|
|
final AssetTransfer _formModel = AssetTransfer();
|
|
|
|
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
|
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
|
|
|
|
|
|
|
@ -76,7 +85,7 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
// _formModel.fromDetails(widget.isSender ? widget.model.sender : widget.model.receiver, withSignature: false);
|
|
|
|
|
_formModel.fromDetails(widget.model);
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -101,103 +110,84 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
|
|
|
|
|
stateCode: 200,
|
|
|
|
|
onRefresh: () async {},
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
SingleChildScrollView(
|
|
|
|
|
padding: EdgeInsets.all(12 * AppStyle.getScaleFactor(context)),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
ASubTitle("Comment"),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
_buildCard(),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
initialValue: widget.isSender? _formModel.senderTravelingHours:_formModel.receiverTravelingHours,
|
|
|
|
|
labelText: context.translation.travelingHours,
|
|
|
|
|
onSaved:(value){
|
|
|
|
|
widget.isSender? _formModel.senderTravelingHours
|
|
|
|
|
: _formModel.receiverTravelingHours= value;
|
|
|
|
|
//_formModel?.workingHours = double.tryParse(value);
|
|
|
|
|
// _formModel.travelingHours = value;
|
|
|
|
|
},
|
|
|
|
|
textInputType: TextInputType.number,
|
|
|
|
|
validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
|
|
|
|
|
),
|
|
|
|
|
// ATextFormField(
|
|
|
|
|
// initialValue: _formModel?.comment,
|
|
|
|
|
// textAlign: TextAlign.center,
|
|
|
|
|
// style: Theme.of(context).textTheme.subtitle1,
|
|
|
|
|
// textInputType: TextInputType.text,
|
|
|
|
|
// onSaved: (value) {
|
|
|
|
|
// _formModel.comment = value;
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
ASubTitle(context.translation.travelingHours),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
// ATextFormField(
|
|
|
|
|
// initialValue: _formModel?.travelingHours,
|
|
|
|
|
// textAlign: TextAlign.center,
|
|
|
|
|
// style: Theme.of(context).textTheme.subtitle1,
|
|
|
|
|
// textInputType: TextInputType.number,
|
|
|
|
|
// onSaved: (value) {
|
|
|
|
|
// _formModel.travelingHours = value;
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 16,
|
|
|
|
|
),
|
|
|
|
|
ASubTitle(context.translation.workingHours),
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
// Expanded(
|
|
|
|
|
// child: AppTimer(
|
|
|
|
|
// timer: _formModel.timer,
|
|
|
|
|
// onChange: (timer) async {
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: context.translation.workingHours,
|
|
|
|
|
initialValue: widget.isSender?_formModel.senderWorkingHours:_formModel.receiverWorkingHours,
|
|
|
|
|
onSaved:(value){
|
|
|
|
|
widget.isSender?
|
|
|
|
|
_formModel?.senderWorkingHours = value:_formModel?.receiverWorkingHours = value;
|
|
|
|
|
// _formModel.timer = timer;
|
|
|
|
|
// _formModel.workingHours = (((timer?.durationInSecond ?? 0) / 60) / 60)?.toStringAsFixed(2) ?? "0";
|
|
|
|
|
// return true;
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
|
ASubTitle(context.translation.status),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
},
|
|
|
|
|
textInputType: TextInputType.number,
|
|
|
|
|
validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
|
|
|
|
|
),
|
|
|
|
|
// AssetStatusMenu(
|
|
|
|
|
// initialValue: _formModel.status,
|
|
|
|
|
// onSelect: (status) {
|
|
|
|
|
// if (status == null) return;
|
|
|
|
|
// _formModel.status = status;
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 16,
|
|
|
|
|
8.height,
|
|
|
|
|
///TBD
|
|
|
|
|
Consumer<GasStatusProvider>(builder: (context, snapshot, _){
|
|
|
|
|
return SingleItemDropDownMenu<Lookup,GasStatusProvider >(
|
|
|
|
|
context: context,
|
|
|
|
|
title: context.translation.reportStatus,
|
|
|
|
|
initialValue: snapshot.items?.firstWhere((element) => element.name == (widget.isSender?_formModel.senderMachineStatusName:_formModel.receiverMachineStatusName), orElse: () => null),
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
if(widget.isSender) {
|
|
|
|
|
_formModel.senderMachineStatusName=value.name;
|
|
|
|
|
_formModel.senderMachineStatusId=value.value;
|
|
|
|
|
}else{
|
|
|
|
|
_formModel.receiverMachineStatusName=value.name;
|
|
|
|
|
_formModel.receiverMachineStatusId=value.value;
|
|
|
|
|
}
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
initialValue: widget.isSender?_formModel.senderComment:_formModel.receiverComment,
|
|
|
|
|
labelText: context.translation.comments,
|
|
|
|
|
textInputType: TextInputType.multiline,
|
|
|
|
|
alignLabelWithHint: true,
|
|
|
|
|
onSaved: (value){
|
|
|
|
|
widget.isSender?
|
|
|
|
|
_formModel.senderComment = value:_formModel.receiverComment;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
// MultiFilesPicker(
|
|
|
|
|
// label: "Attachments",
|
|
|
|
|
// files: _formModel.attachments,
|
|
|
|
|
// ),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 16,
|
|
|
|
|
8.height,
|
|
|
|
|
ESignature(
|
|
|
|
|
title: "Signature",
|
|
|
|
|
//oldSignature: widget.isSender ? widget.model.senderEngSignature : widget.model.receiverEngSignature,
|
|
|
|
|
newSignature: _signature,
|
|
|
|
|
onSaved: (signature) {
|
|
|
|
|
_signature = signature;
|
|
|
|
|
if (signature == null || signature.isEmpty) return;
|
|
|
|
|
// _formModel.engSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
|
|
|
|
|
// base64Encode(signature);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const ASubTitle("Signature"),
|
|
|
|
|
// if(_validate && _formModel.signature == null)
|
|
|
|
|
// ASubTitle(_subtitle.requiredWord,color: Colors.red,),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
// ESignature(
|
|
|
|
|
// oldSignature: widget.isSender ? widget.model.sender.engSignature : widget.model.receiver.engSignature,
|
|
|
|
|
// newSignature: _signature,
|
|
|
|
|
// onSaved: (signature) {
|
|
|
|
|
// _signature = signature;
|
|
|
|
|
// if (signature == null || signature.isEmpty) return;
|
|
|
|
|
// _formModel.engSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
|
|
|
|
|
// // base64Encode(signature);
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
).expanded,
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.all(16.0),
|
|
|
|
|
child: AppFilledButton(
|
|
|
|
|
@ -211,4 +201,33 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_buildCard(){
|
|
|
|
|
return Container(
|
|
|
|
|
width: MediaQuery.of(context).size.width,
|
|
|
|
|
decoration: ShapeDecoration(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.circular(15),
|
|
|
|
|
),
|
|
|
|
|
shadows: const [BoxShadow(color: Color(0x07000000), blurRadius: 14, offset: Offset(0, 0), spreadRadius: 0)],
|
|
|
|
|
),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(context.translation.transferDetails, style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))),
|
|
|
|
|
8.height,
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.assetName}: ${_formModel.assetName}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
|
|
|
|
|
),
|
|
|
|
|
///TBD
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.requesterName}: ',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).paddingAll(16),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|