|
|
@ -18,7 +18,7 @@ from kivymd.uix.card import MDCard, MDSeparator
|
|
|
|
from kivy.uix.gridlayout import GridLayout
|
|
|
|
from kivy.uix.gridlayout import GridLayout
|
|
|
|
from kivy.metrics import dp
|
|
|
|
from kivy.metrics import dp
|
|
|
|
from kivy.properties import NumericProperty
|
|
|
|
from kivy.properties import NumericProperty
|
|
|
|
from kivymd.uix.list import MDList, ThreeLineAvatarListItem
|
|
|
|
from kivymd.uix.list import MDList, TwoLineAvatarListItem, ImageLeftWidget
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
root = None
|
|
|
|
root = None
|
|
|
@ -45,67 +45,40 @@ class MyLabel(MDLabel):
|
|
|
|
for k,v in kwargs.items(): setattr(self,k,v)
|
|
|
|
for k,v in kwargs.items(): setattr(self,k,v)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ScrollCenterLayout(GridLayout):
|
|
|
|
class Post(TwoLineAvatarListItem):
|
|
|
|
rel_max = NumericProperty(dp(800))
|
|
|
|
"""
|
|
|
|
rel_min = NumericProperty(dp(400))
|
|
|
|
text: "Three-line item with avatar"
|
|
|
|
|
|
|
|
secondary_text: "Secondary text here"
|
|
|
|
def __init__(self, **kwargs):
|
|
|
|
tertiary_text: "fit more text than usual"
|
|
|
|
super(ScrollCenterLayout, self).__init__(**kwargs)
|
|
|
|
text_color: 1,0,0,1
|
|
|
|
|
|
|
|
theme_text_color: 'Custom'
|
|
|
|
self.rel_max = kwargs.get('rel_max', dp(800))
|
|
|
|
"""
|
|
|
|
self.rel_min = kwargs.get('rel_min', dp(400))
|
|
|
|
def __init__(self, title, content, *args, **kwargs):
|
|
|
|
|
|
|
|
super().__init__() #*args, **kwargs)
|
|
|
|
def on_width(self, instance, value):
|
|
|
|
self.text = title
|
|
|
|
if self.rel_max < value:
|
|
|
|
self.secondary_text = content
|
|
|
|
padding = max(value * .125, (value - self.rel_max) / 2)
|
|
|
|
|
|
|
|
elif self.rel_min < value:
|
|
|
|
|
|
|
|
padding = min(value * .125, (value - self.rel_min) / 2)
|
|
|
|
|
|
|
|
elif self.rel_min < value:
|
|
|
|
|
|
|
|
padding = (value - self.rel_min) / 2
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
padding = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.padding[0] = self.padding[2] = padding
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Post(MDCard):
|
|
|
|
# self.theme_text_color='Custom'
|
|
|
|
"""MDCard:
|
|
|
|
# self.secondary_theme_text_color = 'Custom'
|
|
|
|
orientation: "vertical"
|
|
|
|
|
|
|
|
padding: "8dp"
|
|
|
|
|
|
|
|
size_hint: None, None
|
|
|
|
|
|
|
|
size: "280dp", "180dp"
|
|
|
|
|
|
|
|
pos_hint: {"center_x": .5, "center_y": .5}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MDLabel:
|
|
|
|
# self.text_color=(1,0,0,1)
|
|
|
|
text: "Title"
|
|
|
|
# self.secondary_text_color = (1,0,0,1)
|
|
|
|
theme_text_color: "Secondary"
|
|
|
|
|
|
|
|
size_hint_y: None
|
|
|
|
|
|
|
|
height: self.texture_size[1]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MDSeparator:
|
|
|
|
avatar = ImageLeftWidget()
|
|
|
|
height: "1dp"
|
|
|
|
avatar.source = 'avatar.jpg'
|
|
|
|
|
|
|
|
self.add_widget(avatar)
|
|
|
|
|
|
|
|
|
|
|
|
MDLabel:
|
|
|
|
|
|
|
|
text: "Body"
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, title, author, content):
|
|
|
|
|
|
|
|
super().__init__()
|
|
|
|
|
|
|
|
self.orientation='vertical'
|
|
|
|
|
|
|
|
self.padding=dp(15)
|
|
|
|
|
|
|
|
self.size_hint = (1, None)
|
|
|
|
|
|
|
|
self.pos_hint = {"center_x": .5, "center_y": .5}
|
|
|
|
|
|
|
|
self.md_bg_color = (0.1,0.1,0.1,1)
|
|
|
|
|
|
|
|
self.halign = 'center'
|
|
|
|
|
|
|
|
self.add_widget(MyLabel(text=title, halign='left', size_hint_y=None)) #, size_hint_y=None, height='10dp'))
|
|
|
|
|
|
|
|
# self.add_widget(MyLabel(text=author, halign='left')) #, size_hint_y=None, height='10dp'))
|
|
|
|
|
|
|
|
self.add_widget(MyLabel(text=content, halign='left')) #, size_hint_y=None, height='50dp'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FeedScreen(MDScreen):
|
|
|
|
class FeedScreen(MDScreen):
|
|
|
|
def on_enter(self):
|
|
|
|
def on_enter(self):
|
|
|
|
for i in range(25):
|
|
|
|
lim=25
|
|
|
|
post = Post(title=f'Title {i}', author=f'Author {i}', content='This is the content')
|
|
|
|
with open('tweets.txt') as f:
|
|
|
|
|
|
|
|
for i,ln in enumerate(f):
|
|
|
|
|
|
|
|
if i>lim: break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
post = Post(title=f'Marx Zuckerberg', content=ln.strip())
|
|
|
|
|
|
|
|
|
|
|
|
sep = MDSeparator()
|
|
|
|
sep = MDSeparator()
|
|
|
|
sep.height='1dp'
|
|
|
|
sep.height='1dp'
|
|
|
|