Class: AppDelegate

Inherits:
Object
  • Object
show all
Defined in:
app/app_delegate.rb

Instance Method Summary collapse

Instance Method Details

#application(application, didFinishLaunchingWithOptions: launchOptions) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/app_delegate.rb', line 2

def application(application, didFinishLaunchingWithOptions:launchOptions)
  @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
  @controller = UIViewController.alloc.initWithNibName(nil, bundle:nil)
  @window.rootViewController = @controller
  @window.makeKeyAndVisible

    Twitter. do |granted, error|
      if granted
        compose = UIButton.buttonWithType(UIButtonTypeRoundedRect)
        compose.setTitle("Compose", forState:UIControlStateNormal)
        compose.sizeToFit
        @controller.view.addSubview(compose)
        compose.when UIControlEventTouchUpInside do
           = Twitter.accounts[0]
          .compose(tweet: "Hello World!", urls: ["http://clayallsopp.com"]) do |composer|
            p "Done? #{composer.done?}"
            p "Cancelled? #{composer.cancelled?}"
            p "Error #{composer.error.inspect}"
          end
        end

        timeline = UIButton.buttonWithType(UIButtonTypeRoundedRect)
        timeline.setTitle("Timeline", forState:UIControlStateNormal)
        timeline.setTitle("Loading", forState:UIControlStateDisabled)
        timeline.sizeToFit
        timeline.frame = compose.frame.below(10)
        @controller.view.addSubview(timeline)
        timeline.when UIControlEventTouchUpInside do
          timeline.enabled = false
           = Twitter.accounts[0]
          .get_timeline do |hash, error|
            timeline.enabled = true
            p "Timeline #{hash}"
          end
        end
      else
        label = UILabel.alloc.initWithFrame(CGRectZero)
        label.text = "Denied :("
        label.sizeToFit
        label.center = @controller.view.frame.center
        @controller.view.addSubview(label)
      end
    end
  true
end