Skip to content

Commit

Permalink
show news image in fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobkoerber committed Jan 1, 2024
1 parent be28c0c commit 8e956a8
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions lib/newsComponent/views/news_card_view.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:campus_flutter/base/helpers/fullscreen_image_view.dart';
import 'package:campus_flutter/base/helpers/string_parser.dart';
import 'package:campus_flutter/base/helpers/url_launcher.dart';
import 'package:campus_flutter/base/networking/apis/tumdev/campus_backend.pbgrpc.dart';
import 'package:campus_flutter/base/extensions/context.dart';
import 'package:flutter/material.dart';
Expand All @@ -14,9 +14,21 @@ class NewsCardView extends ConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
return GestureDetector(
final imageUrl = news.imageUrl.toString().contains("src_1.png")
? news.link.toString()
: news.imageUrl.toString();
return InkWell(
onTap: () {
UrlLauncher.urlString(news.link, ref);
if (imageUrl.isNotEmpty) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ImageFullScreenScaffold.network(
url: imageUrl,
),
),
);
}
},
child: AspectRatio(
aspectRatio: 1.1,
Expand All @@ -31,9 +43,7 @@ class NewsCardView extends ConsumerWidget {
top: Radius.circular(10.0),
),
child: CachedNetworkImage(
imageUrl: news.imageUrl.toString().contains("src_1.png")
? news.link.toString()
: news.imageUrl.toString(),
imageUrl: imageUrl,
fadeOutDuration: Duration.zero,
fadeInDuration: Duration.zero,
placeholder: (context, string) => Image.asset(
Expand Down

0 comments on commit 8e956a8

Please sign in to comment.