login and registration screen
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
from justgetit.app import main
|
||||
|
||||
if __name__ == "__main__":
|
||||
main().main_loop()
|
||||
@@ -0,0 +1,40 @@
|
||||
import toga
|
||||
from toga.style.pack import COLUMN, ROW, CENTER, START, END
|
||||
from toga.style import Pack
|
||||
import requests
|
||||
from justgetit.constants import *
|
||||
from justgetit.login import Login
|
||||
from justgetit.register import Register
|
||||
|
||||
|
||||
class JustEatIt(toga.App):
|
||||
login_screen = toga.Box()
|
||||
register_screen = toga.Box()
|
||||
|
||||
|
||||
def goto_next_page(self, widget):
|
||||
"""
|
||||
ask app to activate a next page, id of the page is in the id of the widget
|
||||
|
||||
:param widget: the widget that called this function
|
||||
"""
|
||||
print(f"action 6 {widget.id}")
|
||||
if widget.id == 'register':
|
||||
self.main_window.content = self.register_screen
|
||||
elif widget.id =='login':
|
||||
self.main_window.content = self.login_screen
|
||||
|
||||
|
||||
def startup(self):
|
||||
self.login_screen = Login(navigate_to=self.goto_next_page)
|
||||
self.register_screen = Register(navigate_to=self.goto_next_page)
|
||||
|
||||
self.main_window = toga.MainWindow(title=self.formal_name, size=(SCREENWIDTH, SCREENHEIGHT))
|
||||
self.main_window.content = self.register_screen
|
||||
self.main_window.show()
|
||||
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
return JustEatIt()
|
||||
@@ -0,0 +1,2 @@
|
||||
SCREENWIDTH = 380
|
||||
SCREENHEIGHT = 680
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 7.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 82 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.0 KiB |
@@ -0,0 +1,106 @@
|
||||
import toga
|
||||
from toga.style import Pack
|
||||
from toga.style.pack import COLUMN, ROW, END, START, CENTER
|
||||
from justgetit.constants import SCREENHEIGHT, SCREENWIDTH
|
||||
|
||||
|
||||
class Login(toga.Box):
|
||||
|
||||
def __init__(self, navigate_to, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.navigate_to= navigate_to
|
||||
|
||||
register_button = toga.Button(
|
||||
icon=toga.Icon("images/register"),
|
||||
style=Pack(
|
||||
width=50,
|
||||
margin=5,
|
||||
),
|
||||
id="register",
|
||||
on_press=self.navigate_to)
|
||||
|
||||
liner =toga.Box(style=Pack(width=SCREENWIDTH, height = 2, background_color="#ddd"))
|
||||
|
||||
menu_bar= toga.Row(
|
||||
children=[register_button, liner],
|
||||
style=Pack(
|
||||
justify_content=END,
|
||||
width = SCREENWIDTH,
|
||||
background_color="#eee"
|
||||
)
|
||||
)
|
||||
|
||||
# Title icon
|
||||
my_image = toga.Image("images/login.png")
|
||||
title = toga.ImageView(my_image, style=Pack(
|
||||
width=50,
|
||||
margin_bottom=20
|
||||
))
|
||||
|
||||
# Email input
|
||||
name_input = toga.TextInput(
|
||||
placeholder="Could be you here",
|
||||
style=Pack(
|
||||
width=250,
|
||||
margin_bottom=10
|
||||
)
|
||||
)
|
||||
|
||||
# Password input
|
||||
password_input = toga.PasswordInput(
|
||||
placeholder="Feeling lucky?",
|
||||
style=Pack(
|
||||
width=250,
|
||||
margin_bottom=20
|
||||
)
|
||||
)
|
||||
|
||||
# Login button
|
||||
login_button = toga.Button(
|
||||
icon=toga.Icon("images/save"),
|
||||
style=Pack(
|
||||
width=50,
|
||||
margin=10,
|
||||
background_color="white"
|
||||
),
|
||||
on_press=self.login_button_press)
|
||||
|
||||
login_area= toga.Box(
|
||||
children=[login_button],
|
||||
style=Pack(
|
||||
width=250,
|
||||
direction=ROW,
|
||||
align_items=START,
|
||||
margin=20
|
||||
)
|
||||
)
|
||||
|
||||
# Main content box (centered)
|
||||
content_box = toga.Column(
|
||||
children=[
|
||||
title,
|
||||
name_input,
|
||||
password_input,
|
||||
login_area
|
||||
],
|
||||
style=Pack(
|
||||
align_items=CENTER,
|
||||
height=SCREENHEIGHT - 50, # iPhone height
|
||||
margin=20,
|
||||
)
|
||||
)
|
||||
|
||||
# Outer box to simulate iPhone screen
|
||||
screen = toga.Column(
|
||||
children=[menu_bar,
|
||||
liner,
|
||||
content_box],
|
||||
style=Pack(
|
||||
width=SCREENWIDTH, # iPhone width
|
||||
)
|
||||
)
|
||||
|
||||
self.add(screen)
|
||||
|
||||
def login_button_press(self, widget):
|
||||
print("pressesd")
|
||||
@@ -0,0 +1,107 @@
|
||||
import toga
|
||||
from toga.style import Pack
|
||||
from toga.style.pack import COLUMN, ROW, END, START, CENTER
|
||||
from justgetit.constants import SCREENHEIGHT, SCREENWIDTH
|
||||
|
||||
|
||||
class Register(toga.Box):
|
||||
|
||||
def __init__(self, navigate_to, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.navigate_to= navigate_to
|
||||
|
||||
register_button = toga.Button(
|
||||
icon=toga.Icon("images/login"),
|
||||
style=Pack(
|
||||
width=50,
|
||||
margin=5,
|
||||
),
|
||||
id="login",
|
||||
on_press=self.navigate_to)
|
||||
|
||||
liner = toga.Box(style=Pack(width=SCREENWIDTH, height = 2, background_color="#ddd"))
|
||||
|
||||
menu_bar= toga.Row(
|
||||
children=[register_button, liner],
|
||||
style=Pack(
|
||||
justify_content=END,
|
||||
width = SCREENWIDTH,
|
||||
background_color="#eee"
|
||||
)
|
||||
)
|
||||
|
||||
# Title icon
|
||||
my_image = toga.Image("images/register.png")
|
||||
title = toga.ImageView(my_image, style=Pack(
|
||||
width=50,
|
||||
margin_bottom=20
|
||||
))
|
||||
|
||||
# Email input
|
||||
name_input = toga.TextInput(
|
||||
placeholder="Gimme you wallet",
|
||||
style=Pack(
|
||||
width=250,
|
||||
margin_bottom=10
|
||||
)
|
||||
)
|
||||
|
||||
# Password input
|
||||
password_input = toga.PasswordInput(
|
||||
placeholder="You have a secret?",
|
||||
style=Pack(
|
||||
width=250,
|
||||
margin_bottom=20
|
||||
)
|
||||
)
|
||||
|
||||
# Login button
|
||||
login_button = toga.Button(
|
||||
icon=toga.Icon("images/save"),
|
||||
style=Pack(
|
||||
width=50,
|
||||
margin=10,
|
||||
background_color="white"
|
||||
),
|
||||
|
||||
on_press=self.register_button_press)
|
||||
|
||||
login_area= toga.Box(
|
||||
children=[login_button],
|
||||
style=Pack(
|
||||
width=250,
|
||||
direction=ROW,
|
||||
align_items=START,
|
||||
margin=20
|
||||
)
|
||||
)
|
||||
|
||||
# Main content box (centered)
|
||||
content_box = toga.Column(
|
||||
children=[
|
||||
title,
|
||||
name_input,
|
||||
password_input,
|
||||
login_area
|
||||
],
|
||||
style=Pack(
|
||||
align_items=CENTER,
|
||||
height=SCREENHEIGHT - 50, # iPhone height
|
||||
margin=20,
|
||||
)
|
||||
)
|
||||
|
||||
# Outer box to simulate iPhone screen
|
||||
screen = toga.Column(
|
||||
children=[menu_bar,
|
||||
liner,
|
||||
content_box],
|
||||
style=Pack(
|
||||
width=SCREENWIDTH, # iPhone width
|
||||
)
|
||||
)
|
||||
|
||||
self.add(screen)
|
||||
|
||||
def register_button_press(self, widget):
|
||||
print("presses register")
|
||||
@@ -0,0 +1,2 @@
|
||||
Put any application resources (e.g., icons and resources) here;
|
||||
they can be referenced in code as "resources/filename".
|
||||
Reference in New Issue
Block a user