2020-08-10 16:37:42 +00:00
|
|
|
from screens.base import BaseScreen
|
2020-08-12 06:49:14 +00:00
|
|
|
from kivymd.uix.boxlayout import MDBoxLayout
|
|
|
|
from kivymd.uix.textfield import MDTextField
|
|
|
|
from kivymd.uix.button import MDRectangleFlatButton
|
|
|
|
from kivymd.uix.label import MDLabel
|
2020-08-21 12:01:41 +00:00
|
|
|
from kivymd.uix.card import MDSeparator
|
2020-08-21 11:49:39 +00:00
|
|
|
from kivy.uix.label import Label
|
2020-08-21 12:01:41 +00:00
|
|
|
from main import MyLabel,rgb,COLOR_TEXT,COLOR_ICON,COLOR_ACCENT,COLOR_CARD
|
2020-08-21 17:52:21 +00:00
|
|
|
from misc import *
|
|
|
|
from kivy.app import App
|
2020-08-12 06:49:14 +00:00
|
|
|
|
|
|
|
class LoginBoxLayout(MDBoxLayout): pass
|
|
|
|
class LoginButtonLayout(MDBoxLayout): pass
|
|
|
|
class UsernameField(MDTextField): pass
|
|
|
|
class PasswordField(MDTextField): pass
|
|
|
|
class LoginButton(MDRectangleFlatButton): pass
|
2020-08-21 17:52:21 +00:00
|
|
|
class RegisterButton(MDRectangleFlatButton):
|
|
|
|
def register(self):
|
|
|
|
un=self.parent.parent.parent.username_field.text
|
|
|
|
app=App.get_running_app()
|
|
|
|
app.register(un)
|
2020-08-22 11:16:50 +00:00
|
|
|
# app.change_screen_from_uri(f'/inbox/{un}')
|
2020-08-21 17:52:21 +00:00
|
|
|
|
|
|
|
pass
|
2020-08-12 06:49:14 +00:00
|
|
|
class LoginStatus(MDLabel): pass
|
2020-08-10 16:37:42 +00:00
|
|
|
|
2020-08-19 19:33:25 +00:00
|
|
|
class UsernameLayout(MDBoxLayout): pass
|
|
|
|
class UsernameLabel(MDLabel): pass
|
2020-08-21 11:49:39 +00:00
|
|
|
class WelcomeLabel(MDLabel): pass
|
2020-08-19 19:33:25 +00:00
|
|
|
|
2020-08-10 16:37:42 +00:00
|
|
|
class LoginScreen(BaseScreen):
|
|
|
|
#def on_pre_enter(self):
|
|
|
|
# global app
|
|
|
|
# if app.is_logged_in():
|
|
|
|
# app.root.change_screen('feed')
|
2020-08-12 06:49:14 +00:00
|
|
|
def on_pre_enter(self):
|
2020-08-17 16:23:40 +00:00
|
|
|
#log(self.ids)
|
|
|
|
#log('hello?')
|
2020-08-12 06:49:14 +00:00
|
|
|
self.layout = LoginBoxLayout()
|
2020-08-21 11:49:39 +00:00
|
|
|
self.label_title = WelcomeLabel()
|
2020-08-21 07:27:27 +00:00
|
|
|
self.label_title.font_name='assets/font.otf'
|
2020-08-21 11:49:39 +00:00
|
|
|
# self.label_title.font_size='20sp'
|
2020-08-21 07:27:27 +00:00
|
|
|
self.label_title.bold=True
|
2020-08-21 11:49:39 +00:00
|
|
|
self.label_title.markup=True
|
|
|
|
self.label_title.color=rgb(*COLOR_TEXT)
|
2020-08-21 17:52:21 +00:00
|
|
|
self.label_title.text='Welcome,'
|
2020-08-21 12:01:41 +00:00
|
|
|
# self.label_title.font_size*=1.5
|
2020-08-22 14:45:48 +00:00
|
|
|
self.layout.add_widget(get_separator('20sp'))
|
2020-08-21 07:27:27 +00:00
|
|
|
self.layout.add_widget(self.label_title)
|
2020-08-21 17:52:21 +00:00
|
|
|
self.layout.add_widget(get_separator('30sp'))
|
|
|
|
# self.layout.add_widget(MySeparator())
|
2020-08-21 11:49:39 +00:00
|
|
|
|
2020-08-19 19:33:25 +00:00
|
|
|
|
|
|
|
self.layout_username = UsernameLayout()
|
2020-08-21 17:52:21 +00:00
|
|
|
self.label_username = UsernameLabel(text="Komrade")
|
2020-08-19 19:33:25 +00:00
|
|
|
|
2020-08-12 06:49:14 +00:00
|
|
|
self.username_field = UsernameField()
|
2020-08-21 07:27:27 +00:00
|
|
|
self.username_field.line_color_focus=rgb(*COLOR_TEXT)
|
|
|
|
self.username_field.line_color_normal=rgb(*COLOR_TEXT,a=0.25)
|
2020-08-19 19:33:25 +00:00
|
|
|
self.username_field.font_name='assets/font.otf'
|
|
|
|
|
|
|
|
self.layout_username.add_widget(self.label_username)
|
|
|
|
self.layout_username.add_widget(self.username_field)
|
|
|
|
|
|
|
|
self.layout.add_widget(self.layout_username)
|
2020-08-17 16:23:40 +00:00
|
|
|
#log(self.username_field)
|
2020-08-12 06:49:14 +00:00
|
|
|
# self.username_field.text='hello????'
|
|
|
|
|
2020-08-21 17:52:21 +00:00
|
|
|
# self.layout_password = UsernameLayout()
|
|
|
|
# self.label_password = UsernameLabel(text='password:')
|
2020-08-19 19:33:25 +00:00
|
|
|
|
2020-08-21 17:52:21 +00:00
|
|
|
# self.label_password.font_name='assets/font.otf'
|
2020-08-19 19:33:25 +00:00
|
|
|
self.label_username.font_name='assets/font.otf'
|
|
|
|
|
2020-08-21 17:52:21 +00:00
|
|
|
# self.password_field = PasswordField()
|
|
|
|
# self.password_field.line_color_focus=rgb(*COLOR_TEXT)
|
|
|
|
# self.password_field.line_color_normal=rgb(*COLOR_TEXT,a=0.25)
|
|
|
|
# self.password_field.font_name='assets/font.otf'
|
2020-08-19 19:33:25 +00:00
|
|
|
|
2020-08-21 17:52:21 +00:00
|
|
|
# self.layout_password.add_widget(self.label_password)
|
|
|
|
# self.layout_password.add_widget(self.password_field)
|
|
|
|
# self.layout.add_widget(self.layout_password)
|
2020-08-12 06:49:14 +00:00
|
|
|
|
|
|
|
self.layout_buttons = LoginButtonLayout()
|
2020-08-22 14:45:48 +00:00
|
|
|
self.layout.add_widget(get_separator('20sp'))
|
2020-08-12 06:49:14 +00:00
|
|
|
self.layout.add_widget(self.layout_buttons)
|
|
|
|
|
2020-08-21 17:52:21 +00:00
|
|
|
# self.login_button = LoginButton()
|
|
|
|
# self.login_button.font_name='assets/font.otf'
|
|
|
|
# self.layout_buttons.add_widget(self.login_button)
|
2020-08-12 06:49:14 +00:00
|
|
|
|
|
|
|
self.register_button = RegisterButton()
|
2020-08-19 19:33:25 +00:00
|
|
|
self.register_button.font_name='assets/font.otf'
|
2020-08-12 06:49:14 +00:00
|
|
|
# self.register_button =
|
|
|
|
self.layout_buttons.add_widget(self.register_button)
|
|
|
|
|
|
|
|
self.login_status = LoginStatus()
|
2020-08-19 19:33:25 +00:00
|
|
|
self.login_status.font_name='assets/font.otf'
|
|
|
|
|
2020-08-12 06:49:14 +00:00
|
|
|
self.layout.add_widget(self.login_status)
|
|
|
|
|
2020-08-22 20:11:19 +00:00
|
|
|
self.label_title.font_size='18sp'
|
2020-08-21 17:52:21 +00:00
|
|
|
# self.label_password.font_size='18sp'
|
2020-08-22 20:11:19 +00:00
|
|
|
self.label_username.font_size='20sp'
|
2020-08-21 17:52:21 +00:00
|
|
|
# self.login_button.font_size='12sp'
|
2020-08-22 20:11:19 +00:00
|
|
|
self.register_button.font_size='9sp'
|
2020-08-21 17:52:21 +00:00
|
|
|
self.register_button.text='enter'
|
2020-08-22 20:11:19 +00:00
|
|
|
self.username_field.font_size='20sp'
|
|
|
|
self.label_username.padding_x=(10,20)
|
|
|
|
self.username_field.padding_x=(20,10)
|
|
|
|
self.username_field.padding_y=(25,0)
|
2020-08-21 11:49:39 +00:00
|
|
|
|
2020-08-19 23:26:25 +00:00
|
|
|
|
2020-08-12 06:49:14 +00:00
|
|
|
|
|
|
|
## add all
|
|
|
|
self.add_widget(self.layout)
|
|
|
|
#pass
|
|
|
|
|
|
|
|
|
|
|
|
def on_enter(self):
|
|
|
|
un=self.app.get_username()
|
|
|
|
if un: self.username_field.text = un
|
|
|
|
|