Added details box
This commit is contained in:
@@ -40,6 +40,8 @@ Adw.ApplicationWindow mainWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Adw.Leaflet leaflet {
|
Adw.Leaflet leaflet {
|
||||||
|
can-navigate-forward: false;
|
||||||
|
can-navigate-back: true;
|
||||||
visible: false;
|
visible: false;
|
||||||
|
|
||||||
Gtk.ScrolledWindow scrollWindow {
|
Gtk.ScrolledWindow scrollWindow {
|
||||||
@@ -49,15 +51,11 @@ Adw.ApplicationWindow mainWindow {
|
|||||||
Gtk.ListBox searchResults {}
|
Gtk.ListBox searchResults {}
|
||||||
}
|
}
|
||||||
|
|
||||||
Gtk.Label seeDetailsText {
|
|
||||||
label: "Select a result to see details";
|
|
||||||
hexpand: true;
|
|
||||||
halign: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
Gtk.Box detailsBox {
|
Gtk.Box detailsBox {
|
||||||
orientation: vertical;
|
orientation: vertical;
|
||||||
|
visible: false;
|
||||||
margin-start: 14;
|
margin-start: 14;
|
||||||
|
margin-end: 14;
|
||||||
|
|
||||||
Gtk.Label detailsTitle {
|
Gtk.Label detailsTitle {
|
||||||
halign: start;
|
halign: start;
|
||||||
@@ -75,6 +73,42 @@ Adw.ApplicationWindow mainWindow {
|
|||||||
Gtk.Label detailsCurrentHours {
|
Gtk.Label detailsCurrentHours {
|
||||||
halign: start;
|
halign: start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Gtk.Label detailsPricing {
|
||||||
|
halign: start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Gtk.ListBox {
|
||||||
|
styles ["boxed-list"]
|
||||||
|
selection-mode: none;
|
||||||
|
margin-top: 8;
|
||||||
|
hexpand: true;
|
||||||
|
|
||||||
|
Gtk.ListBoxRow {
|
||||||
|
Gtk.Label detailsAddress {
|
||||||
|
halign: start;
|
||||||
|
margin-start: 12;
|
||||||
|
margin-top: 12;
|
||||||
|
margin-bottom: 12;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Gtk.ListBoxRow {
|
||||||
|
Gtk.Label detailsPhone {
|
||||||
|
halign: start;
|
||||||
|
margin-start: 12;
|
||||||
|
margin-top: 12;
|
||||||
|
margin-bottom: 12;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Gtk.ListBoxRow {
|
||||||
|
Gtk.LinkButton detailsUrl {
|
||||||
|
label: "View on yelp";
|
||||||
|
halign: start;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,3 @@ module Wince::Yelp
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#response = Wince::Yelp.search_businesses("miss saigon", "94610")
|
|
||||||
#puts response.status_code
|
|
||||||
#puts response.body
|
|
||||||
|
|||||||
@@ -33,4 +33,12 @@ module Wince::Utils
|
|||||||
6
|
6
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def format_address(display_address_json : JSON::Any)
|
||||||
|
display_address_json.as_a.map { |line| line.as_s? || "" }.join("\n")
|
||||||
|
end
|
||||||
|
|
||||||
|
def load_url_to_image(url : String, image : Gtk::Image)
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@@ -93,7 +93,6 @@ module Wince
|
|||||||
|
|
||||||
response_json = JSON.parse(response.body)
|
response_json = JSON.parse(response.body)
|
||||||
|
|
||||||
SEE_DETAILS_TEXT.visible = false
|
|
||||||
DETAILS_TITLE.text = response_json["name"].as_s? || ""
|
DETAILS_TITLE.text = response_json["name"].as_s? || ""
|
||||||
|
|
||||||
is_open = response_json["hours"][0]["is_open_now"].as_bool? || false
|
is_open = response_json["hours"][0]["is_open_now"].as_bool? || false
|
||||||
@@ -105,7 +104,13 @@ module Wince
|
|||||||
end
|
end
|
||||||
|
|
||||||
DETAILS_CURRENT_HOURS.text = Utils.hours_for_day(response_json["hours"], Time.local.day_of_week)
|
DETAILS_CURRENT_HOURS.text = Utils.hours_for_day(response_json["hours"], Time.local.day_of_week)
|
||||||
|
DETAILS_PRICING.text = response_json["price"].as_s? || ""
|
||||||
|
DETAILS_ADDRESS.markup = Utils.format_address(response_json["location"]["display_address"])
|
||||||
|
DETAILS_PHONE.text = response_json["display_phone"].as_s? || ""
|
||||||
|
DETAILS_URL.uri = response_json["url"].as_s? || ""
|
||||||
|
|
||||||
DETAILS_BOX.visible = true
|
DETAILS_BOX.visible = true
|
||||||
|
LEAFLET.visible_child = DETAILS_BOX
|
||||||
end
|
end
|
||||||
|
|
||||||
APP.activate_signal.connect(->activate(Adw::Application))
|
APP.activate_signal.connect(->activate(Adw::Application))
|
||||||
|
|||||||
@@ -13,11 +13,14 @@ module Wince
|
|||||||
POWERD_BY_TEXT = Gtk::Label.cast(B_UI["poweredByText"])
|
POWERD_BY_TEXT = Gtk::Label.cast(B_UI["poweredByText"])
|
||||||
SCROLL_VIEW = Gtk::ScrolledWindow.cast(B_UI["scrollWindow"])
|
SCROLL_VIEW = Gtk::ScrolledWindow.cast(B_UI["scrollWindow"])
|
||||||
LEAFLET = Adw::Leaflet.cast(B_UI["leaflet"])
|
LEAFLET = Adw::Leaflet.cast(B_UI["leaflet"])
|
||||||
SEE_DETAILS_TEXT = Gtk::Label.cast(B_UI["seeDetailsText"])
|
|
||||||
DETAILS_BOX = Gtk::Box.cast(B_UI["detailsBox"])
|
DETAILS_BOX = Gtk::Box.cast(B_UI["detailsBox"])
|
||||||
DETAILS_TITLE = Gtk::Label.cast(B_UI["detailsTitle"])
|
DETAILS_TITLE = Gtk::Label.cast(B_UI["detailsTitle"])
|
||||||
DETAILS_IS_OPEN = Gtk::Label.cast(B_UI["detailsIsOpen"])
|
DETAILS_IS_OPEN = Gtk::Label.cast(B_UI["detailsIsOpen"])
|
||||||
DETAILS_CURRENT_HOURS = Gtk::Label.cast(B_UI["detailsCurrentHours"])
|
DETAILS_CURRENT_HOURS = Gtk::Label.cast(B_UI["detailsCurrentHours"])
|
||||||
|
DETAILS_PRICING = Gtk::Label.cast(B_UI["detailsPricing"])
|
||||||
|
DETAILS_ADDRESS = Gtk::Label.cast(B_UI["detailsAddress"])
|
||||||
|
DETAILS_PHONE = Gtk::Label.cast(B_UI["detailsPhone"])
|
||||||
|
DETAILS_URL = Gtk::LinkButton.cast(B_UI["detailsUrl"])
|
||||||
|
|
||||||
APP = Adw::Application.new("dev.wince", Gio::ApplicationFlags::None)
|
APP = Adw::Application.new("dev.wince", Gio::ApplicationFlags::None)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user