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

61 lines
1.5 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-10 16:37:42 +00:00
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()
def on_enter(self):
2020-08-10 21:16:36 +00:00
post = self.app.get_post(self.root.post_id)
log(post)
2020-08-10 20:38:00 +00:00
post = PostCard(
author='Marx Zuckerberg',
title='',
img_src='avatar.jpg',
2020-08-10 21:16:36 +00:00
content=post['content'])
2020-08-10 20:38:00 +00:00
print(post)
self.add_widget(post)
pass