Permalink
Browse files

wip

  • Loading branch information...
1 parent ca1e92a commit e2bf1e72122c8c6f50d73f2b94428c23e331f39d Neeraj Singh committed Feb 25, 2014
View
2 episode-20-wip/app/app_delegate.rb
@@ -2,7 +2,7 @@ class AppDelegate
attr_reader :language_service
- LOCK_TIME = 10
+ LOCK_TIME = 5 * 60
def application(application, didFinishLaunchingWithOptions:launchOptions)
View
14 episode-20-wip/app/controllers/all_languages_controller.rb
@@ -23,6 +23,20 @@ def tableView(tableView, cellForRowAtIndexPath: indexPath)
super
end
+ def tableView(tableView, didSelectRowAtIndexPath: indexPath)
+ language_name = @keys[indexPath.row]
+
+ controller = load_controller(language_name)
+ self.navigationController.pushViewController(controller, animated:true)
+
+ tableView.deselectRowAtIndexPath(indexPath, animated:true)
+ end
+
+ private
+
+ def load_controller language_name
+ LanguageDetailsController.alloc.initWithLanguage(language_name)
+ end
end
View
52 episode-20-wip/app/controllers/language_details_controller.rb
@@ -0,0 +1,52 @@
+class LanguageDetailsController < UITableViewController
+
+ def initWithLanguage language_name
+ @language_name = language_name
+ self
+ end
+
+ def viewDidLoad
+ super
+
+ rmq.stylesheet = LanguageDetailsControllerStylesheet
+
+ self.title = @language_name
+
+ view.tap do |table|
+ table.delegate = self
+ #table.datasource = self
+ rmq(table).apply_style :table
+ end
+
+ create_header_view
+ end
+
+ def tableView(tableView, numberOfRowsInSection: section)
+ 1
+ end
+
+ def tableView(tableView, cellForRowAtIndexPath: indexPath)
+ @reuseIdentifier ||= "CELL_IDENTIFIER"
+ cell = tableView.dequeueReusableCellWithIdentifier(@reuseIdentifier)
+ unless cell
+ cell = UITableViewCell.alloc.initWithStyle( UITableViewCellStyleDefault, reuseIdentifier:@reuseIdentifier)
+ end
+ cell.textLabel.text = 'Hello'
+ cell
+ end
+
+ private
+
+ def create_header_view
+ rmq.create(UIView, :header).tap do |q|
+ q.append(UILabel, :language_name).style do |st|
+ st.text = @language_name
+ st.size_to_fit
+ end
+ rmq.stylesheet.layout_header q
+ view.tableHeaderView = q.get
+ end
+ end
+
+end
+
View
26 episode-20-wip/app/stylesheets/language_details_controller_stylesheet.rb
@@ -0,0 +1,26 @@
+class LanguageDetailsControllerStylesheet < ApplicationStylesheet
+
+ def header st
+ st.frame = { l: 0, t: 0, w: app_width, h: 60 }
+ end
+
+ def language_name st
+ st.frame = { l: margin, t: margin_double, w: app_width, h: 25 }
+ st.number_of_lines = :unlimited
+ st.font = font.larger
+ end
+
+ def layout_header(header_view_rmq)
+ header_view_rmq.children.distribute(:vertical,
+ margin: 10,
+ margins: [0, margin_and_half, margin_and_half, margin_section])
+ header_view_rmq.resize_to_fit_subviews
+ end
+
+ def table(st)
+ st.view.separatorColor = color.clear
+ st.view.contentInset = [0,0,margin_double,0]
+ st.view.allowsSelection = false
+ end
+
+end

0 comments on commit e2bf1e7

Please sign in to comment.