-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Options buttons in home controller, logout and quit work
- Loading branch information
Showing
15 changed files
with
181 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,70 @@ | ||
#include "home_controller.hpp" | ||
|
||
HomeController::HomeController(AppState *appState): Controller(ftxui::Container::Vertical({ | ||
ftxui::Button("Log out", [this] { | ||
_appState->authManager->logOut(_appState->app.get()); | ||
}), | ||
ftxui::Button("Trigger error", [this] { | ||
_appState->errorManager->setError("Uh oh!"); | ||
}) | ||
})), _appState(appState) { | ||
ftxui::Component VWrap(std::string name, ftxui::Component component) { | ||
return Renderer(component, [name, component] { | ||
return ftxui::vbox({ | ||
hbox(ftxui::text(name)) | ftxui::hcenter | size(ftxui::WIDTH, ftxui::EQUAL, 18), | ||
ftxui::separator(), | ||
component->Render() | ftxui::hcenter, | ||
}); | ||
}); | ||
} | ||
|
||
HomeController::HomeController(AppState *appState): Controller(ftxui::Container::Vertical({})), _appState(appState) { | ||
// ItemManager *itemManager; | ||
// itemManager->init(appState); | ||
|
||
/** This button row displays at the top of the home screen and provides most of the interactions that change app state.*/ | ||
auto goOfflineButtonLabel = std::string{"Go Offline"}; | ||
auto goOnlineButtonLabel = std::string{"Go Online"}; | ||
|
||
if (_appState->databaseState->offlineModeSelection == offlineModeEnabled) { | ||
state.toggleOfflineModeButtonLabel = goOnlineButtonLabel; | ||
} else if (_appState->databaseState->offlineModeSelection == offlineModeDisabled) { | ||
state.toggleOfflineModeButtonLabel = goOfflineButtonLabel; | ||
} | ||
|
||
// auto toggleOfflineModeButton = ftxui::Button(&state.toggleOfflineModeButtonLabel, [=]{ itemManager->toggleOfflineMode(); }); | ||
auto toggleOfflineModeButton = ftxui::Button(&state.toggleOfflineModeButtonLabel, [=]{ }); | ||
toggleOfflineModeButton = VWrap("Offline Mode", toggleOfflineModeButton); | ||
|
||
auto showAllButtonLabel = std::string{"Show All Tasks"}; | ||
auto showMineButtonLabel = std::string{"Show Only My Tasks"}; | ||
|
||
if (_appState->databaseState->subscriptionSelection == allItems) { | ||
state.toggleSubscriptionsButtonLabel = showMineButtonLabel; | ||
} else if (_appState->databaseState->subscriptionSelection == myItems) { | ||
state.toggleSubscriptionsButtonLabel = showAllButtonLabel; | ||
} | ||
|
||
//auto toggleSubscriptionsButton = ftxui::Button(&state.toggleSubscriptionsButtonLabel, [&]{ itemManager->toggleSubscriptions(); }); | ||
auto toggleSubscriptionsButton = ftxui::Button(&state.toggleSubscriptionsButtonLabel, [&]{ }); | ||
toggleSubscriptionsButton = VWrap("Offline Mode", toggleSubscriptionsButton); | ||
|
||
auto filters = ftxui::Checkbox("Hide completed", &_appState->databaseState->hideCompletedTasks); | ||
filters = VWrap("Filters", filters); | ||
|
||
auto logoutButton = ftxui::Button("Logout", [&]{ _appState->authManager->logOut(_appState->app.get()); }); | ||
logoutButton = VWrap("Auth", logoutButton); | ||
|
||
auto quitButton = ftxui::Button("Quit", appState->screen->ExitLoopClosure()); | ||
//auto quitButton = ftxui::Button("Quit", {}); | ||
quitButton = VWrap("Exit", quitButton); | ||
|
||
auto optionsLayout = ftxui::Container::Horizontal( | ||
{toggleOfflineModeButton, toggleSubscriptionsButton, filters, logoutButton, quitButton}); | ||
|
||
auto homeControllerButtonView = Renderer(optionsLayout, [=] { | ||
return vbox( | ||
hbox(toggleOfflineModeButton->Render(), ftxui::separator(), toggleSubscriptionsButton->Render(), | ||
ftxui::separator(), filters->Render(), ftxui::separator(), | ||
logoutButton->Render(), ftxui::separator(), quitButton->Render()) | | ||
ftxui::border); | ||
}); | ||
|
||
component()->Add(homeControllerButtonView); | ||
} | ||
|
||
void HomeController::onFrame() { | ||
// TODO: Refresh the realm from here to get the synced data between runloops | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.