Class: UnderOs::UI::Locker

Inherits:
View
  • Object
show all
Defined in:
lib/under_os/ui/locker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Locker

Returns a new instance of Locker.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/under_os/ui/locker.rb', line 6

def initialize(options={})
  super options

  @dialog  = UnderOs::UI::View.new(class: 'locker-dialog')
  @spinner = UnderOs::UI::Spinner.new
  @label   = UnderOs::UI::Label.new(text: options[:text] || '')

  append @dialog.append(@spinner, @label)

  addClass 'with-label' if options[:text]
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



4
5
6
# File 'lib/under_os/ui/locker.rb', line 4

def label
  @label
end

#spinnerObject (readonly)

Returns the value of attribute spinner.



4
5
6
# File 'lib/under_os/ui/locker.rb', line 4

def spinner
  @spinner
end

Instance Method Details

#hideObject



23
24
25
# File 'lib/under_os/ui/locker.rb', line 23

def hide
  remove
end

#showObject



18
19
20
21
# File 'lib/under_os/ui/locker.rb', line 18

def show
  insertTo(UnderOs::App.history.current_page.view) if ! parent
  repaint
end

#show_for(&block) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/under_os/ui/locker.rb', line 35

def show_for(&block)
  show
  1.ms.later do
    block.call
    1.ms.later { hide }
  end
end

#textObject



27
28
29
# File 'lib/under_os/ui/locker.rb', line 27

def text
  @label.text
end

#text=(text) ⇒ Object



31
32
33
# File 'lib/under_os/ui/locker.rb', line 31

def text=(text)
  @label.text = text
end