Class: UnderOs::Page

Inherits:
Object
  • Object
show all
Includes:
Events, UI
Defined in:
lib/under_os/page.rb

Overview

UOS::Page is kind of a wrap over an iOS controller but instead of the controller, it presents more the main (root) view of the controller in a sence you’ve got for DOM documents in web

Defined Under Namespace

Classes: Builder, Layout, StylesMatcher, Stylesheet, UIViewControllerWrap

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Events

#emit, #off, #on

Constructor Details

#initializePage

Returns a new instance of Page.



21
22
23
# File 'lib/under_os/page.rb', line 21

def initialize
  # page building goes in here
end

Instance Attribute Details

#_Object (readonly)

Returns the value of attribute _.



11
12
13
# File 'lib/under_os/page.rb', line 11

def _
  @_
end

#stylesheetObject (readonly)

Returns the value of attribute stylesheet.



11
12
13
# File 'lib/under_os/page.rb', line 11

def stylesheet
  @stylesheet
end

Class Method Details

.layout(name = nil) ⇒ Object



17
18
19
# File 'lib/under_os/page.rb', line 17

def self.layout(name=nil)
  name ? (@layout = name) : @layout
end

.new(*args) ⇒ Object



13
14
15
# File 'lib/under_os/page.rb', line 13

def self.new(*args)
  alloc.setup_wrap(*args)
end

Instance Method Details

#alert(*args) ⇒ Object



39
40
41
# File 'lib/under_os/page.rb', line 39

def alert(*args)
  Alert.new(*args)
end

#build_layoutObject



91
92
93
# File 'lib/under_os/page.rb', line 91

def build_layout
  @_layout = Layout.new(self)
end

#compile_stylesObject



95
96
97
98
99
# File 'lib/under_os/page.rb', line 95

def compile_styles
  @stylesheet = Stylesheet.new
  @stylesheet << UnderOs::App.stylesheet
  @stylesheet.load("#{name}.css")
end

#historyObject



43
44
45
# File 'lib/under_os/page.rb', line 43

def history
  UnderOs::App.history
end

#nameObject



59
60
61
# File 'lib/under_os/page.rb', line 59

def name
  self.class.name.underscore.sub(/_page$/, '')
end


47
48
49
# File 'lib/under_os/page.rb', line 47

def navbar
  history.navbar
end

#repaintObject



101
102
103
104
# File 'lib/under_os/page.rb', line 101

def repaint
  view.repaint(stylesheet)   if view
  navbar.repaint(stylesheet) if navbar
end

#setup_wrap(*args) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/under_os/page.rb', line 63

def setup_wrap(*args)
  @_ = UIViewControllerWrap.alloc.init(self, {
    on_load_view:      Proc.new{ emit('init')      },
    on_view_loaded:    Proc.new{ emit('load')      },
    on_view_appear:    Proc.new{ emit('appear')    },
    on_view_disappear: Proc.new{ emit('disappear') },
    on_view_rerender:  Proc.new{ emit('rerender')  },
    on_view_rotate:    Proc.new{ emit('rotate')    }
  })

  on 'init' do
    build_layout
    compile_styles
  end

  on 'load' do
    repaint
    initialize(*args)
    repaint
  end

  on 'rotate' do
    repaint
  end

  self
end

#titleObject



51
52
53
# File 'lib/under_os/page.rb', line 51

def title
  @_.navigationItem.title
end

#title=(text) ⇒ Object



55
56
57
# File 'lib/under_os/page.rb', line 55

def title=(text)
  @_.navigationItem.title = text
end

#viewObject



25
26
27
# File 'lib/under_os/page.rb', line 25

def view
  @_view
end

#view=(view) ⇒ Object



29
30
31
# File 'lib/under_os/page.rb', line 29

def view=(view)
  @_view = view
end