2
0
mirror of https://github.com/ComradCollective/Comrad synced 2024-11-05 21:20:51 +00:00
Comrad/client/screens/post/post.py

70 lines
1.8 KiB
Python
Raw Normal View History

2020-08-10 16:37:42 +00:00
from screens.base import ProtectedScreen
from plyer import filechooser
from kivymd.uix.button import MDRectangleFlatButton, MDIconButton
2020-08-10 20:38:00 +00:00
from kivy.properties import ListProperty,ObjectProperty
from kivy.app import App
2020-08-10 20:38:00 +00:00
from main import log
from screens.feed.feed import *
2020-08-11 13:01:48 +00:00
import os
class FileChoose(MDRectangleFlatButton):
'''
Button that triggers 'filechooser.open_file()' and processes
the data response from filechooser Activity.
'''
selection = ListProperty([])
def choose(self):
'''
Call plyer filechooser API to run a filechooser Activity.
'''
filechooser.open_file(on_selection=self.handle_selection)
def handle_selection(self, selection):
'''
Callback function for handling the selection response from Activity.
'''
self.selection = selection
def on_selection(self, *a, **k):
'''
Update TextInput.text after FileChoose.selection is changed
via FileChoose.handle_selection.
'''
pass
#App.get_running_app().root.ids.result.text = str(self.selection)
2020-08-10 20:38:00 +00:00
class AddPostScreen(ProtectedScreen):
post_id = ObjectProperty()
pass
class ViewPostScreen(ProtectedScreen):
post_id = ObjectProperty()
2020-08-11 13:01:48 +00:00
def on_pre_enter(self):
for child in self.children:
log('child: '+str(child))
self.remove_widget(child)
2020-08-10 21:16:36 +00:00
post = self.app.get_post(self.root.post_id)
log(post)
2020-08-11 13:01:48 +00:00
img_src=os.path.join('cache','img',post['img_src']) if post['img_src'] else ''
kwargs = dict(author='Marx Zuckerberg',
2020-08-10 20:38:00 +00:00
title='',
2020-08-11 13:01:48 +00:00
img_src=img_src,
2020-08-10 21:16:36 +00:00
content=post['content'])
2020-08-11 13:01:48 +00:00
log(kwargs)
post = PostCard(**kwargs)
2020-08-10 20:38:00 +00:00
print(post)
self.add_widget(post)
2020-08-11 13:01:48 +00:00
def on_enter(self):
pass
2020-08-10 20:38:00 +00:00
pass