diff --git a/lib/ui/routes/conversation_route.dart b/lib/ui/routes/conversation_route.dart index a95e7f9..cd82c77 100644 --- a/lib/ui/routes/conversation_route.dart +++ b/lib/ui/routes/conversation_route.dart @@ -1,6 +1,6 @@ import 'package:comunic/helpers/conversations_helper.dart'; import 'package:comunic/models/conversation.dart'; -import 'package:comunic/ui/routes/home_route.dart'; +import 'package:comunic/ui/routes/main_route.dart'; import 'package:comunic/ui/routes/update_conversation_route.dart'; import 'package:comunic/ui/screens/conversation_screen.dart'; import 'package:comunic/ui/widgets/comunic_back_button_widget.dart'; @@ -59,7 +59,7 @@ class _ConversationRouteState extends State { } void _openSettings() { - HomeController.of(context).push( + MainController.of(context).push( UpdateConversationRoute( conversationID: widget.conversationID, ), diff --git a/lib/ui/routes/home_route.dart b/lib/ui/routes/main_route.dart similarity index 95% rename from lib/ui/routes/home_route.dart rename to lib/ui/routes/main_route.dart index b738449..01fba81 100644 --- a/lib/ui/routes/home_route.dart +++ b/lib/ui/routes/main_route.dart @@ -24,9 +24,9 @@ import 'login_route.dart'; /// /// @author Pierre HUBERT -class HomeRoute extends StatefulWidget { +class MainRoute extends StatefulWidget { @override - State createState() => _HomeRouteState(); + State createState() => _MainRouteState(); } class CurrPage { @@ -51,10 +51,10 @@ class CurrPage { } /// Public interface of home controller -abstract class HomeController extends State { +abstract class MainController extends State { /// Get current instance of Home controller - static HomeController of(BuildContext context) => - context.findAncestorStateOfType(); + static MainController of(BuildContext context) => + context.findAncestorStateOfType(); /// Open user page void openUserPage(int userID); @@ -78,7 +78,7 @@ abstract class HomeController extends State { } /// Private implementation of HomeController -class _HomeRouteState extends HomeController { +class _MainRouteState extends MainController { CurrPage get _currTab => history.last; List history = List(); diff --git a/lib/ui/screens/conversations_list_screen.dart b/lib/ui/screens/conversations_list_screen.dart index 72dd3ff..2f7c6dc 100644 --- a/lib/ui/screens/conversations_list_screen.dart +++ b/lib/ui/screens/conversations_list_screen.dart @@ -3,7 +3,7 @@ import 'package:comunic/helpers/conversations_helper.dart'; import 'package:comunic/helpers/users_helper.dart'; import 'package:comunic/lists/conversations_list.dart'; import 'package:comunic/models/conversation.dart'; -import 'package:comunic/ui/routes/home_route.dart'; +import 'package:comunic/ui/routes/main_route.dart'; import 'package:comunic/ui/routes/update_conversation_route.dart'; import 'package:comunic/ui/screens/create_conversation_screen.dart'; import 'package:comunic/ui/tiles/conversation_tile.dart'; @@ -95,17 +95,17 @@ class _ConversationScreenState extends State { /// Open a conversation void _openConversation(int conversationId) { - HomeController.of(context).openConversation(conversationId); + MainController.of(context).openConversation(conversationId); } /// Create a new conversation void _createConversation() { - HomeController.of(context).push(CreateConversationScreen()); + MainController.of(context).push(CreateConversationScreen()); } /// Handle conversations updated requests void _updateConversation(Conversation conversation) { - HomeController.of(context).push( + MainController.of(context).push( UpdateConversationRoute( conversationID: conversation.id, ), diff --git a/lib/ui/screens/groups_list_screen.dart b/lib/ui/screens/groups_list_screen.dart index d8be8a2..7574332 100644 --- a/lib/ui/screens/groups_list_screen.dart +++ b/lib/ui/screens/groups_list_screen.dart @@ -1,7 +1,7 @@ import 'package:comunic/helpers/groups_helper.dart'; import 'package:comunic/lists/groups_list.dart'; import 'package:comunic/models/group.dart'; -import 'package:comunic/ui/routes/home_route.dart'; +import 'package:comunic/ui/routes/main_route.dart'; import 'package:comunic/ui/widgets/group_icon_widget.dart'; import 'package:comunic/ui/widgets/group_membership_widget.dart'; import 'package:comunic/ui/widgets/safe_state.dart'; @@ -67,7 +67,7 @@ class _GroupsListScreenState extends SafeState { trailing: IconButton( icon: Icon(Icons.delete), onPressed: () => _deleteGroup(g)), - onTap: () => HomeController.of(context).openGroup(g.id), + onTap: () => MainController.of(context).openGroup(g.id), )) .toList(), ), diff --git a/lib/ui/screens/notifications_screen.dart b/lib/ui/screens/notifications_screen.dart index 5052a8b..f03a9bb 100644 --- a/lib/ui/screens/notifications_screen.dart +++ b/lib/ui/screens/notifications_screen.dart @@ -5,7 +5,7 @@ import 'package:comunic/lists/groups_list.dart'; import 'package:comunic/lists/notifications_list.dart'; import 'package:comunic/lists/users_list.dart'; import 'package:comunic/models/notification.dart' as n; -import 'package:comunic/ui/routes/home_route.dart'; +import 'package:comunic/ui/routes/main_route.dart'; import 'package:comunic/ui/widgets/account_image_widget.dart'; import 'package:comunic/utils/date_utils.dart'; import 'package:comunic/utils/intl_utils.dart'; @@ -309,7 +309,7 @@ class _NotificationTile extends StatelessWidget { openUserPage(userID: notification.fromUser, context: context); } else if (notification.onElemType == n.NotificationElementType.GROUP_MEMBERSHIP) { - HomeController.of(context).openGroup(notification.onElemId); + MainController.of(context).openGroup(notification.onElemId); } else { showSimpleSnack(context, tr("This kind of notification is not supported yet by this application.")); diff --git a/lib/ui/screens/search_screen.dart b/lib/ui/screens/search_screen.dart index 4947b2a..4db149c 100644 --- a/lib/ui/screens/search_screen.dart +++ b/lib/ui/screens/search_screen.dart @@ -7,7 +7,7 @@ import 'package:comunic/lists/users_list.dart'; import 'package:comunic/models/group.dart'; import 'package:comunic/models/search_result.dart'; import 'package:comunic/models/user.dart'; -import 'package:comunic/ui/routes/home_route.dart'; +import 'package:comunic/ui/routes/main_route.dart'; import 'package:comunic/ui/widgets/account_image_widget.dart'; import 'package:comunic/ui/widgets/group_icon_widget.dart'; import 'package:comunic/utils/intl_utils.dart'; @@ -97,7 +97,7 @@ class _SearchResultUser extends StatelessWidget { user: user, ), title: Text(user.displayName), - onTap: () => HomeController.of(context).openUserPage(user.id), + onTap: () => MainController.of(context).openUserPage(user.id), ); } } @@ -115,7 +115,7 @@ class _SearchResultGroup extends StatelessWidget { leading: GroupIcon(group: group), title: Text(group.displayName), subtitle: Text(tr("Group")), - onTap: () => HomeController.of(context).openGroup(group.id), + onTap: () => MainController.of(context).openGroup(group.id), ); } } diff --git a/lib/ui/screens/update_conversation_screen.dart b/lib/ui/screens/update_conversation_screen.dart index a2a0487..109303a 100644 --- a/lib/ui/screens/update_conversation_screen.dart +++ b/lib/ui/screens/update_conversation_screen.dart @@ -1,7 +1,7 @@ import 'package:comunic/helpers/conversations_helper.dart'; import 'package:comunic/lists/users_list.dart'; import 'package:comunic/models/conversation.dart'; -import 'package:comunic/ui/routes/home_route.dart'; +import 'package:comunic/ui/routes/main_route.dart'; import 'package:comunic/ui/tiles/simple_user_tile.dart'; import 'package:comunic/ui/widgets/pick_user_widget.dart'; import 'package:comunic/utils/intl_utils.dart'; @@ -174,8 +174,8 @@ class _UpdateConversationScreen extends State { // Open the conversation - HomeController.of(context).popPage(); + MainController.of(context).popPage(); if (!isUpdating) - HomeController.of(context).openConversation(conversationID); + MainController.of(context).openConversation(conversationID); } } diff --git a/lib/ui/screens/user_access_denied_screen.dart b/lib/ui/screens/user_access_denied_screen.dart index 8e0f5c0..6873a0a 100644 --- a/lib/ui/screens/user_access_denied_screen.dart +++ b/lib/ui/screens/user_access_denied_screen.dart @@ -2,7 +2,7 @@ import 'package:comunic/helpers/friends_helper.dart'; import 'package:comunic/helpers/users_helper.dart'; import 'package:comunic/models/friend_status.dart'; import 'package:comunic/models/user.dart'; -import 'package:comunic/ui/routes/home_route.dart'; +import 'package:comunic/ui/routes/main_route.dart'; import 'package:comunic/ui/widgets/FrienshipStatusWidget.dart'; import 'package:comunic/ui/widgets/account_image_widget.dart'; import 'package:comunic/utils/intl_utils.dart'; @@ -50,7 +50,7 @@ class _UserAccessDeniedScreenState extends State { // Check if the two users are friend now if (status.areFriend) { - final controller = HomeController.of(context); + final controller = MainController.of(context); controller.popPage(); controller.openUserPage(widget.userID); } diff --git a/lib/ui/screens/user_page_screen.dart b/lib/ui/screens/user_page_screen.dart index aa8b0c5..de2e526 100644 --- a/lib/ui/screens/user_page_screen.dart +++ b/lib/ui/screens/user_page_screen.dart @@ -2,7 +2,7 @@ import 'package:comunic/enums/post_target.dart'; import 'package:comunic/helpers/posts_helper.dart'; import 'package:comunic/helpers/users_helper.dart'; import 'package:comunic/models/advanced_user_info.dart'; -import 'package:comunic/ui/routes/home_route.dart'; +import 'package:comunic/ui/routes/main_route.dart'; import 'package:comunic/ui/widgets/account_image_widget.dart'; import 'package:comunic/ui/widgets/post_create_form_widget.dart'; import 'package:comunic/ui/widgets/posts_list_widget.dart'; @@ -76,7 +76,7 @@ class _UserPageScreenState extends State { _setStatus(_PageStatus.ERROR); if (e.cause == GetUserAdvancedInformationErrorCause.NOT_AUTHORIZED) { - final controller = HomeController.of(context); + final controller = MainController.of(context); controller.popPage(); controller.openUserAccessDeniedPage(widget.userID); } @@ -184,7 +184,7 @@ class _UserPageScreenState extends State { void _selectedMenuOption(_MenuOptions value) { switch (value) { case _MenuOptions.FRIENDS_LIST: - HomeController.of(context).openUserFriendsList(_userInfo.id); + MainController.of(context).openUserFriendsList(_userInfo.id); break; } } diff --git a/lib/ui/widgets/init_widget.dart b/lib/ui/widgets/init_widget.dart index 5f65e7a..6e25b0f 100644 --- a/lib/ui/widgets/init_widget.dart +++ b/lib/ui/widgets/init_widget.dart @@ -1,5 +1,5 @@ import 'package:comunic/helpers/websocket_helper.dart'; -import 'package:comunic/ui/routes/home_route.dart'; +import 'package:comunic/ui/routes/main_route.dart'; import 'package:comunic/utils/intl_utils.dart'; import 'package:flutter/material.dart'; @@ -49,7 +49,7 @@ class _InitializeWidgetState extends State { @override Widget build(BuildContext context) { - return WebSocketHelper.isConnected() ? HomeRoute() : _buildNonReadyWidget(); + return WebSocketHelper.isConnected() ? MainRoute() : _buildNonReadyWidget(); } /// Build loading widget diff --git a/lib/utils/conversations_utils.dart b/lib/utils/conversations_utils.dart index 9679491..1ec0f0a 100644 --- a/lib/utils/conversations_utils.dart +++ b/lib/utils/conversations_utils.dart @@ -1,5 +1,5 @@ import 'package:comunic/helpers/conversations_helper.dart'; -import 'package:comunic/ui/routes/home_route.dart'; +import 'package:comunic/ui/routes/main_route.dart'; import 'package:comunic/utils/intl_utils.dart'; import 'package:comunic/utils/ui_utils.dart'; import 'package:flutter/material.dart'; @@ -18,7 +18,7 @@ Future openPrivateConversation(BuildContext context, int userID) async { } // Open the conversation - HomeController.of(context).openConversation(convID); + MainController.of(context).openConversation(convID); // Success return true; diff --git a/lib/utils/navigation_utils.dart b/lib/utils/navigation_utils.dart index cd09aa4..72b3523 100644 --- a/lib/utils/navigation_utils.dart +++ b/lib/utils/navigation_utils.dart @@ -1,5 +1,5 @@ import 'package:comunic/helpers/virtual_directory_helper.dart'; -import 'package:comunic/ui/routes/home_route.dart'; +import 'package:comunic/ui/routes/main_route.dart'; import 'package:comunic/ui/routes/single_post_route.dart'; import 'package:comunic/utils/intl_utils.dart'; import 'package:comunic/utils/ui_utils.dart'; @@ -12,7 +12,7 @@ import 'package:meta/meta.dart'; /// Pop a page void popPage(BuildContext context) { - HomeController.of(context).popPage(); + MainController.of(context).popPage(); } /// Open the page of a user @@ -20,12 +20,12 @@ void openUserPage({@required int userID, @required BuildContext context}) { assert(userID != null); assert(context != null); - HomeController.of(context).openUserPage(userID); + MainController.of(context).openUserPage(userID); } /// Open a post in full screen void openPostFullScreen(int postID, BuildContext context) { - HomeController.of(context).push(SinglePostRoute(postID: postID)); + MainController.of(context).push(SinglePostRoute(postID: postID)); } /// Open a virtual directory @@ -41,7 +41,7 @@ void openVirtualDirectory(BuildContext context, String directory) async { break; case VirtualDirectoryType.GROUP: - HomeController.of(context).openGroup(result.id); + MainController.of(context).openGroup(result.id); break; case VirtualDirectoryType.NONE: