lemmur-app-android/lib/widgets/post/post_title.dart

71 lines
2.2 KiB
Dart
Raw Normal View History

2021-09-11 01:04:15 +02:00
import 'package:flutter/material.dart';
import '../../url_launcher.dart';
import '../../util/observer_consumers.dart';
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;
final thumbnailUrl = post.thumbnailUrl;
final url = post.url;
2021-09-11 01:04:15 +02:00
return Padding(
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),
),
),
if (!store.hasMedia && thumbnailUrl != null && url != null) ...[
2021-09-11 01:04:15 +02:00
InkWell(
borderRadius: BorderRadius.circular(20),
onTap: () => linkLauncher(
context: context,
url: url,
2021-09-11 01:04:15 +02:00
instanceHost: store.postView.instanceHost),
child: Stack(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(20),
child: CachedNetworkImage(
imageUrl: thumbnailUrl,
2021-09-11 01:04:15 +02:00
width: 70,
height: 70,
fit: BoxFit.cover,
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,
),
)
],
),
),
],
],
),
);
},
);
}
}