Update the Rio Version, add meta tags, refactor rio components that have init overwrites, add member picture for Tim
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from .navigation import Navigation
|
||||
from .header import Header
|
||||
from .news_post import NewsPost
|
||||
from .member_card import MemberInfo, MemberCard
|
||||
from .news_post import NewsPost, build_news_post
|
||||
from .member_card import MemberInfo, MemberCard, build_member_card
|
||||
|
||||
@@ -16,31 +16,25 @@ class MemberInfo:
|
||||
|
||||
|
||||
class MemberCard(rio.Component):
|
||||
def __init__(self, info: MemberInfo) -> None:
|
||||
super().__init__()
|
||||
self._info = info
|
||||
self.align_y = 0
|
||||
self.margin_top = 0
|
||||
self.margin_bottom = 2
|
||||
self.margin_right = 1
|
||||
info: MemberInfo
|
||||
|
||||
def build(self) -> rio.Component:
|
||||
contact_row = rio.Row()
|
||||
content = rio.Column(
|
||||
rio.Image(self._info.picture_path, height=9, margin_bottom=1.3, margin_top=0.8),
|
||||
rio.Text(self._info.name, margin_bottom=0.4, style=rio.TextStyle(font_weight="bold")),
|
||||
rio.Text(self._info.position, margin_bottom=0.4, style=rio.TextStyle(italic=True)),
|
||||
rio.Text(f"Mitglied seit {self._info.entry_date}", style=rio.TextStyle(italic=True), margin_bottom=0.4),
|
||||
rio.Image(self.info.picture_path, height=9, margin_bottom=1.3, margin_top=0.8),
|
||||
rio.Text(self.info.name, margin_bottom=0.4, style=rio.TextStyle(font_weight="bold")),
|
||||
rio.Text(self.info.position, margin_bottom=0.4, style=rio.TextStyle(italic=True)),
|
||||
rio.Text(f"Mitglied seit {self.info.entry_date}", style=rio.TextStyle(italic=True), margin_bottom=0.4),
|
||||
contact_row
|
||||
)
|
||||
|
||||
# @Todo: Icon alignment broken if only one icon should be shown.
|
||||
if self._info.contact_mail:
|
||||
contact_row.add(rio.Link(rio.Icon("material/mail"), f"mailto://{self._info.contact_mail}", open_in_new_tab=True, margin_top=1, margin_bottom=1, align_x=0.9))
|
||||
if self._info.contact_steam:
|
||||
contact_row.add(rio.Link(rio.Icon("custom/steam"), self._info.contact_steam, open_in_new_tab=True, margin_top=1, margin_bottom=1, align_x=0.1))
|
||||
if self.info.contact_mail:
|
||||
contact_row.add(rio.Link(rio.Icon("material/mail"), f"mailto://{self.info.contact_mail}", open_in_new_tab=True, margin_top=1, margin_bottom=1, align_x=0.9))
|
||||
if self.info.contact_steam:
|
||||
contact_row.add(rio.Link(rio.Icon("custom/steam"), self.info.contact_steam, open_in_new_tab=True, margin_top=1, margin_bottom=1, align_x=0.1))
|
||||
|
||||
if not self._info.contact_steam and not self._info.contact_mail:
|
||||
if not self.info.contact_steam and not self.info.contact_mail:
|
||||
contact_row.add(rio.Text("", margin_top=2))
|
||||
|
||||
return rio.Rectangle(
|
||||
@@ -51,3 +45,13 @@ class MemberCard(rio.Component):
|
||||
shadow_color=self.session.theme.hud_color,
|
||||
shadow_offset_y=0
|
||||
)
|
||||
|
||||
|
||||
def build_member_card(info: MemberInfo) -> MemberCard:
|
||||
return MemberCard(
|
||||
info=info,
|
||||
align_y=0,
|
||||
margin_top=0,
|
||||
margin_bottom=2,
|
||||
margin_right=1
|
||||
)
|
||||
|
||||
@@ -1,34 +1,36 @@
|
||||
from pathlib import Path
|
||||
from typing import Union
|
||||
|
||||
import rio
|
||||
|
||||
|
||||
class NewsPost(rio.Component):
|
||||
def __init__(self, header: str, article_text: Union[str, Path], date: str):
|
||||
super().__init__()
|
||||
header: str
|
||||
date: str
|
||||
article_text_path_or_text: str | Path
|
||||
article_text = ""
|
||||
|
||||
@rio.event.on_populate
|
||||
def on_populate(self):
|
||||
self.align_y = 0
|
||||
self.margin_top = 0
|
||||
self.margin_bottom = 2
|
||||
self.margin_right = 1
|
||||
self._header = header
|
||||
self._date = date
|
||||
if isinstance(article_text, str):
|
||||
self._article_text = article_text
|
||||
elif isinstance(article_text, Path):
|
||||
with open(article_text, "r", encoding="utf-8") as f:
|
||||
self._article_text = f.read()
|
||||
if isinstance(self.article_text_path_or_text, str):
|
||||
self.article_text = self.article_text_path_or_text
|
||||
elif isinstance(self.article_text_path_or_text, Path):
|
||||
with open(self.article_text_path_or_text, "r", encoding="utf-8") as f:
|
||||
self.article_text = f.read()
|
||||
|
||||
def build(self) -> rio.Component:
|
||||
return rio.Rectangle(
|
||||
content=rio.Column(
|
||||
rio.Row(
|
||||
rio.Text(self._header, align_x=0.1, style="heading2"),
|
||||
rio.Text(self._date, align_x=0.9, style=rio.TextStyle(italic=True)),
|
||||
rio.Text(self.header, align_x=0.1, style="heading2"),
|
||||
rio.Text(self.date, align_x=0.9, style=rio.TextStyle(italic=True)),
|
||||
margin_top=0.5
|
||||
),
|
||||
rio.Column(
|
||||
rio.Markdown(self._article_text, margin=1)
|
||||
rio.Markdown(self.article_text, margin=1)
|
||||
)
|
||||
),
|
||||
fill=self.session.theme.neutral_color,
|
||||
@@ -37,3 +39,15 @@ class NewsPost(rio.Component):
|
||||
shadow_color=self.session.theme.hud_color,
|
||||
shadow_offset_y=0
|
||||
)
|
||||
|
||||
|
||||
def build_news_post(header: str, article_text_path_or_text: str | Path, date: str) -> NewsPost:
|
||||
return NewsPost(
|
||||
header=header,
|
||||
article_text_path_or_text=article_text_path_or_text,
|
||||
date=date,
|
||||
align_y=0,
|
||||
margin_top=0,
|
||||
margin_bottom=2,
|
||||
margin_right=1
|
||||
)
|
||||
|
||||
@@ -2,10 +2,11 @@ import asyncio
|
||||
import logging
|
||||
from random import randint
|
||||
|
||||
from rio import Text, Component, TextStyle
|
||||
from rio import Text, Component, TextStyle, i_know_what_im_doing
|
||||
|
||||
|
||||
class Ticker(Component):
|
||||
@i_know_what_im_doing
|
||||
def __init__(self, texts: list[str], refresh_interval: float, style: TextStyle, tick_in_order: bool, **kwargs) -> None:
|
||||
super().__init__()
|
||||
if refresh_interval <= 0:
|
||||
|
||||
Reference in New Issue
Block a user