1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 04:49:21 +00:00

Can enlarge conversation images

This commit is contained in:
Pierre HUBERT 2019-04-26 11:34:24 +02:00
parent afd999400e
commit eb5b6d6fae
2 changed files with 43 additions and 27 deletions

View File

@ -3,6 +3,7 @@ import 'package:comunic/models/conversation_message.dart';
import 'package:comunic/models/user.dart';
import 'package:comunic/utils/account_utils.dart';
import 'package:comunic/utils/date_utils.dart';
import 'package:comunic/utils/ui_utils.dart';
import 'package:flutter/material.dart';
/// Conversation message tile
@ -47,31 +48,34 @@ class ConversationMessageTile extends StatelessWidget {
}
/// Build widget image
Widget _buildMessageImage() {
Widget _buildMessageImage(BuildContext context) {
return Container(
margin: EdgeInsets.only(bottom: 2),
child: Material(
child: CachedNetworkImage(
imageUrl: message.imageURL,
width: 200.0,
height: 200.0,
fit: BoxFit.cover,
placeholder: (c, s) => Container(
width: 200,
height: 200,
color: Colors.lightBlueAccent,
child: Center(
child: CircularProgressIndicator(),
child: InkWell(
onTap: (){showImageFullScreen(context, message.imageURL);},
child: CachedNetworkImage(
imageUrl: message.imageURL,
width: 200.0,
height: 200.0,
fit: BoxFit.cover,
placeholder: (c, s) => Container(
width: 200,
height: 200,
color: Colors.lightBlueAccent,
child: Center(
child: CircularProgressIndicator(),
),
),
),
errorWidget: (c, s, o) => Container(
width: 200,
height: 200,
color: Colors.red,
child: Center(
child: Icon(Icons.error, color: Colors.white,)
errorWidget: (c, s, o) => Container(
width: 200,
height: 200,
color: Colors.red,
child: Center(
child: Icon(Icons.error, color: Colors.white,)
),
),
),
),
),
borderRadius: BorderRadius.all(Radius.circular(8.0)),
clipBehavior: Clip.hardEdge,
@ -94,7 +98,7 @@ class ConversationMessageTile extends StatelessWidget {
}
/// Build a message of the current user
Widget _buildRightMessage() {
Widget _buildRightMessage(BuildContext context) {
return Container(
margin: EdgeInsets.only(bottom: isLastMessage ? 20.0 : 10.0),
child: Row(
@ -108,7 +112,7 @@ class ConversationMessageTile extends StatelessWidget {
children: <Widget>[
// Text image
Container(
child: message.hasImage ? _buildMessageImage() : null,
child: message.hasImage ? _buildMessageImage(context) : null,
),
// Text message
@ -152,7 +156,7 @@ class ConversationMessageTile extends StatelessWidget {
}
/// Build a message of a peer user
Widget _buildLeftMessage() {
Widget _buildLeftMessage(BuildContext context) {
return Container(
margin: EdgeInsets.only(bottom: isLastMessage ? 20.0 : 5.0),
child: Column(
@ -179,7 +183,7 @@ class ConversationMessageTile extends StatelessWidget {
children: <Widget>[
// Text image
Container(
child: message.hasImage ? _buildMessageImage() : null,
child: message.hasImage ? _buildMessageImage(context) : null,
),
// Text message
@ -221,7 +225,7 @@ class ConversationMessageTile extends StatelessWidget {
@override
Widget build(BuildContext context) {
return userID() == message.userID
? _buildRightMessage()
: _buildLeftMessage();
? _buildRightMessage(context)
: _buildLeftMessage(context);
}
}

View File

@ -1,3 +1,4 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
/// User interface utilities
@ -9,7 +10,6 @@ Widget buildCenteredProgressBar() {
);
}
/// Build and return a full loading page
Widget buildLoadingPage() {
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,
);
}));
}