ok last push

pull/20/head
quadrismegistus 4 years ago
parent b1f5fe3e0e
commit ae7589e4a6

@ -313,7 +313,8 @@ class MainApp(MDApp):
self.root.ids.login_screen.login_status.text_color=rgb(*COLOR_ACCENT)
await asyncio.sleep(1)
#self.save_login(dat)
self.change_screen_from_uri('/inbox/world')
# self.change_screen_from_uri('/inbox/world')
self.change_screen('profile')
return True
elif 'error' in dat:
self.root.ids.login_screen.login_status.text=dat['error']
@ -384,6 +385,9 @@ class MainApp(MDApp):
async def get_posts(self,uri='/inbox/world'):
if uri.count('/')<2: raise Exception('not a URI: '+uri)
if 'login' in uri:
raise Exception('!!!! '+uri)
self.log(f'app.get_posts(uri={uri} -> ...')
data = await self.api.get_posts(uri)
self.log(f'app.get_posts() got back from api.get_posts() a {type(data)}')

@ -225,10 +225,13 @@ from kivy.uix.behaviors import FocusBehavior
from kivy.uix.recycleview.layout import LayoutSelectionBehavior
Builder.load_string('''
#:import COLOR_CARD main.COLOR_CARD
#:import rgb main.rgb
<Body>:
canvas:
Color:
rgba:(1, 1, 1, 1)
rgba:rgb(*COLOR_CARD)
Rectangle:
pos: self.pos
size: self.size
@ -237,7 +240,7 @@ Builder.load_string('''
<DropDownWidget>:
canvas:
Color:
rgba:(1, 1, 1, 1)
rgba:rgb(*COLOR_CARD)
Rectangle:
pos: self.pos
size: self.size
@ -265,22 +268,24 @@ Builder.load_string('''
<SelectableLabel>:
# Draw a background to indicate selection
color: 0,0,0,1
font_name: 'assets/font.otf'
canvas.before:
Color:
rgba: (0, 0, 1, .5) if self.selected else (1, 1, 1, 1)
rgba: (0, 0, 8, .5) if self.selected else rgb(*COLOR_CARD)
Rectangle:
pos: self.pos
size: self.size
<RV>:
# height:'400sp'
canvas:
Color:
rgba: 0,0,0,.2
rgba: 0,0,0,0
Line:
rectangle: self.x +1 , self.y, self.width - 2, self.height -2
bar_width: 10
bar_width: 0
scroll_type:['bars']
viewclass: 'SelectableLabel'
SelectableRecycleBoxLayout:
@ -325,7 +330,7 @@ class SelectableLabel(RecycleDataViewBehavior, Label):
# raise Exception(str([is_selected, rv.data[index]]))
newval=rv.data[index]['text']
try:
pcard=self.parent.parent.parent.parent
pcard=self.parent.parent.parent.parent.parent
except AttributeError:
return
@ -334,11 +339,11 @@ class SelectableLabel(RecycleDataViewBehavior, Label):
pcard.parent.close_author_option()
alabel=pcard.author_label
alabel.text=f'@{pcard.author}\n[size=14sp]to @{pcard.recipient}[/size]'
#alabel.text=f'@{pcard.author}\n[size=14sp]to @{pcard.recipient}[/size]'
pcard.parent.to_whom_btn.ids.txt_input.text = recip
pcard.parent.to_whom_btn.ids.txt_input.text = '@'+recip
#pcard.remove_widget(pcard.parent.to_whom_btn)
pcard.parent.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)
@ -376,20 +381,21 @@ class MyTextInput(TextInput):
display_data.append({'text':i})
self.parent.ids.rv.data = display_data
#ensure the size is okay
if len(matches) <= 10:
self.parent.height = (50 + (len(matches)*20))
if len(matches) <= 10*2:
self.parent.height = (50*2 + (len(matches)*20*2))
else:
self.parent.height = 240
self.parent.height = 240*2
def keyboard_on_key_down(self, window, keycode, text, modifiers):
pcard = self.parent.parent
recip = pcard.parent.to_whom_btn.ids.txt_input.text.strip()
recip = recip[1:] if recip and recip[0]=='@' else recip
pcard.recipient = recip
alabel=pcard.author_label
alabel.text=f'@{pcard.author}\n[size=14sp]to @{pcard.recipient}'
# pcard = self.parent.parent.parent
# # raise Exception(type(pcard))
# recip = pcard.parent.to_whom_btn.ids.txt_input.text.strip()
# recip = recip[1:] if recip and recip[0]=='@' else recip
# pcard.recipient = recip
# alabel=pcard.author_label
# #alabel.text=f'@{pcard.author}\n[size=14sp]to @{pcard.recipient}'

@ -164,7 +164,7 @@ MyLayout:
background_palette: 'Red'
theme_text_color:'Custom'
background_hue: '500'
right_action_items: [['card-text', partial(root.change_screen_from_uri, '/inbox/world')],['pencil-plus-outline', partial(root.change_screen, 'post')],['message-outline', partial(root.change_screen, 'messages')],['account-circle-outline', partial(root.change_screen, 'profile')],['exit-run', partial(root.change_screen, 'login')]]
right_action_items: [['account-circle-outline', partial(root.change_screen, 'profile')],['card-text', partial(root.change_screen_from_uri, '/inbox/world')],['message-outline', partial(root.change_screen, 'messages')],['pencil-plus-outline', partial(root.change_screen, 'post')],['exit-run', partial(root.change_screen, 'login')]]
#left_action_items: [[f"assets/fist2.png", partial(root.change_screen, 'feed')]]
# ['bell-outline', partial(root.change_screen, 'login')]

@ -12,6 +12,7 @@
Carousel:
id: post_carousel
direction: 'right'
loop: True
@ -142,11 +143,11 @@
id: post_content
text: ''
pos_hint: {'center_y':1}
font_size:'15sp'
font_size:'13sp'
# font_style:'H5'
#font_name: "Strengthen"
# height: '400'
size_hint_y: 1
#size_hint_y: 1
text_color:rgb(*COLOR_TEXT)
theme_text_color: 'Custom'
halign: 'left'

@ -192,7 +192,7 @@ class PostCard(MDCard):
#log('img_src ' + str(bool(self.img_src)))
if self.img_src: self.add_widget(image_layout)
def estimate_height(minlen=100,maxlen=500):
def estimate_height(minlen=100,maxlen=300):
num_chars = len(self.content)
# num_lines = num_chars
height = num_chars*1.1
@ -253,6 +253,7 @@ class FeedScreen(BaseScreen):
lim=25
posts=await self.app.get_posts(self.app.uri)
for i,post in enumerate(reversed(posts)):
# for i,post in enumerate(posts)):
#if ln.startswith('@') or ln.startswith('RT '): continue
#i+=1
if i>lim: break

@ -58,7 +58,8 @@
#app.register(username.text, password.text)
theme_text_color: "Custom"
text_color: rgb(*COLOR_TEXT)
md_bg_color: 0,0,0,1
md_bg_color: 0,0,0,0
size_hint:None,None
font_size: '28sp'
# fill:rgb(*COLOR_TEXT)
font_name: 'assets/overpass-mono-regular.otf'

@ -126,17 +126,23 @@ class PostScreen(ProtectedScreen):
post_TextField.font_name='assets/overpass-mono-regular.otf'
post_TextField.hint_text='word?'
self.to_whom_btn = DropDownWidget(
pos_hint = {'x':0,'center_y':.5},
self.post_card.to_whom_btn = self.to_whom_btn = DropDownWidget(
pos_hint = {'center_x':0.5,'center_y':0.5},
size_hint = (None, None),
height='200sp',
width='100sp'
)
inp_towhom = self.to_whom_btn.ids.txt_input
inp_towhom.size_hint=(None,None)
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)
inp_towhom.background_color=rgb(*COLOR_CARD)
inp_towhom.color=rgb(*COLOR_CARD)
inp_towhom.text_color=rgb(*COLOR_CARD)
inp_towhom.theme_text_color='Custom'
# self.post_card.author_section_layout.md_bg_color=1,0,0,1
self.to_whom_layo = MDBoxLayout()
self.to_whom_layo.cols=1
@ -149,8 +155,9 @@ class PostScreen(ProtectedScreen):
# 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.tmp_msg = MDLabel(text='to')
# self.post_card.author_section_layout.add_widget(self.tmp_msg,1)
self.post_card.author_section_layout.add_widget(self.to_whom_btn,1)
self.to_whom_btn.ids.txt_input.text = '@'
@ -184,19 +191,20 @@ class PostScreen(ProtectedScreen):
self.post_button.screen = self
self.post_status = PostStatus()
self.post_status_added = False
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.upload_button.font_size='8sp'
self.post_button.font_size='8sp'
self.post_button.md_bg_color=rgb(*COLOR_ACTIVE)
self.upload_button.md_bg_color=rgb(*COLOR_ACTIVE)
self.post_button.md_bg_color=rgb(*COLOR_CARD)
self.upload_button.md_bg_color=rgb(*COLOR_CARD)
self.post_status.md_bg_color=rgb(*COLOR_CARD)
self.add_widget(self.button_layout)
post.add_widget(self.button_layout)
# self.add_widget(self.post_status)
@ -297,6 +305,8 @@ class PostScreen(ProtectedScreen):
self.log('no recipient was selected')
# self.='No place was selected'
return
if recipient.startswith('@'): recipient=recipient[1:]
self.recipient = recipient
channel = recipient
@ -311,6 +321,7 @@ class PostScreen(ProtectedScreen):
await self.app.post(content=content, channel = channel, file_id=file_id, file_ext=file_ext)
import time
self.close_dialog()
self.app.change_screen_from_uri('/inbox/'+channel)
# self.open_dialog('')
#Thread(target=do_post).start()

@ -602,7 +602,7 @@ class Api(object):
def add_world_key(self,fn=PATH_WORLD_KEY):
import shutil
thisdir=os.path.dirname(__file__)
fnfn=os.path.join(thisdir,fn)
fnfn=os.path.join(thisdir,fn+'.priv')
self.log('getting',fnfn)
name='.'.join(os.path.basename(fn).split('.')[1:-1])

Loading…
Cancel
Save