Centralize handling of modal error display.

This commit is contained in:
Jared Boone 2016-05-17 09:33:16 -07:00
parent 682a1706a3
commit 6a3cd4c144
4 changed files with 16 additions and 2 deletions

View file

@ -117,6 +117,10 @@ View* NavigationView::push_view(std::unique_ptr<View> new_view) {
}
void NavigationView::pop() {
if( view() == modal_view ) {
modal_view = nullptr;
}
// Can't pop last item from stack.
if( view_stack.size() > 1 ) {
free_view();
@ -127,6 +131,13 @@ void NavigationView::pop() {
}
}
void NavigationView::display_error(const std::string& message) {
/* If a modal view is already visible, don't display another */
if( !modal_view ) {
modal_view = push<ModalMessageView>(message);
}
}
void NavigationView::free_view() {
remove_child(view());
}