| @@ -228,53 +228,123 @@ class _WidgetItemMedia extends StatelessWidget { | |||
| _WidgetItemMedia({required this.item, required this.deleteImage}); | |||
| @override | |||
| Widget build(BuildContext context) { | |||
| return GestureDetector( | |||
| onTap: () { | |||
| print("Show preview image or video"); | |||
| }, | |||
| child: Stack( | |||
| alignment: Alignment.topRight, | |||
| children: <Widget>[ | |||
| Positioned.fill( | |||
| child: item.isVideo ?? false | |||
| ? VideoWidget( | |||
| pathFile: item.pathFile ?? '', | |||
| isServerFile: item.isServerFile, | |||
| play: false, | |||
| ) | |||
| : Container( | |||
| margin: EdgeInsets.all(4.0), | |||
| decoration: BoxDecoration( | |||
| color: Colors.white, | |||
| border: Border.all(color: Colors.grey), | |||
| borderRadius: BorderRadius.all( | |||
| Radius.circular(8.0), | |||
| void _showPhotoPreview(BuildContext context) { | |||
| if (item.isVideo ?? false) return; | |||
| showDialog( | |||
| context: context, | |||
| builder: (context) => Dialog( | |||
| backgroundColor: Colors.transparent, | |||
| insetPadding: EdgeInsets.all(20), | |||
| child: Container( | |||
| decoration: BoxDecoration( | |||
| color: Colors.white, | |||
| borderRadius: BorderRadius.circular(16), | |||
| boxShadow: [ | |||
| BoxShadow( | |||
| color: Colors.black.withOpacity(0.1), | |||
| blurRadius: 10, | |||
| spreadRadius: 2, | |||
| ), | |||
| ], | |||
| ), | |||
| child: Stack( | |||
| children: [ | |||
| Container( | |||
| constraints: BoxConstraints( | |||
| maxHeight: MediaQuery.of(context).size.height * 0.7, | |||
| ), | |||
| child: ClipRRect( | |||
| borderRadius: BorderRadius.circular(16), | |||
| child: item.isServerFile | |||
| ? CachedNetworkImage( | |||
| imageUrl: item.pathFile ?? '', | |||
| fit: BoxFit.contain, | |||
| placeholder: (context, url) => Center( | |||
| child: CircularProgressIndicator(), | |||
| ), | |||
| errorWidget: (context, url, error) => Center( | |||
| child: Icon(Icons.error, color: Colors.red), | |||
| ), | |||
| ) | |||
| : Image.file( | |||
| File(item.pathFile ?? ''), | |||
| fit: BoxFit.contain, | |||
| ), | |||
| child: item.isServerFile | |||
| ? CachedNetworkImage( | |||
| placeholder: (context, url) => Icon(Icons.crop_original), | |||
| imageUrl: item.pathFile ?? '', | |||
| ) | |||
| : Image.file(File(item.pathFile ?? '')), | |||
| )), | |||
| Positioned.fill( | |||
| top: -(120.0 - 36), | |||
| right: -(120.0 - 36), | |||
| child: IconButton( | |||
| icon: Icon( | |||
| Icons.delete, | |||
| color: Colors.redAccent, | |||
| size: 24, | |||
| ), | |||
| ), | |||
| Positioned( | |||
| top: 0, | |||
| right: 0, | |||
| child: Material( | |||
| color: Colors.transparent, | |||
| child: IconButton( | |||
| icon: Icon(Icons.close, color: Colors.black), | |||
| onPressed: () => Navigator.pop(context), | |||
| ), | |||
| ), | |||
| ) | |||
| ], | |||
| ), | |||
| ), | |||
| ), | |||
| ); | |||
| } | |||
| @override | |||
| Widget build(BuildContext context) { | |||
| return Stack( | |||
| alignment: Alignment.topRight, | |||
| children: <Widget>[ | |||
| GestureDetector( | |||
| onTap: () => _showPhotoPreview(context), | |||
| child: Container( | |||
| width: 120, | |||
| height: 120, | |||
| child: item.isVideo ?? false | |||
| ? VideoWidget( | |||
| pathFile: item.pathFile ?? '', | |||
| isServerFile: item.isServerFile, | |||
| play: false, | |||
| ) | |||
| : Container( | |||
| margin: EdgeInsets.all(4.0), | |||
| decoration: BoxDecoration( | |||
| color: Colors.white, | |||
| border: Border.all(color: Colors.grey), | |||
| borderRadius: BorderRadius.all( | |||
| Radius.circular(8.0), | |||
| ), | |||
| ), | |||
| onPressed: () { | |||
| print("On tap delete media"); | |||
| deleteImage(item); | |||
| })) | |||
| ], | |||
| )); | |||
| child: item.isServerFile | |||
| ? CachedNetworkImage( | |||
| placeholder: (context, url) => Icon(Icons.crop_original), | |||
| imageUrl: item.pathFile ?? '', | |||
| ) | |||
| : Image.file(File(item.pathFile ?? '')), | |||
| ), | |||
| ), | |||
| ), | |||
| Positioned( | |||
| top: 0, | |||
| right: 0, | |||
| child: Material( | |||
| color: Colors.transparent, | |||
| child: IconButton( | |||
| icon: Icon( | |||
| Icons.delete, | |||
| color: Colors.redAccent, | |||
| size: 24, | |||
| ), | |||
| onPressed: () { | |||
| print("On tap delete media"); | |||
| deleteImage(item); | |||
| }, | |||
| ), | |||
| ), | |||
| ) | |||
| ], | |||
| ); | |||
| } | |||
| } | |||