compass screen with dark theme

This commit is contained in:
rgarcia-herrera 2020-08-28 18:56:32 -05:00
parent d4683f6200
commit c7c4760c8c
4 changed files with 130 additions and 51 deletions

BIN
assets/to_map.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

@ -1,3 +1,52 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_2_copy" x="0px" y="0px" width="100px" height="100px" viewBox="0 0 100 100" enable-background="new 0 0 100 100" xml:space="preserve">
<path d="M62.397,23.657c-3.29,0-5.969,2.677-5.969,5.969c0,2.347,1.365,4.376,3.339,5.35l-5.251,14.905l-12.012-8.859l-7.671,20.367 c-0.014,0-0.027-0.002-0.041-0.002c-3.291,0-5.969,2.678-5.969,5.969c0,3.29,2.677,5.969,5.969,5.969 c3.291,0,5.969-2.678,5.969-5.969c0-2.376-1.399-4.425-3.413-5.385l6.358-16.883l12.075,8.904l6.484-18.405 c0.044,0.001,0.088,0.007,0.132,0.007c3.29,0,5.969-2.677,5.969-5.969S65.687,23.657,62.397,23.657z M34.792,69.914 c-1.41,0-2.558-1.148-2.558-2.558c0-1.41,1.148-2.558,2.558-2.558s2.558,1.148,2.558,2.558S36.203,69.914,34.792,69.914z M62.397,32.184c-1.41,0-2.558-1.148-2.558-2.558s1.148-2.558,2.558-2.558s2.558,1.148,2.558,2.558 C64.955,31.036,63.807,32.184,62.397,32.184z M63.572,14.923l-0.771,0.289c-13.259,4.972-19.791,17.1-20.647,18.787 c-6.083,2.661-14.998-0.402-14.998-0.402l-1.019,0.373c-13.961,5.236-20.47,18.415-20.74,18.973L5,53.762l31.315,31.315l0.794-1.587 c6.079-12.157,17.585-17.019,19.145-17.631c8.559,2.706,16.726,0.46,16.726,0.46l0.794-1.587C80.269,51.739,95,46.351,95,46.351 L63.572,14.923z M72.309,62.03L59.252,49.077L58.4,51.741l12.31,12.311c-6.466,1.954-14.007-0.574-14.007-0.574L43.608,50.279 l-0.929,2.688l11.074,11.177c-3.776,1.747-12.513,6.653-18.107,16.645L8.122,53.266c1.568-2.798,7.511-12.279,18.15-16.602 l11.611,11.721l0.746-2.771l-8.527-8.633c5.542,1.386,10.978,0.587,12.969-0.57l10.692,10.696l0.853-2.665l-9.829-9.933 c1.568-2.798,7.511-12.279,18.151-16.602l27.48,27.48C86.641,47.133,77.904,52.038,72.309,62.03z"/>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="Layer_2_copy"
x="0px"
y="0px"
width="100px"
height="100px"
viewBox="0 0 100 100"
enable-background="new 0 0 100 100"
xml:space="preserve"
sodipodi:docname="to_map.svg"
inkscape:export-filename="/home/rgarcia/flockompass/assets/to_map.png"
inkscape:export-xdpi="133"
inkscape:export-ydpi="133"
inkscape:version="0.92.3 (2405546, 2018-03-11)"><metadata
id="metadata7261"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs7259" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1916"
inkscape:window-height="1056"
id="namedview7257"
showgrid="false"
inkscape:pagecheckerboard="true"
inkscape:zoom="6.675088"
inkscape:cx="7.3523141"
inkscape:cy="53.672817"
inkscape:window-x="0"
inkscape:window-y="22"
inkscape:window-maximized="0"
inkscape:current-layer="Layer_2_copy" />
<path
d="M62.397,23.657c-3.29,0-5.969,2.677-5.969,5.969c0,2.347,1.365,4.376,3.339,5.35l-5.251,14.905l-12.012-8.859l-7.671,20.367 c-0.014,0-0.027-0.002-0.041-0.002c-3.291,0-5.969,2.678-5.969,5.969c0,3.29,2.677,5.969,5.969,5.969 c3.291,0,5.969-2.678,5.969-5.969c0-2.376-1.399-4.425-3.413-5.385l6.358-16.883l12.075,8.904l6.484-18.405 c0.044,0.001,0.088,0.007,0.132,0.007c3.29,0,5.969-2.677,5.969-5.969S65.687,23.657,62.397,23.657z M34.792,69.914 c-1.41,0-2.558-1.148-2.558-2.558c0-1.41,1.148-2.558,2.558-2.558s2.558,1.148,2.558,2.558S36.203,69.914,34.792,69.914z M62.397,32.184c-1.41,0-2.558-1.148-2.558-2.558s1.148-2.558,2.558-2.558s2.558,1.148,2.558,2.558 C64.955,31.036,63.807,32.184,62.397,32.184z M63.572,14.923l-0.771,0.289c-13.259,4.972-19.791,17.1-20.647,18.787 c-6.083,2.661-14.998-0.402-14.998-0.402l-1.019,0.373c-13.961,5.236-20.47,18.415-20.74,18.973L5,53.762l31.315,31.315l0.794-1.587 c6.079-12.157,17.585-17.019,19.145-17.631c8.559,2.706,16.726,0.46,16.726,0.46l0.794-1.587C80.269,51.739,95,46.351,95,46.351 L63.572,14.923z M72.309,62.03L59.252,49.077L58.4,51.741l12.31,12.311c-6.466,1.954-14.007-0.574-14.007-0.574L43.608,50.279 l-0.929,2.688l11.074,11.177c-3.776,1.747-12.513,6.653-18.107,16.645L8.122,53.266c1.568-2.798,7.511-12.279,18.15-16.602 l11.611,11.721l0.746-2.771l-8.527-8.633c5.542,1.386,10.978,0.587,12.969-0.57l10.692,10.696l0.853-2.665l-9.829-9.933 c1.568-2.798,7.511-12.279,18.151-16.602l27.48,27.48C86.641,47.133,77.904,52.038,72.309,62.03z"
id="path7254"
style="fill:#f3e8d2;fill-opacity:1" />
</svg>

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -1,6 +1,20 @@
#:import random random.random
#:import RiseInTransition kivy.uix.screenmanager.RiseInTransition
#:import facade plyer.compass
#:import rgba kivy.utils.get_color_from_hex
<BackgroundColor@Widget>:
background_color: 1, 1, 1, 1
canvas.before:
Color:
rgba: root.background_color
Rectangle:
size: self.size
pos: self.pos
<BackgroundLabel@Label+BackgroundColor>:
background_color: 0, 0, 0, 0
background_color: rgba("#c0464b")
<RootScreen>:
@ -62,33 +76,15 @@
orientation: 'vertical'
padding: '20dp'
spacing: '10dp'
BoxLayout:
orientation: 'vertical'
ActionBar:
pos_hint: {'top':1}
ActionView:
use_separator: True
ActionPrevious:
title: 'Social Cycling'
with_previous: False
ActionButton:
important: True
text: 'set destination'
on_press: root.manager.current = 'map';
FloatLayout:
canvas:
Color:
rgb: .9, .9, .9
rgba: rgba("#336645")
Rectangle:
size: self.size
Label:
text: app.dest_distance
color: 0, 0, 0.3, 1
size_hint: 0.5, 0.1
pos: 0, 0.1
font_size: '40sp'
Image:
source: 'assets/needle.png'
pos_hint: {"center_x": 0.5, "center_y": 0.7}
canvas.before:
PushMatrix
Rotate:
@ -100,6 +96,7 @@
Image:
id: to_dest
source: 'assets/needle_to_dest.png'
pos_hint: {"center_x": 0.5, "center_y": 0.7}
canvas.before:
PushMatrix
Rotate:
@ -110,3 +107,24 @@
PopMatrix
Image:
source: 'assets/pivot.png'
pos_hint: {"center_x": 0.5, "center_y": 0.7}
size_hint: 1, 1
IconButton:
source: 'assets/to_map.png'
pos_hint: {"center_x": 0.1, "center_y": 0.95}
size_hint: 0.2, 0.2
on_press: root.manager.current = 'map';
BackgroundLabel:
text: app.dest_distance
background_color: rgba("#c0464b")
color: rgba("#f3e8d2")
size_hint: 1, 0.2
pos_hint: {"x": 0, "top": 0.4}
font_size: '40sp'
BackgroundLabel:
text: app.dashboard_flock
background_color: rgba("#679958")
color: rgba("#f3e8d2")
size_hint: 1, 0.2
pos_hint: {"x": 0, "top": 0.2}
font_size: '40sp'

14
main.py
View File

@ -35,6 +35,8 @@ class FlockompassApp(App):
fbearing = NumericProperty(0)
dest_distance = StringProperty("")
dashboard_dest = StringProperty("")
dashboard_flock = StringProperty("")
def dump(self, dt):
print(dt, self.gps_data, self.session_data)
@ -79,9 +81,19 @@ class FlockompassApp(App):
self.ms.ids.mapview.center_on(self.session_data['dest_lat'],
self.session_data['dest_lon'])
else:
self.dest_distance = "D: %0.1f km" % geodesic(
dest_distance = geodesic(
(self.gps_data['lat'], self.gps_data['lon']),
(self.session_data['dest_lat'], self.session_data['dest_lon'])).kilometers
if dest_distance < 1:
dest_distance *= 1000
dest_distance = "%i metros" % dest_distance
else:
dest_distance = "%0.1f km" % dest_distance
self.dest_distance = "Destino: %s\nVel: %0.1f km/h" % (dest_distance,
self.gps_data['speed'])
def center_map_on_gps(self):
self.ms.ids.mapview.center_on(self.gps_data['lat'],