Added icon and makefile
This commit is contained in:
@@ -12,6 +12,7 @@ module Wince
|
||||
@@business_rows = [] of BusinessRow
|
||||
@@hour_rows = [] of HourRow
|
||||
@@business_ids = [] of String
|
||||
@@marker = nil
|
||||
|
||||
def activate(app : Adw::Application)
|
||||
main_window = APP.window_by_id(@@main_window_id)
|
||||
@@ -39,9 +40,26 @@ module Wince
|
||||
handle_business_select
|
||||
end
|
||||
|
||||
setup_map
|
||||
|
||||
window.present
|
||||
end
|
||||
|
||||
def setup_map
|
||||
DETAILS_MAP.map_source = Shumate::MapSourceRegistry
|
||||
.new_with_defaults().by_id(Shumate::MAP_SOURCE_OSM_MAPNIK)
|
||||
|
||||
icon = Gtk::Image.new_from_icon_name("view-pin-symbolic")
|
||||
@@marker = Shumate::Marker.new
|
||||
|
||||
@@marker.try do|m|
|
||||
m.child = icon
|
||||
marker_layer = Shumate::MarkerLayer.new(DETAILS_MAP.viewport)
|
||||
marker_layer.add_marker(m)
|
||||
DETAILS_MAP.add_overlay_layer(marker_layer)
|
||||
end
|
||||
end
|
||||
|
||||
def handle_geolocate
|
||||
latlon = Location.find_location()
|
||||
LOCATION_ENTRY.text = "#{latlon[0]}, #{latlon[1]}"
|
||||
@@ -134,6 +152,8 @@ module Wince
|
||||
@@hour_rows = format_hours(response_json["hours"])
|
||||
@@hour_rows.each { |hour_row| DETAILS_HOURS_BOX.append(hour_row) }
|
||||
|
||||
set_map_location(response_json["coordinates"])
|
||||
|
||||
# If we're in the small layout we want to show the back button
|
||||
if LEAFLET.folded
|
||||
DETAILS_BACK.visible = true
|
||||
@@ -145,6 +165,17 @@ module Wince
|
||||
LEAFLET.visible_child = DETAILS_SCROLL
|
||||
end
|
||||
|
||||
def set_map_location(coordinates : JSON::Any)
|
||||
latitude = coordinates["latitude"].as_f
|
||||
longitude = coordinates["longitude"].as_f
|
||||
|
||||
viewport = DETAILS_MAP.viewport
|
||||
viewport.set_location(latitude, longitude)
|
||||
viewport.zoom_level = 14
|
||||
|
||||
@@marker.try {|m| m.set_location(latitude, longitude) }
|
||||
end
|
||||
|
||||
def format_hours(hours_json : JSON::Any)
|
||||
Time::DayOfWeek.values.map do |day|
|
||||
hours = Utils.hours_for_day(hours_json, day, "\n")
|
||||
|
||||
@@ -27,6 +27,7 @@ module Wince
|
||||
DETAILS_URL = Gtk::LinkButton.cast(B_UI["detailsUrl"])
|
||||
DETAILS_BACK = Gtk::Button.cast(B_UI["detailsBack"])
|
||||
DETAILS_HOURS_BOX = Gtk::ListBox.cast(B_UI["detailsHoursBox"])
|
||||
DETAILS_MAP = Shumate::SimpleMap.cast(B_UI["detailsMap"])
|
||||
|
||||
APP = Adw::Application.new("dev.wince", Gio::ApplicationFlags::None)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user