From a97ac81de225204bba6fd5dc652209d3a6cd0ca5 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Wed, 17 Mar 2021 17:46:50 +0100 Subject: [PATCH] Can follow friend --- .../about_user_section.dart | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/ui/screens/user_page_sections/about_user_section.dart b/lib/ui/screens/user_page_sections/about_user_section.dart index b5cbac6..587f172 100644 --- a/lib/ui/screens/user_page_sections/about_user_section.dart +++ b/lib/ui/screens/user_page_sections/about_user_section.dart @@ -1,6 +1,10 @@ import 'package:comunic/enums/user_page_visibility.dart'; +import 'package:comunic/helpers/friends_helper.dart'; import 'package:comunic/models/advanced_user_info.dart'; import 'package:comunic/models/displayed_content.dart'; +import 'package:comunic/models/friend_status.dart'; +import 'package:comunic/ui/widgets/FrienshipStatusWidget.dart'; +import 'package:comunic/ui/widgets/async_screen_widget.dart'; import 'package:comunic/ui/widgets/text_widget.dart'; import 'package:comunic/utils/date_utils.dart'; import 'package:comunic/utils/intl_utils.dart'; @@ -24,9 +28,31 @@ class AboutUserSection extends StatefulWidget { } class _AboutUserSectionState extends State { + FriendStatus _friendStatus; + + final _screenKey = GlobalKey(); + + Future _init() async { + if (!widget.user.isCurrentUser) + _friendStatus = await FriendsHelper().getFriendshipStatus(widget.user.id); + } + + void _toggleRefresh() => _screenKey.currentState.refresh(); + @override - Widget build(BuildContext context) => ListView( + Widget build(BuildContext context) => AsyncScreenWidget( + key: _screenKey, + onReload: _init, + onBuild: _buildList, + errorMessage: tr("Failed to load user information!")); + + Widget _buildList() => ListView( children: [ + widget.user.isCurrentUser + ? Container() + : FriendshipStatusWidget( + status: _friendStatus, onFriendshipUpdated: _toggleRefresh), + // Account URL widget.user.hasPersonalWebsite ? ListTile(