Skip to content

Commit

Permalink
style: make ui components smaller
Browse files Browse the repository at this point in the history
  • Loading branch information
amit9838 committed Jul 28, 2024
1 parent e3c1ee9 commit f7c1164
Show file tree
Hide file tree
Showing 15 changed files with 157 additions and 164 deletions.
2 changes: 1 addition & 1 deletion src/backendAirPollution.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def current_air_pollution(latitude: float, longitude: float, **kwargs):
url = url + f"&hourly={hourly_fields}"

try:
url = url + f"&timeformat=unixtime" + f"&forecast_days=1"
url = url + "&timeformat=unixtime" + "&forecast_days=1"
response = requests.get(url)
response.raise_for_status() # Raise an exception if the request was unsuccessful
data = response.json()
Expand Down
2 changes: 1 addition & 1 deletion src/backendFindCity.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def find_city(city, count=3):
cities_res = response.json()
cities = cities_res.get('results')
cities_list = []
if cities == None:
if cities is None:
return cities_list
for city in cities:
data = {
Expand Down
8 changes: 4 additions & 4 deletions src/backendWeather.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self) -> None:
global extend_url

if settings.unit == "imperial":
extend_url = f"&temperature_unit=fahrenheit&wind_speed_unit=mph"
extend_url = "&temperature_unit=fahrenheit&wind_speed_unit=mph"
else:
extend_url = ""

Expand All @@ -31,7 +31,7 @@ def current_weather(cls,latitude: float, longitude: float, **kwargs):
url = url + f"&current={current_fields}" + extend_url

try:
url = url + f"&timeformat=unixtime"
url = url + "&timeformat=unixtime"
response = requests.get(url)
response.raise_for_status() # Raise an exception if the request was unsuccessful
data = response.json()
Expand Down Expand Up @@ -65,7 +65,7 @@ def forecast_hourly(cls,latitude: float, longitude: float, **kwargs):
url = url + f"&hourly={hourly_fields}" + extend_url

try:
url = url + f"&timeformat=unixtime"
url = url + "&timeformat=unixtime"
response = requests.get(url)
response.raise_for_status() # Raise an exception if the request was unsuccessful
data = response.json()
Expand Down Expand Up @@ -113,7 +113,7 @@ def forecast_daily(cls,latitude: float, longitude: float, **kwargs):
url = url + f"&end_date={kwargs.get('end_date')}"

try:
url = url + f"&timeformat=unixtime" + extend_url
url = url + "&timeformat=unixtime" + extend_url
response = requests.get(url)
response.raise_for_status() # Raise an exception if the request was unsuccessful
data = response.json()
Expand Down
2 changes: 0 additions & 2 deletions src/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import gettext

icon_loc = "@icon_location@/share/icons/hicolor/scalable/mousam_icons/"

icons = {
Expand Down
10 changes: 5 additions & 5 deletions src/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
font-size: 30px;
}
.main_temp_label {
font-size: 3.7rem;
font-size: 3.5rem;
}

.btn_sm{
Expand Down Expand Up @@ -58,7 +58,7 @@
font-size: .95rem;
}
.text-7{
font-size: 9rem;
font-size: .9rem;
}
.text-8{
font-size: .85rem;
Expand Down Expand Up @@ -158,7 +158,7 @@
}

.custom_card{
padding:.5rem 1rem;
padding:.7rem .85rem;
}

.bar_container{
Expand All @@ -168,13 +168,13 @@
}

.custom_card_forecast_item{
padding: 0.12rem 1.5rem;
padding: 0rem 1.1rem;
border-radius: .7rem;
}

.custom_card_hourly{
border-radius: .5rem;
padding: .7rem .7rem;
padding: .4rem .6rem;
margin-top: .3rem;
}

Expand Down
11 changes: 3 additions & 8 deletions src/frontendCardAirPollution.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import gi
import time

gi.require_version("Gtk", "4.0")
gi.require_version("Adw", "1")
from gi.repository import Gtk

from .frontendUiDrawPollutionBar import PollutionBar
from .config import settings

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

class CardAirPollution:
def __init__(self):
Expand Down Expand Up @@ -51,11 +51,6 @@ def create_card(self):
icon.set_halign(Gtk.Align.END)
icon.set_css_classes(["light-4"])
icon.set_tooltip_text(_("United States AQI standard"))
# icon.set_margin_end(20)
# title = Gtk.Label(label="info")
# title.set_hexpand(True)
# title.set_halign(Gtk.Align.END)
# title.set_css_classes(["text-4", "light-3", "bolda"])
card.attach(icon, 3, 0, 4, 2)

# Main value (like windspeed = 32km/h)
Expand All @@ -64,7 +59,7 @@ def create_card(self):
)
card.attach(info_box, 0, 2, 4, 2)
info_box.set_margin_start(10)
info_box.set_margin_top(20)
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"])
Expand Down
18 changes: 10 additions & 8 deletions src/frontendCardDayNight.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from datetime import datetime
import gi

gi.require_version("Gtk", "4.0")
gi.require_version("Adw", "1")
from gi.repository import Gtk

from .frontendUiDrawDayNight import *
from .frontendUiDrawDayNight import DrawDayNight
from .config import settings
from .utils import (
get_cords,
get_time_difference,
)
gi.require_version("Gtk", "4.0")
gi.require_version("Adw", "1")


