mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-26 14:59:22 +00:00
Can call MainController from dialogs
This commit is contained in:
parent
4367dcc728
commit
b23aa782b8
@ -15,7 +15,7 @@ final mainControllerKey = GlobalKey<MainController>();
|
|||||||
mixin MainRoute implements StatefulWidget {}
|
mixin MainRoute implements StatefulWidget {}
|
||||||
|
|
||||||
/// Public interface of home controller
|
/// Public interface of home controller
|
||||||
mixin MainController implements State<MainRoute> {
|
abstract class MainController extends State<MainRoute> {
|
||||||
/// Get current instance of Home controller
|
/// Get current instance of Home controller
|
||||||
static MainController of(BuildContext context) {
|
static MainController of(BuildContext context) {
|
||||||
assert(context != null); // A future implementation might need context again
|
assert(context != null); // A future implementation might need context again
|
||||||
@ -34,7 +34,18 @@ mixin MainController implements State<MainRoute> {
|
|||||||
void openUserFriendsList(int userID);
|
void openUserFriendsList(int userID);
|
||||||
|
|
||||||
/// Pop current page. Last page can not be popped
|
/// 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
|
/// Push a new widget
|
||||||
void push(Widget w, {bool hideNavBar});
|
void push(Widget w, {bool hideNavBar});
|
||||||
|
@ -55,7 +55,7 @@ class CurrPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Private implementation of HomeController
|
/// Private implementation of HomeController
|
||||||
class _MainRouteState extends State<MainRoute> implements MainController {
|
class _MainRouteState extends MainController {
|
||||||
CurrPage get _currTab => history.last;
|
CurrPage get _currTab => history.last;
|
||||||
List<CurrPage> history = List();
|
List<CurrPage> history = List();
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ class _MainRouteState extends State<MainRoute> implements MainController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Pop the page
|
/// Pop the page
|
||||||
void popPage() {
|
void doPopPage() {
|
||||||
if (history.length > 1) history.removeLast();
|
if (history.length > 1) history.removeLast();
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ class TabletRoute extends StatefulWidget implements MainRoute {
|
|||||||
_TabletRouteState createState() => _TabletRouteState();
|
_TabletRouteState createState() => _TabletRouteState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TabletRouteState extends State<MainRoute> implements MainController {
|
class _TabletRouteState extends MainController {
|
||||||
final _conversationsKey = GlobalKey<ConversationsAreaWidgetState>();
|
final _conversationsKey = GlobalKey<ConversationsAreaWidgetState>();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -88,11 +88,6 @@ class _TabletRouteState extends State<MainRoute> implements MainController {
|
|||||||
// TODO: implement openUserPage
|
// TODO: implement openUserPage
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
void popPage() {
|
|
||||||
// TODO: implement popPage
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void push(Widget w, {bool hideNavBar}) {
|
void push(Widget w, {bool hideNavBar}) {
|
||||||
// TODO: implement push
|
// TODO: implement push
|
||||||
@ -102,4 +97,9 @@ class _TabletRouteState extends State<MainRoute> implements MainController {
|
|||||||
void startCall(int convID) {
|
void startCall(int convID) {
|
||||||
// TODO: implement startCall
|
// TODO: implement startCall
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void doPopPage() {
|
||||||
|
// TODO: implement doPopPage
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user