do print "Notification {uniqueness_id}: {title}; {content}"
# View for an item in a list, like a beer or a person
-abstract class ItemView
- super View
-end
+abstract class ItemView super View end
+
+# Descriptive label providing extra information
+class DescLabel super Label end
+
+# `HorizontalLayout` header to a section
+class SectionHeader super HorizontalLayout end
+
+# `Label` used in section headers
+class SectionTitle super Label end
# Basic async HTTP request for this app
#
redef class UserWindow
- private var lbl_checkins_options_title = new Label(parent=layout,
+ private var header = new SectionHeader(parent=layout)
+ private var lbl_checkins_options_title = new SectionTitle(parent=header,
text="Share options".t)
private var chk_share_checkins = new CheckBox(parent=layout,
init
do
chk_share_checkins.is_checked = app.share_checkins
- lbl_checkins_options_title.size = 1.5
end
redef fun on_event(event)
redef class UserWindow
- private var layout_push_options = new VerticalLayout(parent=layout)
+ private var header = new SectionHeader(parent=layout)
+
+ private var lbl_push_options_title = new SectionTitle(parent=header,
+ text="Notifications options".t)
- private var lbl_push_options_title = new Label(parent=layout_push_options,
- text="Notifications options".t, size=1.5)
+ private var layout_push_options = new VerticalLayout(parent=layout)
private var chk_notify_on_new_beers = new CheckBox(parent=layout_push_options,
text="Notify when there are new beers".t)
var top_line_layout = new HorizontalLayout(parent=self)
var lbl_name = new Label(parent=top_line_layout, text=beer_info.beer.name, size = 1.25) is lazy
- var lbl_stats = new Label(parent=self, text=beer_info.rating_text, align=0.0, size=0.5) is lazy
+ var lbl_stats = new DescLabel(parent=self, text=beer_info.rating_text, size=0.5) is lazy
var lbl_desc: Label is noinit
var lbl_comment: nullable Label = null
var desc = beer_info.beer.desc
if beer_info.is_new then desc += " (New)".t
- lbl_desc = new Label(parent=self, text=desc, align=0.0)
+ lbl_desc = new DescLabel(parent=self, text=desc)
lbl_stats
var badges = beer_info.badges
if badges != null then
- var lbl_comment = new Label(parent=self, text=badges.join(" "))
+ var lbl_comment = new DescLabel(parent=self, text=badges.join(" "))
lbl_comment.size = 0.5
self.lbl_comment = lbl_comment
end
# Cut-point for the iOS adaptation
var layout_user = new VerticalLayout(parent=layout)
- private var layout_login = new HorizontalLayout(parent=layout_user)
+ private var layout_login = new SectionHeader(parent=layout_user)
private var but_preferences: nullable Button = null
private var but_login: nullable Button = null
private var layout_beers = new VerticalLayout(parent=layout)
- var layout_beers_title = new HorizontalLayout(parent=layout_beers)
+ var layout_beers_title = new SectionHeader(parent=layout_beers)
var title_beers = new SectionTitle(parent=layout_beers_title, text="Beer Menu".t, size=1.5)
private var beer_button = new Button(parent=layout_beers_title, text="View all".t)
private var beer_list = new VerticalLayout(parent=layout_beers)
private var beer_temp_lbl = new Label(parent=beer_list, text="Loading...".t)
private var layout_social = new VerticalLayout(parent=layout)
- private var social_header = new HorizontalLayout(parent=layout_social)
+ private var social_header = new SectionHeader(parent=layout_social)
private var social_title = new SectionTitle(parent=social_header, text="Friends".t, size=1.5)
private var social_button = new Button(parent=social_header, text="Manage".t)
private var social_list = new VerticalLayout(parent=layout_social)
private var social_temp_lbl = new Label(parent=social_list, text="Loading...".t)
private var layout_news = new VerticalLayout(parent=layout)
- private var news_header = new HorizontalLayout(parent=layout_news)
+ var news_header = new SectionHeader(parent=layout_news)
private var news_title = new SectionTitle(parent=news_header, text="Events".t, size=1.5)
#private var news_button = new Button(parent=news_header, text="Open website") # TODO
- private var news_label = new Label(parent=layout_news, text="Bière en cask le jeudi!")
+ private var news_cask = new EventView(parent=layout_news, text="Bière en cask le jeudi!")
redef fun on_resume do refresh
layout_login.clear
if app.user != null then
# Logged in
- var lbl_login_status = new Label(parent=layout_login, text="Welcome".t, size=1.5)
+ var lbl_login_status = new SectionTitle(parent=layout_login, text="Welcome".t, size=1.5)
lbl_login_status.set_welcome
else
self.but_login = new Button(parent=layout_login, text="Login or signup".t)
end
end
-# `Label` used in section headers
-class SectionTitle super Label end
+private class EventView
+ super VerticalLayout
+ super ItemView
+
+ var text: Text
+
+ var lbl = new Label(parent=self, text=text) is lazy
+ init do lbl
+end
# Async request to update the beer list on the home screen
class ListDiffAction
private var layout_header = new VerticalLayout(parent=list_search)
private var layout_search = new HorizontalLayout(parent=layout_header)
- private var txt_query = new TextInput(parent=layout_search)
+ var txt_query = new TextInput(parent=layout_search)
private var but_search = new Button(parent=layout_search, text="Search".t)
private var layout_list = new HorizontalLayout(parent=layout_header)
var favs = if not user_and_following.favs.is_empty then
"Favorites: %0".t.format(user_and_following.favs)
else "No favorites yet".t
- var lbl_desc = new Label(parent=self, text=favs, size=0.5)
+ var lbl_desc = new DescLabel(parent=self, text=favs, size=0.5)
end
end
private var layout_user_options = new VerticalLayout(parent=layout)
- private var lbl_user_options_title = new Label(parent=layout_user_options,
+ private var user_options_header = new SectionHeader(parent=layout_user_options)
+ private var lbl_user_options_title = new SectionTitle(parent=user_options_header,
text="Account options".t)
- private var lbl_welcome = new Label(parent=layout_user_options)
+ var lbl_welcome = new DescLabel(parent=layout_user_options)
private var but_logout = new Button(parent=layout_user_options, text="Logout".t)
# Refesh displayed text
fun refresh
do
- lbl_user_options_title.size = 1.5
lbl_welcome.set_user_name
but_logout.enabled = app.user != null
end
super Window
private var list = new ListLayout(parent=self)
- private var lbl_feedback = new Label(parent=list, text="Welcome")
+ private var lbl_feedback = new DescLabel(parent=list, text="Welcome")
private var layout_login = new VerticalLayout(parent=list)
private var pass_line = new HorizontalLayout(parent=layout_login)
private var lbl_pass = new Label(parent=pass_line, text="Password".t)
private var txt_pass = new TextInput(parent=pass_line, is_password=true)
- private var lbl_pass_desc = new Label(parent=layout_login, size = 0.5,
+ private var lbl_pass_desc = new DescLabel(parent=layout_login, size = 0.5,
text="Passwords must be composed of at least 6 characters.".t)
private var but_login = new Button(parent=layout_login, text="Login".t)
private var layout_register = new VerticalLayout(parent=list)
- private var lbl_signup_desc = new Label(parent=layout_register, size = 0.5,
+ private var lbl_signup_desc = new DescLabel(parent=layout_register, size = 0.5,
text="Fill the following fields to sign up.".t)
# Repeat password