Skip to content

Commit

Permalink
style: use smaller font in sq cards and pollution card
Browse files Browse the repository at this point in the history
  • Loading branch information
amit9838 committed Jul 28, 2024
1 parent f7c1164 commit 40ba2c2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/frontendCardAirPollution.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def create_card(self):
info_box.set_margin_top(15)

main_val = Gtk.Label(label=self.air_apllution_data["hourly"]["us_aqi"][idx])
main_val.set_css_classes(["text-l3", "bold"])
main_val.set_css_classes(["text-l4", "bold"])
main_val.set_halign(Gtk.Align.START)
main_val.set_margin_end(10)
info_box.append(main_val)
Expand Down
25 changes: 17 additions & 8 deletions src/frontendCardDayNight.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
get_cords,
get_time_difference,
)

gi.require_version("Gtk", "4.0")
gi.require_version("Adw", "1")

Expand Down Expand Up @@ -49,7 +50,7 @@ def get_sunset_sunrise_degree(self):
sunrise = sunrise_dt.strftime("%H:%M")
sunset = sunset_dt.strftime("%H:%M")

angle = self._calculate_sun_rotation(target_dt,sunrise_dt,sunset_dt)
angle = self._calculate_sun_rotation(target_dt, sunrise_dt, sunset_dt)
return sunrise, sunset, angle

def create_card(self):
Expand Down Expand Up @@ -82,7 +83,7 @@ def create_card(self):
card_info.attach(sun_rise_label, 0, 1, 1, 2)

sun_rise = Gtk.Label(label=self.sun_rise)
sun_rise.set_margin_top(2)
sun_rise.set_margin_top(5)
sun_rise.set_css_classes(["text-2a", "bold", "light-2"])
sun_rise.set_halign(Gtk.Align.START)
card_info.attach(sun_rise, 0, 2, 3, 3)
Expand All @@ -109,21 +110,29 @@ def create_card(self):
card_icon.attach(obj.img_box, 0, 1, 1, 1)

# Sun Rotation
def _calculate_sun_rotation(self,target_dt,sunrise_dt,sunset_dt):
def _calculate_sun_rotation(self, target_dt, sunrise_dt, sunset_dt):
angle = 0
target_ctime_hr = target_dt.hour + (target_dt.minute / 60)
target_sunrise_hr = sunrise_dt.hour + (sunrise_dt.minute / 60)
target_sunset_hr = sunset_dt.hour + (sunset_dt.minute / 60)

# day
if target_ctime_hr > target_sunrise_hr and target_ctime_hr < target_sunset_hr:
angle = (target_ctime_hr-target_sunrise_hr)*180/(target_sunset_hr-target_sunrise_hr)
angle += 180 # Sun is above the horizon
angle = (
(target_ctime_hr - target_sunrise_hr)
* 180
/ (target_sunset_hr - target_sunrise_hr)
)
angle += 180 # Sun is above the horizon

# Night
else:
if target_ctime_hr < target_sunrise_hr:
target_ctime_hr += 24 # Adjust for times after midnight
angle = (target_ctime_hr - target_sunset_hr)*180/(24-(target_sunset_hr-target_sunrise_hr))

return angle
angle = (
(target_ctime_hr - target_sunset_hr)
* 180
/ (24 - (target_sunset_hr - target_sunrise_hr))
)

return angle
6 changes: 3 additions & 3 deletions src/frontendCardSquare.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import gi
from .constants import icons
from .config import settings
from .frontendUiDrawBar import *
from .frontendUiDrawImageIcon import *
from .frontendUiDrawBar import DrawLevelBar
from .frontendUiDrawImageIcon import DrawImage

gi.require_version("Gtk", "4.0")
gi.require_version("Adw", "1")
Expand Down Expand Up @@ -72,7 +72,7 @@ def create_card(self):
# convert pressure value to int
self.main_val = int(self.main_val) if self.title == 'Pressure' else self.main_val
main_val = Gtk.Label(label=self.main_val)
main_val.set_css_classes(["text-1", "bold"])
main_val.set_css_classes(["text-2a", "bold"])
main_val.set_halign(Gtk.Align.START)
card_info.attach(main_val, 0, 1, 3, 3)

Expand Down

0 comments on commit 40ba2c2

Please sign in to comment.