Skip to content

Instantly share code, notes, and snippets.

@theCrab
Created November 22, 2016 09:50
Show Gist options
  • Save theCrab/5f57a4662641e2e54f7a4c1ab1be61e9 to your computer and use it in GitHub Desktop.
Save theCrab/5f57a4662641e2e54f7a4c1ab1be61e9 to your computer and use it in GitHub Desktop.
ProMotion-map and MotionKit as root view
# MapLayout
class MapLayout < MK::Layout
# view :info_container
# view :info_image
# view :info_label
#
# view :settings_container
# view :settings_segmented_control
def layout
# root :map do
add UIView, :info_container do
add UIImageView, :info_image
add UILabel, :info_label
end
# end
add UIView, :settings_container do
add UISegmentedControl, :settings_segmented_control
add UIButton, :request_step_one
end
end
def info_container_style
background_color UIColor.blackColor
constraints do
x(20)
top(64)
right(-20)
height(50)
end
end
def info_image_style
image UIImage.imageNamed("work")
# size_to_fit
clips_to_bounds true
constraints do
top(5)
left(5)
width(40)
height(:scale) # scale height according to width
end
end
def info_label_style
text("INFO LABEL INSIDE INFO VIEW")
text_color UIColor.whiteColor
font UIFont.fontWithName("Helvetica Neue", size: 10)
text_alignment UITextAlignmentLeft
constraints do
top(5)
left.equals(nearest(:info_image), :right).plus(5)
height(40)
end
end
def settings_container_style
background_color UIColor.blackColor
constraints do
bottom(0)
height(150)
left(10)
right(-10)
end
end
end
class MapScreen < PM::MapScreen
start_position latitude: 53.226340, longitude: -0.545652, radius: 1.5
def annotation_data
[]
end
def on_load
# @layout = MapLayout.new(root: self.view).build
end
def layout
@layout = MapLayout.new
end
def will_appear
add(layout.view)
end
def on_appear
super
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment