wip
This commit is contained in:
@@ -1,72 +1,59 @@
|
||||
import gleam/dict
|
||||
import gleam/io
|
||||
import gleam/string
|
||||
import gleeunit
|
||||
import gleeunit/should
|
||||
import musicplayer/ui/virtual_ansi
|
||||
|
||||
import musicplayer/ui/layout.{Layout, Percent, Section, Style}
|
||||
import musicplayer/ui/layout.{Percent, Section, Style}
|
||||
|
||||
pub fn main() -> Nil {
|
||||
gleeunit.main()
|
||||
}
|
||||
|
||||
pub fn percent_layout_test() {
|
||||
let layout =
|
||||
Layout(
|
||||
width: 80,
|
||||
height: 20,
|
||||
nodes: dict.from_list([
|
||||
#(
|
||||
layout.Root,
|
||||
layout.Row(
|
||||
content: "container",
|
||||
style: Style(dimensions: Percent(width: 100, height: 100)),
|
||||
children: [
|
||||
Section("Row1"),
|
||||
Section("Row2"),
|
||||
],
|
||||
),
|
||||
),
|
||||
#(
|
||||
Section("Row1"),
|
||||
layout.Row(
|
||||
content: "row 1",
|
||||
style: Style(dimensions: Percent(width: 100, height: 50)),
|
||||
children: [
|
||||
Section("A"),
|
||||
Section("B"),
|
||||
],
|
||||
),
|
||||
),
|
||||
#(
|
||||
let nodes = [
|
||||
#(
|
||||
Section("Row1"),
|
||||
layout.Row(
|
||||
content: "row 1",
|
||||
style: Style(dimensions: Percent(width: 100, height: 50)),
|
||||
children: [
|
||||
Section("A"),
|
||||
layout.Cell(
|
||||
content: "cell 1",
|
||||
style: Style(dimensions: Percent(width: 50, height: 100)),
|
||||
),
|
||||
),
|
||||
#(
|
||||
Section("B"),
|
||||
layout.Cell(
|
||||
content: "cell 2",
|
||||
style: Style(dimensions: Percent(width: 50, height: 100)),
|
||||
),
|
||||
),
|
||||
#(
|
||||
Section("Row2"),
|
||||
layout.Row(
|
||||
content: "row 1",
|
||||
style: Style(dimensions: Percent(width: 100, height: 50)),
|
||||
children: [],
|
||||
),
|
||||
),
|
||||
]),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
#(
|
||||
Section("A"),
|
||||
layout.Cell(
|
||||
content: "cell 1",
|
||||
style: Style(dimensions: Percent(width: 50, height: 100)),
|
||||
),
|
||||
),
|
||||
#(
|
||||
Section("B"),
|
||||
layout.Cell(
|
||||
content: "cell 2",
|
||||
style: Style(dimensions: Percent(width: 50, height: 100)),
|
||||
),
|
||||
),
|
||||
#(
|
||||
Section("Row2"),
|
||||
layout.Row(
|
||||
content: "row 1",
|
||||
style: Style(dimensions: Percent(width: 100, height: 50)),
|
||||
children: [],
|
||||
),
|
||||
),
|
||||
]
|
||||
|
||||
let columns = 80
|
||||
let rows = 20
|
||||
let layout = layout.new(columns, rows, nodes)
|
||||
|
||||
let expected =
|
||||
"
|
||||
container──────────────────────────────────────────────────────────────────────┐
|
||||
┌──────────────────────────────────────────────────────────────────────────────┐
|
||||
│row 1────────────────────────────────────────────────────────────────────────┐│
|
||||
││cell 1───────────────────────────────┐cell 2───────────────────────────────┐││
|
||||
│││ ││ │││
|
||||
|
||||
@@ -18,12 +18,12 @@ pub fn render(layout: Layout) -> String {
|
||||
let screen =
|
||||
layout.render_generic(
|
||||
layout,
|
||||
int.to_float(layout.width),
|
||||
int.to_float(layout.height),
|
||||
int.to_float(layout.columns),
|
||||
int.to_float(layout.rows),
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
layout.Root,
|
||||
layout.Section(layout.root_section),
|
||||
dict.new(),
|
||||
test_renders,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user