mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-12 10:18:56 +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(
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
|
||||
class ItemDetailsDataBox extends StatelessWidget {
|
||||
const ItemDetailsDataBox({
|
||||
Key? key,
|
||||
@@ -316,6 +317,22 @@ class ItemDetailsDataBox extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
Divider(),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 20),
|
||||
child: ListView.separated(
|
||||
shrinkWrap: true,
|
||||
itemBuilder: (ctx, index) {
|
||||
return Image(image: NetworkImage(datas.filePath![index]));
|
||||
},
|
||||
separatorBuilder: (ctx, index) => Divider(),
|
||||
itemCount: datas.filePath!.length,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -35,21 +35,21 @@ class ItemItemBox extends StatelessWidget {
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
if (item!.udi != null)
|
||||
Container(
|
||||
padding: const EdgeInsets.all(6.0),
|
||||
child: Text(
|
||||
item!.udi!,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 3 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (item!.udi != null)
|
||||
SizedBox(
|
||||
width: 3 * _deviceBlockSize,
|
||||
),
|
||||
// if (item!.udi != null)
|
||||
// Container(
|
||||
// padding: const EdgeInsets.all(6.0),
|
||||
// child: Text(
|
||||
// item!.udi!,
|
||||
// style: TextStyle(
|
||||
// fontWeight: FontWeight.w700,
|
||||
// fontSize: 3 * _deviceBlockSize,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// if (item!.udi != null)
|
||||
// SizedBox(
|
||||
// width: 3 * _deviceBlockSize,
|
||||
// ),
|
||||
// Spacer(),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -69,7 +69,7 @@ class ItemItemBox extends StatelessWidget {
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
'Size: ',
|
||||
'Udi: ',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 3 * _deviceBlockSize,
|
||||
@@ -77,7 +77,7 @@ class ItemItemBox extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
item!.size,
|
||||
item!.udi ?? '',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
@@ -92,7 +92,7 @@ class ItemItemBox extends StatelessWidget {
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'User: ',
|
||||
'Owner: ',
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: 3 * _deviceBlockSize,
|
||||
|
||||
@@ -37,21 +37,21 @@ class MyItemsItemDataBox extends StatelessWidget {
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
if (items!.udi != null)
|
||||
Container(
|
||||
padding: const EdgeInsets.all(6.0),
|
||||
child: Text(
|
||||
items!.udi!,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 3 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (items!.udi != null)
|
||||
SizedBox(
|
||||
width: 3 * _deviceBlockSize,
|
||||
),
|
||||
// if (items!.udi != null)
|
||||
// Container(
|
||||
// padding: const EdgeInsets.all(6.0),
|
||||
// child: Text(
|
||||
// items!.udi!,
|
||||
// style: TextStyle(
|
||||
// fontWeight: FontWeight.w700,
|
||||
// fontSize: 3 * _deviceBlockSize,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// if (items!.udi != null)
|
||||
// SizedBox(
|
||||
// width: 3 * _deviceBlockSize,
|
||||
// ),
|
||||
// Spacer(),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -71,7 +71,7 @@ class MyItemsItemDataBox extends StatelessWidget {
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
'Size: ',
|
||||
'Udi: ',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 3 * _deviceBlockSize,
|
||||
@@ -79,7 +79,7 @@ class MyItemsItemDataBox extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
items!.size,
|
||||
items!.udi ?? '',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
@@ -95,7 +95,7 @@ class MyItemsItemDataBox extends StatelessWidget {
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'User: ',
|
||||
'Owner: ',
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: 3 * _deviceBlockSize,
|
||||
|
||||
@@ -235,7 +235,7 @@ class PackageDetailsDataBox extends StatelessWidget {
|
||||
shrinkWrap: true,
|
||||
itemBuilder: (ctx, index) => RichText(
|
||||
text: TextSpan(
|
||||
text: 'Item ',
|
||||
text: '${index + 1}. ',
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
fontFamily: 'montserrat',
|
||||
|
||||
@@ -105,7 +105,7 @@ class _FormCreatorState extends State<FormCreator> {
|
||||
),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
await loadAssets(context);
|
||||
await loadAssetsFromFilePicker(context);
|
||||
},
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width - 40,
|
||||
@@ -570,34 +570,33 @@ class _FormCreatorState extends State<FormCreator> {
|
||||
profileProviderObject.setImages();
|
||||
}
|
||||
|
||||
Future<void> loadAssets(BuildContext context) async {
|
||||
var profileProviderObject =
|
||||
Provider.of<TestResultsProvider>(context, listen: false);
|
||||
List<PlatformFile> files = profileProviderObject.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;
|
||||
// files +=
|
||||
|
||||
// print(files);
|
||||
} catch (_) {}
|
||||
|
||||
profileProviderObject.setCatchImages(files);
|
||||
profileProviderObject.setImages();
|
||||
// profileProviderObject.addImage();
|
||||
Future<void> loadAssetsFromFilePicker(BuildContext context) async {
|
||||
var providerObject = Provider.of<TestResultsProvider>(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 {
|
||||
var providerObject =
|
||||
Provider.of<TestResultsProvider>(context, listen: false);
|
||||
var providerObject = Provider.of<TestResultsProvider>(context, listen: false);
|
||||
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