mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 03:08:55 +03:30
beta commit
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
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 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,
|
||||
}) : _form = form,
|
||||
_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;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
if (!_form.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
Provider.of<ItemProvider>(context, listen: false).createItemResult(
|
||||
nameCTRL.text,
|
||||
sizeCTRL.text,
|
||||
specificCTRL.text,
|
||||
udiCTRL.text,
|
||||
descriptionCTRL.text,
|
||||
batchId,
|
||||
);
|
||||
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);
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5 * _deviceBlockSize,
|
||||
vertical: 10,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [kBlue, kBlueSub],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'Save',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:cssd/providers/items.dart';
|
||||
|
||||
import '../../../config/routes.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class ItemUpdateButton extends StatelessWidget {
|
||||
const ItemUpdateButton({
|
||||
Key? key,
|
||||
required GlobalKey<FormState> form,
|
||||
required this.id,
|
||||
required this.descriptionCTRL,
|
||||
required this.nameCTRL,
|
||||
required this.udiCTRL,
|
||||
required this.sizeCTRL,
|
||||
required this.specificCTRL,
|
||||
required double deviceBlockSize,
|
||||
}) : _form = form,
|
||||
_deviceBlockSize = deviceBlockSize,
|
||||
super(key: key);
|
||||
|
||||
final GlobalKey<FormState> _form;
|
||||
final String id;
|
||||
final TextEditingController descriptionCTRL;
|
||||
final TextEditingController nameCTRL;
|
||||
final TextEditingController udiCTRL;
|
||||
final TextEditingController sizeCTRL;
|
||||
final TextEditingController specificCTRL;
|
||||
final double _deviceBlockSize;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
if (!_form.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
Provider.of<ItemProvider>(context, listen: false).updateItemResult(
|
||||
id,
|
||||
nameCTRL.text,
|
||||
sizeCTRL.text,
|
||||
specificCTRL.text,
|
||||
udiCTRL.text,
|
||||
descriptionCTRL.text,
|
||||
);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
content: Text('Item updated.'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
child: Text('Ok'),
|
||||
)
|
||||
],
|
||||
),
|
||||
).then((_) {
|
||||
Navigator.of(context).pushReplacementNamed(Routes.itemResultScreen);
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5 * _deviceBlockSize,
|
||||
vertical: 10,
|
||||
),
|
||||
// margin:
|
||||
// EdgeInsets.symmetric(horizontal: 35, vertical: 15),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [kBlue, kBlueSub],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'Update',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
import 'package:cssd/providers/items.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class UploaderImage extends StatelessWidget {
|
||||
final double deviceBlockSize;
|
||||
final ItemProvider providerObject;
|
||||
const UploaderImage({
|
||||
super.key,
|
||||
required this.deviceBlockSize,
|
||||
required this.providerObject,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
child: Directionality(
|
||||
textDirection: TextDirection.rtl,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 20),
|
||||
height: providerObject.catchImages.length != 0 ? 60 : 0,
|
||||
child: ImageBox(
|
||||
deviceBlockSize: deviceBlockSize,
|
||||
itemProvider: providerObject,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: providerObject.catchImages.length != 0 ? 10 : 0,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
await loadAssets(context);
|
||||
},
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width - 40,
|
||||
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 30),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
color: Colors.black,
|
||||
),
|
||||
child: Text(
|
||||
'+ Add an image or file from device',
|
||||
textDirection: TextDirection.ltr,
|
||||
style: TextStyle(color: Colors.white),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> loadAssets(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();
|
||||
}
|
||||
}
|
||||
|
||||
class ImageBox extends StatelessWidget {
|
||||
const ImageBox({
|
||||
Key? key,
|
||||
required double deviceBlockSize,
|
||||
required ItemProvider itemProvider,
|
||||
}) : _deviceBlockSize = deviceBlockSize,
|
||||
_providerObject = itemProvider,
|
||||
super(key: key);
|
||||
|
||||
final double _deviceBlockSize;
|
||||
final ItemProvider _providerObject;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView.separated(
|
||||
shrinkWrap: true,
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemBuilder: (ctx, index) {
|
||||
bool isPdf = _providerObject.catchImages[index].path!.endsWith('pdf');
|
||||
bool isWord =
|
||||
_providerObject.catchImages[index].path!.endsWith('docx') ||
|
||||
_providerObject.catchImages[index].path!.endsWith('doc');
|
||||
|
||||
// print(_providerObject.catchImages[index].path.endsWith('jpg'));
|
||||
// .substring(_providerObject.catchImages[index].path.length - 4));
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
child: Container(
|
||||
width: 60,
|
||||
height: 60,
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
Positioned(
|
||||
top: 10,
|
||||
left: 0,
|
||||
child: GestureDetector(
|
||||
onTap: () => isPdf
|
||||
? print('pdf')
|
||||
: isWord
|
||||
? print('word')
|
||||
: Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => Container(
|
||||
color: Colors.white,
|
||||
child: Center(
|
||||
child: Image.memory(
|
||||
_providerObject
|
||||
.catchImages[index].bytes!,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: isPdf
|
||||
? Image.asset(
|
||||
'assets/Images/pdf.png',
|
||||
width: 60,
|
||||
height: 60,
|
||||
fit: BoxFit.fill,
|
||||
)
|
||||
: isWord
|
||||
? Image.asset(
|
||||
'assets/Images/word.png',
|
||||
width: 60,
|
||||
height: 60,
|
||||
fit: BoxFit.fill,
|
||||
)
|
||||
: Image.memory(
|
||||
_providerObject.catchImages[index].bytes!,
|
||||
// asset: _images[index],
|
||||
width: 60,
|
||||
height: 60,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 0,
|
||||
right: 0,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
// setState(() {
|
||||
_providerObject.removeImage(index);
|
||||
// });
|
||||
},
|
||||
child: CircleAvatar(
|
||||
backgroundColor: Colors.red,
|
||||
radius: 10,
|
||||
child: Icon(
|
||||
Icons.close,
|
||||
size: 12,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
itemCount: _providerObject.catchImages.length,
|
||||
separatorBuilder: (BuildContext context, int index) => SizedBox(
|
||||
width: 3 * _deviceBlockSize,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user