Remove flutter chat #26
1 changed files with 82 additions and 82 deletions
constrain images to a max size
commit
b9e42ec51b
|
|
@ -96,29 +96,21 @@ class RenderEvent extends ConsumerWidget {
|
||||||
Flexible(child: timestamp),
|
Flexible(child: timestamp),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
ClipRRect(
|
Card(
|
||||||
borderRadius: textOnly
|
color:
|
||||||
? BorderRadius.zero
|
ref.watch(
|
||||||
: BorderRadius.all(Radius.circular(8)),
|
ClientStateController.provider.select(
|
||||||
child: Container(
|
(value) => value?.userId,
|
||||||
padding: textOnly
|
),
|
||||||
? EdgeInsets.zero
|
) ==
|
||||||
: EdgeInsets.symmetric(vertical: 8, horizontal: 12),
|
event.sender
|
||||||
decoration: textOnly
|
? (event.eventId.startsWith("~")
|
||||||
? null
|
? colorScheme.onPrimary
|
||||||
: BoxDecoration(
|
: colorScheme.primaryContainer)
|
||||||
color:
|
: colorScheme.surfaceContainer,
|
||||||
ref.watch(
|
|
||||||
ClientStateController.provider.select(
|
child: Padding(
|
||||||
(value) => value?.userId,
|
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||||
),
|
|
||||||
) ==
|
|
||||||
event.sender
|
|
||||||
? (event.eventId.startsWith("~")
|
|
||||||
? colorScheme.onPrimary
|
|
||||||
: colorScheme.primaryContainer)
|
|
||||||
: colorScheme.surfaceContainer,
|
|
||||||
),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
|
@ -185,72 +177,80 @@ class RenderEvent extends ConsumerWidget {
|
||||||
).colorScheme.primary,
|
).colorScheme.primary,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (event.content case ImageMessageContent(
|
|
||||||
:final url,
|
if (!textOnly)
|
||||||
:final info,
|
if (event.content case ImageMessageContent(
|
||||||
))
|
:final url,
|
||||||
switch (url?.mxcToHttps(
|
:final info,
|
||||||
ref.watch(
|
))
|
||||||
ClientStateController.provider.select(
|
switch (url?.mxcToHttps(
|
||||||
(value) => value!.homeserverUrl!,
|
ref.watch(
|
||||||
),
|
ClientStateController.provider.select(
|
||||||
),
|
(value) => value!.homeserverUrl!,
|
||||||
)) {
|
|
||||||
final url? => ExpandableImage(
|
|
||||||
url.toString(),
|
|
||||||
child: ClipRRect(
|
|
||||||
borderRadius: BorderRadius.all(
|
|
||||||
Radius.circular(8),
|
|
||||||
),
|
),
|
||||||
child: Image(
|
),
|
||||||
image: CachedNetworkImage(
|
)) {
|
||||||
url.toString(),
|
final url? => ConstrainedBox(
|
||||||
ref.watch(
|
constraints: BoxConstraints.loose(
|
||||||
CrossCacheController.provider,
|
Size.fromWidth(500),
|
||||||
|
),
|
||||||
|
child: ExpandableImage(
|
||||||
|
url.toString(),
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.all(
|
||||||
|
Radius.circular(8),
|
||||||
),
|
),
|
||||||
headers: ref.headers,
|
child: Image(
|
||||||
),
|
image: CachedNetworkImage(
|
||||||
width: info?.width,
|
url.toString(),
|
||||||
loadingBuilder:
|
ref.watch(
|
||||||
(_, child, loadingProgress) =>
|
CrossCacheController.provider,
|
||||||
loadingProgress == null
|
),
|
||||||
? child
|
headers: ref.headers,
|
||||||
: switch (info?.blurHash) {
|
),
|
||||||
final blurHash? => SizedBox(
|
width: info?.width,
|
||||||
width:
|
loadingBuilder:
|
||||||
info?.width ??
|
(_, child, loadingProgress) =>
|
||||||
info?.height ??
|
loadingProgress == null
|
||||||
200,
|
? child
|
||||||
height:
|
: switch (info?.blurHash) {
|
||||||
info?.height ??
|
final blurHash? =>
|
||||||
info?.width ??
|
SizedBox(
|
||||||
200,
|
width:
|
||||||
child: BlurHash(
|
info?.width ??
|
||||||
hash: blurHash,
|
info?.height ??
|
||||||
|
200,
|
||||||
|
height:
|
||||||
|
info?.height ??
|
||||||
|
info?.width ??
|
||||||
|
200,
|
||||||
|
child: BlurHash(
|
||||||
|
hash: blurHash,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
_ => Loading(),
|
||||||
|
},
|
||||||
|
errorBuilder:
|
||||||
|
(context, error, stackTrace) =>
|
||||||
|
Center(
|
||||||
|
child: Text(
|
||||||
|
"Image Failed to Load",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.error,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
_ => Loading(),
|
),
|
||||||
},
|
),
|
||||||
errorBuilder:
|
|
||||||
(context, error, stackTrace) =>
|
|
||||||
Center(
|
|
||||||
child: Text(
|
|
||||||
"Image Failed to Load",
|
|
||||||
style: TextStyle(
|
|
||||||
color: Theme.of(
|
|
||||||
context,
|
|
||||||
).colorScheme.error,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
_ => Text(
|
||||||
_ => Text(
|
"Nexus currently cannot handle encrypted media",
|
||||||
"Nexus currently cannot handle encrypted media",
|
style: errorStyle,
|
||||||
style: errorStyle,
|
),
|
||||||
),
|
},
|
||||||
},
|
|
||||||
if (event.lastEditRowId != null && !textOnly)
|
if (event.lastEditRowId != null && !textOnly)
|
||||||
Text(
|
Text(
|
||||||
"(edited)",
|
"(edited)",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue