1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-12-25 12:28:50 +00:00

Can call MainController from dialogs

This commit is contained in:
Pierre HUBERT 2020-05-09 14:18:09 +02:00
parent 4367dcc728
commit b23aa782b8
3 changed files with 21 additions and 10 deletions

View File

@ -15,7 +15,7 @@ final mainControllerKey = GlobalKey<MainController>();
mixin MainRoute implements StatefulWidget {}
/// Public interface of home controller
mixin MainController implements State<MainRoute> {
abstract class MainController extends State<MainRoute> {
/// Get current instance of Home controller
static MainController of(BuildContext context) {
assert(context != null); // A future implementation might need context again
@ -34,7 +34,18 @@ mixin MainController implements State<MainRoute> {
void openUserFriendsList(int userID);
/// Pop current page. Last page can not be popped
void popPage();
///
/// If the current route is not the main route, we pop one page
void popPage() {
if(!ModalRoute.of(context).isCurrent)
Navigator.of(context).pop();
else
doPopPage();
}
/// Pop current page. Do not call this method directly.
@protected
void doPopPage();
/// Push a new widget
void push(Widget w, {bool hideNavBar});

View File

@ -55,7 +55,7 @@ class CurrPage {
}
/// Private implementation of HomeController
class _MainRouteState extends State<MainRoute> implements MainController {
class _MainRouteState extends MainController {
CurrPage get _currTab => history.last;
List<CurrPage> history = List();
@ -67,7 +67,7 @@ class _MainRouteState extends State<MainRoute> implements MainController {
}
/// Pop the page
void popPage() {
void doPopPage() {
if (history.length > 1) history.removeLast();
setState(() {});
}

View File

@ -17,7 +17,7 @@ class TabletRoute extends StatefulWidget implements MainRoute {
_TabletRouteState createState() => _TabletRouteState();
}
class _TabletRouteState extends State<MainRoute> implements MainController {
class _TabletRouteState extends MainController {
final _conversationsKey = GlobalKey<ConversationsAreaWidgetState>();
@override
@ -88,11 +88,6 @@ class _TabletRouteState extends State<MainRoute> implements MainController {
// TODO: implement openUserPage
}
@override
void popPage() {
// TODO: implement popPage
}
@override
void push(Widget w, {bool hideNavBar}) {
// TODO: implement push
@ -102,4 +97,9 @@ class _TabletRouteState extends State<MainRoute> implements MainController {
void startCall(int convID) {
// TODO: implement startCall
}
@override
void doPopPage() {
// TODO: implement doPopPage
}
}