fullImagePreview method
Implementation
Widget fullImagePreview() {
return GestureDetector(
onTap: () {
setState(() {
isFullScreen = !isFullScreen;
});
},
child: SizedBox(
height: MediaQuery.of(context).size.height,
child: Stack(
children: [
PageView.builder(
controller: previewPageController,
itemCount: widget._controller.files.length,
onPageChanged: (index) {
setState(() {
currentIndex = index;
});
},
itemBuilder: (BuildContext context, int index) {
final file = widget._controller.files.elementAt(index);
return kIsWeb
? DisplayMediaWeb(
file: file,
aspectRatio: widget
.controller.cameraController?.value.aspectRatio)
: Center(
child: file.getMediaType() == MediaType.image
? Image.file(file.toFile()!)
: InlineVideoPlayer(
file: file,
));
},
),
isFullScreen
? appbar(
backArrowAction: () {
if (widget._controller.cameraController != null) {
widget._controller.cameraController!.resumePreview();
}
setState(() {
showPreviewPage = false;
});
},
deleteButtonAction: deleteImages,
onShareButtonAction: () async {
try {
final file =
widget._controller.files.elementAt(currentIndex);
await Share.shareXFiles([XFile('${file.path}')]);
} on Exception catch (e) {
widget.onError?.call(e);
}
})
: const SizedBox.shrink(),
Visibility(
visible: isFullScreen,
child: Align(
alignment: Alignment.bottomCenter,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
GestureDetector(
onTap: () {
if (widget._controller.minCount != null &&
(widget._controller.files.length <
widget._controller.minCount!)) {
final errorMessage = widget
._controller.minCountMessage ??
Utils.translateWithFallback(
'ensemble.input.minCountMessage',
'Minimum ${widget._controller.minCount} capture are required');
ToastController().showToast(
context,
ShowToastAction(
type: ToastType.error,
message: errorMessage,
alignment: Alignment.topCenter,
dismissible: true,
duration: 3),
null);
return;
}
Navigator.pop(context, widget._controller.files);
widget.onComplete?.call();
},
child: Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.white),
borderRadius: BorderRadius.circular(24.0)),
padding: const EdgeInsets.symmetric(
horizontal: 12.0, vertical: 4.0),
child: Text(
'Done',
style: TextStyle(
color:
hasPermission ? Colors.black : Colors.white,
fontSize: 18.0,
fontWeight: FontWeight.w500),
),
),
),
const SizedBox(height: 8),
Container(
color: Colors.black.withValues(alpha: 0.4),
child: mediaThumbnail(isBorderView: true)),
],
),
),
)
],
),
),
);
}