From 94f61f733bcaf7416e3b7773cffb1ea41b2a2b1b Mon Sep 17 00:00:00 2001 From: maxxkim Date: Tue, 23 Apr 2024 12:14:53 +0300 Subject: [PATCH] feat(settings): User Avatar display --- .../chat/chat_screen/chat_screen.dart | 5 ++-- .../my_profile_screen/my_profile_screen.dart | 27 ++++++++++++------- lib/routes/app_routes.dart | 4 +-- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/lib/presentation/chat/chat_screen/chat_screen.dart b/lib/presentation/chat/chat_screen/chat_screen.dart index afd7ab40..8b1fc731 100644 --- a/lib/presentation/chat/chat_screen/chat_screen.dart +++ b/lib/presentation/chat/chat_screen/chat_screen.dart @@ -1,4 +1,4 @@ -import 'bloc/chat_bloc.dart'; +/*import 'bloc/chat_bloc.dart'; import 'models/chat_model.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:flutter/material.dart'; @@ -722,5 +722,4 @@ class ChatScreen extends StatelessWidget { NavigatorService.goBack(); } } - -_ \ No newline at end of file +*/ \ No newline at end of file diff --git a/lib/presentation/profile/my_profile_screen/my_profile_screen.dart b/lib/presentation/profile/my_profile_screen/my_profile_screen.dart index 0a387801..5e328570 100644 --- a/lib/presentation/profile/my_profile_screen/my_profile_screen.dart +++ b/lib/presentation/profile/my_profile_screen/my_profile_screen.dart @@ -13,6 +13,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:hive/hive.dart'; import 'package:flutter/services.dart'; +import 'package:cached_network_image/cached_network_image.dart'; import 'package:http/http.dart' as http; import 'package:fl_chart/fl_chart.dart'; import 'package:intl/intl.dart'; @@ -55,12 +56,7 @@ class MyProfileScreen extends StatelessWidget { mediaQueryData = MediaQuery.of(context); return SafeArea( child: Scaffold( - appBar: _buildAppBar( - context, - ((state.userDetails?['first_name'] ?? '') + - ' ' + - (state.userDetails?['last_name'] ?? '')) ?? - 'loading'.tr), + appBar: _buildAppBar(context, state), body: Container( width: double.maxFinite, padding: EdgeInsets.symmetric(horizontal: 8.h, vertical: 18.v), @@ -83,16 +79,29 @@ class MyProfileScreen extends StatelessWidget { } /// Section Widget - _buildAppBar(BuildContext context, String username) { + _buildAppBar(BuildContext context, MyProfileLoadedState state) { + print(state.user?['profile_photo_url']); return CustomAppBar( height: 54.v, leadingWidth: 28.h, title: Padding( padding: EdgeInsets.only(left: 20.h), child: Row(children: [ - AppbarTitleCircleimage(imagePath: ImageConstant.imgEllipse1), + CachedNetworkImage( + imageUrl: state.user?['profile_photo_url'], + imageBuilder: (context, imageProvider) => CircleAvatar( + backgroundImage: imageProvider, + radius: 20, + ), + placeholder: (context, url) => CircularProgressIndicator(), + errorWidget: (context, url, error) => CircleAvatar( + child: Icon(Icons.error), + backgroundColor: Colors.red, + radius: 20, + ), + ), AppbarSubtitle( - text: username, + text: state.user?['name'], margin: EdgeInsets.only(left: 35.h, top: 12.v, bottom: 9.v)) ])), actions: [ diff --git a/lib/routes/app_routes.dart b/lib/routes/app_routes.dart index 97311c58..6f988361 100644 --- a/lib/routes/app_routes.dart +++ b/lib/routes/app_routes.dart @@ -20,7 +20,7 @@ import 'package:eatvio_app/presentation/auth/auth_screen/auth_screen.dart'; import 'package:eatvio_app/presentation/profile/my_profile_screen/my_profile_screen.dart'; import 'package:eatvio_app/presentation/profile/my_profile_screen/my_settings_screen.dart'; import 'package:eatvio_app/presentation/diary/diary_edit_screen/diary_edit_screen.dart'; -import 'package:eatvio_app/presentation/chat/chat_screen/chat_screen.dart'; +//import 'package:eatvio_app/presentation/chat/chat_screen/chat_screen.dart'; import 'package:eatvio_app/presentation/chat/chat_select_screen/chat_select_screen.dart'; class AppRoutes { @@ -101,7 +101,7 @@ class AppRoutes { myProfile: MyProfileScreen.builder, mySettings: MySettingsScreen.builder, diaryEdit: DiaryEditScreen.builder, - chatScreen: ChatScreen.builder, + //chatScreen: ChatScreen.builder, chatSelectScreen: ChatSelectScreen.builder, }; }