diff --git a/lib/models/user.dart b/lib/models/user.dart index 97fded8..1a496e9 100644 --- a/lib/models/user.dart +++ b/lib/models/user.dart @@ -41,6 +41,9 @@ class User extends CacheModel { /// Get user display name String get displayName => htmlDecodeCharacters(fullName); + bool get hasVirtualDirectory => + virtualDirectory != null && virtualDirectory.length > 0; + Map toMap() { return { UserTableContract.C_ID: id, diff --git a/lib/ui/widgets/tablet_mode/user_page_tablet.dart b/lib/ui/widgets/tablet_mode/user_page_tablet.dart index c9ac665..65c6c90 100644 --- a/lib/ui/widgets/tablet_mode/user_page_tablet.dart +++ b/lib/ui/widgets/tablet_mode/user_page_tablet.dart @@ -65,28 +65,46 @@ class _UserPageTabletState extends State { showPostsTarget: false, ); + /// Main user information card Widget _buildMainCard() => ConstrainedBox( - constraints: BoxConstraints(minWidth: 200), + constraints: BoxConstraints(maxWidth: 200), child: Card( child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ Center(child: AccountImageWidget(user: _userInfo, width: 75)), - SizedBox(height: 10), + _MainCardSpacer(), Text( _userInfo.displayName, + textAlign: TextAlign.center, style: TextStyle(fontSize: 20), ), - SizedBox(height: 10), - SizedBox(height: 10), + _MainCardSpacer(), + Container( + child: _userInfo.hasVirtualDirectory + ? Text("@${_userInfo.virtualDirectory}") + : null), + _MainCardSpacer(visible: _userInfo.hasVirtualDirectory), LikeWidget(likeElement: _userInfo), - SizedBox(height: 10), ], ), ), ), ); + /// Build user information card Widget _buildAboutCard() => Container(); } + +class _MainCardSpacer extends StatelessWidget { + final bool visible; + + const _MainCardSpacer({this.visible = true, Key key}) + : assert(visible != null), + super(key: key); + + @override + Widget build(BuildContext context) => + visible ? SizedBox(height: 10) : Container(); +}