mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 04:49:21 +00:00
parent
56c5eb335b
commit
11829273e2
@ -101,14 +101,10 @@ abstract class MainController extends State<MainRoute> {
|
|||||||
PageInfo(type: PageType.LATEST_POSTS_PAGE, child: NewestPostsScreen()));
|
PageInfo(type: PageType.LATEST_POSTS_PAGE, child: NewestPostsScreen()));
|
||||||
|
|
||||||
/// Open user page
|
/// Open user page
|
||||||
void openUserPage(int userID) {
|
void openUserPage(int userID) => pushPage(PageInfo(
|
||||||
final key = GlobalKey();
|
|
||||||
pushPage(PageInfo(
|
|
||||||
type: PageType.USER_PAGE,
|
type: PageType.USER_PAGE,
|
||||||
child: UserPageScreen(userID: userID, key: key),
|
child: UserPageScreen(userID: userID),
|
||||||
id: userID,
|
id: userID));
|
||||||
widgetKey: key));
|
|
||||||
}
|
|
||||||
|
|
||||||
void openUserAccessDeniedPage(int userID) =>
|
void openUserAccessDeniedPage(int userID) =>
|
||||||
pushPage(PageInfo(child: UserAccessDeniedScreen(userID: userID)));
|
pushPage(PageInfo(child: UserAccessDeniedScreen(userID: userID)));
|
||||||
|
@ -24,7 +24,6 @@ class PageInfo {
|
|||||||
|
|
||||||
/// Unique identification of this child
|
/// Unique identification of this child
|
||||||
final key = UniqueKey();
|
final key = UniqueKey();
|
||||||
final GlobalKey? widgetKey;
|
|
||||||
|
|
||||||
PageInfo({
|
PageInfo({
|
||||||
this.type = PageType.OTHER_PAGE,
|
this.type = PageType.OTHER_PAGE,
|
||||||
@ -32,6 +31,5 @@ class PageInfo {
|
|||||||
this.id,
|
this.id,
|
||||||
this.hideNavBar = false,
|
this.hideNavBar = false,
|
||||||
this.canShowAsDialog = false,
|
this.canShowAsDialog = false,
|
||||||
this.widgetKey
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,8 @@ enum _PageStatus { LOADING, ERROR, READY }
|
|||||||
class UserPageScreen extends StatefulWidget {
|
class UserPageScreen extends StatefulWidget {
|
||||||
final int userID;
|
final int userID;
|
||||||
|
|
||||||
const UserPageScreen({Key? key, required this.userID}) : super(key: key);
|
const UserPageScreen({Key? key, required this.userID})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_UserPageScreenState createState() => _UserPageScreenState();
|
_UserPageScreenState createState() => _UserPageScreenState();
|
||||||
@ -32,23 +33,18 @@ class _UserPageScreenState extends SafeState<UserPageScreen> {
|
|||||||
|
|
||||||
// Objects members
|
// Objects members
|
||||||
_PageStatus _status = _PageStatus.LOADING;
|
_PageStatus _status = _PageStatus.LOADING;
|
||||||
AdvancedUserInfo? _userInfo;
|
late AdvancedUserInfo _userInfo;
|
||||||
FriendStatus? _frienshipStatus;
|
FriendStatus? _frienshipStatus;
|
||||||
final _refreshIndicatorKey = GlobalKey<RefreshIndicatorState>();
|
final _refreshIndicatorKey = GlobalKey<RefreshIndicatorState>();
|
||||||
|
|
||||||
final _pageKey = GlobalKey();
|
|
||||||
|
|
||||||
_setStatus(_PageStatus s) => setState(() => _status = s);
|
_setStatus(_PageStatus s) => setState(() => _status = s);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didChangeDependencies() {
|
void didChangeDependencies() {
|
||||||
super.didChangeDependencies();
|
super.didChangeDependencies();
|
||||||
if(_userInfo?.id != widget.userID)
|
|
||||||
_getUserInfo();
|
_getUserInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Future<void> _getUserInfo() async {
|
Future<void> _getUserInfo() async {
|
||||||
_setStatus(_PageStatus.LOADING);
|
_setStatus(_PageStatus.LOADING);
|
||||||
|
|
||||||
@ -116,14 +112,12 @@ class _UserPageScreenState extends SafeState<UserPageScreen> {
|
|||||||
Widget _buildBody() {
|
Widget _buildBody() {
|
||||||
return isTablet(context)
|
return isTablet(context)
|
||||||
? UserPageTablet(
|
? UserPageTablet(
|
||||||
key: _pageKey,
|
userInfo: _userInfo,
|
||||||
userInfo: _userInfo!,
|
|
||||||
onNeedRefresh: () => _refreshIndicatorKey.currentState!.show(),
|
onNeedRefresh: () => _refreshIndicatorKey.currentState!.show(),
|
||||||
friendshipStatus: _frienshipStatus,
|
friendshipStatus: _frienshipStatus,
|
||||||
)
|
)
|
||||||
: UserMobilePage(
|
: UserMobilePage(
|
||||||
key: _pageKey,
|
userInfo: _userInfo,
|
||||||
userInfo: _userInfo!,
|
|
||||||
onNeedRefresh: () => _refreshIndicatorKey.currentState!.show(),
|
onNeedRefresh: () => _refreshIndicatorKey.currentState!.show(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,6 @@ class UserPageTablet extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _UserPageTabletState extends State<UserPageTablet> {
|
class _UserPageTabletState extends State<UserPageTablet> {
|
||||||
final _formKey = GlobalKey<PostCreateFormWidgetState>();
|
|
||||||
|
|
||||||
AdvancedUserInfo get _userInfo => widget.userInfo;
|
AdvancedUserInfo get _userInfo => widget.userInfo;
|
||||||
|
|
||||||
bool get _isCurrentUser => _userInfo.id == userID();
|
bool get _isCurrentUser => _userInfo.id == userID();
|
||||||
@ -72,7 +70,6 @@ class _UserPageTabletState extends State<UserPageTablet> {
|
|||||||
topWidgets: [
|
topWidgets: [
|
||||||
_userInfo.canPostTexts
|
_userInfo.canPostTexts
|
||||||
? PostCreateFormWidget(
|
? PostCreateFormWidget(
|
||||||
key: _formKey,
|
|
||||||
postTarget: PostTarget.USER_PAGE,
|
postTarget: PostTarget.USER_PAGE,
|
||||||
targetID: _userInfo.id,
|
targetID: _userInfo.id,
|
||||||
onCreated: widget.onNeedRefresh,
|
onCreated: widget.onNeedRefresh,
|
||||||
|
Loading…
Reference in New Issue
Block a user