|
|
|
|
@ -33,117 +33,121 @@ class _MultiFilesPickerState extends State<MultiFilesPicker> with TickerProvider
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
_size = MediaQuery.of(context).size;
|
|
|
|
|
Subtitle subtitle = AppLocalization.of(context).subtitle;
|
|
|
|
|
return Container(
|
|
|
|
|
padding: const EdgeInsets.all(12),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: const Color(0xfff5f5f5),
|
|
|
|
|
border: Border.all(
|
|
|
|
|
color: const Color(0xffefefef),
|
|
|
|
|
),
|
|
|
|
|
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
|
|
|
|
),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
// SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Text(
|
|
|
|
|
widget.label ?? subtitle.images,
|
|
|
|
|
style: Theme.of(context).textTheme.headline6.copyWith(
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
),
|
|
|
|
|
textScaleFactor: AppStyle.getScaleFactor(context),
|
|
|
|
|
),
|
|
|
|
|
return (widget.enabled == false && (widget.files?.isEmpty ?? false))
|
|
|
|
|
? const SizedBox()
|
|
|
|
|
: Container(
|
|
|
|
|
padding: const EdgeInsets.all(12),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: const Color(0xfff5f5f5),
|
|
|
|
|
border: Border.all(
|
|
|
|
|
color: const Color(0xffefefef),
|
|
|
|
|
),
|
|
|
|
|
AFlatButton(
|
|
|
|
|
text: subtitle.add,
|
|
|
|
|
onPressed: widget.enabled
|
|
|
|
|
? () {
|
|
|
|
|
// onImagePick(_subtitle);
|
|
|
|
|
onFilePicker(subtitle);
|
|
|
|
|
}
|
|
|
|
|
: null,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
AnimatedSize(
|
|
|
|
|
duration: const Duration(milliseconds: 400),
|
|
|
|
|
child: !widget.error
|
|
|
|
|
? const SizedBox.shrink()
|
|
|
|
|
: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
subtitle.imagesRequired,
|
|
|
|
|
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
|
|
|
|
),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
// SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Text(
|
|
|
|
|
widget.label ?? subtitle.images,
|
|
|
|
|
style: Theme.of(context).textTheme.headline6.copyWith(
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
color: AColors.red,
|
|
|
|
|
),
|
|
|
|
|
textScaleFactor: AppStyle.getScaleFactor(context),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 8 * AppStyle.getScaleFactor(context),
|
|
|
|
|
),
|
|
|
|
|
if (widget.enabled)
|
|
|
|
|
AFlatButton(
|
|
|
|
|
text: subtitle.add,
|
|
|
|
|
onPressed: widget.enabled
|
|
|
|
|
? () {
|
|
|
|
|
// onImagePick(_subtitle);
|
|
|
|
|
onFilePicker(subtitle);
|
|
|
|
|
}
|
|
|
|
|
: null,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
AnimatedSwitcher(
|
|
|
|
|
duration: const Duration(milliseconds: 400),
|
|
|
|
|
child: Container(
|
|
|
|
|
key: ValueKey(widget.files.length),
|
|
|
|
|
width: _size.width,
|
|
|
|
|
height: 200 * AppStyle.getScaleFactor(context),
|
|
|
|
|
padding: EdgeInsets.all(
|
|
|
|
|
8 * AppStyle.getScaleFactor(context),
|
|
|
|
|
),
|
|
|
|
|
alignment: Alignment.topLeft,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
border: Border.all(color: Theme.of(context).primaryColor, width: 2),
|
|
|
|
|
borderRadius: BorderRadius.circular(8 * AppStyle.getScaleFactor(context)),
|
|
|
|
|
),
|
|
|
|
|
child: widget.files.isEmpty
|
|
|
|
|
? MaterialButton(
|
|
|
|
|
onPressed: widget.enabled
|
|
|
|
|
? () {
|
|
|
|
|
// onImagePick(_subtitle);
|
|
|
|
|
onFilePicker(subtitle);
|
|
|
|
|
}
|
|
|
|
|
: null,
|
|
|
|
|
child: Center(
|
|
|
|
|
child: Icon(
|
|
|
|
|
Icons.file_upload,
|
|
|
|
|
size: 48 * AppStyle.getScaleFactor(context),
|
|
|
|
|
color: Theme.of(context).primaryColor,
|
|
|
|
|
)),
|
|
|
|
|
)
|
|
|
|
|
: GridView.count(
|
|
|
|
|
crossAxisCount: 2,
|
|
|
|
|
//_size.width ~/ 80,
|
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
|
mainAxisSpacing: 10,
|
|
|
|
|
crossAxisSpacing: 10,
|
|
|
|
|
children: List.generate(widget.files.length, (index) {
|
|
|
|
|
File _image = widget.files[index];
|
|
|
|
|
return MultiFilesPickerItem(
|
|
|
|
|
file: _image,
|
|
|
|
|
onRemoveTap: (image) {
|
|
|
|
|
if (!widget.enabled) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
widget.files.remove(image);
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
AnimatedSize(
|
|
|
|
|
duration: const Duration(milliseconds: 400),
|
|
|
|
|
child: !widget.error
|
|
|
|
|
? const SizedBox.shrink()
|
|
|
|
|
: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
subtitle.imagesRequired,
|
|
|
|
|
style: Theme.of(context).textTheme.headline6.copyWith(
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
color: AColors.red,
|
|
|
|
|
),
|
|
|
|
|
textScaleFactor: AppStyle.getScaleFactor(context),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 8 * AppStyle.getScaleFactor(context),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
AnimatedSwitcher(
|
|
|
|
|
duration: const Duration(milliseconds: 400),
|
|
|
|
|
child: Container(
|
|
|
|
|
key: ValueKey(widget.files.length),
|
|
|
|
|
width: _size.width,
|
|
|
|
|
height: 200 * AppStyle.getScaleFactor(context),
|
|
|
|
|
padding: EdgeInsets.all(
|
|
|
|
|
8 * AppStyle.getScaleFactor(context),
|
|
|
|
|
),
|
|
|
|
|
alignment: Alignment.topLeft,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
border: Border.all(color: Theme.of(context).primaryColor, width: 2),
|
|
|
|
|
borderRadius: BorderRadius.circular(8 * AppStyle.getScaleFactor(context)),
|
|
|
|
|
),
|
|
|
|
|
child: widget.files.isEmpty && widget.enabled
|
|
|
|
|
? MaterialButton(
|
|
|
|
|
onPressed: widget.enabled
|
|
|
|
|
? () {
|
|
|
|
|
// onImagePick(_subtitle);
|
|
|
|
|
onFilePicker(subtitle);
|
|
|
|
|
}
|
|
|
|
|
: null,
|
|
|
|
|
child: Center(
|
|
|
|
|
child: Icon(
|
|
|
|
|
Icons.file_upload,
|
|
|
|
|
size: 48 * AppStyle.getScaleFactor(context),
|
|
|
|
|
color: Theme.of(context).primaryColor,
|
|
|
|
|
)),
|
|
|
|
|
)
|
|
|
|
|
: GridView.count(
|
|
|
|
|
crossAxisCount: 2,
|
|
|
|
|
//_size.width ~/ 80,
|
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
|
mainAxisSpacing: 10,
|
|
|
|
|
crossAxisSpacing: 10,
|
|
|
|
|
children: List.generate(widget.files.length, (index) {
|
|
|
|
|
File _image = widget.files[index];
|
|
|
|
|
return MultiFilesPickerItem(
|
|
|
|
|
file: _image,
|
|
|
|
|
enabled: widget.enabled,
|
|
|
|
|
onRemoveTap: (image) {
|
|
|
|
|
if (!widget.enabled) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
widget.files.remove(image);
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fromFilePicker(Subtitle subtitle) async {
|
|
|
|
|
|