2
0
mirror of https://github.com/ComradCollective/Comrad synced 2024-11-11 13:10:45 +00:00
Comrad/komrade/app/screens/base.py

56 lines
1.4 KiB
Python
Raw Normal View History

2020-08-10 16:37:42 +00:00
from kivymd.uix.screen import MDScreen
from kivy.properties import ObjectProperty
from kivymd.uix.boxlayout import MDBoxLayout
from kivymd.uix.label import MDLabel
from kivy.app import App
2020-08-22 13:06:50 +00:00
import asyncio
2020-09-26 13:14:29 +00:00
from kivymd.uix.dialog import MDDialog
2020-09-26 13:03:12 +00:00
from komrade.app.screens.dialog import MDDialog2
2020-08-10 16:37:42 +00:00
### Layout
### Base screens
class BaseScreen(MDScreen):
2020-09-20 19:34:45 +00:00
2020-09-26 12:11:56 +00:00
def on_pre_enter(self):
2020-09-26 13:03:12 +00:00
# self.clear_widgets()
2020-09-26 13:14:29 +00:00
# if hasattr(self.app,'msg_dialog') and self.app.msg_dialog:
# self.root.remove_widget(self.app.msg_dialog)
# if hasattr(self.app,'msg_dialog0') and self.app.msg_dialog0: self.root.remove_widget(self.app.msg_dialog0)
self.app.clear_widget_tree(MDDialog)
2020-09-26 13:03:12 +00:00
self.app.clear_widget_tree(MDDialog2)
pass
2020-09-26 12:11:56 +00:00
2020-08-10 16:37:42 +00:00
@property
def root(self):
return self.app.root
@property
def app(self):
return App.get_running_app()
2020-08-19 10:29:56 +00:00
def log(self,*x):
return self.app.log(*x)
2020-08-21 17:52:21 +00:00
@property
def channel(self):
return self.app.channel
def stat(self,*x,**y): return self.app.stat(*x,**y)
2020-08-22 19:39:56 +00:00
2020-09-20 19:34:45 +00:00
2020-09-26 10:12:16 +00:00
class ProtectedScreen(BaseScreen):
def on_pre_enter(self):
2020-09-26 12:11:56 +00:00
super().on_pre_enter()
2020-09-26 10:12:16 +00:00
if not hasattr(self.app,'is_logged_in') or not self.app.is_logged_in or not hasattr(self.app,'komrade') or not self.app.komrade:
self.root.change_screen('login')
self.log('changing screen???')
return None
return True