class CardDayNight:
Expand Down Expand Up @@ -56,7 +56,7 @@ def create_card(self):
card = Gtk.Grid(margin_top=10, margin_start=5, margin_bottom=0)
self.card = card
card.halign = Gtk.Align.FILL
card.set_row_spacing(5)
# card.set_row_spacing(5)
card.set_css_classes(["view", "card", "custom_card"])

if settings.is_using_dynamic_bg:
Expand All @@ -82,14 +82,14 @@ 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(10)
sun_rise.set_margin_top(2)
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)

sun_set_label = Gtk.Label(label=_("Sunset"))
sun_set_label.set_halign(Gtk.Align.START)
sun_set_label.set_margin_top(20)
sun_set_label.set_margin_top(15)
sun_set_label.set_css_classes(["text-4", "light-4"])
card_info.attach(sun_set_label, 0, 4, 1, 2)

Expand All @@ -99,11 +99,13 @@ def create_card(self):
card_info.attach(sun_set, 0, 6, 3, 3)

card_icon = Gtk.Grid()
card_icon.set_css_classes(["view", "card_infao"])
card_icon.set_css_classes(["view"])
card_icon.add_css_class("transparent_0")
# card_icon.add_css_class("card_info")

card.attach(card_icon, 1, 2, 2, 1)

obj = DrawDayNight(self.degree, 200, 100)
obj = DrawDayNight(self.degree, 120, 90)
card_icon.attach(obj.img_box, 0, 1, 1, 1)

# Sun Rotation
Expand Down
21 changes: 10 additions & 11 deletions src/frontendCardSquare.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ def create_card(self):
margin_start=5,
margin_end=5,
row_spacing=5,
column_spacing=25,
column_spacing=0,
)
card.halign = Gtk.Align.FILL
card.set_size_request(200, 150)
card.set_size_request(170, 100)
card.set_css_classes(["view", "card", "custom_card"])

if settings.is_using_dynamic_bg:
Expand All @@ -65,10 +65,11 @@ def create_card(self):
card.attach(title, 0, 0, 1, 2)

# Info Grid: It contains - Main value,units, short description, sub description
card_info = Gtk.Grid(margin_top=5, row_spacing=0, column_spacing=0)
card_info = Gtk.Grid()
card.attach(card_info, 0, 2, 1, 2)

# Main value (like windspeed = 32km/h)
# 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"])
Expand All @@ -77,26 +78,25 @@ def create_card(self):

# Unit if the main value
main_val_unit = Gtk.Label(label=self.main_val_unit)
main_val_unit.set_css_classes(["text-5", "light-3"])
main_val_unit.set_css_classes(["text-7", "light-3"])
main_val_unit.set_halign(Gtk.Align.START)
card_info.attach(main_val_unit, 3, 3, 1, 1)

# Short description
# Short description [light, moderate]
desc_box = Gtk.Box()
desc_box.set_size_request(10, 30)
desc_box.set_size_request(5, 27)
card_info.attach(desc_box, 0, 4, 6, 1)

desc = Gtk.Label(label=self.desc)
desc.set_css_classes(["text-5", "light-2", "bold-2"])
desc.set_wrap(True)
desc.set_margin_start(0)
desc.set_halign(Gtk.Align.START)
desc.set_valign(Gtk.Align.START)
desc_box.append(desc)

# Sub description heading
# Sub description heading [dewpoint,from]
sub_desc_heading = Gtk.Label(label=self.sub_desc_heading)
sub_desc_heading.set_css_classes(["text-4", "light-1"])
sub_desc_heading.set_css_classes(["text-6", "light-1"])
sub_desc_heading.set_halign(Gtk.Align.START)
card_info.attach(sub_desc_heading, 0, 5, 4, 1)

Expand All @@ -106,7 +106,6 @@ def create_card(self):
card_info.attach(sub_desc, 0, 6, 4, 1)

card_icon = Gtk.Grid(halign=Gtk.Align.END)
card_icon.set_margin_top(5)
card.attach(card_icon, 1, 2, 2, 1)

icon_upper_text = Gtk.Label(label=self.text_up)
Expand All @@ -116,7 +115,7 @@ def create_card(self):
icon_upper_text.set_css_classes(["title-5"])

icon_upper_text.set_halign(Gtk.Align.CENTER)
icon_upper_text.set_margin_bottom(5)
icon_upper_text.set_margin_bottom(0)
card_icon.attach(icon_upper_text, 0, 0, 1, 1)

if self.title.lower() == "wind":
Expand Down
6 changes: 3 additions & 3 deletions src/frontendCurrentCond.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def paint_ui(self):
orientation=Gtk.Orientation.VERTICAL,
hexpand=True,
halign=Gtk.Align.START,
margin_top=40,
margin_top=30,
)
self.attach(box_left, 0, 0, 1, 1)

Expand All @@ -38,7 +38,7 @@ def paint_ui(self):

icon_main = Gtk.Image().new_from_file(condition_icon)
icon_main.set_hexpand(True)
icon_main.set_pixel_size(110)
icon_main.set_pixel_size(90)
condition_grid.attach(icon_main, 0, 0, 1, 2)

# Condition label
Expand All @@ -47,7 +47,7 @@ def paint_ui(self):
halign=Gtk.Align.START,
valign=Gtk.Align.END,
)
cond_label.set_css_classes(["text-2a", "light-4", "bold-2"])
cond_label.set_css_classes(["text-2b", "light-4", "bold-2"])
condition_grid.attach(cond_label, 1, 0, 1, 1)

# Condition temperature
Expand Down
Loading

0 comments on commit f7c1164

Please sign in to comment.