From 116613f4240b4331c4bf9e1a8682bbe6eb107736 Mon Sep 17 00:00:00 2001 From: Daniel Saul Date: Sun, 2 Sep 2018 13:28:54 +0100 Subject: [PATCH] Massive refactor: seperate files, screen state, dialog back, edit profile, local images --- tildr/biglogo.png | Bin 0 -> 7052 bytes tildr/main.py | 206 +++++++++++--------------------------------- tildr/nomore.py | 32 +++++++ tildr/old.py | 163 +++++++++++++++++++++++++++++++++++ tildr/person.py | 66 ++++++++++++++ tildr/profile.py | 66 ++++++++++++++ tildr/shared.py | 12 +++ tildr/smalllogo.png | Bin 0 -> 910 bytes tildr/splash.py | 31 +++++++ 9 files changed, 420 insertions(+), 156 deletions(-) create mode 100644 tildr/biglogo.png create mode 100644 tildr/nomore.py create mode 100644 tildr/old.py create mode 100644 tildr/person.py create mode 100644 tildr/profile.py create mode 100644 tildr/shared.py create mode 100644 tildr/smalllogo.png create mode 100644 tildr/splash.py diff --git a/tildr/biglogo.png b/tildr/biglogo.png new file mode 100644 index 0000000000000000000000000000000000000000..545e83d9ea8231ece8f648a6ceed88011b3b3c53 GIT binary patch literal 7052 zcmdsc^;=Y5^e){DC?E*Zp(02K4BaUVA)z!lAe}=DIUoo~3M$YtV?b{3H@ImQgE|-6P%Z3=VmK6@d!AENjVx4srAn| z=x5xh*z9V)X9>;%z%)5Q{{O4Rgo?J{|#phH4;IW@d*hv zu50pBLSm>jYJGiA(}#aUd}HZiU>C;(?85Bqpgs#aM6OcQK7dz~zXdmfS@B6P9aux> z$0Z?{6ldU&yNz7{G{qnNf2WD6^Ej;5q@h1}Dc?27{_maO42Y0*A5uChv&^GLGxpwJ zH&RR=ViCj-4-dDtw%*>}>f|XGu*PDk?%-cVGXHz~S(kni^1=$iZ?;V@Zi!Ro+h%5+5HQ z^b%xjdn9ddZ_m>dl@vaPDl03yxj{a(yRQ9CPk+`zp^1Z~t?zlV-s>>)%g)ZOS);4X z?eCwGpReAJrUAze!8B=GLrE^naL;eg`f4n@!<3?)%m<8r&UrDo?2T*#_r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_@&akBd|A;W_o%$$@81r8UqW1tgr7ihU3K8YNg%f_hRdI7q?kJEKuZR zLD@_<&VbJ&gYa`cgKP2Tcy>v@swI2P3yJSxzWi)yG~4JqXVC2V^GxXae^)OjSkVMrRBT4l0BL4i@V7e!e#=DJ`YX#yUVPvbRKGYQrBterTkN zR##Q=%gD$8f#~0rcB|>LfBxv{|0j%+&?<~7zkUr@3_RjU(o|MfHZxnn5b6i$8?gGW z3Uh!5hTu|CQfh8)PK0o(xBL9}v+{CYga0b5<(yucG(zH@@aSl=p~a7Jeek2XMjBQt z_22({x+s)2!XR}`%?6D)7{5sF0;8;CaaoyhM_}9H0S3sY|E9y$Ha2!}FgZc22b>_^ z(t)D|ri8j-j~`+E*Pd!XaQ^?+l`2Pq3+)4`cDVaTxCGV=rptz", parent=None, shape=ugfx.Button.RECT, style=None) - - -def no_more(my_profile): - top_left_logo() - - ugfx.set_default_font(ugfx.FONT_TITLE) - ugfx.Label(5, 90, 230, 50, "You've swiped everybody!", justification=ugfx.Label.CENTERTOP) - ugfx.set_default_font(ugfx.FONT_SMALL) - ugfx.Label(5, 160, 230, 20, "Soz "+my_profile["username"], justification=ugfx.Label.CENTERTOP) - ugfx.Label(5, 180, 230, 20, "Come back later ;)", justification=ugfx.Label.CENTERTOP) - - # ugfx.Button(0, 280, 100, 40, "< Edit profile", parent=None, shape=ugfx.Button.RECT, style=None) - ugfx.Button(160, 280, 100, 40, "Try again >", parent=None, shape=ugfx.Button.RECT, style=None) - - -def get_profile(): - profile_json = database.get("tildr_profile") - if profile_json is None: - return None - - profile = ujson.loads(profile_json) - return profile - - -def top_left_logo(): - ugfx.clear(ugfx.html_color(0x000000)) - try: - logo = http.get("https://i.imgur.com/5HXmXBU.png").raise_for_status().content - ugfx.display_image(0, 5, bytearray(logo)) - except: - pass - - -def quit_loop(): - while True: - if buttons.is_triggered(Buttons.BTN_Menu): - return False - - -while True: - - profile = get_profile() - - if profile is None: - render_splash_screen() - if not run_splash_screen(): - break - profile = { - 'username': "", - 'age': "", - 'tag_line': "", - 'looking_for': "", - 'contact': "" - } - if not create_profile(profile): - continue - - main_screen(profile) - if not quit_loop(): - break app.restart_to_default() diff --git a/tildr/nomore.py b/tildr/nomore.py new file mode 100644 index 0000000..839e642 --- /dev/null +++ b/tildr/nomore.py @@ -0,0 +1,32 @@ +import ugfx, buttons +from tilda import Buttons +from tildr.shared import top_left_logo + +def screen(state): + window = ugfx.Container(0, 0, 240, 320) + window.show() + + top_left_logo() + + ugfx.set_default_font(ugfx.FONT_TITLE) + l1 = ugfx.Label(5, 90, 230, 50, "You've swiped everybody!", parent=window, justification=ugfx.Label.CENTERTOP) + ugfx.set_default_font(ugfx.FONT_SMALL) + l2 = ugfx.Label(5, 160, 230, 20, "Soz "+state["profile"]["username"], parent=window, justification=ugfx.Label.CENTERTOP) + l3 = ugfx.Label(5, 180, 230, 20, "Come back later ;)", parent=window, justification=ugfx.Label.CENTERTOP) + + b2 = ugfx.Button(0, 280, 120, 40, "< Edit profile", parent=window, shape=ugfx.Button.RECT, style=None) + b1 = ugfx.Button(120, 280, 120, 40, "Try again >", parent=window, shape=ugfx.Button.RECT, style=None) + + state['ui'].append(window) + state['ui'].append(l1) + state['ui'].append(l2) + state['ui'].append(l3) + state['ui'].append(b1) + state['ui'].append(b2) + + +def actions(state): + if buttons.is_triggered(Buttons.BTN_B) or buttons.is_triggered(Buttons.JOY_Right): + state['next'] = "NEXT_PERSON" + if buttons.is_triggered(Buttons.BTN_A) or buttons.is_triggered(Buttons.JOY_Left): + state['next'] = "PROFILE" diff --git a/tildr/old.py b/tildr/old.py new file mode 100644 index 0000000..e9c1359 --- /dev/null +++ b/tildr/old.py @@ -0,0 +1,163 @@ + +def render_splash_screen(): + ugfx.clear(ugfx.html_color(0x000000)) + try: + logo = http.get("https://i.imgur.com/0TjxEPs.png").raise_for_status().content + ugfx.display_image( + int((ugfx.width() - 164)/2), + 20, + bytearray(logo)) + except: + pass + + ugfx.text(160, 100, "TILDR", ugfx.WHITE) + ugfx.text(0, 270, "Find your match @emfcamp ;)", ugfx.WHITE) + ugfx.text(45, 300, "Press A to begin", ugfx.WHITE) + + +def run_splash_screen(): + while True: + if buttons.is_triggered(Buttons.BTN_Menu): + return False + if buttons.is_triggered(Buttons.BTN_A): + return True + +def create_profile(my_profile): + ugfx.clear(ugfx.html_color(0x000000)) + + name, age = "", "" + while name == "": + name = dialogs.prompt_text("What's your name?") + while age == "": + age = dialogs.prompt_text("What's your age?") + tag_line = dialogs.prompt_text("Tell us your tagline:") + looking_for = dialogs.prompt_text("And what you're looking for:") + contact = dialogs.prompt_text("And your twitter username?") + imei = sim800.imei() + + top_left_logo() + ugfx.text(5, 100, "Working...", ugfx.BLACK) + + profile = { + 'unique_identifier': imei, + 'username': name, + 'age': age, + 'tag_line': tag_line, + 'looking_for': looking_for, + 'contact': contact + } + + profile_json = ujson.dumps(profile) + + try: + http.post(api_url+'/create_user', json=profile).raise_for_status().close() + except: + ugfx.clear() + ugfx.text(5, 100, "Error. Try again later. :(", ugfx.BLACK) + return False + + database.set("tildr_profile", profile_json) + + return True + + +def main_screen(my_profile): + while True: + next_person(my_profile) + while True: + if buttons.is_triggered(Buttons.BTN_Menu): + return False + if buttons.is_triggered(Buttons.BTN_B) or buttons.is_triggered(Buttons.JOY_Right): + break + # if buttons.is_triggered(Buttons.BTN_A) or buttons.is_triggered(Buttons.JOY_Left): + # create_profile(my_profile) + # break + + +def next_person(my_profile): + ugfx.clear(ugfx.html_color(0x000000)) + ugfx.text(5, 100, "Loading...", ugfx.WHITE) + try: + resp = http.get(api_url+'/get_user/'+my_profile['unique_identifier']).json() + except: + ugfx.clear() + ugfx.text(5, 100, "Error. Try again later. :(", ugfx.BLACK) + return + + if resp['success']: + display_person(resp['value']) + else: + no_more(my_profile) + + +def display_person(person): + top_left_logo() + + ugfx.set_default_font(ugfx.FONT_TITLE) + ugfx.Label(5, 90, 230, 40, person["username"], justification=ugfx.Label.LEFTTOP) + ugfx.set_default_font(ugfx.FONT_SMALL) + ugfx.text(200, 92, person["age"], ugfx.WHITE) + + ugfx.Label(5, 120, 230, 60, person["tag_line"]) + + ugfx.Label(5, 200, 230, 40, person["looking_for"]) + ugfx.text(5, 190, "Looking for...", ugfx.RED) + + ugfx.text(5, 245, person["contact"], ugfx.BLUE) + + # ugfx.Button(0, 280, 100, 40, "< Edit profile", parent=None, shape=ugfx.Button.RECT, style=None) + ugfx.Button(160, 280, 100, 40, "Swipe >", parent=None, shape=ugfx.Button.RECT, style=None) + + +def no_more(my_profile): + top_left_logo() + + ugfx.set_default_font(ugfx.FONT_TITLE) + ugfx.Label(5, 90, 230, 50, "You've swiped everybody!", justification=ugfx.Label.CENTERTOP) + ugfx.set_default_font(ugfx.FONT_SMALL) + ugfx.Label(5, 160, 230, 20, "Soz "+my_profile["username"], justification=ugfx.Label.CENTERTOP) + ugfx.Label(5, 180, 230, 20, "Come back later ;)", justification=ugfx.Label.CENTERTOP) + + # ugfx.Button(0, 280, 100, 40, "< Edit profile", parent=None, shape=ugfx.Button.RECT, style=None) + ugfx.Button(160, 280, 100, 40, "Try again >", parent=None, shape=ugfx.Button.RECT, style=None) + + + + +def top_left_logo(): + ugfx.clear(ugfx.html_color(0x000000)) + try: + logo = http.get("https://i.imgur.com/5HXmXBU.png").raise_for_status().content + ugfx.display_image(0, 5, bytearray(logo)) + except: + pass + + +def quit_loop(): + while True: + if buttons.is_triggered(Buttons.BTN_Menu): + return False + + +while True: + + profile = get_profile() + + if profile is None: + render_splash_screen() + if not run_splash_screen(): + break + profile = { + 'username': "", + 'age': "", + 'tag_line': "", + 'looking_for': "", + 'contact': "" + } + if not create_profile(profile): + continue + + main_screen(profile) + if not quit_loop(): + break + diff --git a/tildr/person.py b/tildr/person.py new file mode 100644 index 0000000..4a0e05e --- /dev/null +++ b/tildr/person.py @@ -0,0 +1,66 @@ +import http, ugfx, buttons +from tilda import Buttons +from tildr.shared import top_left_logo + + +def get_next_person(state): + try: + resp = http.get(state['api']+'/get_user/'+state['profile']['unique_identifier']).json() + except: + return None + + if not resp['success']: + return None + + return resp['value'] + + +def screen(state): + loading = ugfx.Container(0, 0, 240, 320) + loading.text(5, 100, "Loading...", ugfx.WHITE) + state['ui'].append(loading) + + loading.show() + person = get_next_person(state) + loading.hide() + + if person is None: + state['next'] = "NO_MORE" + return + + window = ugfx.Container(0, 0, 240, 320) + window.show() + + top_left_logo() + + ugfx.set_default_font(ugfx.FONT_TITLE) + l1 = ugfx.Label(5, 90, 230, 40, person["username"], parent=window, justification=ugfx.Label.LEFTTOP) + ugfx.set_default_font(ugfx.FONT_SMALL) + window.text(200, 92, person["age"], ugfx.WHITE) + + l2 = ugfx.Label(5, 120, 230, 60, person["tag_line"], parent=window) + + l3 = ugfx.Label(5, 200, 230, 40, person["looking_for"], parent=window) + window.text(5, 180, "Looking for...", ugfx.RED) + + if not person["contact"].startswith("@"): + person["contact"] = "@" + person["contact"] + + window.text(5, 245, person["contact"], ugfx.BLUE) + + b2 = ugfx.Button(0, 280, 120, 40, "< Edit profile", parent=window, shape=ugfx.Button.RECT, style=None) + b1 = ugfx.Button(120, 280, 120, 40, "Swipe >", parent=window, shape=ugfx.Button.RECT, style=None) + + state['ui'].append(window) + state['ui'].append(l1) + state['ui'].append(l2) + state['ui'].append(l3) + state['ui'].append(b1) + state['ui'].append(b2) + + +def actions(state): + if buttons.is_triggered(Buttons.BTN_B) or buttons.is_triggered(Buttons.JOY_Right): + state['next'] = "NEXT_PERSON" + if buttons.is_triggered(Buttons.BTN_A) or buttons.is_triggered(Buttons.JOY_Left): + state['next'] = "PROFILE" diff --git a/tildr/profile.py b/tildr/profile.py new file mode 100644 index 0000000..f4d0fac --- /dev/null +++ b/tildr/profile.py @@ -0,0 +1,66 @@ +import database, ujson, sim800, dialogs, http + + +def get_profile(): + profile_json = database.get("tildr_profile") + if profile_json is None: + return {} + + profile = ujson.loads(profile_json) + return profile + +def create_profile(state): + try: + http.post(state['api']+'/create_user', json=state['profile']).raise_for_status().close() + except Exception as ex: + print(ex) + return False + + profile_json = ujson.dumps(state['profile']) + database.set("tildr_profile", profile_json) + + return True + +def screen(state): + + if state['profile'] is None: + state['profile'] = { + 'unique_identifier': "", + 'username': "", + 'age': "", + 'tag_line': "", + 'looking_for': "", + 'contact': "" + } + + ds = [ + ["username", "What's your name?"], + ["age", "What's your age?"], + ["tag_line", "Tell us your tagline"], + ["looking_for", "And what you're looking for"], + ["contact", "And your twitter username"], + ] + + i = 0 + + while i < len(ds): + res = dialogs.prompt_text(ds[i][1], init_text=state['profile'][ds[i][0]]) + if res is None: + i -= 1 + if i < 0: + state['next'] = "SPLASH" + return + elif res != "": + state['profile'][ds[i][0]] = res + i += 1 + + state['profile']['unique_identifier'] = sim800.imei() + + if not create_profile(state): + state['next'] = "ERROR" + return + + state['next'] = "NEXT_PERSON" + +def actions(state): + return diff --git a/tildr/shared.py b/tildr/shared.py new file mode 100644 index 0000000..3291a2d --- /dev/null +++ b/tildr/shared.py @@ -0,0 +1,12 @@ +import ugfx, http + +def clear(): + ugfx.clear(ugfx.html_color(0x000000)) + + +def top_left_logo(): + try: + # logo = http.get("https://i.imgur.com/5HXmXBU.png").raise_for_status().content + ugfx.display_image(1, 5, "tildr/smalllogo.png") + except: + pass diff --git a/tildr/smalllogo.png b/tildr/smalllogo.png new file mode 100644 index 0000000000000000000000000000000000000000..8c6582c00d1efe8dcb5bfead02b495d1b031ecbd GIT binary patch literal 910 zcmV;919AL`P)nr<`|hA7qj6r*{7VOCz=3zy3u29Dg$5hQ|XS z1T-Hz_CD!M`*Uty-fy>WnbR}KIZi)yQU8E2O=pr|#$;-1rp(L{r*m0l<*3scjfaro>Mc-Vn+jjU+(m2)OqKfq3y`w+Krn<+jsotU6z^75~qPsP9w-FbwsFobq?XQ5D zvt~uC7P$vY7MBu{7;_`2By3tib7m5e)V_yRfAZJRoNSt%Mq{oNqT-Sg9ggJWBq9=u zio`@V*P=D$^mH<%k}p6+DJGK+$I#Fa5gAfb5aMLex=S(v7EmZ<1`&-659@F|>>qFw z(V`;p(l0z-4F_BkaC@kt{E^@L@(ZZE?8XJV zR#-$z%gO-Y#)B#PNI7LkB*f2`RAUkD_H&@Huu!*yh>je!0^nWOrao8_Z2JL$;G6P6 znOnbCO^a}$2S7_}Yczr|KX!Bgz~D%rs?l4%CGcgF+;CK`X;LaT^VPfX^cjE?Cr?H% z2-DEG`;V~)gnFi1Zuu7W>+pvF2w+=X-M