Previously, we were trying to render messages using a seperate widget
called Paragraph. This would enable us to put msgs on the right of the
screen using the enum Alignment.
However, rendering msgs as a seperate widget meant we had to keep track
of the position of other widgets in order to align properly. This quickly
became highly complex.
Instead, we have now rendered all the data in a single widget called List.
List is composed of a ListItem which is composed of Spans. Spans
indiciate a seperate line whereas Span is a grapheme on a single line.
We render addrs and msgs on the same line as follows:
lines.push(Spans::from(vec![addr, msgs])
Where lines is a Vec<Spans> that initializes ListItem.
We are currently aligning the msgs Span with empty spaces, which is the
method used by tui-rs/example/list.rs. Ideally we would use some variant
of Alignment for this so we don't have variation between screen sizes.
get_and_draw_outbound():
* loop through the slots of every outbound connection, instead of
just the first value (&connect.outbound[0])
* recursively initialize and draw new widgets for each node instead
of writing everything to the same vectors and frame.
get_and_draw_inbound()
* recursively initialize and draw new widgets for each node instead
of writing everything to the same vectors and frame.
for now we have the following hierarchy:
ListObject
NetFrame
NetWidget
where ListObject is composed of NetFrame's and NetFrame is composed of
NetWidget's.
this line was silently crashing:
let inbound_connect: InboundInfo = serde_json::from_value(inbound_connected.clone())?;
we resolve this by parsing the data manually.
we reduce boilerplate by creating a new generic function called draw().
variables are initialized in draw_outbound(), draw_inbound(), and
draw_manual() and are then sent to draw().
dynamic resizing is enabled by returning the total frame length like so:
let len = draw_outbound(...)
let len = draw_inbound(..., len)
it would be cleaner to store this value in a struct. however this is non
trivial to implement.
ui::ui() cannot be async and therefore cannot use mutexes due to its use
in the following non-async function from external library tui::Terminal:
terminal.draw(|f| {
ui::ui(f, view.clone());
})?;
however ui::ui() is called within the async function render(), which
means values set inside ui::ui() may be overwritten during async calls.
let external_addr = addr.as_str().unwrap()
^ this line was crashing when we receive a Null value for external_addr.
we now set the string value to "Null" if external_addr.is_null()
created seperate functions to render the different data types. frames
dynamically resize according to the length of the data. we do this by
keeping track of the previous length and passing it into each new render.
there's a lot of boilerplate rn that needs to be cleaned up, and the
dynamic resizing can probably be further simplified.
NodeId is read from config and is initalized into Model.
The values from Model are then copied into View.
We therefore do not need to read this data in the UI, as it already exists in View.
node_info = HashMap<NodeId, NodeInfo>
If we receive an external addr from the rpc data, we set that as the NodeID.
otherwise we display client's rpc port as the NodeID.
Note: this is a temporary solution until we add a 'name' param to the
config. This commit indicates a number of TODOs.