2
0
mirror of https://github.com/ComradCollective/Comrad synced 2024-11-11 13:10:45 +00:00
This commit is contained in:
quadrismegistus 2020-08-22 20:39:56 +01:00
parent 083de5e0ff
commit 4a493fe3d3
5 changed files with 116 additions and 25 deletions

View File

@ -259,6 +259,7 @@ Builder.load_string('''
<MyTextInput>:
readonly: False
multiline: False
size_hint:1,None
<SelectableLabel>:
@ -324,13 +325,18 @@ class SelectableLabel(RecycleDataViewBehavior, Label):
# raise Exception(str([is_selected, rv.data[index]]))
newval=rv.data[index]['text']
try:
pcard=self.parent.parent.parent.parent.parent
pcard=self.parent.parent.parent.parent
except AttributeError:
return
pcard.recipient=newval[1:]
pcard.parent.recipient=newval[1:]
pcard.parent.close_author_option()
alabel=pcard.author_label
alabel.text=f'@{pcard.author}\n[size=14sp]to @{pcard.recipient}[/size]'
pcard.author_section_layout.remove_widget(pcard.parent.to_whom_btn)
#pcard.remove_widget(pcard.parent.to_whom_btn)
# pcard.author_section_layout.remove_widget(pcard.author_section_layout.children[2])
# pcard.remove_widget(pcard.parent.to_whom_btn)
# pcard.remove_widget(self.parent.parent.parent)

View File

@ -26,6 +26,29 @@ class BaseScreen(MDScreen):
def channel(self):
return self.app.channel
def open_dialog(self,msg):
from screens.post.post import MessagePopup,ProgressPopup
if not hasattr(self,'dialog') or not self.dialog:
self.dialog = ProgressPopup()
self.dialog.ids.progress_label.text=msg
self.dialog.open()
def open_msg_dialog(self,msg):
from screens.post.post import MessagePopup,ProgressPopup
if not hasattr(self,'msg_dialog') or not self.msg_dialog:
self.msg_dialog = MessagePopup()
self.msg_dialog.ids.msg_label.text=msg
self.msg_dialog.open()
def close_dialog(self):
if hasattr(self,'dialog'):
self.dialog.dismiss()
def close_msg_dialog(self):
if hasattr(self,'msg_dialog'):
self.msg_dialog.dismiss()
class ProtectedScreen(BaseScreen): pass
# def on_pre_enter(self):
# if not self.channel in self.app.api.keys:

View File

@ -132,7 +132,9 @@ class PostCard(MDCard):
self.author_label = author_label = PostAuthorLabel(text='@'+self.author)
self.author_label.font_name='assets/overpass-mono-semibold.otf'
if self.recipient:
self.author_label.text+='\n[size=14sp]to @'+self.recipient+'[/size]'
recip=self.recipient
recip='@'+recip if recip and recip[0].isalpha() else recip
self.author_label.text+='\n[size=14sp]to '+recip+'[/size]'
self.author_label.markup=True
self.author_label.font_size = '18sp'
self.author_avatar = author_avatar = PostAuthorAvatar(source='assets/avatar.jpg') #self.img_src)

View File

@ -68,8 +68,8 @@
on_release: self.screen.post() #self.post_content_input.text, file_chooser_button.selection)
theme_text_color: "Custom"
text_color: rgb(*COLOR_TEXT)
md_bg_color: 0,0,0,1
font_size: '28sp'
# md_bg_color: 0,0,0,1
# font_size: '28sp'
# fill:rgb(*COLOR_TEXT)
font_name: 'assets/overpass-mono-regular.otf'
@ -89,14 +89,14 @@
type: "custom"
size_hint: (None, None)
size: ('200dp','200dp')
md_bg_color: 0,0,0,1
# md_bg_color: 0,0,0,1
MDBoxLayout:
id: popup_box_layout
size_hint:(1,1)
orientation: 'vertical'
cols:1
md_bg_color: 0,0,0,1
md_bg_color: rgb(*COLOR_ACCENT)
spacing:'0dp'
padding:'0dp'
# radius:[20,]
@ -134,7 +134,7 @@
type: "custom"
size_hint: None,None
size: ('300dp','300dp')
md_bg_color: 0,0,0,1
# md_bg_color: 0,0,0,1
MDBoxLayout:
id: msg_popup_box_layout
@ -260,3 +260,38 @@
# text: "ALERT DIALOG"
# pos_hint: {'center_x': .5, 'center_y': .5}
# on_release: app.show_simple_dialog()
<SelectPopup>:
type: "custom"
size_hint: None,None
size: ('300dp','300dp')
md_bg_color: 0,0,0,1
MDBoxLayout:
id: msg_popup_box_layout
size_hint:(1,1)
orientation: 'vertical'
cols:1
md_bg_color: 0,0,0,1
spacing:'0dp'
padding:'0dp'
pos_hint: {'center_x':0.5, 'center_y':0.5}
# radius:[20,]
# border_radius:20
MDLabel:
# size_hint:(None,None)
id: msg_label
text: ''
halign: 'center'
# valign: 'middle'
theme_text_color: 'Custom'
text_color: rgb(*COLOR_TEXT)
font_size: '18dp'
font_name: 'assets/overpass-mono-regular.otf'
pos_hint: {'center_x': .5, 'y': 0}

View File

@ -84,10 +84,16 @@ class PostScreen(ProtectedScreen):
post_id = ObjectProperty()
def open_author_option(self):
self.to_whom_btn.height='100dp'
self.to_whom_btn.size_hint_y=None
import kivy
try:
self.post_card.add_widget(self.to_whom_btn,1)
self.to_whom_btn.height='100dp'
self.to_whom_btn.size_hint_y=None
except kivy.uix.widget.WidgetException:
return
def close_author_option(self):
self.post_card.remove_widget(self.to_whom_btn)
self.to_whom_btn.height='0dp'
self.to_whom_btn.size_hint_y=None
@ -103,7 +109,7 @@ class PostScreen(ProtectedScreen):
post_json = {'author':self.app.username, 'timestamp':time.time()}
key=list(self.app.keys.keys())[0]
# post_json['to_name']=key
post_json['to_name']='...?'
self.post_card = post = PostCard(post_json)
self.post_card.add_widget(get_separator('15sp'),1)
@ -121,18 +127,27 @@ class PostScreen(ProtectedScreen):
)
inp_towhom = self.to_whom_btn.ids.txt_input
inp_towhom.size_hint=(None,None)
# inp_towhom.width = '100sp'
inp_towhom.width = '100sp'
inp_towhom.font_name='assets/font.otf'
# inp_towhom.height = '75sp'
inp_towhom.adaptive_height=True
inp_towhom.md_bg_color=rgb(*COLOR_CARD)
# self.post_card.author_section_layout.md_bg_color=1,0,0,1
self.to_whom_layo = MDBoxLayout()
self.to_whom_layo.cols=1
self.to_whom_layo.size_hint=(None,None)
# self.to_whom_layo.width='200sp'
# self.to_whom_layo.md_bg_color=1,1,0,1
# self.to_whom_layo.size_hint=(None,None)
self.to_whom_layo.width='300sp'
self.to_whom_layo.height='2000sp'
self.to_whom_layo.md_bg_color=1,1,0,1
# self.post_card.author_section_layout.add_widget(MDLabel(text='-->'),1)
self.post_card.author_section_layout.add_widget(self.to_whom_btn,1)
# self.post_card.author_section_layout.add_widget(self.to_whom_btn)
# self.to_whom_layo.add_widget(self.to_whom_btn)
# self.tmp_msg = MDLabel(text='-->')
self.post_card.add_widget(self.to_whom_btn,1)
self.to_whom_btn.ids.txt_input.text = '@'
#self.to_whom_btn.adaptive_height = True
self.to_whom_btn.ids.txt_input.word_list = ['@'+k for k in self.app.keys if k != self.app.username]
@ -141,7 +156,10 @@ class PostScreen(ProtectedScreen):
#self.post_card.author_section_layout.add_widget(self.to_whom_btn,3)
# close for now
self.close_author_option()
# self.close_author_option()
# self.post_card.remove_widget(self.to_whom_btn)
# self.to_whom_btn.height='0dp'
# self.to_whom_btn.size_hint_y=None
# remove content, add text input
post.scroller.remove_widget(post.post_content)
@ -165,10 +183,13 @@ class PostScreen(ProtectedScreen):
self.button_layout.add_widget(self.upload_button)
self.button_layout.add_widget(self.post_button)
self.upload_button.font_size='12sp'
self.post_button.font_size='12sp'
self.post_button.md_bg_color=(0,0,0,1)
self.upload_button.md_bg_color=(0,0,0,1)
self.post_status.md_bg_color=(0,0,0,1)
self.post_button.md_bg_color=rgb(*COLOR_ACTIVE)
self.upload_button.md_bg_color=rgb(*COLOR_ACTIVE)
self.post_status.md_bg_color=rgb(*COLOR_CARD)
self.add_widget(self.button_layout)
# self.add_widget(self.post_status)
@ -264,11 +285,12 @@ class PostScreen(ProtectedScreen):
self.open_msg_dialog(f'Text is currently {lencontent} words long, which is {lendiff} over the maximum text length of {maxlen} words.\n\n({lencontent}/{maxlen})')
return
channels = [k[1:] for k,v in self.to_channels.items() if v]
if not channels:
self.log('no place was selected')
#channels = [k[1:] for k,v in self.to_channels.items() if v]
if not hasattr(self,'recipient') or not self.recipient or self.app.username==self.recipient:
self.log('no recipient was selected')
# self.='No place was selected'
return
channels = [self.recipient]
# log('?????????????????'+self.media_uid)
# if not hasattr(self,'img_id') and self.upload_button.selection:
@ -291,3 +313,6 @@ class PostScreen(ProtectedScreen):
def get_random_id():
import uuid
return uuid.uuid4().hex
class MessagePopup(MDDialog): pass