2021-09-11 01:04:15 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import '../../url_launcher.dart';
|
|
|
|
import '../../util/observer_consumers.dart';
|
2021-10-21 20:51:35 +02:00
|
|
|
import '../cached_network_image.dart';
|
2021-09-11 01:04:15 +02:00
|
|
|
import 'post_store.dart';
|
|
|
|
|
|
|
|
class PostTitle extends StatelessWidget {
|
|
|
|
const PostTitle();
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ObserverBuilder<PostStore>(
|
|
|
|
builder: (context, store) {
|
|
|
|
final post = store.postView.post;
|
2021-10-19 01:30:30 +02:00
|
|
|
final thumbnailUrl = post.thumbnailUrl;
|
|
|
|
final url = post.url;
|
2021-09-11 01:04:15 +02:00
|
|
|
|
|
|
|
return Padding(
|
2021-10-19 01:30:30 +02:00
|
|
|
padding: const EdgeInsets.all(10).copyWith(top: 0),
|
2021-09-11 01:04:15 +02:00
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Text(
|
|
|
|
post.name,
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
softWrap: true,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 18, fontWeight: FontWeight.w600),
|
|
|
|
),
|
|
|
|
),
|
2021-10-19 01:30:30 +02:00
|
|
|
if (!store.hasMedia && thumbnailUrl != null && url != null) ...[
|
2021-09-11 01:04:15 +02:00
|
|
|
InkWell(
|
|
|
|
borderRadius: BorderRadius.circular(20),
|
|
|
|
onTap: () => linkLauncher(
|
|
|
|
context: context,
|
2021-10-19 01:30:30 +02:00
|
|
|
url: url,
|
2021-09-11 01:04:15 +02:00
|
|
|
instanceHost: store.postView.instanceHost),
|
|
|
|
child: Stack(
|
|
|
|
children: [
|
|
|
|
ClipRRect(
|
|
|
|
borderRadius: BorderRadius.circular(20),
|
|
|
|
child: CachedNetworkImage(
|
2021-10-19 01:30:30 +02:00
|
|
|
imageUrl: thumbnailUrl,
|
2021-09-11 01:04:15 +02:00
|
|
|
width: 70,
|
|
|
|
height: 70,
|
|
|
|
fit: BoxFit.cover,
|
2021-10-21 20:51:35 +02:00
|
|
|
errorBuilder: (context, error) =>
|
2021-09-11 01:04:15 +02:00
|
|
|
Text(error.toString()),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const Positioned(
|
|
|
|
top: 8,
|
|
|
|
right: 8,
|
|
|
|
child: Icon(
|
|
|
|
Icons.launch,
|
|
|
|
size: 20,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|