1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-10-23 15:03:22 +00:00
comunicmobile/lib/ui/routes/main_route/main_route.dart

59 lines
1.6 KiB
Dart
Raw Normal View History

2020-05-05 11:21:37 +00:00
import 'package:flutter/material.dart';
/// Abstract main application route
///
/// This mixin contains methods available in all display modes
///
/// @author Pierre Hubert
2020-05-09 12:07:14 +00:00
/// Main controller key statically shared across application
///
/// Do not use it directly to avoid context leak, instead use the access method
/// [MainController.of]
final mainControllerKey = GlobalKey<MainController>();
2020-05-05 11:21:37 +00:00
mixin MainRoute implements StatefulWidget {}
/// Public interface of home controller
2020-05-09 12:18:09 +00:00
abstract class MainController extends State<MainRoute> {
2020-05-05 11:21:37 +00:00
/// Get current instance of Home controller
2020-05-09 12:07:14 +00:00
static MainController of(BuildContext context) {
assert(context != null); // A future implementation might need context again
return mainControllerKey.currentState;
}
2020-05-05 11:21:37 +00:00
/// 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
2020-05-09 12:18:09 +00:00
///
/// If the current route is not the main route, we pop one page
void popPage() {
2020-05-09 12:38:58 +00:00
if (!ModalRoute.of(context).isCurrent)
2020-05-09 12:18:09 +00:00
Navigator.of(context).pop();
else
doPopPage();
}
/// Pop current page. Do not call this method directly.
@protected
void doPopPage();
2020-05-05 11:21:37 +00:00
/// Push a new widget
2020-05-09 12:38:58 +00:00
void push(Widget w, {bool hideNavBar, bool allowAsDialog});
2020-05-05 11:21:37 +00:00
/// Open a conversation
void openConversation(int convID, {fullScreen: false});
2020-05-05 11:21:37 +00:00
/// Start a call for a given conversation
void startCall(int convID);
}