|
|
|
|
@ -19,6 +19,7 @@ import 'package:test_sa/views/widgets/status/gas_refill/gas_status.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
|
|
|
|
|
|
|
|
|
|
import '../../../../controllers/localization/localization.dart';
|
|
|
|
|
|
|
|
|
|
class UpdateDeviceTransfer extends StatefulWidget {
|
|
|
|
|
final DeviceTransfer model;
|
|
|
|
|
final bool isSender;
|
|
|
|
|
@ -43,25 +44,19 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
|
|
|
|
|
|
|
|
|
|
_update() async {
|
|
|
|
|
_validate = true;
|
|
|
|
|
if(!_formKey.currentState.validate()){
|
|
|
|
|
if (!_formKey.currentState.validate()) {
|
|
|
|
|
setState(() {});
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
_formKey.currentState.save();
|
|
|
|
|
|
|
|
|
|
_isLoading =true;
|
|
|
|
|
_isLoading = true;
|
|
|
|
|
setState(() {});
|
|
|
|
|
int status = await _deviceTransferProvider.updateRequest(
|
|
|
|
|
user: _userProvider.user,
|
|
|
|
|
host: _settingProvider.host,
|
|
|
|
|
requestId: widget.model.id,
|
|
|
|
|
isSender: widget.isSender,
|
|
|
|
|
newModel: _formModel,
|
|
|
|
|
oldModel: widget.model
|
|
|
|
|
);
|
|
|
|
|
_isLoading =false;
|
|
|
|
|
user: _userProvider.user, host: _settingProvider.host, requestId: widget.model.id, isSender: widget.isSender, newModel: _formModel, oldModel: widget.model);
|
|
|
|
|
_isLoading = false;
|
|
|
|
|
setState(() {});
|
|
|
|
|
if(status >= 200 && status < 300){
|
|
|
|
|
if (status >= 200 && status < 300) {
|
|
|
|
|
Fluttertoast.showToast(
|
|
|
|
|
msg: _subtitle.requestCompleteSuccessfully,
|
|
|
|
|
);
|
|
|
|
|
@ -72,16 +67,13 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void setState(VoidCallback fn){
|
|
|
|
|
if(!mounted) super.setState(() {});
|
|
|
|
|
void setState(VoidCallback fn) {
|
|
|
|
|
if (!mounted) super.setState(() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
_formModel.fromDetails(widget.isSender
|
|
|
|
|
? widget.model.sender : widget.model.receiver,
|
|
|
|
|
withSignature: false
|
|
|
|
|
);
|
|
|
|
|
_formModel.fromDetails(widget.isSender ? widget.model.sender : widget.model.receiver, withSignature: false);
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -96,7 +88,7 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
|
|
|
|
|
_subtitle = AppLocalization.of(context).subtitle;
|
|
|
|
|
_userProvider = Provider.of<UserProvider>(context);
|
|
|
|
|
_settingProvider = Provider.of<SettingProvider>(context);
|
|
|
|
|
_deviceTransferProvider = Provider.of<DeviceTransferProvider>(context,listen: false);
|
|
|
|
|
_deviceTransferProvider = Provider.of<DeviceTransferProvider>(context, listen: false);
|
|
|
|
|
return Scaffold(
|
|
|
|
|
key: _scaffoldKey,
|
|
|
|
|
body: Form(
|
|
|
|
|
@ -117,48 +109,56 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
|
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
|
child: Text(
|
|
|
|
|
"Edit Transfer Device",
|
|
|
|
|
style: Theme.of(context).textTheme.headline5.copyWith(
|
|
|
|
|
color: Theme.of(context).primaryColor,
|
|
|
|
|
fontSize: 28,
|
|
|
|
|
fontWeight: FontWeight.bold
|
|
|
|
|
),
|
|
|
|
|
style: Theme.of(context).textTheme.headline5.copyWith(color: Theme.of(context).primaryColor, fontSize: 28, fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 8,),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
ASubTitle("Comment"),
|
|
|
|
|
|
|
|
|
|
const SizedBox(height: 4,),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
ATextFormField(
|
|
|
|
|
initialValue: _formModel?.comment,
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle1,
|
|
|
|
|
textInputType: TextInputType.text,
|
|
|
|
|
onSaved: (value){
|
|
|
|
|
onSaved: (value) {
|
|
|
|
|
_formModel.comment = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 8,),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
ASubTitle(_subtitle.travelingHours),
|
|
|
|
|
const SizedBox(height: 4,),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
ATextFormField(
|
|
|
|
|
initialValue: _formModel?.travelingHours,
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle1,
|
|
|
|
|
textInputType: TextInputType.number,
|
|
|
|
|
onSaved: (value){
|
|
|
|
|
onSaved: (value) {
|
|
|
|
|
_formModel.travelingHours = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 8,),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
ASubTitle(_subtitle.workingHours),
|
|
|
|
|
const SizedBox(height: 4,),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
ATextFormField(
|
|
|
|
|
initialValue: _formModel?.workingHours,
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle1,
|
|
|
|
|
textInputType: TextInputType.number,
|
|
|
|
|
onSaved: (value){
|
|
|
|
|
onSaved: (value) {
|
|
|
|
|
_formModel.workingHours = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
@ -174,32 +174,37 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
const SizedBox(height: 8,),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
ASubTitle(_subtitle.status),
|
|
|
|
|
const SizedBox(height: 4,),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
GasStatusMenu(
|
|
|
|
|
initialValue: _formModel.status,
|
|
|
|
|
onSelect: (status){
|
|
|
|
|
onSelect: (status) {
|
|
|
|
|
_formModel.status = status;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 8,),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
const ASubTitle("Signature"),
|
|
|
|
|
// if(_validate && _formModel.signature == null)
|
|
|
|
|
// ASubTitle(_subtitle.requiredWord,color: Colors.red,),
|
|
|
|
|
const SizedBox(height: 4,),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
ESignature(
|
|
|
|
|
oldSignature: widget.isSender
|
|
|
|
|
? widget.model.sender.signature
|
|
|
|
|
: widget.model.receiver.signature,
|
|
|
|
|
newSignature: _signature,
|
|
|
|
|
onSaved: (signature){
|
|
|
|
|
_signature = signature;
|
|
|
|
|
if(signature == null || signature.isEmpty) return;
|
|
|
|
|
_formModel.signature = base64Encode(signature);
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
oldSignature: widget.isSender ? widget.model.sender.signature : widget.model.receiver.signature,
|
|
|
|
|
newSignature: _signature,
|
|
|
|
|
onSaved: (signature) {
|
|
|
|
|
_signature = signature;
|
|
|
|
|
if (signature == null || signature.isEmpty) return;
|
|
|
|
|
_formModel.signature = base64Encode(signature);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.all(16.0),
|
|
|
|
|
@ -208,7 +213,9 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
|
|
|
|
|
onPressed: _update,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 100,)
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 100,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
@ -218,4 +225,3 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|