added pair screen, home screen, and channels screen
This commit is contained in:
55
desktop_app/ui/widgets/channels_list.py
Normal file
55
desktop_app/ui/widgets/channels_list.py
Normal file
@@ -0,0 +1,55 @@
|
||||
from textual.containers import VerticalScroll, Vertical, HorizontalGroup
|
||||
from textual.widgets import Static, Button, Rule
|
||||
|
||||
from api.channel import Channel
|
||||
|
||||
|
||||
class ChannelView(Button):
|
||||
DEFAULT_CSS = """
|
||||
ChannelView {
|
||||
margin: 0 1;
|
||||
background: $boost;
|
||||
border: $surface-lighten-1 tall;
|
||||
content-align: left middle;
|
||||
text-align: left;
|
||||
width: 30;
|
||||
}
|
||||
"""
|
||||
|
||||
def __init__(self, channel: Channel):
|
||||
super().__init__(" [b]" + channel.name, flat=True)
|
||||
self.channel = channel
|
||||
|
||||
class ChannelsList(Vertical):
|
||||
DEFAULT_CSS = """
|
||||
ChannelsList {
|
||||
Rule {
|
||||
color: $surface-lighten-1;
|
||||
}
|
||||
|
||||
#buttons {
|
||||
margin-bottom: 1;
|
||||
|
||||
Button {
|
||||
margin: 0 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
def compose(self):
|
||||
with VerticalScroll():
|
||||
yield Static("channels", classes="banner")
|
||||
yield ChannelView(Channel("test channel", "AQ=="))
|
||||
yield ChannelView(Channel("test channel", "AQ=="))
|
||||
yield ChannelView(Channel("test channel", "AQ=="))
|
||||
yield ChannelView(Channel("test channel", "AQ=="))
|
||||
yield ChannelView(Channel("test channel", "AQ=="))
|
||||
yield ChannelView(Channel("test channel", "AQ=="))
|
||||
yield ChannelView(Channel("test channel", "AQ=="))
|
||||
|
||||
yield Rule()
|
||||
|
||||
with HorizontalGroup(id="buttons"):
|
||||
yield Button("Create Channel")
|
||||
yield Button("Advertise")
|
||||
25
desktop_app/ui/widgets/home_info.py
Normal file
25
desktop_app/ui/widgets/home_info.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from textual.containers import Center
|
||||
from textual.widgets import Static
|
||||
from textualeffects.widgets import EffectLabel
|
||||
|
||||
|
||||
class HomeInfo(Center):
|
||||
DEFAULT_CSS = """
|
||||
HomeInfo {
|
||||
width: 100%;
|
||||
padding: 0 3;
|
||||
|
||||
EffectLabel {
|
||||
min-width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
def compose(self):
|
||||
with open("ui/assets/banner.txt", "r") as f:
|
||||
yield EffectLabel(f.read(), effect="Print")
|
||||
|
||||
yield Static("[cyan][/] [b blink]1[/] new message(s)")
|
||||
yield Static("[cyan][/] [b]2 of 3[/] nodes online")
|
||||
yield Static("[lime][/] [b]SNR:[/] 10.0 dBm [b]| RSSI:[/] -115.0 dBm")
|
||||
39
desktop_app/ui/widgets/home_sidebar.py
Normal file
39
desktop_app/ui/widgets/home_sidebar.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from textual.containers import Vertical
|
||||
from textual.widgets import Button, ContentSwitcher
|
||||
|
||||
|
||||
class SidebarButton(Button):
|
||||
DEFAULT_CSS = """
|
||||
SidebarButton {
|
||||
max-width: 100%;
|
||||
margin-bottom: 1;
|
||||
}
|
||||
"""
|
||||
|
||||
class HomeSidebar(Vertical):
|
||||
DEFAULT_CSS = """
|
||||
HomeSidebar {
|
||||
width: 11;
|
||||
background: $boost;
|
||||
border-right: $surface-lighten-1 tall;
|
||||
padding: 1;
|
||||
dock: left;
|
||||
margin-top: 1;
|
||||
}
|
||||
"""
|
||||
|
||||
def on_button_pressed(self, event: Button.Pressed):
|
||||
content_switcher: ContentSwitcher = self.screen.query_one(ContentSwitcher)
|
||||
|
||||
match event.button.id:
|
||||
case "home-btn":
|
||||
content_switcher.current = "home-info"
|
||||
case "channels-btn":
|
||||
content_switcher.current = "channels-list"
|
||||
case "settings-btn":
|
||||
content_switcher.current = "settings"
|
||||
|
||||
def compose(self):
|
||||
yield SidebarButton("", tooltip="Home", id="home-btn")
|
||||
yield SidebarButton("", tooltip="Channels", id="channels-btn")
|
||||
yield SidebarButton("", tooltip="Settings", id="settings-btn")
|
||||
Reference in New Issue
Block a user