✨ Apply texas's pathc to reblur content
This commit is contained in:
		| @@ -802,8 +802,8 @@ class _CloudFileListEntry extends HookConsumerWidget { | ||||
|     this.onTap, | ||||
|   }); | ||||
|  | ||||
| @override | ||||
| Widget build(BuildContext context, WidgetRef ref) { | ||||
|   @override | ||||
|   Widget build(BuildContext context, WidgetRef ref) { | ||||
|     final dataSaving = ref.watch( | ||||
|       appSettingsNotifierProvider.select((s) => s.dataSavingMode), | ||||
|     ); | ||||
| @@ -812,7 +812,8 @@ Widget build(BuildContext context, WidgetRef ref) { | ||||
|     final lockedByDS = dataSaving && !showDataSaving.value; | ||||
|     final lockedByMature = file.sensitiveMarks.isNotEmpty && !showMature.value; | ||||
|     final meta = file.fileMeta is Map ? file.fileMeta as Map : const {}; | ||||
|     final ratio = (meta['ratio'] is num && (meta['ratio'] as num) != 0) | ||||
|     final ratio = | ||||
|         (meta['ratio'] is num && (meta['ratio'] as num) != 0) | ||||
|             ? (meta['ratio'] as num).toDouble() | ||||
|             : 1.0; | ||||
|  | ||||
| @@ -835,7 +836,8 @@ Widget build(BuildContext context, WidgetRef ref) { | ||||
|     } | ||||
|  | ||||
|     final bool fullyUnlocked = !lockedByDS && !lockedByMature; | ||||
|     Widget fg = fullyUnlocked | ||||
|     Widget fg = | ||||
|         fullyUnlocked | ||||
|             ? (isImage | ||||
|                 ? CloudFileWidget( | ||||
|                   item: file, | ||||
| @@ -849,26 +851,25 @@ Widget build(BuildContext context, WidgetRef ref) { | ||||
|                   heroTag: heroTag, | ||||
|                   fit: BoxFit.contain, | ||||
|                   useInternalGate: false, | ||||
|             ) | ||||
|         ) | ||||
|                 )) | ||||
|             : AspectRatio(aspectRatio: ratio, child: const SizedBox.shrink()); | ||||
|  | ||||
|     Widget overlays; | ||||
|     if (lockedByDS) { | ||||
|       overlays = _DataSavingOverlay(); | ||||
|     } else if (lockedByMature) { | ||||
|         overlays = _SensitiveOverlay(file: file); | ||||
|     } else if (file.sensitiveMarks.isNotEmpty) { | ||||
|       overlays = _SensitiveOverlay( | ||||
|         file: file, | ||||
|         isRevealed: showMature.value, | ||||
|         onHide: () => showMature.value = false, | ||||
|       ); | ||||
|     } else { | ||||
|       overlays = const SizedBox.shrink(); | ||||
|     } | ||||
|  | ||||
|     final content = Stack( | ||||
|       fit: StackFit.expand, | ||||
|         children: [ | ||||
|             if (isImage) Positioned.fill(child: bg), | ||||
|             fg, | ||||
|             overlays, | ||||
|         ], | ||||
|       children: [if (isImage) Positioned.fill(child: bg), fg, overlays], | ||||
|     ); | ||||
|  | ||||
|     return InkWell( | ||||
| @@ -884,15 +885,36 @@ Widget build(BuildContext context, WidgetRef ref) { | ||||
|       }, | ||||
|       child: content, | ||||
|     ); | ||||
| } | ||||
|   } | ||||
| } | ||||
|  | ||||
| class _SensitiveOverlay extends StatelessWidget { | ||||
|   final SnCloudFile file; | ||||
|   const _SensitiveOverlay({required this.file}); | ||||
|   final VoidCallback? onHide; | ||||
|   final bool isRevealed; | ||||
|  | ||||
|   const _SensitiveOverlay({ | ||||
|     required this.file, | ||||
|     this.onHide, | ||||
|     this.isRevealed = false, | ||||
|   }); | ||||
|  | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     if (isRevealed) { | ||||
|       return Positioned( | ||||
|         top: 3, | ||||
|         left: 4, | ||||
|         child: IconButton( | ||||
|           iconSize: 16, | ||||
|           constraints: const BoxConstraints(), | ||||
|           icon: const Icon(Icons.visibility_off, color: Colors.white), | ||||
|           tooltip: 'Blur content', | ||||
|           onPressed: onHide, | ||||
|         ), | ||||
|       ); | ||||
|     } | ||||
|  | ||||
|     return BackdropFilter( | ||||
|       filter: ImageFilter.blur(sigmaX: 64, sigmaY: 64), | ||||
|       child: Container( | ||||
| @@ -928,6 +950,7 @@ class _DataSavingOverlay extends StatelessWidget { | ||||
|     ); | ||||
|   } | ||||
| } | ||||
|  | ||||
| class _OverlayCard extends StatelessWidget { | ||||
|   final IconData icon; | ||||
|   final String title; | ||||
| @@ -956,15 +979,20 @@ class _OverlayCard extends StatelessWidget { | ||||
|         children: [ | ||||
|           Icon(icon, color: Colors.white, size: 24), | ||||
|           const Gap(4), | ||||
|           Text(title, | ||||
|           Text( | ||||
|             title, | ||||
|             style: const TextStyle( | ||||
|                   color: Colors.white, fontWeight: FontWeight.w600), | ||||
|               textAlign: TextAlign.center), | ||||
|           Text(subtitle, | ||||
|               style: const TextStyle(color: Colors.white, fontSize: 13)), | ||||
|               color: Colors.white, | ||||
|               fontWeight: FontWeight.w600, | ||||
|             ), | ||||
|             textAlign: TextAlign.center, | ||||
|           ), | ||||
|           Text( | ||||
|             subtitle, | ||||
|             style: const TextStyle(color: Colors.white, fontSize: 13), | ||||
|           ), | ||||
|           const Gap(4), | ||||
|           Text(hint, | ||||
|               style: const TextStyle(color: Colors.white, fontSize: 11)), | ||||
|           Text(hint, style: const TextStyle(color: Colors.white, fontSize: 11)), | ||||
|         ], | ||||
|       ), | ||||
|     ); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user