Compare commits

...

2 Commits

3 changed files with 65 additions and 10 deletions

View File

@ -1,3 +1,4 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
@ -44,6 +45,17 @@ class ConversationsPageState extends State<ConversationsPage> with TickerProvide
_controller.dispose();
super.dispose();
}
Future<void> _showAvatarFullsize(BuildContext context, String path) async {
await showDialog<void>(
context: context,
builder: (context) {
return IgnorePointer(
child: Image.file(File(path)),
);
},
);
}
Widget _listWrapper(BuildContext context, ConversationsState state) {
final maxTextWidth = MediaQuery.of(context).size.width * 0.6;
@ -57,6 +69,9 @@ class ConversationsPageState extends State<ConversationsPage> with TickerProvide
maxTextWidth,
item,
true,
avatarOnTap: item.avatarUrl.isNotEmpty ?
() => _showAvatarFullsize(context, item.avatarUrl) :
null,
key: ValueKey('conversationRow;${item.jid}'),
);

View File

@ -1,3 +1,4 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
import 'package:moxxyv2/i18n/strings.g.dart';
@ -14,6 +15,34 @@ class ConversationProfileHeader extends StatelessWidget {
const ConversationProfileHeader(this.conversation, { super.key });
final Conversation conversation;
Future<void> _showAvatarFullsize(BuildContext context) async {
await showDialog<void>(
context: context,
builder: (context) {
return IgnorePointer(
child: Image.file(File(conversation.avatarUrl)),
);
},
);
}
Widget _buildAvatar(BuildContext context) {
final avatar = AvatarWrapper(
radius: 110,
avatarUrl: conversation.avatarUrl,
altText: conversation.title,
);
if (conversation.avatarUrl.isNotEmpty) {
return InkWell(
onTap: () => _showAvatarFullsize(context),
child: avatar,
);
}
return avatar;
}
@override
Widget build(BuildContext context) {
//final subscribed = conversation.subscription == 'both' || conversation.subscription == 'to';
@ -23,11 +52,7 @@ class ConversationProfileHeader extends StatelessWidget {
Hero(
tag: 'conversation_profile_picture',
child: Material(
child: AvatarWrapper(
radius: 110,
avatarUrl: conversation.avatarUrl,
altText: conversation.title,
),
child: _buildAvatar(context),
),
),
Padding(

View File

@ -20,6 +20,7 @@ class ConversationsListRow extends StatefulWidget {
this.showTimestamp = true,
this.showLock = false,
this.extra,
this.avatarOnTap,
super.key,
}
);
@ -28,6 +29,7 @@ class ConversationsListRow extends StatefulWidget {
final bool update; // Should a timer run to update the timestamp
final bool showLock;
final bool showTimestamp;
final void Function()? avatarOnTap;
final Widget? extra;
@override
@ -80,6 +82,23 @@ class ConversationsListRowState extends State<ConversationsListRow> {
super.dispose();
}
Widget _buildAvatar() {
final avatar = AvatarWrapper(
radius: 35,
avatarUrl: widget.conversation.avatarUrl,
altText: widget.conversation.title,
);
if (widget.avatarOnTap != null) {
return InkWell(
onTap: widget.avatarOnTap,
child: avatar,
);
}
return avatar;
}
Widget _buildLastMessageBody() {
if (widget.conversation.isTyping) {
return const TypingIndicatorWidget(Colors.black, Colors.white);
@ -165,11 +184,7 @@ class ConversationsListRowState extends State<ConversationsListRow> {
padding: const EdgeInsets.all(8),
child: Row(
children: [
AvatarWrapper(
radius: 35,
avatarUrl: widget.conversation.avatarUrl,
altText: widget.conversation.title,
),
_buildAvatar(),
Padding(
padding: const EdgeInsets.only(left: 8),
child: LimitedBox(