pull/20/head
quadrismegistus 4 years ago
parent 0e4ad88e8a
commit 6bd1f8c1b1

@ -8,7 +8,7 @@ WINDOW_SIZE = (1136*FACTOR,640*FACTOR) if HORIZONTAL else (640*FACTOR,1136*FACTO
PLAYING_CARDS = (2.5,3.5)
ASPECT_RATIO = PLAYING_CARDS[0]/PLAYING_CARDS[1]
HEIGHT = 800
HEIGHT = 850
if platform.platform().startswith('Linux'):
HEIGHT *= 2

@ -23,6 +23,7 @@ from kivymd.app import MDApp
from kivymd.uix.button import MDFillRoundFlatButton, MDIconButton
from kivymd.uix.toolbar import MDToolbar
from kivymd.uix.screen import MDScreen
from kivymd.uix.dialog import MDDialog
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivymd.theming import ThemeManager
@ -89,7 +90,8 @@ class MyLayout(MDBoxLayout):
self.post_id=post_id
self.change_screen('view')
class ProgressPopup(MDDialog): pass
class MessagePopup(MDDialog): pass
class MyBoxLayout(MDBoxLayout): pass
class MyLabel(MDLabel): pass
@ -196,6 +198,7 @@ class MainApp(MDApp):
store_global = JsonStore('../p2p/.keys.global.json')
login_expiry = 60 * 60 * 24 * 7 # once a week
texture = ObjectProperty()
uri = '/inbox/world'
# def connect(self):
# # connect to kad?
@ -237,7 +240,7 @@ class MainApp(MDApp):
self.load_store()
self.uri=DEFAULT_URI
# connect to API
self.api = api.Api(log=self.log)
self.api = api.Api(log=self.log,app=self)
@property
def channel(self):
@ -344,6 +347,7 @@ class MainApp(MDApp):
if content: jsond['content']=str(content)
if file_id: jsond['file_id']=str(file_id)
if file_ext: jsond['file_ext']=str(file_ext)
if channel and channel[0]=='@': channel=channel[1:]
self.log(f'''app.json(
content={content},
file_id={file_id},
@ -427,6 +431,33 @@ class MainApp(MDApp):
def open_dialog(self,msg):
if not hasattr(self,'dialog') or not self.dialog:
self.dialog = ProgressPopup()
# raise Exception(self.dialog, msg)
self.dialog.text=msg
self.dialog.open()
#stop
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()
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(MainApp().app_func())

@ -329,13 +329,15 @@ class SelectableLabel(RecycleDataViewBehavior, Label):
except AttributeError:
return
pcard.recipient=newval[1:]
recip=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.parent.to_whom_btn.ids.txt_input.text = recip
#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)
@ -380,6 +382,17 @@ class MyTextInput(TextInput):
self.parent.height = 240
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}'
if self.suggestion_text and keycode[1] == 'tab':
self.insert_text(self.suggestion_text + ' ')
return True

@ -46,6 +46,94 @@
<ProgressPopup>:
type: "custom"
size_hint: (None, None)
size: ('200dp','200dp')
# md_bg_color: 0,0,0,1
MDBoxLayout:
id: popup_box_layout
size_hint:(1,1)
orientation: 'vertical'
cols:1
md_bg_color: rgb(*COLOR_ACCENT)
spacing:'0dp'
padding:'0dp'
# radius:[20,]
# border_radius:20
canvas:
Color:
rgb: rgb(*COLOR_TEXT)
Line:
width: 1
rectangle: (self.x, self.y, self.width, self.height)
# radius:[20,]
# border_radius:20
MDLabel:
size_hint:(None,None)
# id: progress_label
text: ''
halign: 'center'
theme_text_color: 'Custom'
text_color: rgb(*COLOR_TEXT)
font_size: '18dp'
font_name: 'assets/overpass-mono-regular.otf'
pos_hint: {'center_x': .5, 'center_y': 0.5}
MDSpinner:
size_hint: None, None
size: '46dp','46dp'
pos_hint: {'center_x': .5, 'center_y': 0.5}
active: True
color:rgb(*COLOR_TEXT)
<MessagePopup>:
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}
### LAYOUT
MyLayout:
@ -75,8 +163,10 @@ MyLayout:
background_palette: 'Red'
theme_text_color:'Custom'
background_hue: '500'
right_action_items: [['card-text-outline', partial(root.change_screen, 'feed')], ['pencil-plus-outline', partial(root.change_screen, 'post')], ['message-outline', partial(root.change_screen, 'messages')], ['bell-outline', partial(root.change_screen, 'login')], ['account-circle-outline', partial(root.change_screen, 'profile')]]
right_action_items: [['earth', partial(root.change_screen, 'feed')],['email-receive-outline', partial(root.change_screen, 'messages')],['account-tie-voice-outline', partial(root.change_screen, 'profile')],['pencil-plus-outline', partial(root.change_screen, 'post')], ['wardrobe-outline', partial(root.change_screen, 'login')]]
#left_action_items: [[f"assets/fist2.png", partial(root.change_screen, 'feed')]]
# ['bell-outline', partial(root.change_screen, 'login')]
font_context: None
font_name: f'assets/Strengthen.ttf'
# canvas:

@ -26,27 +26,6 @@ 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

@ -142,7 +142,7 @@
id: post_content
text: ''
pos_hint: {'center_y':1}
font_size:'13sp'
font_size:'15sp'
# font_style:'H5'
#font_name: "Strengthen"
# height: '400'

@ -245,7 +245,7 @@ class FeedScreen(BaseScreen):
i=0
lim=25
posts=await self.app.get_posts()
posts=await self.app.get_posts(self.app.uri)
for i,post in enumerate(reversed(posts)):
#if ln.startswith('@') or ln.startswith('RT '): continue
#i+=1

@ -2,5 +2,10 @@ from screens.base import ProtectedScreen
from screens.feed.feed import *
from screens.post.post import *
class MessagesScreen(PostScreen): pass
class MessagesScreen(FeedScreen):
def on_pre_enter(self):
if not self.app.username: return
self.app.uri = '/inbox/'+self.app.username
super().on_pre_enter()

@ -85,82 +85,82 @@
# fill:rgb(*COLOR_TEXT)
font_name: 'assets/overpass-mono-regular.otf'
<ProgressPopup>:
type: "custom"
size_hint: (None, None)
size: ('200dp','200dp')
# md_bg_color: 0,0,0,1
MDBoxLayout:
id: popup_box_layout
size_hint:(1,1)
orientation: 'vertical'
cols:1
md_bg_color: rgb(*COLOR_ACCENT)
spacing:'0dp'
padding:'0dp'
# radius:[20,]
# border_radius:20
canvas:
Color:
rgb: rgb(*COLOR_TEXT)
Line:
width: 1
rectangle: (self.x, self.y, self.width, self.height)
# radius:[20,]
# border_radius:20
MDLabel:
size_hint:(None,None)
id: progress_label
text: ''
halign: 'center'
theme_text_color: 'Custom'
text_color: rgb(*COLOR_TEXT)
font_size: '18dp'
font_name: 'assets/overpass-mono-regular.otf'
pos_hint: {'center_x': .5, 'center_y': 0.5}
MDSpinner:
size_hint: None, None
size: '46dp','46dp'
pos_hint: {'center_x': .5, 'center_y': 0.5}
active: True
color:rgb(*COLOR_TEXT)
<MessagePopup>:
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}
# <ProgressPopup>:
# type: "custom"
# size_hint: (None, None)
# size: ('200dp','200dp')
# # md_bg_color: 0,0,0,1
# MDBoxLayout:
# id: popup_box_layout
# size_hint:(1,1)
# orientation: 'vertical'
# cols:1
# md_bg_color: rgb(*COLOR_ACCENT)
# spacing:'0dp'
# padding:'0dp'
# # radius:[20,]
# # border_radius:20
# canvas:
# Color:
# rgb: rgb(*COLOR_TEXT)
# Line:
# width: 1
# rectangle: (self.x, self.y, self.width, self.height)
# # radius:[20,]
# # border_radius:20
# MDLabel:
# size_hint:(None,None)
# # id: progress_label
# text: ''
# halign: 'center'
# theme_text_color: 'Custom'
# text_color: rgb(*COLOR_TEXT)
# font_size: '18dp'
# font_name: 'assets/overpass-mono-regular.otf'
# pos_hint: {'center_x': .5, 'center_y': 0.5}
# MDSpinner:
# size_hint: None, None
# size: '46dp','46dp'
# pos_hint: {'center_x': .5, 'center_y': 0.5}
# active: True
# color:rgb(*COLOR_TEXT)
# <MessagePopup>:
# 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}

@ -307,7 +307,7 @@ class PostScreen(ProtectedScreen):
import time
self.close_dialog()
self.open_dialog('')
# self.open_dialog('')
#Thread(target=do_post).start()
asyncio.create_task(do_post())

@ -316,7 +316,7 @@ class ProfileScreen(BaseScreen):
# add posts
lim=25
posts=await self.app.get_my_posts()
# self.log('POSTS!?',posts)
self.log('POSTS!?',posts)
# stop
for i,post in enumerate(posts):
if i>lim: break

@ -59,7 +59,8 @@ KEYDIR_BUILTIN = '.'
async def _getdb(self=None,port=PORT_LISTEN):
from kademlia.network import Server
if self: self.log('starting server..')
if self:
self.log('starting server..')
import os
if self: self.log(os.getcwd())
@ -73,15 +74,20 @@ async def _getdb(self=None,port=PORT_LISTEN):
if self: node.log = self.log
self.log('NODE:',node)
# if self and self.app:
# self.app.close_dialog()
return node
def logg(*x):
print(*x)
class Api(object):
def __init__(self,user=None,log=None):
def __init__(self,user=None,log=None,app=None):
self.log = log if log is not None else logg
self.username = user
self.app=app
def private_key(self):
if self.username:
@ -119,6 +125,7 @@ class Api(object):
return self._node
async def connect(self,port=PORT_LISTEN):
if self.app: self.app.open_dialog('hello?')
self.log('connecting...')
node = await _getdb(self,port)
self.log(f'connect() has node {node}')
@ -305,7 +312,7 @@ class Api(object):
async def decode_data(self,entire_packet_orig,sep=BSEP,private_key=None,sep2=BSEP2):
#if entire_packet_orig is None: return entire_packet_orig
if entire_packet_orig is None: return entire_packet_orig
self.log(f'decode_data({entire_packet_orig})...')
import binascii
entire_packet = entire_packet_orig

Loading…
Cancel
Save