2020-05-16 09:04:58 +00:00
|
|
|
import 'package:comunic/enums/post_target.dart';
|
|
|
|
import 'package:comunic/helpers/posts_helper.dart';
|
|
|
|
import 'package:comunic/models/advanced_user_info.dart';
|
2020-05-16 11:41:11 +00:00
|
|
|
import 'package:comunic/ui/widgets/account_image_widget.dart';
|
|
|
|
import 'package:comunic/ui/widgets/like_widget.dart';
|
2020-05-16 09:04:58 +00:00
|
|
|
import 'package:comunic/ui/widgets/post_create_form_widget.dart';
|
|
|
|
import 'package:comunic/ui/widgets/posts_list_widget.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
2020-05-16 11:41:11 +00:00
|
|
|
import 'package:flutter/rendering.dart';
|
2020-05-16 09:04:58 +00:00
|
|
|
|
|
|
|
/// Tablet mode of user page
|
|
|
|
///
|
|
|
|
/// @author Pierre HUBERT
|
|
|
|
|
|
|
|
class UserPageTablet extends StatefulWidget {
|
|
|
|
final AdvancedUserInfo userInfo;
|
|
|
|
final void Function() onNeedRefresh;
|
|
|
|
|
|
|
|
const UserPageTablet({
|
|
|
|
Key key,
|
|
|
|
@required this.userInfo,
|
|
|
|
@required this.onNeedRefresh,
|
|
|
|
}) : assert(userInfo != null),
|
|
|
|
assert(onNeedRefresh != null),
|
|
|
|
super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_UserPageTabletState createState() => _UserPageTabletState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _UserPageTabletState extends State<UserPageTablet> {
|
|
|
|
AdvancedUserInfo get _userInfo => widget.userInfo;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) => Flex(
|
|
|
|
direction: Axis.horizontal,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
_buildLeftColumn(),
|
|
|
|
Expanded(child: _buildRightColumn())
|
|
|
|
],
|
|
|
|
);
|
|
|
|
|
2020-05-16 11:41:11 +00:00
|
|
|
Widget _buildLeftColumn() => Column(
|
|
|
|
children: <Widget>[
|
|
|
|
_buildMainCard(),
|
|
|
|
_buildAboutCard(),
|
|
|
|
],
|
|
|
|
);
|
2020-05-16 09:04:58 +00:00
|
|
|
|
|
|
|
Widget _buildRightColumn() => PostsListWidget(
|
|
|
|
disablePullToRefresh: true,
|
|
|
|
topWidgets: [
|
|
|
|
_userInfo.canPostTexts
|
|
|
|
? PostCreateFormWidget(
|
|
|
|
postTarget: PostTarget.USER_PAGE,
|
|
|
|
targetID: _userInfo.id,
|
|
|
|
onCreated: widget.onNeedRefresh,
|
|
|
|
)
|
|
|
|
: Container()
|
|
|
|
],
|
|
|
|
getPostsList: () => PostsHelper().getUserPosts(_userInfo.id),
|
|
|
|
getOlder: (from) =>
|
|
|
|
PostsHelper().getUserPosts(_userInfo.id, from: from),
|
|
|
|
showPostsTarget: false,
|
|
|
|
);
|
2020-05-16 11:41:11 +00:00
|
|
|
|
|
|
|
Widget _buildMainCard() => ConstrainedBox(
|
|
|
|
constraints: BoxConstraints(minWidth: 200),
|
|
|
|
child: Card(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Center(child: AccountImageWidget(user: _userInfo, width: 75)),
|
|
|
|
SizedBox(height: 10),
|
|
|
|
Text(
|
|
|
|
_userInfo.displayName,
|
|
|
|
style: TextStyle(fontSize: 20),
|
|
|
|
),
|
|
|
|
SizedBox(height: 10),
|
|
|
|
SizedBox(height: 10),
|
|
|
|
LikeWidget(likeElement: _userInfo),
|
|
|
|
SizedBox(height: 10),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
Widget _buildAboutCard() => Container();
|
2020-05-16 09:04:58 +00:00
|
|
|
}
|