Archived
1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
cli-old/lib/widgets/chat/info.rb
2017-07-31 02:07:45 +00:00

45 lines
1.4 KiB
Ruby

# frozen_string_literal: true
module Widgets
class Chat < VPanel
class Info < React::Component
PUBLIC_KEY_LABEL = 'Public key: '
def render
create_element :window, x: props[:x], y: props[:y], width: props[:width], height: props[:height] do
create_element :lines do
create_element :line do
create_element :text, text: status_text, attr: status_attr
create_element :text, text: ' '
create_element :text, text: props[:name], attr: Style.default.peer_info_name_attr
create_element :text, text: ' : '
create_element :text, text: props[:status_message]
end
create_element :line do
create_element :text, text: PUBLIC_KEY_LABEL
create_element :text, text: props[:public_key]
end
end
end
end
def status_text
case props[:status]
when Tox::UserStatus::NONE then '[Online]'
when Tox::UserStatus::AWAY then '[Away]'
when Tox::UserStatus::BUSY then '[Busy]'
else '[Unknown]'
end
end
def status_attr
case props[:status]
when Tox::UserStatus::NONE then Style.default.online_mark_attr
when Tox::UserStatus::AWAY then Style.default.away_mark_attr
when Tox::UserStatus::BUSY then Style.default.busy_mark_attr
end
end
end
end
end