Class: TestViewController

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#sheetObject

Returns the value of attribute sheet.



3
4
5
# File 'app/test_view_controller.rb', line 3

def sheet
  @sheet
end

Instance Method Details

#share_email_buttonObject



59
60
61
62
63
64
65
66
67
68
69
70
# File 'app/test_view_controller.rb', line 59

def share_email_button
  button = UIButton.buttonWithType(UIButtonTypeRoundedRect)
  button.frame = [[15, 100], [290, 25]]
  button.setTitle("Share via mail", forState:UIControlStateNormal)
  button.setTitleColor(UIColor.blackColor, forState:UIControlStateNormal)
  self.view.addSubview(button)

  button.whenTapped do
    email = Sharemotion::SHMEmail.alloc.initWithItem(@item)
    email.share(self)
  end
end

#share_facebook_buttonObject



85
86
87
88
89
90
91
92
93
94
95
96
# File 'app/test_view_controller.rb', line 85

def share_facebook_button
  button = UIButton.buttonWithType(UIButtonTypeRoundedRect)
  button.frame = [[15, 200], [290, 25]]
  button.setTitle("Share via facebook", forState:UIControlStateNormal)
  button.setTitleColor(UIColor.blackColor, forState:UIControlStateNormal)
  self.view.addSubview(button)

  button.whenTapped do
    facebook = Sharemotion::SHMFacebook.alloc.initWithItem(@item)
    facebook.share(self)
  end
end

#share_sms_buttonObject



98
99
100
101
102
103
104
105
106
107
108
109
# File 'app/test_view_controller.rb', line 98

def share_sms_button
  button = UIButton.buttonWithType(UIButtonTypeRoundedRect)
  button.frame = [[15, 250], [290, 25]]
  button.setTitle("Share via sms", forState:UIControlStateNormal)
  button.setTitleColor(UIColor.blackColor, forState:UIControlStateNormal)
  self.view.addSubview(button)

  button.whenTapped do
    sms = Sharemotion::SHMSms.alloc.initWithItem(@item)
    sms.share(self)
  end
end

#share_twitter_buttonObject



72
73
74
75
76
77
78
79
80
81
82
83
# File 'app/test_view_controller.rb', line 72

def share_twitter_button
  button = UIButton.buttonWithType(UIButtonTypeRoundedRect)
  button.frame = [[15, 150], [290, 25]]
  button.setTitle("Share via twitter", forState:UIControlStateNormal)
  button.setTitleColor(UIColor.blackColor, forState:UIControlStateNormal)
  self.view.addSubview(button)

  button.whenTapped do
    twitter = Sharemotion::SHMTwitter.alloc.initWithItem(@item)
    twitter.share(self)
  end
end

#show_sheet_buttonObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/test_view_controller.rb', line 34

def show_sheet_button
  button = UIButton.buttonWithType(UIButtonTypeRoundedRect)
  button.frame = [[15, 50], [290, 25]]
  button.setTitle("Share", forState:UIControlStateNormal)
  button.setTitleColor(UIColor.blackColor, forState:UIControlStateNormal)
  self.view.addSubview(button)


  button.whenTapped do
    facebook = Sharemotion::SHMFacebook.alloc.initWithItem(@item) {|sharer|
      sharer.sharer_title = "Bookface"
    }

    sharers = [
      Sharemotion::SHMEmail.alloc.initWithItem(@item),
      Sharemotion::SHMSms.alloc.initWithItem(@item),
      Sharemotion::SHMTwitter.alloc.initWithItem(@item),
      facebook
    ]

    @sheet = Sharemotion::Sheet.alloc.initWithSharers(sharers, controller:self)
    @sheet.showInView(self.view)
  end
end

#viewDidLoadObject



5
6
7
# File 'app/test_view_controller.rb', line 5

def viewDidLoad
  super
end

#viewWillAppear(animated) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/test_view_controller.rb', line 9

def viewWillAppear(animated)
  @item = Sharemotion::Item.new({
    :title => "Look at that bro!",
    :url => "http://www.google.fr",
    :image => "http://www.aujardin.ch/photos/tulipe1.jpg",
    :text => "You should watch this site, it's incredible",
    :sharers => {
      :email => {
        :to => ["[email protected]", "[email protected]"],
        :text => "Well you shouldn't..."
      },
      :facebook => {
        :caption => "OHAI",
        :title => "HEY HEY"
      }
    }
  })

  show_sheet_button
  share_email_button
  share_twitter_button
  share_facebook_button
  share_sms_button
end