def __init__(self, **kw): super().__init__(**kw) self.app = MDApp.get_running_app() # self.mi_conexion = Conexion_BD() pantalla_navegacion = NavigationScreen() self.app.root.add_widget(pantalla_navegacion)
def login(self, email, password): login_url = "https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key=" + WAK login_payload = { "email": email, "password": password, "returnSecureToken": True } login_request = requests.post(login_url, data=login_payload) login_data = json.loads(login_request.content.decode()) if login_request.ok: refresh_token = login_data["refreshToken"] with open("resources/refresh_token.txt", "w") as f: f.write(refresh_token) # Refresh self.data user_data = requests.get( f'https://remasterautostop-fc4ec.firebaseio.com/users/{login_data["localId"]}.json' ) APP.data = json.loads(user_data.content.decode()) # Change to NavigationScreen and remove login_screen login_screen = APP.root.current_screen from navigation_screen import NavigationScreen self.nav_screen = NavigationScreen() APP.root.add_widget(self.nav_screen) APP.root.current = "navigation_screen" APP.root.remove_widget(login_screen) return True else: return login_data["error"]["message"]
def load_navigation_screen(self, ): # SAVE USER DATA ON THE APP AND LOAD THE NAVIGATION_SCREEN if not APP.root.has_screen("navigation_screen"): from navigation_screen import NavigationScreen APP.root.add_widget(NavigationScreen()) APP.root.remove_widget(APP.root.get_screen("login_screen")) APP.root.current = "navigation_screen"
def on_enter(self): pantalla_navegacion = NavigationScreen() pantalla_inicio = LoginScreen() self.app.root.add_widget(pantalla_navegacion) self.app.root.add_widget(pantalla_inicio) try: with open("info_paciente.txt", "r") as f: lineas_texto = f.readlines() nombre = lineas_texto[0] apellido = lineas_texto[1] num_dni = lineas_texto[2] centro = lineas_texto[3] f.close() self.mi_conexion.verificar_mi_conexion(nombre, apellido, num_dni, centro) Clock.schedule_once(lambda dt: self.cargar_navegacion(), 2) except: Clock.schedule_once(lambda dt: self.cargar_login(), 2)
def load_navigation_screen(self): nav_screen = NavigationScreen() APP.root.add_widget(nav_screen) APP.root.current = "navigation_screen" self.remove_screen()
def build(self): nav_screen = NavigationScreen() return nav_screen
def load_navigation_screen(self): nav_screen = NavigationScreen() self.app.root.add_widget(nav_screen) self.app.root.current = "navigation_screen"