use mediaviewpage in a post
This commit is contained in:
parent
689b4c41cc
commit
9e27380985
|
@ -8,6 +8,7 @@ import 'package:timeago/timeago.dart' as timeago;
|
||||||
import 'package:url_launcher/url_launcher.dart' as ul;
|
import 'package:url_launcher/url_launcher.dart' as ul;
|
||||||
|
|
||||||
import '../pages/full_post.dart';
|
import '../pages/full_post.dart';
|
||||||
|
import '../pages/media_view.dart';
|
||||||
import '../url_launcher.dart';
|
import '../url_launcher.dart';
|
||||||
import '../util/api_extensions.dart';
|
import '../util/api_extensions.dart';
|
||||||
import '../util/goto.dart';
|
import '../util/goto.dart';
|
||||||
|
@ -25,7 +26,13 @@ MediaType whatType(String url) {
|
||||||
if (url == null) return MediaType.other;
|
if (url == null) return MediaType.other;
|
||||||
|
|
||||||
// TODO: make detection more nuanced
|
// TODO: make detection more nuanced
|
||||||
if (url.endsWith('.jpg') || url.endsWith('.png') || url.endsWith('.gif')) {
|
if (url.endsWith('.jpg') ||
|
||||||
|
url.endsWith('.jpeg') ||
|
||||||
|
url.endsWith('.png') ||
|
||||||
|
url.endsWith('.gif') ||
|
||||||
|
url.endsWith('.webp') ||
|
||||||
|
url.endsWith('.bmp') ||
|
||||||
|
url.endsWith('.wbpm')) {
|
||||||
return MediaType.image;
|
return MediaType.image;
|
||||||
}
|
}
|
||||||
return MediaType.other;
|
return MediaType.other;
|
||||||
|
@ -42,10 +49,10 @@ class Post extends StatelessWidget {
|
||||||
|
|
||||||
void _openLink() => urlLauncher(post.url);
|
void _openLink() => urlLauncher(post.url);
|
||||||
|
|
||||||
void _openFullImage() {
|
void _openFullImage(BuildContext context) =>
|
||||||
// TODO: fullscreen media view
|
Navigator.of(context).push(MaterialPageRoute(
|
||||||
print('OPEN FULL IMAGE');
|
builder: (context) => MediaViewPage(post.url),
|
||||||
}
|
));
|
||||||
|
|
||||||
// POST ACTIONS
|
// POST ACTIONS
|
||||||
|
|
||||||
|
@ -371,12 +378,15 @@ class Post extends StatelessWidget {
|
||||||
assert(post.url != null);
|
assert(post.url != null);
|
||||||
|
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: _openFullImage,
|
onTap: () => _openFullImage(context),
|
||||||
|
child: Hero(
|
||||||
|
tag: post.url,
|
||||||
child: CachedNetworkImage(
|
child: CachedNetworkImage(
|
||||||
imageUrl: post.url,
|
imageUrl: post.url,
|
||||||
progressIndicatorBuilder: (context, url, progress) =>
|
progressIndicatorBuilder: (context, url, progress) =>
|
||||||
CircularProgressIndicator(value: progress.progress),
|
CircularProgressIndicator(value: progress.progress),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue