mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 12:59:21 +00:00
Prepare Tablet mode integration
This commit is contained in:
parent
86c89e782c
commit
28451eddbd
@ -1,6 +1,6 @@
|
||||
import 'package:comunic/helpers/conversations_helper.dart';
|
||||
import 'package:comunic/models/conversation.dart';
|
||||
import 'package:comunic/ui/routes/main_route.dart';
|
||||
import 'package:comunic/ui/routes/main_route/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';
|
||||
|
39
lib/ui/routes/main_route/main_route.dart
Normal file
39
lib/ui/routes/main_route/main_route.dart
Normal file
@ -0,0 +1,39 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Abstract main application route
|
||||
///
|
||||
/// This mixin contains methods available in all display modes
|
||||
///
|
||||
/// @author Pierre Hubert
|
||||
|
||||
mixin MainRoute implements StatefulWidget {}
|
||||
|
||||
/// Public interface of home controller
|
||||
mixin MainController implements State<MainRoute> {
|
||||
/// Get current instance of Home controller
|
||||
static MainController of(BuildContext context) =>
|
||||
context.findAncestorStateOfType<MainController>();
|
||||
|
||||
/// Open user page
|
||||
void openUserPage(int userID);
|
||||
|
||||
void openUserAccessDeniedPage(int userID);
|
||||
|
||||
/// Open a specific group page specified by its [groupID]
|
||||
void openGroup(int groupID);
|
||||
|
||||
/// Display the list of friends of a user
|
||||
void openUserFriendsList(int userID);
|
||||
|
||||
/// Pop current page. Last page can not be popped
|
||||
void popPage();
|
||||
|
||||
/// Push a new widget
|
||||
void push(Widget w, {bool hideNavBar});
|
||||
|
||||
/// Open a conversation
|
||||
void openConversation(int convID);
|
||||
|
||||
/// Start a call for a given conversation
|
||||
void startCall(int convID);
|
||||
}
|
@ -2,6 +2,7 @@ import 'package:comunic/helpers/account_helper.dart';
|
||||
import 'package:comunic/ui/routes/account_settings/account_settings_route.dart';
|
||||
import 'package:comunic/ui/routes/app_settings_route.dart';
|
||||
import 'package:comunic/ui/routes/conversation_route.dart';
|
||||
import 'package:comunic/ui/routes/main_route/main_route.dart';
|
||||
import 'package:comunic/ui/screens/call_screen.dart';
|
||||
import 'package:comunic/ui/screens/conversations_list_screen.dart';
|
||||
import 'package:comunic/ui/screens/friends_list_screen.dart';
|
||||
@ -19,13 +20,13 @@ import 'package:comunic/utils/intl_utils.dart';
|
||||
import 'package:comunic/utils/ui_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'login_route.dart';
|
||||
import '../login_route.dart';
|
||||
|
||||
/// Main route of the application
|
||||
///
|
||||
/// @author Pierre HUBERT
|
||||
|
||||
class MainRoute extends StatefulWidget {
|
||||
class SmartphoneMainRoute extends StatefulWidget implements MainRoute {
|
||||
@override
|
||||
State<StatefulWidget> createState() => _MainRouteState();
|
||||
}
|
||||
@ -51,38 +52,10 @@ class CurrPage {
|
||||
"\n}";
|
||||
}
|
||||
|
||||
/// Public interface of home controller
|
||||
abstract class MainController extends State<MainRoute> {
|
||||
/// Get current instance of Home controller
|
||||
static MainController of(BuildContext context) =>
|
||||
context.findAncestorStateOfType<MainController>();
|
||||
|
||||
/// Open user page
|
||||
void openUserPage(int userID);
|
||||
|
||||
void openUserAccessDeniedPage(int userID);
|
||||
|
||||
/// Open a specific group page specified by its [groupID]
|
||||
void openGroup(int groupID);
|
||||
|
||||
/// Display the list of friends of a user
|
||||
void openUserFriendsList(int userID);
|
||||
|
||||
/// Pop current page. Last page can not be popped
|
||||
void popPage();
|
||||
|
||||
/// Push a new widget
|
||||
void push(Widget w, {bool hideNavBar});
|
||||
|
||||
/// Open a conversation
|
||||
void openConversation(int convID);
|
||||
|
||||
/// Start a call for a given conversation
|
||||
void startCall(int convID);
|
||||
}
|
||||
|
||||
/// Private implementation of HomeController
|
||||
class _MainRouteState extends MainController {
|
||||
class _MainRouteState extends State<MainRoute> implements MainController {
|
||||
CurrPage get _currTab => history.last;
|
||||
List<CurrPage> history = List();
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'package:comunic/enums/post_target.dart';
|
||||
import 'package:comunic/helpers/posts_helper.dart';
|
||||
import 'package:comunic/models/advanced_group_info.dart';
|
||||
import 'package:comunic/ui/routes/main_route.dart';
|
||||
import 'package:comunic/ui/routes/main_route/main_route.dart';
|
||||
import 'package:comunic/ui/screens/group_members_screen.dart';
|
||||
import 'package:comunic/ui/screens/group_settings_screen.dart';
|
||||
import 'package:comunic/ui/widgets/group_following_widget.dart';
|
||||
|
@ -10,7 +10,7 @@ import 'package:comunic/models/call_config.dart';
|
||||
import 'package:comunic/models/call_member.dart';
|
||||
import 'package:comunic/models/conversation.dart';
|
||||
import 'package:comunic/plugins_interface/wake_lock.dart';
|
||||
import 'package:comunic/ui/routes/main_route.dart';
|
||||
import 'package:comunic/ui/routes/main_route/main_route.dart';
|
||||
import 'package:comunic/ui/widgets/safe_state.dart';
|
||||
import 'package:comunic/utils/account_utils.dart';
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
|
@ -4,7 +4,7 @@ import 'package:comunic/helpers/events_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/main_route.dart';
|
||||
import 'package:comunic/ui/routes/main_route/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';
|
||||
@ -35,7 +35,7 @@ class _ConversationScreenState extends SafeState<ConversationsListScreen> {
|
||||
super.initState();
|
||||
|
||||
this.listen<NewNumberUnreadConversations>(
|
||||
(d) => _refreshIndicatorKey.currentState.show());
|
||||
(d) => _refreshIndicatorKey.currentState.show());
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -6,7 +6,7 @@ import 'package:comunic/models/group.dart';
|
||||
import 'package:comunic/ui/dialogs/input_user_password_dialog.dart';
|
||||
import 'package:comunic/ui/dialogs/multi_choices_dialog.dart';
|
||||
import 'package:comunic/ui/dialogs/virtual_directory_dialog.dart';
|
||||
import 'package:comunic/ui/routes/main_route.dart';
|
||||
import 'package:comunic/ui/routes/main_route/main_route.dart';
|
||||
import 'package:comunic/ui/widgets/async_screen_widget.dart';
|
||||
import 'package:comunic/ui/widgets/comunic_back_button_widget.dart';
|
||||
import 'package:comunic/ui/widgets/group_icon_widget.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/main_route.dart';
|
||||
import 'package:comunic/ui/routes/main_route/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';
|
||||
|
@ -6,7 +6,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/main_route.dart';
|
||||
import 'package:comunic/ui/routes/main_route/main_route.dart';
|
||||
import 'package:comunic/ui/widgets/account_image_widget.dart';
|
||||
import 'package:comunic/ui/widgets/safe_state.dart';
|
||||
import 'package:comunic/utils/date_utils.dart';
|
||||
@ -120,11 +120,11 @@ class _NotificationsScreenState extends SafeState<NotificationsScreen> {
|
||||
return ListView(
|
||||
children: _list
|
||||
.map((f) => _NotificationTile(
|
||||
notification: f,
|
||||
usersList: _users,
|
||||
groupsList: _groups,
|
||||
onDelete: _deleteNotification,
|
||||
))
|
||||
notification: f,
|
||||
usersList: _users,
|
||||
groupsList: _groups,
|
||||
onDelete: _deleteNotification,
|
||||
))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
@ -202,12 +202,12 @@ class _NotificationTile extends StatelessWidget {
|
||||
String message = "${srcUser.fullName} ";
|
||||
|
||||
switch (notification.type) {
|
||||
// Comment
|
||||
// Comment
|
||||
case n.NotificationType.COMMENT_CREATED:
|
||||
message += tr("posted a comment");
|
||||
break;
|
||||
|
||||
// Friendship requests
|
||||
// Friendship requests
|
||||
case n.NotificationType.SENT_FRIEND_REQUEST:
|
||||
message += tr("sent you a friendship request.");
|
||||
break;
|
||||
@ -220,7 +220,7 @@ class _NotificationTile extends StatelessWidget {
|
||||
message += tr("rejected your friendship request.");
|
||||
break;
|
||||
|
||||
// Groups membership
|
||||
// Groups membership
|
||||
case n.NotificationType.SENT_GROUP_MEMBERSHIP_INVITATION:
|
||||
message += tr("invited you to join the group");
|
||||
break;
|
||||
@ -245,14 +245,14 @@ class _NotificationTile extends StatelessWidget {
|
||||
message += tr("rejected your request to join the group");
|
||||
break;
|
||||
|
||||
// Generic element creation
|
||||
// Generic element creation
|
||||
case n.NotificationType.ELEM_CREATED:
|
||||
if (notification.onElemType == n.NotificationElementType.POST)
|
||||
message += tr("created a new post");
|
||||
break;
|
||||
|
||||
case n.NotificationType.ELEM_UPDATED:
|
||||
// Operation not implemented
|
||||
// Operation not implemented
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -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/main_route.dart';
|
||||
import 'package:comunic/ui/routes/main_route/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';
|
||||
|
@ -2,7 +2,7 @@ import 'package:comunic/helpers/conversations_helper.dart';
|
||||
import 'package:comunic/lists/users_list.dart';
|
||||
import 'package:comunic/models/conversation.dart';
|
||||
import 'package:comunic/models/user.dart';
|
||||
import 'package:comunic/ui/routes/main_route.dart';
|
||||
import 'package:comunic/ui/routes/main_route/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';
|
||||
|
@ -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/main_route.dart';
|
||||
import 'package:comunic/ui/routes/main_route/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';
|
||||
|
@ -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/main_route.dart';
|
||||
import 'package:comunic/ui/routes/main_route/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';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'package:comunic/helpers/events_helper.dart';
|
||||
import 'package:comunic/helpers/websocket_helper.dart';
|
||||
import 'package:comunic/ui/routes/login_route.dart';
|
||||
import 'package:comunic/ui/routes/main_route.dart';
|
||||
import 'package:comunic/ui/routes/main_route/smartphone_route.dart';
|
||||
import 'package:comunic/ui/widgets/safe_state.dart';
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@ -75,7 +75,7 @@ class _InitializeWidgetState extends SafeState<InitializeWidget> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return !_error && WebSocketHelper.isConnected()
|
||||
? MainRoute()
|
||||
? SmartphoneMainRoute()
|
||||
: _buildNonReadyWidget();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:comunic/helpers/conversations_helper.dart';
|
||||
import 'package:comunic/ui/routes/main_route.dart';
|
||||
import 'package:comunic/ui/routes/main_route/main_route.dart';
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
import 'package:comunic/utils/ui_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:comunic/helpers/virtual_directory_helper.dart';
|
||||
import 'package:comunic/ui/routes/main_route.dart';
|
||||
import 'package:comunic/ui/routes/main_route/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';
|
||||
|
@ -192,6 +192,10 @@ const darkerAccentColor = Colors.white30;
|
||||
/// Check out whether dark theme is enabled or not
|
||||
bool darkTheme() => preferences().getBool(PreferencesKeyList.ENABLE_DARK_THEME);
|
||||
|
||||
/// Check out whether we use tablet mode or not
|
||||
bool isTablet(BuildContext context) =>
|
||||
MediaQuery.of(context).size.width >= 1024;
|
||||
|
||||
/// Show about Comunic dialog
|
||||
void showAboutAppDialog(BuildContext context) {
|
||||
showAboutDialog(
|
||||
|
Loading…
Reference in New Issue
Block a user