Skip to content

Commit

Permalink
feat: Add cached network images to stories
Browse files Browse the repository at this point in the history
  • Loading branch information
0niel committed Jan 3, 2024
1 parent 657961d commit 6603fe8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
18 changes: 10 additions & 8 deletions lib/stories/view/stories_page_view.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher_string.dart';

Expand Down Expand Up @@ -74,16 +75,17 @@ class _StoriesPageViewState extends State<StoriesPageView> {
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: page.media.formats != null
? Image.network(
MediaQuery.of(context).size.width > 580
? StrapiUtils.getLargestImageUrl(
page.media.formats!)
: StrapiUtils.getMediumImageUrl(
page.media.formats!),
? CachedNetworkImage(
imageUrl:
MediaQuery.of(context).size.width > 580
? StrapiUtils.getLargestImageUrl(
page.media.formats!)
: StrapiUtils.getMediumImageUrl(
page.media.formats!),
fit: BoxFit.cover,
)
: Image.network(
page.media.url,
: CachedNetworkImage(
imageUrl: page.media.url,
fit: BoxFit.cover,
),
),
Expand Down
5 changes: 3 additions & 2 deletions lib/stories/widgets/story_item.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:rtu_mirea_app/domain/entities/story.dart';
Expand Down Expand Up @@ -30,11 +31,11 @@ class StoryItem extends StatelessWidget {
image: DecorationImage(
fit: BoxFit.cover,
image: stories[storyIndex].preview.formats != null
? NetworkImage(
? CachedNetworkImageProvider(
stories[storyIndex].preview.formats!.small != null
? stories[storyIndex].preview.formats!.small!.url
: stories[storyIndex].preview.formats!.thumbnail.url)
: NetworkImage(stories[storyIndex].preview.url),
: CachedNetworkImageProvider(stories[storyIndex].preview.url),
colorFilter: ColorFilter.mode(
AppTheme.colors.background02.withOpacity(0.15),
BlendMode.dstOut),
Expand Down

0 comments on commit 6603fe8

Please sign in to comment.