mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 05:48:54 +03:30
'3.1.1'
This commit is contained in:
@@ -1,108 +1,23 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:cssd/providers/items.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../config/routes.dart';
|
||||
|
||||
class ItemAddSaveButton extends StatefulWidget {
|
||||
ItemAddSaveButton({
|
||||
class ItemAddSaveButton extends StatelessWidget {
|
||||
const ItemAddSaveButton({
|
||||
Key? key,
|
||||
required GlobalKey<FormState> form,
|
||||
this.batchId,
|
||||
required this.nameCTRL,
|
||||
required this.descriptionCTRL,
|
||||
required this.udiCTRL,
|
||||
required double deviceBlockSize,
|
||||
required this.sizeCTRL,
|
||||
required this.specificCTRL,
|
||||
required this.dateValue,
|
||||
required this.isLoading,
|
||||
}) : _form = form,
|
||||
_deviceBlockSize = deviceBlockSize,
|
||||
required this.onTap,
|
||||
}) : _deviceBlockSize = deviceBlockSize,
|
||||
super(key: key);
|
||||
|
||||
final GlobalKey<FormState> _form;
|
||||
final TextEditingController nameCTRL;
|
||||
final TextEditingController descriptionCTRL;
|
||||
final TextEditingController udiCTRL;
|
||||
final TextEditingController sizeCTRL;
|
||||
final TextEditingController specificCTRL;
|
||||
final String dateValue;
|
||||
final String? batchId;
|
||||
final double _deviceBlockSize;
|
||||
bool isLoading;
|
||||
|
||||
@override
|
||||
State<ItemAddSaveButton> createState() => _ItemAddSaveButtonState();
|
||||
}
|
||||
|
||||
class _ItemAddSaveButtonState extends State<ItemAddSaveButton> {
|
||||
final VoidCallback onTap;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
if (!widget._form.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
widget.isLoading = true;
|
||||
});
|
||||
Provider.of<ItemProvider>(context, listen: false)
|
||||
.createItemResult(
|
||||
widget.nameCTRL.text,
|
||||
widget.sizeCTRL.text,
|
||||
widget.specificCTRL.text,
|
||||
widget.udiCTRL.text,
|
||||
widget.descriptionCTRL.text,
|
||||
widget.batchId,
|
||||
)
|
||||
.then(
|
||||
(result) {
|
||||
setState(() {
|
||||
widget.isLoading = false;
|
||||
});
|
||||
if (result == 'done') {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
content: Text('Item added.'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
child: Text('Ok'),
|
||||
)
|
||||
],
|
||||
),
|
||||
).then((value) => Navigator.of(context)
|
||||
.popAndPushNamed(Routes.testResultScreen));
|
||||
}
|
||||
},
|
||||
);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
content: Text('Item added.'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
child: Text('Ok'),
|
||||
)
|
||||
],
|
||||
),
|
||||
).then((_) {
|
||||
Navigator.of(context).pushReplacementNamed(Routes.itemResultScreen);
|
||||
});
|
||||
},
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5 * widget._deviceBlockSize,
|
||||
horizontal: 5 * _deviceBlockSize,
|
||||
vertical: 10,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
@@ -117,7 +32,7 @@ class _ItemAddSaveButtonState extends State<ItemAddSaveButton> {
|
||||
'Save',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * widget._deviceBlockSize,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -90,20 +90,24 @@ class _UploaderImageState extends State<UploaderImage> {
|
||||
}
|
||||
|
||||
Future<void> loadAssetsFromFilePicker(BuildContext context) async {
|
||||
var providerObject = Provider.of<ItemProvider>(context, listen: false);
|
||||
List<PlatformFile> files = providerObject.catchImages;
|
||||
try {
|
||||
var datas = await FilePicker.platform.pickFiles(
|
||||
type: FileType.custom,
|
||||
allowedExtensions: ['jpg', 'png', 'bmp', 'jpeg', 'pdf', 'docx', 'doc'],
|
||||
withData: true,
|
||||
withReadStream: true,
|
||||
);
|
||||
files += datas!.files;
|
||||
} catch (_) {}
|
||||
|
||||
providerObject.setCatchImages(files);
|
||||
providerObject.setImages();
|
||||
var providerObject = Provider.of<ItemProvider>(context, listen: false);
|
||||
List<PlatformFile> files = providerObject.catchImages;
|
||||
var image = await ImagePicker.platform.pickImage(
|
||||
source: ImageSource.gallery,
|
||||
imageQuality: 25,
|
||||
);
|
||||
if (image != null) {
|
||||
files.add(
|
||||
PlatformFile(
|
||||
path: image.path,
|
||||
name: "item_image",
|
||||
bytes: File(image.path).readAsBytesSync(),
|
||||
size: File(image.path).lengthSync(),
|
||||
),
|
||||
);
|
||||
providerObject.setCatchImages(files);
|
||||
providerObject.setImages();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> loadAssetsFromCamera(BuildContext context) async {
|
||||
@@ -111,6 +115,7 @@ class _UploaderImageState extends State<UploaderImage> {
|
||||
List<PlatformFile> _catchImages = providerObject.catchImages;
|
||||
var image = await ImagePicker.platform.pickImage(
|
||||
source: ImageSource.camera,
|
||||
imageQuality: 25,
|
||||
);
|
||||
if (image != null) {
|
||||
_catchImages.add(
|
||||
|
||||
Reference in New Issue
Block a user