improve news and news manager
This commit is contained in:
@@ -2,7 +2,7 @@ from datetime import datetime
|
||||
from functools import partial
|
||||
from typing import Optional, Callable
|
||||
|
||||
from rio import Component, Rectangle, Text, TextStyle, Column, Row, TextInput, DateInput, MultiLineTextInput, IconButton, Color, Button
|
||||
from rio import Component, Rectangle, Text, TextStyle, Column, Row, TextInput, DateInput, MultiLineTextInput, IconButton, Color, Button, ThemeContextSwitcher
|
||||
|
||||
|
||||
class NewsPost(Component):
|
||||
@@ -94,56 +94,59 @@ class EditableNewsPost(NewsPost):
|
||||
self.__setattr__(prop, value)
|
||||
|
||||
def build(self) -> Component:
|
||||
return Rectangle(
|
||||
content=Column(
|
||||
Row(
|
||||
TextInput(
|
||||
text=self.title,
|
||||
label="Titel",
|
||||
style="rounded",
|
||||
min_width=15,
|
||||
on_change=lambda e: self.set_prop("title", e.text)
|
||||
return ThemeContextSwitcher(
|
||||
content=Rectangle(
|
||||
content=Column(
|
||||
Row(
|
||||
TextInput(
|
||||
text=self.title,
|
||||
label="Titel",
|
||||
style="rounded",
|
||||
min_width=15,
|
||||
on_change=lambda e: self.set_prop("title", e.text)
|
||||
),
|
||||
DateInput(
|
||||
value=datetime.strptime(self.date, "%d.%m.%Y"),
|
||||
style="rounded",
|
||||
on_change=lambda e: self.set_prop("date", e.value.strftime("%d.%m.%Y"))
|
||||
)
|
||||
),
|
||||
DateInput(
|
||||
value=datetime.strptime(self.date, "%d.%m.%Y"),
|
||||
style="rounded",
|
||||
on_change=lambda e: self.set_prop("date", e.value.strftime("%d.%m.%Y"))
|
||||
)
|
||||
),
|
||||
TextInput(
|
||||
text=self.subtitle,
|
||||
label="Untertitel",
|
||||
style="rounded",
|
||||
grow_x=True,
|
||||
on_change=lambda e: self.set_prop("subtitle", e.text)
|
||||
),
|
||||
MultiLineTextInput(
|
||||
text=self.text,
|
||||
label="Text",
|
||||
style="rounded",
|
||||
grow_x=True,
|
||||
min_height=12,
|
||||
on_change=lambda e: self.set_prop("text", e.text)
|
||||
),
|
||||
Row(
|
||||
TextInput(
|
||||
text=self.author,
|
||||
label="Autor",
|
||||
text=self.subtitle,
|
||||
label="Untertitel",
|
||||
style="rounded",
|
||||
grow_x=True,
|
||||
on_change=lambda e: self.set_prop("author", e.text)
|
||||
on_change=lambda e: self.set_prop("subtitle", e.text)
|
||||
),
|
||||
Rectangle(content=Button(icon="material/delete", style="major", color="danger", shape="rectangle", on_press=partial(self.delete_cb, self.news_id)), fill=Color.from_hex("0b7372")),
|
||||
Rectangle(content=Button(icon="material/save", style="major", color="success", shape="rectangle", on_press=partial(self.save_cb, self)), fill=Color.from_hex("0b7372"))
|
||||
)
|
||||
MultiLineTextInput(
|
||||
text=self.text,
|
||||
label="Text",
|
||||
style="rounded",
|
||||
grow_x=True,
|
||||
min_height=12,
|
||||
on_change=lambda e: self.set_prop("text", e.text)
|
||||
),
|
||||
Row(
|
||||
TextInput(
|
||||
text=self.author,
|
||||
label="Autor",
|
||||
style="rounded",
|
||||
grow_x=True,
|
||||
on_change=lambda e: self.set_prop("author", e.text)
|
||||
),
|
||||
Rectangle(content=Button(icon="material/delete", style="major", color="danger", shape="rectangle", on_press=partial(self.delete_cb, self.news_id)), fill=Color.from_hex("0b7372")),
|
||||
Rectangle(content=Button(icon="material/save", style="major", color="success", shape="rectangle", on_press=partial(self.save_cb, self)), fill=Color.from_hex("0b7372"))
|
||||
)
|
||||
),
|
||||
fill=self.session.theme.primary_color,
|
||||
margin_left=1,
|
||||
margin_right=1,
|
||||
margin_top=2,
|
||||
margin_bottom=1,
|
||||
shadow_radius=0.2,
|
||||
shadow_color=self.session.theme.background_color,
|
||||
shadow_offset_y=0,
|
||||
corner_radius=0.2
|
||||
),
|
||||
fill=self.session.theme.primary_color,
|
||||
margin_left=1,
|
||||
margin_right=1,
|
||||
margin_top=2,
|
||||
margin_bottom=1,
|
||||
shadow_radius=0.2,
|
||||
shadow_color=self.session.theme.background_color,
|
||||
shadow_offset_y=0,
|
||||
corner_radius=0.2
|
||||
color="primary"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user