2018-09-01 17:35:04 -04:00
|
|
|
""" Tildr Dating
|
|
|
|
"""
|
|
|
|
___name___ = "Tildr Dating"
|
|
|
|
___license___ = "MIT"
|
|
|
|
___dependencies___ = ["wifi", "http", "ugfx_helper", "sleep", "dialogs", "sim800", "database"]
|
|
|
|
___categories___ = ["Other"]
|
2018-09-02 09:08:44 -04:00
|
|
|
___bootstrapped___ = False
|
2018-09-01 17:35:04 -04:00
|
|
|
|
2018-09-02 08:28:54 -04:00
|
|
|
import app, buttons, ugfx, ugfx_helper, sleep, http, dialogs, sim800, database, ujson
|
2018-09-01 17:35:04 -04:00
|
|
|
from tilda import Buttons
|
|
|
|
|
2018-09-02 08:28:54 -04:00
|
|
|
from tildr.profile import get_profile
|
|
|
|
from tildr.shared import clear
|
|
|
|
from tildr import splash, profile, person, nomore
|
|
|
|
|
2018-09-01 17:35:04 -04:00
|
|
|
api_url = "http://emf2018.us-east-2.elasticbeanstalk.com"
|
|
|
|
|
|
|
|
ugfx_helper.init()
|
|
|
|
ugfx.clear(ugfx.html_color(0x000000))
|
|
|
|
|
|
|
|
style = ugfx.Style()
|
|
|
|
style.set_enabled([ugfx.WHITE, ugfx.WHITE, ugfx.html_color(0x888888), ugfx.html_color(0x444444)])
|
|
|
|
style.set_background(ugfx.html_color(0x000000))
|
|
|
|
ugfx.set_default_style(style)
|
|
|
|
|
2018-09-02 08:28:54 -04:00
|
|
|
def error_screen(state):
|
|
|
|
ugfx.text(5, 100, "Error: try again later :(", ugfx.WHITE)
|
2018-09-01 17:35:04 -04:00
|
|
|
|
2018-09-02 08:28:54 -04:00
|
|
|
def error_actions(state):
|
|
|
|
if buttons.is_triggered(Buttons.BTN_A):
|
|
|
|
state['next'] = "SPLASH"
|
2018-09-01 17:35:04 -04:00
|
|
|
|
2018-09-02 08:28:54 -04:00
|
|
|
screens = {
|
|
|
|
'SPLASH': {'render': splash.screen, 'actions': splash.actions},
|
|
|
|
'PROFILE': {'render': profile.screen, 'actions': profile.actions},
|
|
|
|
'ERROR': {'render': error_screen, 'actions': error_actions},
|
|
|
|
'NEXT_PERSON': {'render': person.screen, 'actions': person.actions},
|
|
|
|
'NO_MORE': {'render': nomore.screen, 'actions': nomore.actions}
|
|
|
|
}
|
2018-09-01 17:35:04 -04:00
|
|
|
|
2018-09-02 08:28:54 -04:00
|
|
|
state = {
|
|
|
|
'api': api_url,
|
|
|
|
'running': True,
|
|
|
|
'screen': None,
|
|
|
|
'next': "SPLASH",
|
|
|
|
'ui': [],
|
|
|
|
'profile': None
|
|
|
|
}
|
2018-09-01 17:35:04 -04:00
|
|
|
|
|
|
|
|
2018-09-02 08:28:54 -04:00
|
|
|
def destroy(state):
|
|
|
|
for item in state['ui']:
|
|
|
|
try:
|
|
|
|
item.hide()
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
item.destroy()
|
2018-09-01 17:35:04 -04:00
|
|
|
|
2018-09-02 08:28:54 -04:00
|
|
|
state['ui'] = []
|
2018-09-01 17:35:04 -04:00
|
|
|
|
|
|
|
|
2018-09-02 08:28:54 -04:00
|
|
|
state['profile'] = get_profile()
|
2018-09-01 17:35:04 -04:00
|
|
|
|
2018-09-02 08:28:54 -04:00
|
|
|
while state['running']:
|
2018-09-01 17:35:04 -04:00
|
|
|
|
2018-09-02 08:28:54 -04:00
|
|
|
# Move to next screen
|
|
|
|
if state['next']:
|
|
|
|
destroy(state)
|
|
|
|
nxt = state['next']
|
|
|
|
state['screen'] = nxt
|
|
|
|
state['next'] = None
|
2018-09-01 17:35:04 -04:00
|
|
|
|
2018-09-02 08:28:54 -04:00
|
|
|
clear()
|
|
|
|
screens[nxt]['render'](state)
|
2018-09-01 17:35:04 -04:00
|
|
|
|
2018-09-02 08:28:54 -04:00
|
|
|
sleep.wfi()
|
2018-09-01 17:35:04 -04:00
|
|
|
|
2018-09-02 08:28:54 -04:00
|
|
|
s = state['screen']
|
|
|
|
screens[s]['actions'](state)
|
2018-09-01 17:35:04 -04:00
|
|
|
|
2018-09-02 08:28:54 -04:00
|
|
|
if buttons.is_triggered(Buttons.BTN_Menu):
|
|
|
|
state['running'] = False
|
2018-09-01 17:35:04 -04:00
|
|
|
|
|
|
|
|
|
|
|
app.restart_to_default()
|