wip set view
This commit is contained in:
@@ -5,6 +5,7 @@ import musicplayer/ui/layout.{type Section}
|
|||||||
pub type Control {
|
pub type Control {
|
||||||
UpdateDimensions(columns: Int, rows: Int)
|
UpdateDimensions(columns: Int, rows: Int)
|
||||||
UpdateState(section: Section, content: String)
|
UpdateState(section: Section, content: String)
|
||||||
|
SetView(view_idx: layout.ViewIdx)
|
||||||
|
|
||||||
Exit(reply_to: Subject(Nil))
|
Exit(reply_to: Subject(Nil))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,6 +123,9 @@ pub fn update_dimensions(layout: Layout, columns: Int, rows: Int) -> Layout {
|
|||||||
Layout(..layout, columns:, rows:)
|
Layout(..layout, columns:, rows:)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_view(layout: Layout, view_idx: ViewIdx) -> Layout {
|
||||||
|
Layout(..layout, current_view: view_idx)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn render(layout: Layout) -> Nil {
|
pub fn render(layout: Layout) -> Nil {
|
||||||
let context =
|
let context =
|
||||||
@@ -142,6 +145,7 @@ pub fn render(layout: Layout) -> Nil {
|
|||||||
render_loop(
|
render_loop(
|
||||||
view,
|
view,
|
||||||
context,
|
context,
|
||||||
|
// TODO extract to function `view_index`
|
||||||
Section(string.append("view_", string.inspect(layout.current_view))),
|
Section(string.append("view_", string.inspect(layout.current_view))),
|
||||||
buffer,
|
buffer,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -120,6 +120,12 @@ fn handle_message(
|
|||||||
process.send(reply_to, Nil)
|
process.send(reply_to, Nil)
|
||||||
actor.stop()
|
actor.stop()
|
||||||
}
|
}
|
||||||
|
control.SetView(view_idx) -> {
|
||||||
|
let layout = layout.set_view(state.layout, view_idx)
|
||||||
|
|
||||||
|
actor.send(state.redraw, layout)
|
||||||
|
actor.continue(State(..state, layout:))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user