Little tweaks
This commit is contained in:
parent
bb789b3ac9
commit
ccfbc0188c
|
@ -33,12 +33,7 @@ class Post extends StatelessWidget {
|
||||||
final String instanceUrl;
|
final String instanceUrl;
|
||||||
final bool fullPost;
|
final bool fullPost;
|
||||||
|
|
||||||
/// nullable
|
Post(this.post, {this.fullPost = false}) : instanceUrl = post.instanceUrl;
|
||||||
final String postUrlDomain;
|
|
||||||
|
|
||||||
Post(this.post, {this.fullPost = false})
|
|
||||||
: instanceUrl = post.instanceUrl,
|
|
||||||
postUrlDomain = post.url != null ? post.url.split('/')[2] : null;
|
|
||||||
|
|
||||||
// == ACTIONS ==
|
// == ACTIONS ==
|
||||||
|
|
||||||
|
@ -73,6 +68,14 @@ class Post extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
|
|
||||||
|
final urlDomain = () {
|
||||||
|
if (post.url == null) return null;
|
||||||
|
|
||||||
|
var url = post.url.split('/')[2];
|
||||||
|
if (url.startsWith('www.')) return url.substring(4);
|
||||||
|
return url;
|
||||||
|
}();
|
||||||
|
|
||||||
// TODO: add NSFW, locked, removed, deleted, stickied
|
// TODO: add NSFW, locked, removed, deleted, stickied
|
||||||
/// assemble info section
|
/// assemble info section
|
||||||
Widget info() => Column(children: [
|
Widget info() => Column(children: [
|
||||||
|
@ -171,8 +174,8 @@ class Post extends StatelessWidget {
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: 'NSFW',
|
text: 'NSFW',
|
||||||
style: TextStyle(color: Colors.red)),
|
style: TextStyle(color: Colors.red)),
|
||||||
if (postUrlDomain != null)
|
if (urlDomain != null)
|
||||||
TextSpan(text: ' · $postUrlDomain'),
|
TextSpan(text: ' · $urlDomain'),
|
||||||
if (post.removed) TextSpan(text: ' · REMOVED'),
|
if (post.removed) TextSpan(text: ' · REMOVED'),
|
||||||
if (post.deleted) TextSpan(text: ' · DELETED'),
|
if (post.deleted) TextSpan(text: ' · DELETED'),
|
||||||
],
|
],
|
||||||
|
@ -200,7 +203,8 @@ class Post extends StatelessWidget {
|
||||||
padding: const EdgeInsets.only(left: 10, right: 10, bottom: 10),
|
padding: const EdgeInsets.only(left: 10, right: 10, bottom: 10),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Flexible(
|
Expanded(
|
||||||
|
flex: 100,
|
||||||
child: Text(
|
child: Text(
|
||||||
'${post.name}',
|
'${post.name}',
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
|
@ -210,11 +214,8 @@ class Post extends StatelessWidget {
|
||||||
),
|
),
|
||||||
if (post.url != null &&
|
if (post.url != null &&
|
||||||
whatType(post.url) == MediaType.other &&
|
whatType(post.url) == MediaType.other &&
|
||||||
post.thumbnailUrl != null)
|
post.thumbnailUrl != null) ...[
|
||||||
Spacer(),
|
Spacer(),
|
||||||
if (post.url != null &&
|
|
||||||
whatType(post.url) == MediaType.other &&
|
|
||||||
post.thumbnailUrl != null)
|
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: _openLink,
|
onTap: _openLink,
|
||||||
child: Stack(children: [
|
child: Stack(children: [
|
||||||
|
@ -238,6 +239,7 @@ class Post extends StatelessWidget {
|
||||||
)
|
)
|
||||||
]),
|
]),
|
||||||
)
|
)
|
||||||
|
]
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -246,11 +248,6 @@ class Post extends StatelessWidget {
|
||||||
Widget linkPreview() {
|
Widget linkPreview() {
|
||||||
assert(post.url != null);
|
assert(post.url != null);
|
||||||
|
|
||||||
var url = post.url.split('/')[2];
|
|
||||||
if (url.startsWith('www.')) {
|
|
||||||
url = url.substring(4);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(10),
|
padding: const EdgeInsets.all(10),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
|
@ -267,7 +264,7 @@ class Post extends StatelessWidget {
|
||||||
children: [
|
children: [
|
||||||
Row(children: [
|
Row(children: [
|
||||||
Spacer(),
|
Spacer(),
|
||||||
Text('$url ',
|
Text('$urlDomain ',
|
||||||
style: theme.textTheme.caption
|
style: theme.textTheme.caption
|
||||||
.apply(fontStyle: FontStyle.italic)),
|
.apply(fontStyle: FontStyle.italic)),
|
||||||
Icon(Icons.launch, size: 12),
|
Icon(Icons.launch, size: 12),
|
||||||
|
|
Loading…
Reference in New Issue