Expandable room icons
This commit is contained in:
parent
ab61338382
commit
690d2549bc
10 changed files with 139 additions and 87 deletions
48
lib/widgets/chat_page/expandable_image.dart
Normal file
48
lib/widgets/chat_page/expandable_image.dart
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import "dart:math";
|
||||
import "package:cross_cache/cross_cache.dart";
|
||||
import "package:flutter/material.dart";
|
||||
import "package:hooks_riverpod/hooks_riverpod.dart";
|
||||
import "package:nexus/controllers/cross_cache_controller.dart";
|
||||
import "package:nexus/helpers/extensions/get_headers.dart";
|
||||
import "package:nexus/widgets/error_dialog.dart";
|
||||
|
||||
class ExpandableImage extends ConsumerWidget {
|
||||
final Widget child;
|
||||
final String? source;
|
||||
const ExpandableImage(this.source, {required this.child, super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) => InkWell(
|
||||
onTap: source == null
|
||||
? null
|
||||
: () => showDialog(
|
||||
context: context,
|
||||
builder: (_) => LayoutBuilder(
|
||||
builder: (context, constraints) => Dialog(
|
||||
backgroundColor: Colors.transparent,
|
||||
insetPadding: EdgeInsets.all(constraints.maxWidth / 100),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
minWidth: min(constraints.maxWidth, 1000),
|
||||
),
|
||||
child: InteractiveViewer(
|
||||
child: Image(
|
||||
fit: BoxFit.contain,
|
||||
errorBuilder: (_, error, stackTrace) => ErrorDialog(
|
||||
"Loading failed for $source\nError: $error",
|
||||
stackTrace,
|
||||
),
|
||||
image: CachedNetworkImage(
|
||||
source!,
|
||||
ref.watch(CrossCacheController.provider),
|
||||
headers: ref.headers,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue