From 35bafdc7014e83740cb476bbae47b9b1f805c159 Mon Sep 17 00:00:00 2001 From: maxxkim Date: Tue, 21 May 2024 12:30:49 +0300 Subject: [PATCH] feat(feed): Author name and avatar fetched from API --- .../feed/feed_screen/feed_screen.dart | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/presentation/feed/feed_screen/feed_screen.dart b/lib/presentation/feed/feed_screen/feed_screen.dart index 947bab58..b15ab6df 100644 --- a/lib/presentation/feed/feed_screen/feed_screen.dart +++ b/lib/presentation/feed/feed_screen/feed_screen.dart @@ -118,7 +118,7 @@ class FeedScreen extends StatelessWidget { itemCount: state.posts?.length ?? 0, itemBuilder: (context, index) { final post = state.posts?[index]; - print(post); + print(post['author']['name']); return Container( margin: EdgeInsets.only(bottom: 10), decoration: BoxDecoration( @@ -136,7 +136,8 @@ class FeedScreen extends StatelessWidget { child: Column(children: [ ListTile( leading: CachedNetworkImage( - imageUrl: dotenv.env['STORAGE_URL']! + post['image'], + imageUrl: dotenv.env['STORAGE_URL']! + + (post["author"]['profile_photo_path'] ?? ''), imageBuilder: (context, imageProvider) => CircleAvatar( backgroundImage: imageProvider, radius: 25, @@ -149,12 +150,12 @@ class FeedScreen extends StatelessWidget { ), ), title: Text( - post?['title'] ?? '', + post?['author']['name'] ?? '', style: CustomTextStyles.titleMediumSemiBold, ), subtitle: Text( DateFormat('dd.MM.yyyy') - .format(DateTime.parse(post?['updated_at'])), + .format(DateTime.parse(post?['post']['updated_at'])), style: theme.textTheme.bodyMedium, ), onTap: () => Navigator.pushNamed( @@ -188,7 +189,7 @@ class FeedScreen extends StatelessWidget { Align( alignment: Alignment.center, child: Text( - post?['title'], + post?['post']['title'], style: CustomTextStyles.titleMediumBlack, ), ), @@ -197,13 +198,13 @@ class FeedScreen extends StatelessWidget { ), SizedBox(height: 8.0), Text( - post?['description'], + post?['post']['description'], style: CustomTextStyles.bodyMediumBluegray800, ), SizedBox(height: 16.0), CachedNetworkImage( - imageUrl: - dotenv.env['STORAGE_URL']! + (post?['image'] ?? ''), + imageUrl: dotenv.env['STORAGE_URL']! + + (post?['post']['image'] ?? ''), imageBuilder: (context, imageProvider) => Stack( children: [ ClipRRect(