Lots of style improvements

This commit is contained in:
2022-12-18 23:13:52 -08:00
parent 5e2e9e2752
commit 9aa5741e1a
5 changed files with 53 additions and 33 deletions

View File

@@ -1,26 +1,30 @@
module Wince
@[Gtk::UiTemplate(resource: "/wince/ui/compiled/templates.ui", children: %w(businessName businessRating businessHours businessWebsite))]
@[Gtk::UiTemplate(resource: "/wince/ui/compiled/templates.ui", children: %w(businessName businessRating businessOpen businessDistance))]
class BusinessRow < Gtk::ListBoxRow
include Gtk::WidgetTemplate
@name : Gtk::Label
@rating : Gtk::Label
@hours : Gtk::Label
@website : Gtk::LinkButton
@open : Gtk::Label
@distance : Gtk::Label
def initialize(name : String, rating : String, hours : String, website : String)
def initialize(name : String, rating : Float32, open : Bool, distance : Float32)
super()
@name = Gtk::Label.cast(template_child("businessName"))
@rating = Gtk::Label.cast(template_child("businessRating"))
@hours = Gtk::Label.cast(template_child("businessHours"))
@website = Gtk::LinkButton.cast(template_child("businessWebsite"))
@open = Gtk::Label.cast(template_child("businessOpen"))
@distance = Gtk::Label.cast(template_child("businessDistance"))
@name.text = name
@rating.text = rating
@hours.text = hours
@website.uri = website
@website.label = "view on yelp"
@rating.text = rating.round(2).to_s
if open
@open.markup = "<span foreground=\"green\">open</span>"
else
@open.markup = "<span foreground=\"red\">closed</span>"
end
distance_miles = distance / 1609.344
@distance.text = distance_miles.round(2).to_s + "mi"
end
end
end