Archived
1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
cli-old/lib/widgets/chat/info.rb
2017-07-28 11:32:52 +00:00

70 lines
1.5 KiB
Ruby

# frozen_string_literal: true
module Widgets
using Helpers
class Chat < VPanel
class Info < Curses::React::Component
PUBLIC_KEY_LABEL = 'Public key: '
private
def render
render_main_line
render_public_key
end
def render_main_line
setpos 0, 0
case props[:status]
when Tox::UserStatus::NONE
Style.default.online_mark window do
addstr '[Online]'
end
when Tox::UserStatus::AWAY
Style.default.away_mark window do
addstr '[Away]'
end
when Tox::UserStatus::BUSY
Style.default.busy_mark window do
addstr '[Busy]'
end
else
addstr '[Unknown]'
end
addstr ' '
Style.default.peer_info_name window do
addstr props[:name]
end
addstr ' : '
addstr props[:status_message]
end
def render_public_key
Curses::React::Nodes.create(
Curses::React::Element.create(:line) do
Curses::React::Element.create(
:text_line,
x: 0,
y: 1,
width: PUBLIC_KEY_LABEL.length,
text: PUBLIC_KEY_LABEL,
)
Curses::React::Element.create(
:text_line,
x: PUBLIC_KEY_LABEL.length,
y: 1,
width: props[:width] - PUBLIC_KEY_LABEL.length,
text: props[:public_key],
)
end,
window,
).draw
end
end
end
end