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

Show user membership

This commit is contained in:
Pierre HUBERT 2020-05-17 14:17:37 +02:00
parent cfc3552011
commit e3c11e48b2
3 changed files with 58 additions and 1 deletions

View File

@ -164,6 +164,7 @@ class UsersHelper {
canPostTexts: data["can_post_texts"], canPostTexts: data["can_post_texts"],
isFriendsListPublic: data["friend_list_public"], isFriendsListPublic: data["friend_list_public"],
numberFriends: data["number_friends"], numberFriends: data["number_friends"],
accountCreationTime: data["account_creation_time"],
likes: data["pageLikes"], likes: data["pageLikes"],
userLike: data["user_like_page"], userLike: data["user_like_page"],
); );

View File

@ -14,6 +14,7 @@ class AdvancedUserInfo extends User implements LikeElement {
final bool canPostTexts; final bool canPostTexts;
final bool isFriendsListPublic; final bool isFriendsListPublic;
final int numberFriends; final int numberFriends;
final int accountCreationTime;
bool userLike; bool userLike;
int likes; int likes;
@ -29,12 +30,14 @@ class AdvancedUserInfo extends User implements LikeElement {
@required this.canPostTexts, @required this.canPostTexts,
@required this.isFriendsListPublic, @required this.isFriendsListPublic,
@required this.numberFriends, @required this.numberFriends,
@required this.accountCreationTime,
@required this.userLike, @required this.userLike,
@required this.likes, @required this.likes,
}) : assert(publicNote != null), }) : assert(publicNote != null),
assert(canPostTexts != null), assert(canPostTexts != null),
assert(isFriendsListPublic != null), assert(isFriendsListPublic != null),
assert(numberFriends != null), assert(numberFriends != null),
assert(accountCreationTime != null),
assert(userLike != null), assert(userLike != null),
assert(likes != null), assert(likes != null),
super( super(

View File

@ -10,6 +10,8 @@ import 'package:comunic/ui/widgets/post_create_form_widget.dart';
import 'package:comunic/ui/widgets/posts_list_widget.dart'; import 'package:comunic/ui/widgets/posts_list_widget.dart';
import 'package:comunic/utils/account_utils.dart'; import 'package:comunic/utils/account_utils.dart';
import 'package:comunic/utils/conversations_utils.dart'; import 'package:comunic/utils/conversations_utils.dart';
import 'package:comunic/utils/date_utils.dart';
import 'package:comunic/utils/intl_utils.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
@ -138,7 +140,19 @@ class _UserPageTabletState extends State<UserPageTablet> {
); );
/// Build user information card /// Build user information card
Widget _buildAboutCard() => Container(); Widget _buildAboutCard() => _LeftPaneContainer(
child: Column(
children: <Widget>[
// User membership
_AboutUserEntry(
icon: Icons.access_time,
title: tr("Membership"),
value: tr("Member for %t%", args: {
"t": diffTimeFromNowToStr(_userInfo.accountCreationTime)
})),
],
),
);
} }
class _LeftPaneContainer extends StatelessWidget { class _LeftPaneContainer extends StatelessWidget {
@ -171,3 +185,42 @@ class _MainCardSpacer extends StatelessWidget {
Widget build(BuildContext context) => Widget build(BuildContext context) =>
visible ? SizedBox(height: 10) : Container(); visible ? SizedBox(height: 10) : Container();
} }
class _AboutUserEntry extends StatelessWidget {
final IconData icon;
final String title;
final String value;
final bool visible;
const _AboutUserEntry({
Key key,
@required this.icon,
@required this.title,
@required this.value,
this.visible = true,
}) : assert(icon != null),
assert(title != null),
assert(visible != null),
super(key: key);
@override
Widget build(BuildContext context) {
if (!visible) return Container();
return ListTile(
title: RichText(
text: TextSpan(
children: [
WidgetSpan(
child: Icon(icon, size: 15),
alignment: PlaceholderAlignment.middle,
),
TextSpan(text: " $title")
],
),
),
subtitle: Text(value),
dense: true,
);
}
}