1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-26 14:59:22 +00:00

Can follow friend

This commit is contained in:
Pierre HUBERT 2021-03-17 17:46:50 +01:00
parent 1ba7784324
commit a97ac81de2

View File

@ -1,6 +1,10 @@
import 'package:comunic/enums/user_page_visibility.dart'; 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/advanced_user_info.dart';
import 'package:comunic/models/displayed_content.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/ui/widgets/text_widget.dart';
import 'package:comunic/utils/date_utils.dart'; import 'package:comunic/utils/date_utils.dart';
import 'package:comunic/utils/intl_utils.dart'; import 'package:comunic/utils/intl_utils.dart';
@ -24,9 +28,31 @@ class AboutUserSection extends StatefulWidget {
} }
class _AboutUserSectionState extends State<AboutUserSection> { class _AboutUserSectionState extends State<AboutUserSection> {
FriendStatus _friendStatus;
final _screenKey = GlobalKey<AsyncScreenWidgetState>();
Future<void> _init() async {
if (!widget.user.isCurrentUser)
_friendStatus = await FriendsHelper().getFriendshipStatus(widget.user.id);
}
void _toggleRefresh() => _screenKey.currentState.refresh();
@override @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: [ children: [
widget.user.isCurrentUser
? Container()
: FriendshipStatusWidget(
status: _friendStatus, onFriendshipUpdated: _toggleRefresh),
// Account URL // Account URL
widget.user.hasPersonalWebsite widget.user.hasPersonalWebsite
? ListTile( ? ListTile(