1
0
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:
Pierre HUBERT 2020-05-05 13:21:37 +02:00
parent 86c89e782c
commit 28451eddbd
17 changed files with 73 additions and 57 deletions

View File

@ -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';

View 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);
}

View File

@ -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();

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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();
}

View File

@ -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';

View File

@ -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';

View File

@ -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(