From 3b3bc64d19715c418f407d5231795ca5a2c2fa71 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Fri, 25 Aug 2023 10:13:37 +1000 Subject: Add modal dialog support --- src/ui/ui_fsm.cpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/ui/ui_fsm.cpp') 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 -#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 UiState::sDb; std::stack> UiState::sScreens; std::shared_ptr UiState::sCurrentScreen; +std::shared_ptr UiState::sCurrentModal; auto UiState::Init(drivers::IGpios* gpio_expander, audio::TrackQueue* queue) -> bool { @@ -75,6 +82,7 @@ void UiState::PushScreen(std::shared_ptr 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() { -- cgit v1.2.3