diff --git a/data/ui/main.blp b/data/ui/main.blp index 6239a18..bb114a2 100644 --- a/data/ui/main.blp +++ b/data/ui/main.blp @@ -40,6 +40,8 @@ Adw.ApplicationWindow mainWindow { } Adw.Leaflet leaflet { + can-navigate-forward: false; + can-navigate-back: true; visible: false; Gtk.ScrolledWindow scrollWindow { @@ -49,15 +51,11 @@ Adw.ApplicationWindow mainWindow { Gtk.ListBox searchResults {} } - Gtk.Label seeDetailsText { - label: "Select a result to see details"; - hexpand: true; - halign: center; - } - Gtk.Box detailsBox { orientation: vertical; + visible: false; margin-start: 14; + margin-end: 14; Gtk.Label detailsTitle { halign: start; @@ -75,6 +73,42 @@ Adw.ApplicationWindow mainWindow { Gtk.Label detailsCurrentHours { 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; + } + } } } } diff --git a/src/modules/api/yelp.cr b/src/modules/api/yelp.cr index 7dd6712..494ce58 100644 --- a/src/modules/api/yelp.cr +++ b/src/modules/api/yelp.cr @@ -36,6 +36,3 @@ module Wince::Yelp end -#response = Wince::Yelp.search_businesses("miss saigon", "94610") -#puts response.status_code -#puts response.body diff --git a/src/modules/utils/utils.cr b/src/modules/utils/utils.cr index 111173c..eded762 100644 --- a/src/modules/utils/utils.cr +++ b/src/modules/utils/utils.cr @@ -33,4 +33,12 @@ module Wince::Utils 6 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 \ No newline at end of file diff --git a/src/modules/views/main.cr b/src/modules/views/main.cr index cfebeb5..231b0f4 100644 --- a/src/modules/views/main.cr +++ b/src/modules/views/main.cr @@ -93,7 +93,6 @@ module Wince response_json = JSON.parse(response.body) - SEE_DETAILS_TEXT.visible = false DETAILS_TITLE.text = response_json["name"].as_s? || "" is_open = response_json["hours"][0]["is_open_now"].as_bool? || false @@ -105,7 +104,13 @@ module Wince end 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 + LEAFLET.visible_child = DETAILS_BOX end APP.activate_signal.connect(->activate(Adw::Application)) diff --git a/src/wince.cr b/src/wince.cr index 1df3867..aece288 100644 --- a/src/wince.cr +++ b/src/wince.cr @@ -13,11 +13,14 @@ module Wince POWERD_BY_TEXT = Gtk::Label.cast(B_UI["poweredByText"]) SCROLL_VIEW = Gtk::ScrolledWindow.cast(B_UI["scrollWindow"]) 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_TITLE = Gtk::Label.cast(B_UI["detailsTitle"]) DETAILS_IS_OPEN = Gtk::Label.cast(B_UI["detailsIsOpen"]) 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) end