added scrolling widget for lists
This commit is contained in:
@@ -16,7 +16,7 @@ class JustEatIt(toga.App):
|
|||||||
lists_screen = toga.Box()
|
lists_screen = toga.Box()
|
||||||
backend = None
|
backend = None
|
||||||
configuration = None
|
configuration = None
|
||||||
last_screen_width = SCREENWIDTH
|
last_screen_width = -1
|
||||||
|
|
||||||
|
|
||||||
def goto_next_page_by_name(self, destination):
|
def goto_next_page_by_name(self, destination):
|
||||||
@@ -58,19 +58,20 @@ class JustEatIt(toga.App):
|
|||||||
# Initial layout clamp
|
# Initial layout clamp
|
||||||
self.on_resize(self.main_window)
|
self.on_resize(self.main_window)
|
||||||
|
|
||||||
def set_page(self, page):
|
def set_page(self, page):
|
||||||
page.set_screen_width(self.last_screen_width)
|
if self.last_screen_width > 0:
|
||||||
|
page.set_screen_width(self.last_screen_width)
|
||||||
self.main_window.content = page
|
self.main_window.content = page
|
||||||
|
|
||||||
def on_resize(self, widget, **kwargs):
|
def on_resize(self, widget, **kwargs):
|
||||||
width = self.main_window.size.width
|
width = self.main_window.size.width
|
||||||
|
|
||||||
if width < SCREENWIDTH:
|
if width >= TABLET_WIDTH:
|
||||||
# Phone-like: fill available width
|
self.last_screen_width = MAX_NONMOBILE_SCREENWIDTH
|
||||||
self.last_screen_width = width
|
|
||||||
else:
|
else:
|
||||||
self.last_screen_width = SCREENWIDTH
|
self.last_screen_width = -1
|
||||||
# set actie screen to the corre ct width
|
|
||||||
|
# set current screen to the correct width
|
||||||
self.main_window.content.set_screen_width(self.last_screen_width)
|
self.main_window.content.set_screen_width(self.last_screen_width)
|
||||||
|
|
||||||
def on_exit(self):
|
def on_exit(self):
|
||||||
|
|||||||
@@ -62,8 +62,10 @@ class BasePage(toga.Box):
|
|||||||
style=Pack(
|
style=Pack(
|
||||||
direction=COLUMN,
|
direction=COLUMN,
|
||||||
align_items=CENTER,
|
align_items=CENTER,
|
||||||
justify_content=END,
|
justify_content=START,
|
||||||
margin=24
|
margin=24,
|
||||||
|
flex=1,
|
||||||
|
background_color="yellow"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -131,10 +133,15 @@ class BasePage(toga.Box):
|
|||||||
:param self: this screen
|
:param self: this screen
|
||||||
:param w: width
|
:param w: width
|
||||||
"""
|
"""
|
||||||
self.content_box.style.width = w
|
if w>0:
|
||||||
|
self.content_box.style.width = w
|
||||||
|
|
||||||
async def display_warning(self, message):
|
async def display_warning(self, message):
|
||||||
self.warningtext.text = message
|
self.warningtext.text = message
|
||||||
self.warning_box = self.warningline_outer
|
self.warning_box = self.warningline_outer
|
||||||
await asyncio.sleep(5)
|
await asyncio.sleep(5)
|
||||||
self.warning_box = self.warning_placeholder
|
self.warning_box = self.warning_placeholder
|
||||||
|
|
||||||
|
def logout_button_pressed(self, widget):
|
||||||
|
self.app.configuration.logout_user()
|
||||||
|
self.app.goto_next_page_by_name(PAGE_LOGIN)
|
||||||
@@ -37,6 +37,7 @@ class Configuration():
|
|||||||
|
|
||||||
|
|
||||||
def has_valid_app_key(self):
|
def has_valid_app_key(self):
|
||||||
|
return True
|
||||||
if 'appkey' in self.data:
|
if 'appkey' in self.data:
|
||||||
print("found app key {self.data['appkey']}")
|
print("found app key {self.data['appkey']}")
|
||||||
today = datetime.date.today()
|
today = datetime.date.today()
|
||||||
@@ -52,6 +53,7 @@ class Configuration():
|
|||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
def user_is_logged_in(self):
|
def user_is_logged_in(self):
|
||||||
|
return True
|
||||||
if 'username' in self.data:
|
if 'username' in self.data:
|
||||||
print("found user {self.data['username']}")
|
print("found user {self.data['username']}")
|
||||||
today = datetime.date.today()
|
today = datetime.date.today()
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
SCREENWIDTH = 400
|
MAX_NONMOBILE_SCREENWIDTH = 400
|
||||||
# SCREENHEIGHT = 680
|
MOBILE_PLATFORMS = ['ios', 'android']
|
||||||
|
TABLET_WIDTH = 600
|
||||||
|
|
||||||
PAGE_LOGIN = 'login'
|
PAGE_LOGIN = 'login'
|
||||||
PAGE_REGISTER = 'register'
|
PAGE_REGISTER = 'register'
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 7.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
+90
-56
@@ -4,86 +4,120 @@ from toga.style.pack import COLUMN, ROW, END, START, CENTER, HIDDEN, JUSTIFY
|
|||||||
# from justgetit.constants import SCREENHEIGHT, SCREENWIDTH
|
# from justgetit.constants import SCREENHEIGHT, SCREENWIDTH
|
||||||
import asyncio
|
import asyncio
|
||||||
from justgetit.constants import *
|
from justgetit.constants import *
|
||||||
import httpx
|
from justgetit.basepage import BasePage
|
||||||
|
|
||||||
|
|
||||||
class Lists(toga.Box):
|
class Lists(BasePage):
|
||||||
dialog_txt = ""
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Docstring for __init__
|
This page allows you to enter the aplication key
|
||||||
|
The aplication-key is kept until a month after the app is last used
|
||||||
|
|
||||||
:param self: register-screen
|
:param self: register-screen
|
||||||
|
:param navigate_to: function to call if we want to switch screens
|
||||||
:param args: args for super
|
:param args: args for super
|
||||||
:param kwargs: kwars for super
|
:param kwargs: kwars for super
|
||||||
"""
|
"""
|
||||||
|
# set button and image
|
||||||
|
self.first_menu_button_icon = 'edit3'
|
||||||
|
self.first_menu_button_callback = self.edit_button_pressed
|
||||||
|
self.second_menu_button_icon = 'logout'
|
||||||
|
self.second_menu_button_callback = self.logout_button_pressed
|
||||||
|
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
# menu bar with register button
|
# here the list of lists
|
||||||
register_button = toga.Button(
|
listholder = toga.Column(
|
||||||
icon=toga.Icon("images/logout"),
|
|
||||||
id="login",
|
|
||||||
style=Pack(margin=5),
|
|
||||||
on_press=self.logout_button_pressed)
|
|
||||||
menu_bar_inner = toga.Box(
|
|
||||||
children = [register_button],
|
|
||||||
style=Pack(
|
style=Pack(
|
||||||
background_color="#efefef",
|
margin_bottom=10,
|
||||||
justify_content=END,
|
background_color="#aaa",
|
||||||
flex=1),
|
)
|
||||||
)
|
)
|
||||||
menu_bar = toga.Row(
|
scrollarea = toga.ScrollContainer(
|
||||||
children = [menu_bar_inner]
|
content=listholder,
|
||||||
|
style=Pack(
|
||||||
|
flex=1,
|
||||||
|
margin=10,
|
||||||
|
),
|
||||||
|
horizontal=False
|
||||||
)
|
)
|
||||||
|
|
||||||
# line ast the bottom of the menubar
|
|
||||||
liner=toga.Box(style=Pack(flex=1, height = 2, background_color="#ddd"))
|
|
||||||
|
|
||||||
# body of the screen with image 2 edit fielfds and ok button
|
|
||||||
# Title icon
|
for i in range(30):
|
||||||
my_image = toga.Image("images/key.png")
|
listholder.add(self.create_row("Supermarkt",f"{i}","30"))
|
||||||
title = toga.ImageView(my_image, style=Pack(
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# at the bottom of the list: edit-button
|
||||||
|
save_button = toga.Button(
|
||||||
|
icon=toga.Icon("images/edit"),
|
||||||
|
style=Pack(
|
||||||
width=50,
|
width=50,
|
||||||
margin_bottom=20
|
margin=10,
|
||||||
))
|
),
|
||||||
|
on_press=self.edit_button_pressed)
|
||||||
|
|
||||||
|
save_button_box= toga.Column(
|
||||||
|
children=[save_button],
|
||||||
|
style=Pack(
|
||||||
|
flex=1,
|
||||||
|
align_items=START,
|
||||||
|
margin=20
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
# wrapping up the windows elements
|
# wrapping up the windows elements
|
||||||
self.content_box = toga.Box(
|
self.content_box.add(scrollarea)
|
||||||
children=[
|
# self.content_box.add(save_button_box)
|
||||||
title,
|
|
||||||
|
|
||||||
# self.helpbox
|
def edit_button_pressed(self):
|
||||||
|
self.app.goto_next_page_by_name(PAGE_EDITLISTS)
|
||||||
|
|
||||||
],
|
def create_row(self, text, open, total):
|
||||||
style=Pack(
|
label = toga.Button(
|
||||||
direction=COLUMN,
|
text=text,
|
||||||
align_items=CENTER,
|
margin_bottom=2,
|
||||||
justify_content=END,
|
style = Pack(
|
||||||
margin=24
|
# margin_bottom=2, # scrollig doesnt work, bug?, replaced by margin_bottom in Button
|
||||||
|
width=250,
|
||||||
|
background_color="white",
|
||||||
|
font_size=15
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
spacer = toga.Box(
|
||||||
# bringing the 3 parts together
|
style = Pack(
|
||||||
self.add(menu_bar)
|
flex=1
|
||||||
self.add(liner)
|
|
||||||
self.add(self.content_box)
|
|
||||||
|
|
||||||
self.style=Pack(
|
|
||||||
direction=COLUMN,
|
|
||||||
flex=1,
|
|
||||||
align_items=CENTER,
|
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
indicator = toga.Label(
|
||||||
|
text = f"{open} / {total}",
|
||||||
|
style = Pack(
|
||||||
|
color="blue",
|
||||||
|
margin=8
|
||||||
|
)
|
||||||
|
)
|
||||||
|
listrow_inner = toga.Box(
|
||||||
|
style = Pack(
|
||||||
|
margin_bottom=1,
|
||||||
|
flex=1,
|
||||||
|
background_color="white",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
listrow_inner.add(label)
|
||||||
|
listrow_inner.add(spacer)
|
||||||
|
listrow_inner.add(indicator)
|
||||||
|
|
||||||
def set_screen_width(self, w):
|
listrow_outer = toga.Box(
|
||||||
"""
|
style = Pack(
|
||||||
mainscreen is calling this for setting proper screen width, upon start and on-resize
|
flex=1,
|
||||||
|
background_color="#ccc",
|
||||||
:param self: this screen
|
)
|
||||||
:param w: width
|
)
|
||||||
"""
|
listrow_outer.add(listrow_inner)
|
||||||
self.content_box.style.width = w
|
|
||||||
|
|
||||||
def logout_button_pressed(self, widget):
|
return(listrow_outer)
|
||||||
self.app.configuration.logout_user()
|
|
||||||
self.app.goto_next_page_by_name(PAGE_LOGIN)
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
|
||||||
|
class ListItems():
|
||||||
|
id = 0
|
||||||
|
updated_at = None
|
||||||
|
owner_user_id = 0
|
||||||
|
name = ''
|
||||||
|
is_active = True
|
||||||
|
|
||||||
|
|
||||||
|
class Item():
|
||||||
|
id = 0
|
||||||
|
updated_at = db.Column(db.TIMESTAMP, default=datetime.now(), onupdate=datetime.now(), nullable=False)
|
||||||
|
listofitems_id = db.Column(db.Integer, nullable=False)
|
||||||
|
label = db.Column(db.String(40), nullable=False)
|
||||||
|
quantity = db.Column(db.Integer, default=0)
|
||||||
|
unit = db.Column(db.String(10))
|
||||||
|
label_alt1 = db.Column(db.String(40))
|
||||||
|
label_alt2 = db.Column(db.String(40))
|
||||||
|
is_checked = db.Column(db.Boolean, default=False)
|
||||||
|
is_suggestion = db.Column(db.Boolean, default=False)
|
||||||
|
category = db.Column(db.String(20))
|
||||||
Reference in New Issue
Block a user