Created
August 6, 2016 07:37
-
-
Save andrewhavens/ca21f9bf6d177630e41c3d7a3a1a4b5a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ListEventsScreen < PM::TableScreen | |
title "Upcoming Events" | |
def on_load | |
@events = [] | |
load_events | |
end | |
def load_events | |
AFMotion::JSON.get("http://calagator.org/events.json") do |response| | |
if response.success? | |
@events = response.object | |
update_table_data | |
else | |
app.alert "Sorry, there was an error while trying to load the events." | |
end | |
end | |
end | |
def table_data | |
[{ | |
cells: @events.map do |event| | |
{ title: event["title"] } | |
end | |
}] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment