58 lines
1.7 KiB
Python
58 lines
1.7 KiB
Python
from textual.containers import VerticalScroll, Vertical, HorizontalGroup
|
|
from textual.widgets import Static, Button, Rule, ContentSwitcher
|
|
|
|
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 on_button_pressed(self, event: ChannelView.Pressed):
|
|
self.screen.query_one(ContentSwitcher).current = "chat-window"
|
|
|
|
def compose(self):
|
|
with VerticalScroll():
|
|
yield Static("channels", classes="banner")
|
|
yield ChannelView(Channel("test channel 1", "AQ=="))
|
|
yield ChannelView(Channel("test channel 2", "AQ=="))
|
|
yield ChannelView(Channel("test channel 3", "AQ=="))
|
|
yield ChannelView(Channel("test channel 4", "AQ=="))
|
|
yield ChannelView(Channel("test channel 5", "AQ=="))
|
|
yield ChannelView(Channel("test channel 6", "AQ=="))
|
|
yield ChannelView(Channel("test channel 7", "AQ=="))
|
|
|
|
yield Rule()
|
|
|
|
with HorizontalGroup(id="buttons"):
|
|
yield Button("Create Channel")
|
|
yield Button("Advertise") |