mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 12:59:21 +00:00
Can enlarge conversation images
This commit is contained in:
parent
afd999400e
commit
eb5b6d6fae
@ -3,6 +3,7 @@ import 'package:comunic/models/conversation_message.dart';
|
|||||||
import 'package:comunic/models/user.dart';
|
import 'package:comunic/models/user.dart';
|
||||||
import 'package:comunic/utils/account_utils.dart';
|
import 'package:comunic/utils/account_utils.dart';
|
||||||
import 'package:comunic/utils/date_utils.dart';
|
import 'package:comunic/utils/date_utils.dart';
|
||||||
|
import 'package:comunic/utils/ui_utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
/// Conversation message tile
|
/// Conversation message tile
|
||||||
@ -47,10 +48,12 @@ class ConversationMessageTile extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Build widget image
|
/// Build widget image
|
||||||
Widget _buildMessageImage() {
|
Widget _buildMessageImage(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
margin: EdgeInsets.only(bottom: 2),
|
margin: EdgeInsets.only(bottom: 2),
|
||||||
child: Material(
|
child: Material(
|
||||||
|
child: InkWell(
|
||||||
|
onTap: (){showImageFullScreen(context, message.imageURL);},
|
||||||
child: CachedNetworkImage(
|
child: CachedNetworkImage(
|
||||||
imageUrl: message.imageURL,
|
imageUrl: message.imageURL,
|
||||||
width: 200.0,
|
width: 200.0,
|
||||||
@ -73,6 +76,7 @@ class ConversationMessageTile extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
borderRadius: BorderRadius.all(Radius.circular(8.0)),
|
borderRadius: BorderRadius.all(Radius.circular(8.0)),
|
||||||
clipBehavior: Clip.hardEdge,
|
clipBehavior: Clip.hardEdge,
|
||||||
),
|
),
|
||||||
@ -94,7 +98,7 @@ class ConversationMessageTile extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Build a message of the current user
|
/// Build a message of the current user
|
||||||
Widget _buildRightMessage() {
|
Widget _buildRightMessage(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
margin: EdgeInsets.only(bottom: isLastMessage ? 20.0 : 10.0),
|
margin: EdgeInsets.only(bottom: isLastMessage ? 20.0 : 10.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
@ -108,7 +112,7 @@ class ConversationMessageTile extends StatelessWidget {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
// Text image
|
// Text image
|
||||||
Container(
|
Container(
|
||||||
child: message.hasImage ? _buildMessageImage() : null,
|
child: message.hasImage ? _buildMessageImage(context) : null,
|
||||||
),
|
),
|
||||||
|
|
||||||
// Text message
|
// Text message
|
||||||
@ -152,7 +156,7 @@ class ConversationMessageTile extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Build a message of a peer user
|
/// Build a message of a peer user
|
||||||
Widget _buildLeftMessage() {
|
Widget _buildLeftMessage(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
margin: EdgeInsets.only(bottom: isLastMessage ? 20.0 : 5.0),
|
margin: EdgeInsets.only(bottom: isLastMessage ? 20.0 : 5.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -179,7 +183,7 @@ class ConversationMessageTile extends StatelessWidget {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
// Text image
|
// Text image
|
||||||
Container(
|
Container(
|
||||||
child: message.hasImage ? _buildMessageImage() : null,
|
child: message.hasImage ? _buildMessageImage(context) : null,
|
||||||
),
|
),
|
||||||
|
|
||||||
// Text message
|
// Text message
|
||||||
@ -221,7 +225,7 @@ class ConversationMessageTile extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return userID() == message.userID
|
return userID() == message.userID
|
||||||
? _buildRightMessage()
|
? _buildRightMessage(context)
|
||||||
: _buildLeftMessage();
|
: _buildLeftMessage(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
/// User interface utilities
|
/// User interface utilities
|
||||||
@ -9,7 +10,6 @@ Widget buildCenteredProgressBar() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Build and return a full loading page
|
/// Build and return a full loading page
|
||||||
Widget buildLoadingPage() {
|
Widget buildLoadingPage() {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@ -48,3 +48,15 @@ Widget buildErrorCard(String message, {List<Widget> actions}) {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Show an image with a given [url] in full screen
|
||||||
|
void showImageFullScreen(BuildContext context, String url) {
|
||||||
|
Navigator.of(context).push(MaterialPageRoute(builder: (c) {
|
||||||
|
|
||||||
|
// TODO : add better support later
|
||||||
|
return CachedNetworkImage(
|
||||||
|
imageUrl: url,
|
||||||
|
);
|
||||||
|
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user