summaryrefslogtreecommitdiff
path: root/src/ui/ui_fsm.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-08-25 10:13:37 +1000
committerjacqueline <me@jacqueline.id.au>2023-08-25 10:13:37 +1000
commit3b3bc64d19715c418f407d5231795ca5a2c2fa71 (patch)
tree87fb1bf2b9ec366abc712f2096a0908d0ae2cc4b /src/ui/ui_fsm.cpp
parent079b2b53d434869df419da1373aba239990c34d9 (diff)
downloadtangara-fw-3b3bc64d19715c418f407d5231795ca5a2c2fa71.tar.gz
Add modal dialog support
Diffstat (limited to 'src/ui/ui_fsm.cpp')
-rw-r--r--src/ui/ui_fsm.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/ui/ui_fsm.cpp b/src/ui/ui_fsm.cpp
index 1f83477d..8b2d3a3c 100644
--- a/src/ui/ui_fsm.cpp
+++ b/src/ui/ui_fsm.cpp
@@ -5,13 +5,18 @@
*/
#include "ui_fsm.hpp"
+
#include <memory>
-#include "audio_events.hpp"
+
#include "core/lv_obj.h"
+#include "misc/lv_gc.h"
+
+#include "audio_events.hpp"
#include "display.hpp"
#include "event_queue.hpp"
#include "gpios.hpp"
#include "lvgl_task.hpp"
+#include "modal_confirm.hpp"
#include "relative_wheel.hpp"
#include "screen.hpp"
#include "screen_menu.hpp"
@@ -23,6 +28,7 @@
#include "touchwheel.hpp"
#include "track_queue.hpp"
#include "ui_events.hpp"
+#include "widget_top_bar.hpp"
namespace ui {
@@ -40,6 +46,7 @@ std::weak_ptr<database::Database> UiState::sDb;
std::stack<std::shared_ptr<Screen>> UiState::sScreens;
std::shared_ptr<Screen> UiState::sCurrentScreen;
+std::shared_ptr<Modal> UiState::sCurrentModal;
auto UiState::Init(drivers::IGpios* gpio_expander, audio::TrackQueue* queue)
-> bool {
@@ -75,6 +82,7 @@ void UiState::PushScreen(std::shared_ptr<Screen> screen) {
sScreens.push(sCurrentScreen);
}
sCurrentScreen = screen;
+ UpdateTopBar();
}
void UiState::PopScreen() {
@@ -83,12 +91,28 @@ void UiState::PopScreen() {
}
sCurrentScreen = sScreens.top();
sScreens.pop();
+ UpdateTopBar();
}
void UiState::react(const system_fsm::KeyLockChanged& ev) {
sDisplay->SetDisplayOn(ev.falling);
}
+void UiState::react(const system_fsm::BatteryPercentChanged&) {
+ UpdateTopBar();
+}
+
+void UiState::UpdateTopBar() {
+ widgets::TopBar::State state{
+ .playback_state = widgets::TopBar::PlaybackState::kIdle,
+ .battery_percent = 50,
+ .is_charging = true,
+ };
+ if (sCurrentScreen) {
+ sCurrentScreen->UpdateTopBar(state);
+ }
+}
+
namespace states {
void Splash::exit() {