mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-12-26 04:48:51 +00:00
Added support of weblink posts
This commit is contained in:
parent
54482fc70f
commit
4085c6cdd5
@ -23,6 +23,7 @@ import 'package:comunic/utils/navigation_utils.dart';
|
||||
import 'package:comunic/utils/post_utils.dart';
|
||||
import 'package:comunic/utils/ui_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
/// Single posts tile
|
||||
///
|
||||
@ -166,6 +167,10 @@ class _PostTileState extends State<PostTile> {
|
||||
postContent = _buildPostImage();
|
||||
break;
|
||||
|
||||
case PostKind.WEB_LINK:
|
||||
postContent = _buildPostWebLink();
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
|
||||
@ -249,6 +254,41 @@ class _PostTileState extends State<PostTile> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPostWebLink() {
|
||||
return Card(
|
||||
color: Color.fromRGBO(0xf7, 0xf7, 0xf7, 1),
|
||||
child: InkWell(
|
||||
onTap: () => launch(widget.post.linkURL),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 8.0),
|
||||
child: NetworkImageWidget(
|
||||
url: widget.post.linkImage,
|
||||
width: 70,
|
||||
roundedEdges: false,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(htmlDecodeCharacters(widget.post.linkTitle),
|
||||
style: TextStyle(fontSize: 20.0)),
|
||||
Text(
|
||||
widget.post.linkURL,
|
||||
maxLines: 3,
|
||||
),
|
||||
Text(htmlDecodeCharacters(widget.post.linkDescription))
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Build the list of comments
|
||||
Widget _buildComments() {
|
||||
assert(widget.post.hasComments);
|
||||
|
@ -1,6 +1,7 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:html/parser.dart';
|
||||
|
||||
/// User interface utilities
|
||||
///
|
||||
@ -171,3 +172,8 @@ Widget smartInputCounterWidgetBuilder(
|
||||
@required bool isFocused,
|
||||
}) =>
|
||||
currentLength > 0 ? Text("$currentLength/$maxLength") : Container();
|
||||
|
||||
/// Parse an HTML String to decode special characters
|
||||
String htmlDecodeCharacters(String input) {
|
||||
return parse(input).documentElement.text;
|
||||
}
|
||||
|
14
pubspec.lock
14
pubspec.lock
@ -57,6 +57,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.6"
|
||||
csslib:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: csslib
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.16.0"
|
||||
cupertino_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -88,6 +95,13 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
html:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: html
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.14.0+2"
|
||||
http:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -42,6 +42,9 @@ dependencies:
|
||||
# URL launcher is useful to open URL in the phone browser
|
||||
url_launcher: ^5.0.2
|
||||
|
||||
# Allows to parse HTML special characters
|
||||
html: ^0.14.0+2
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
Loading…
Reference in New Issue
Block a user