|
|
|
@ -5,7 +5,9 @@ import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
|
|
|
import 'package:test_sa/models/device/asset.dart';
|
|
|
|
import 'package:test_sa/models/service_request/service_request.dart';
|
|
|
|
import 'package:test_sa/models/service_request/service_request.dart';
|
|
|
|
|
|
|
|
import 'package:test_sa/views/widgets/equipment/pick_asset.dart';
|
|
|
|
|
|
|
|
|
|
|
|
import '../../../../controllers/providers/api/service_requests_provider.dart';
|
|
|
|
import '../../../../controllers/providers/api/service_requests_provider.dart';
|
|
|
|
import '../../../../models/lookup.dart';
|
|
|
|
import '../../../../models/lookup.dart';
|
|
|
|
@ -27,6 +29,7 @@ class FirstActionBottomSheet extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
|
|
class _FirstActionBottomSheetState extends State<FirstActionBottomSheet> {
|
|
|
|
class _FirstActionBottomSheetState extends State<FirstActionBottomSheet> {
|
|
|
|
ServiceRequest _serviceRequest;
|
|
|
|
ServiceRequest _serviceRequest;
|
|
|
|
|
|
|
|
Asset asset;
|
|
|
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
|
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
void initState() {
|
|
|
|
@ -37,8 +40,9 @@ class _FirstActionBottomSheetState extends State<FirstActionBottomSheet> {
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final userProvider = Provider.of<UserProvider>(context, listen: false);
|
|
|
|
final userProvider = Provider.of<UserProvider>(context, listen: false);
|
|
|
|
return Container(
|
|
|
|
return Wrap(
|
|
|
|
height: MediaQuery.of(context).size.height * 0.55,
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Container(
|
|
|
|
clipBehavior: Clip.antiAlias,
|
|
|
|
clipBehavior: Clip.antiAlias,
|
|
|
|
margin: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
|
|
|
|
margin: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
@ -48,6 +52,7 @@ class _FirstActionBottomSheetState extends State<FirstActionBottomSheet> {
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth, vertical: 8.toScreenHeight),
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth, vertical: 8.toScreenHeight),
|
|
|
|
child: Form(
|
|
|
|
child: Form(
|
|
|
|
key: _formKey,
|
|
|
|
key: _formKey,
|
|
|
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
Container(
|
|
|
|
@ -88,8 +93,23 @@ class _FirstActionBottomSheetState extends State<FirstActionBottomSheet> {
|
|
|
|
context: context,
|
|
|
|
context: context,
|
|
|
|
title: context.translation.loanAvailability,
|
|
|
|
title: context.translation.loanAvailability,
|
|
|
|
initialValue: _serviceRequest.loanAvailability,
|
|
|
|
initialValue: _serviceRequest.loanAvailability,
|
|
|
|
onSelect: (value) {
|
|
|
|
onSelect: (status) {
|
|
|
|
_serviceRequest.loanAvailability = value;
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
_serviceRequest.loanAvailability = status;
|
|
|
|
|
|
|
|
if (_serviceRequest.loanAvailability.value != 1) {
|
|
|
|
|
|
|
|
asset = null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
if (_serviceRequest?.loanAvailability?.value == 1) 8.height,
|
|
|
|
|
|
|
|
if (_serviceRequest?.loanAvailability?.value == 1)
|
|
|
|
|
|
|
|
PickAsset(
|
|
|
|
|
|
|
|
device: asset ?? _serviceRequest.device,
|
|
|
|
|
|
|
|
onPickAsset: (asset) {
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
this.asset = asset;
|
|
|
|
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
8.height,
|
|
|
|
8.height,
|
|
|
|
@ -108,6 +128,7 @@ class _FirstActionBottomSheetState extends State<FirstActionBottomSheet> {
|
|
|
|
loading: snapshot.isLoading,
|
|
|
|
loading: snapshot.isLoading,
|
|
|
|
onPressed: () async {
|
|
|
|
onPressed: () async {
|
|
|
|
_formKey.currentState.save();
|
|
|
|
_formKey.currentState.save();
|
|
|
|
|
|
|
|
_serviceRequest.device = asset;
|
|
|
|
await snapshot.updateRequest(user: userProvider.user, request: _serviceRequest);
|
|
|
|
await snapshot.updateRequest(user: userProvider.user, request: _serviceRequest);
|
|
|
|
Navigator.pop(context);
|
|
|
|
Navigator.pop(context);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
@ -117,6 +138,9 @@ class _FirstActionBottomSheetState extends State<FirstActionBottomSheet> {
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
],
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|