under-os 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -0
  3. data/Gemfile.lock +25 -2
  4. data/README.md +1 -1
  5. data/Rakefile +2 -4
  6. data/lib/under-os.rb +3 -8
  7. data/under-os.gemspec +6 -2
  8. metadata +47 -191
  9. data/lib/assets/fontawesome-webfont.ttf +0 -0
  10. data/lib/assets/under-os.css +0 -115
  11. data/lib/under_os.rb +0 -41
  12. data/lib/under_os/app.rb +0 -33
  13. data/lib/under_os/color.rb +0 -184
  14. data/lib/under_os/config.rb +0 -33
  15. data/lib/under_os/core/array.rb +0 -5
  16. data/lib/under_os/core/hash.rb +0 -10
  17. data/lib/under_os/core/json.rb +0 -19
  18. data/lib/under_os/core/kernel.rb +0 -16
  19. data/lib/under_os/core/numeric.rb +0 -23
  20. data/lib/under_os/core/object.rb +0 -9
  21. data/lib/under_os/core/string.rb +0 -80
  22. data/lib/under_os/delegate.rb +0 -10
  23. data/lib/under_os/events.rb +0 -85
  24. data/lib/under_os/file.rb +0 -110
  25. data/lib/under_os/history.rb +0 -53
  26. data/lib/under_os/http.rb +0 -31
  27. data/lib/under_os/http/cookies.rb +0 -30
  28. data/lib/under_os/http/receiver.rb +0 -44
  29. data/lib/under_os/http/request.rb +0 -106
  30. data/lib/under_os/http/response.rb +0 -28
  31. data/lib/under_os/http/session.rb +0 -49
  32. data/lib/under_os/page.rb +0 -169
  33. data/lib/under_os/page/builder.rb +0 -96
  34. data/lib/under_os/page/layout.rb +0 -43
  35. data/lib/under_os/page/matcher.rb +0 -128
  36. data/lib/under_os/page/stylesheet.rb +0 -67
  37. data/lib/under_os/parser.rb +0 -24
  38. data/lib/under_os/parser/css.rb +0 -37
  39. data/lib/under_os/parser/html.rb +0 -97
  40. data/lib/under_os/point.rb +0 -47
  41. data/lib/under_os/screen.rb +0 -9
  42. data/lib/under_os/timer.rb +0 -65
  43. data/lib/under_os/ui.rb +0 -3
  44. data/lib/under_os/ui/alert.rb +0 -52
  45. data/lib/under_os/ui/button.rb +0 -42
  46. data/lib/under_os/ui/collection.rb +0 -65
  47. data/lib/under_os/ui/collection/cell.rb +0 -21
  48. data/lib/under_os/ui/collection/delegate.rb +0 -70
  49. data/lib/under_os/ui/collection/item.rb +0 -32
  50. data/lib/under_os/ui/collection/layout.rb +0 -43
  51. data/lib/under_os/ui/collection/styles.rb +0 -15
  52. data/lib/under_os/ui/div.rb +0 -3
  53. data/lib/under_os/ui/form.rb +0 -60
  54. data/lib/under_os/ui/icon.rb +0 -61
  55. data/lib/under_os/ui/icon/awesome.rb +0 -376
  56. data/lib/under_os/ui/icon/engine.rb +0 -10
  57. data/lib/under_os/ui/image.rb +0 -31
  58. data/lib/under_os/ui/input.rb +0 -140
  59. data/lib/under_os/ui/label.rb +0 -21
  60. data/lib/under_os/ui/locker.rb +0 -42
  61. data/lib/under_os/ui/navbar.rb +0 -123
  62. data/lib/under_os/ui/progress.rb +0 -17
  63. data/lib/under_os/ui/scroll.rb +0 -41
  64. data/lib/under_os/ui/select.rb +0 -95
  65. data/lib/under_os/ui/sidebar.rb +0 -45
  66. data/lib/under_os/ui/slider.rb +0 -37
  67. data/lib/under_os/ui/spinner.rb +0 -23
  68. data/lib/under_os/ui/style.rb +0 -21
  69. data/lib/under_os/ui/style/fonts.rb +0 -54
  70. data/lib/under_os/ui/style/margins.rb +0 -164
  71. data/lib/under_os/ui/style/outlining.rb +0 -170
  72. data/lib/under_os/ui/style/positioning.rb +0 -169
  73. data/lib/under_os/ui/switch.rb +0 -26
  74. data/lib/under_os/ui/textarea.rb +0 -19
  75. data/lib/under_os/ui/utils/animation.rb +0 -99
  76. data/lib/under_os/ui/utils/commons.rb +0 -70
  77. data/lib/under_os/ui/utils/dimensions.rb +0 -37
  78. data/lib/under_os/ui/utils/events.rb +0 -170
  79. data/lib/under_os/ui/utils/manipulation.rb +0 -44
  80. data/lib/under_os/ui/utils/position.rb +0 -21
  81. data/lib/under_os/ui/utils/size.rb +0 -21
  82. data/lib/under_os/ui/utils/styles.rb +0 -89
  83. data/lib/under_os/ui/utils/traversing.rb +0 -44
  84. data/lib/under_os/ui/utils/wrap.rb +0 -77
  85. data/lib/under_os/ui/view.rb +0 -31
  86. data/resources/test.png +0 -0
  87. data/spec/assets/app.css +0 -13
  88. data/spec/assets/test.css +0 -7
  89. data/spec/assets/test.html +0 -3
  90. data/spec/assets/test_page.rb +0 -2
  91. data/spec/lib/core/hash_spec.rb +0 -19
  92. data/spec/lib/core/json_spec.rb +0 -32
  93. data/spec/lib/core/numeric_spec.rb +0 -37
  94. data/spec/lib/core/string_spec.rb +0 -121
  95. data/spec/lib/under_os/color_spec.rb +0 -133
  96. data/spec/lib/under_os/events_spec.rb +0 -71
  97. data/spec/lib/under_os/file_spec.rb +0 -98
  98. data/spec/lib/under_os/http/cookies_spec.rb +0 -13
  99. data/spec/lib/under_os/http/request_spec.rb +0 -44
  100. data/spec/lib/under_os/http_spec.rb +0 -20
  101. data/spec/lib/under_os/page/builder_spec.rb +0 -128
  102. data/spec/lib/under_os/page/layout_spec.rb +0 -18
  103. data/spec/lib/under_os/page/matcher_spec.rb +0 -260
  104. data/spec/lib/under_os/page/stylesheet_spec.rb +0 -83
  105. data/spec/lib/under_os/page_spec.rb +0 -5
  106. data/spec/lib/under_os/parser/css_spec.rb +0 -77
  107. data/spec/lib/under_os/parser/html_spec.rb +0 -152
  108. data/spec/lib/under_os/parser_spec.rb +0 -16
  109. data/spec/lib/under_os/point_spec.rb +0 -54
  110. data/spec/lib/under_os/screen_spec.rb +0 -11
  111. data/spec/lib/under_os/timer_spec.rb +0 -93
  112. data/spec/lib/under_os/ui/button_spec.rb +0 -50
  113. data/spec/lib/under_os/ui/collection_spec.rb +0 -19
  114. data/spec/lib/under_os/ui/div_spec.rb +0 -24
  115. data/spec/lib/under_os/ui/form_spec.rb +0 -156
  116. data/spec/lib/under_os/ui/icon_spec.rb +0 -57
  117. data/spec/lib/under_os/ui/image_spec.rb +0 -39
  118. data/spec/lib/under_os/ui/input_spec.rb +0 -109
  119. data/spec/lib/under_os/ui/label_spec.rb +0 -22
  120. data/spec/lib/under_os/ui/locker_spec.rb +0 -31
  121. data/spec/lib/under_os/ui/progress_spec.rb +0 -31
  122. data/spec/lib/under_os/ui/scroll_spec.rb +0 -40
  123. data/spec/lib/under_os/ui/select_spec.rb +0 -135
  124. data/spec/lib/under_os/ui/sidebar_spec.rb +0 -35
  125. data/spec/lib/under_os/ui/slider_spec.rb +0 -69
  126. data/spec/lib/under_os/ui/spinner_spec.rb +0 -57
  127. data/spec/lib/under_os/ui/style/fonts_spec.rb +0 -73
  128. data/spec/lib/under_os/ui/style/margins_spec.rb +0 -106
  129. data/spec/lib/under_os/ui/style/outlining_spec.rb +0 -101
  130. data/spec/lib/under_os/ui/style/positioning_spec.rb +0 -69
  131. data/spec/lib/under_os/ui/style_spec.rb +0 -19
  132. data/spec/lib/under_os/ui/switch_spec.rb +0 -60
  133. data/spec/lib/under_os/ui/textarea_spec.rb +0 -34
  134. data/spec/lib/under_os/ui/utils/commons_spec.rb +0 -81
  135. data/spec/lib/under_os/ui/utils/events_spec.rb +0 -87
  136. data/spec/lib/under_os/ui/utils/manipulation_spec.rb +0 -130
  137. data/spec/lib/under_os/ui/utils/styles_spec.rb +0 -140
  138. data/spec/lib/under_os/ui/utils/traversing_spec.rb +0 -124
  139. data/spec/lib/under_os/ui/utils/wrap_spec.rb +0 -69
  140. data/spec/lib/under_os/ui/view_spec.rb +0 -39
@@ -1,10 +0,0 @@
1
- module UnderOs::UI::IconEngine
2
- def self.included(base)
3
- base.instance_eval do
4
- def self.engine(name=nil)
5
- @engine = UnderOs::UI.const_get("IconEngine#{name}") if name
6
- @engine
7
- end
8
- end
9
- end
10
- end
@@ -1,31 +0,0 @@
1
- class UnderOs::UI::Image < UnderOs::UI::View
2
- wraps UIImageView, tag: 'img'
3
-
4
- def initialize(options)
5
- options = {srs: options} unless options.is_a?(Hash)
6
-
7
- super(options)
8
-
9
- @_.contentMode = UIViewContentModeScaleAspectFit
10
-
11
- self.src = options.delete(:src) if options.has_key?(:src)
12
- end
13
-
14
- def src
15
- @_.image
16
- end
17
-
18
- def src=(src)
19
- src = UIImage.imageNamed(src) if src.is_a?(String)
20
- src = UIImage.imageWithData(src) if src.is_a?(NSData)
21
- @_.image = src
22
- end
23
-
24
- def load(url, options={}, &complete)
25
- UnderOs::HTTP.get(url, options) do |response|
26
- self.src = response.data
27
- complete.call(response) if complete && complete.arity != 0
28
- complete.call if complete && complete.arity == 0
29
- end
30
- end
31
- end
@@ -1,140 +0,0 @@
1
- class UnderOs::UI::Input < UnderOs::UI::View
2
- wraps UITextField, tag: 'input'
3
-
4
- def initialize(options={})
5
- super
6
-
7
- self.type = options[:type] if options[:type]
8
- self.name = options[:name] if options[:name]
9
- self.value = options[:value] if options[:value]
10
- self.placeholder = options[:placeholder] if options[:placeholder]
11
- self.keyboard = options[:keyboard] if options[:keyboard]
12
- self.disabled = true if options[:disabled]
13
-
14
- @_.delegate = self if @_.respond_to?(:delegate=)
15
-
16
- if @_.class == UITextField
17
- @_.addTarget self, action: :handle_focus, forControlEvents:UIControlEventEditingDidBegin
18
- @_.addTarget self, action: :handle_change, forControlEvents:UIControlEventEditingChanged
19
- @_.addTarget self, action: :handle_blur, forControlEvents:UIControlEventEditingDidEnd
20
- end
21
- end
22
-
23
- def name
24
- @name
25
- end
26
-
27
- def name=(text)
28
- @name = text
29
- end
30
-
31
- def value
32
- @_.text
33
- end
34
-
35
- def value=(value)
36
- @_.text = value
37
- end
38
-
39
- def placeholder
40
- @_.placeholder
41
- end
42
-
43
- def placeholder=(value)
44
- @_.placeholder = value
45
- end
46
-
47
- def type
48
- if @_.respond_to?(:secureTextEntry) && @_.secureTextEntry
49
- :password
50
- else
51
- keyboard == :default ? :text : keyboard
52
- end
53
- end
54
-
55
- def type=(type)
56
- case type.to_sym
57
- when :password then @_.secureTextEntry = true
58
- else self.keyboard = type
59
- end
60
- end
61
-
62
- def keyboard
63
- KEYBOARDS.index(@_.keyboardType)
64
- end
65
-
66
- def keyboard=(keyboard)
67
- keyboard = keyboard.to_sym if keyboard.is_a?(String)
68
- keyboard = KEYBOARDS[keyboard] || keyboard
69
-
70
- raise "Unknown keyboard type: #{keyboard}" if keyboard.is_a?(Symbol)
71
-
72
- @_.keyboardType = keyboard
73
- end
74
-
75
- def hide_keyboard
76
- puts "DEPRECATED: please use the `#blur` method instead of `#hide_keyboard`"
77
- blur
78
- end
79
-
80
- KEYBOARDS = {
81
- default: UIKeyboardTypeDefault,
82
- text: UIKeyboardTypeDefault,
83
- ascii: UIKeyboardTypeASCIICapable,
84
- numeric: UIKeyboardTypeNumbersAndPunctuation,
85
- url: UIKeyboardTypeURL,
86
- numbers: UIKeyboardTypeNumberPad,
87
- phone: UIKeyboardTypePhonePad,
88
- name: UIKeyboardTypeNamePhonePad,
89
- email: UIKeyboardTypeEmailAddress,
90
- decimal: UIKeyboardTypeDecimalPad,
91
- twitter: UIKeyboardTypeTwitter,
92
- search: UIKeyboardTypeWebSearch
93
- }
94
-
95
- def disabled
96
- ! @_.isEnabled
97
- end
98
-
99
- alias :disabled? :disabled
100
-
101
- def disabled=(value)
102
- @_.enabled = ! value
103
- end
104
-
105
- def disable
106
- self.disabled = true
107
- end
108
-
109
- def enable
110
- self.disabled = false
111
- end
112
-
113
- def focus
114
- @_.becomeFirstResponder
115
- end
116
-
117
- def blur
118
- @_.resignFirstResponder
119
- end
120
-
121
- # delegate
122
-
123
- def textFieldShouldReturn(textField)
124
- blur
125
- end
126
-
127
- protected
128
-
129
- def handle_focus
130
- emit('focus')
131
- end
132
-
133
- def handle_change
134
- emit('change')
135
- end
136
-
137
- def handle_blur
138
- emit('blur')
139
- end
140
- end
@@ -1,21 +0,0 @@
1
- class UnderOs::UI::Label < UnderOs::UI::View
2
- wraps UILabel, tag: 'label'
3
-
4
- def initialize(options={})
5
- super
6
-
7
- self.text = options.delete(:text) || ''
8
- @_.sizeToFit
9
-
10
- @_.numberOfLines = 1;
11
- @_.adjustsFontSizeToFitWidth = true;
12
- end
13
-
14
- def text
15
- @_.text
16
- end
17
-
18
- def text=(text)
19
- @_.text = text
20
- end
21
- end
@@ -1,42 +0,0 @@
1
- class UnderOs::UI::Locker < UnderOs::UI::View
2
- wraps UIView, tag: :locker
3
-
4
- attr_reader :label, :spinner
5
-
6
- def initialize(options={})
7
- super options
8
-
9
- @dialog = UnderOs::UI::View.new(class: 'locker-dialog')
10
- @spinner = UnderOs::UI::Spinner.new
11
- @label = UnderOs::UI::Label.new(text: options[:text] || '')
12
-
13
- append @dialog.append(@spinner, @label)
14
-
15
- addClass 'with-label' if options[:text]
16
- end
17
-
18
- def show
19
- insertTo(UnderOs::App.history.current_page.view) if ! parent
20
- repaint
21
- end
22
-
23
- def hide
24
- remove
25
- end
26
-
27
- def text
28
- @label.text
29
- end
30
-
31
- def text=(text)
32
- @label.text = text
33
- end
34
-
35
- def show_for(&block)
36
- show
37
- 1.ms.later do
38
- block.call
39
- 1.ms.later { hide }
40
- end
41
- end
42
- end
@@ -1,123 +0,0 @@
1
- class UnderOs::UI::Navbar
2
- attr_reader :_
3
-
4
- def initialize(ui_navigation_controller)
5
- @_ = ui_navigation_controller
6
- end
7
-
8
- def repaint(stylesheet)
9
- end
10
-
11
- def hide(animated=true)
12
- @_.setNavigationBarHidden(true, animated:animated)
13
- end
14
-
15
- def show(animated=true)
16
- @_.setNavigationBarHidden(false, animated:animated)
17
- end
18
-
19
- def hidden
20
- @_.navigationBarHidden
21
- end
22
-
23
- def visible
24
- !hidden
25
- end
26
-
27
- def disable_swipes
28
- @_.interactivePopGestureRecognizer.enabled = false
29
- end
30
-
31
- def enable_swipes
32
- @_.interactivePopGestureRecognizer.enabled = true
33
- end
34
-
35
- def left_button
36
- @left_button
37
- end
38
-
39
- def left_button=(view)
40
- @left_button = view
41
- @_.topViewController.navigationItem.leftBarButtonItem = to_navigation_item(view)
42
- end
43
-
44
- def right_button
45
- right_buttons[0]
46
- end
47
-
48
- def right_button=(view)
49
- self.right_buttons = [view]
50
- end
51
-
52
- def right_buttons
53
- @right_buttons || []
54
- end
55
-
56
- def right_buttons=(views)
57
- views = [views] if views.is_a?(Hash)
58
- @right_buttons = views
59
- @_.topViewController.navigationItem.rightBarButtonItems =
60
- views.map{|v| to_navigation_item(v)}.flatten.compact.reverse
61
- end
62
-
63
- private
64
-
65
- def to_navigation_item(view)
66
- view = to_raw_uiview(view)
67
-
68
- if view.is_a?(UIBarButtonItem)
69
- view
70
- elsif view.is_a?(UIView)
71
- UIBarButtonItem.alloc.initWithCustomView(view)
72
- elsif view.is_a?(Hash)
73
- view.map do |type, callback|
74
- if SYSTEM_BUTTONS[type.to_sym]
75
- UIBarButtonItem.alloc.initWithBarButtonSystemItem SYSTEM_BUTTONS[type.to_sym], target: callback, action: :call
76
- elsif type.is_a?(UIImage)
77
- UIBarButtonItem.alloc.initWithImage(type, style: UIBarButtonItemStylePlain, target: callback, action: :call)
78
- else
79
- UIBarButtonItem.alloc.initWithTitle(type.to_s, style: UIBarButtonItemStylePlain, target: callback, action: :call)
80
- end
81
- end
82
- end
83
- end
84
-
85
- def to_raw_uiview(view)
86
- view = view.to_sym if view.is_a?(String)
87
- view = {view: Proc.new{}} if view.is_a?(Symbol)
88
-
89
- if view.is_a?(UnderOs::UI::View)
90
- view.addClass('navbar-item')
91
- view.repaint(UnderOs::App.history.current_page.stylesheet)
92
- view = view._
93
- end
94
-
95
- view
96
- end
97
-
98
- SYSTEM_BUTTONS = {
99
- done: UIBarButtonSystemItemDone,
100
- cancel: UIBarButtonSystemItemCancel,
101
- edit: UIBarButtonSystemItemEdit,
102
- save: UIBarButtonSystemItemSave,
103
- add: UIBarButtonSystemItemAdd,
104
- space: UIBarButtonSystemItemFlexibleSpace,
105
- compose: UIBarButtonSystemItemCompose,
106
- reply: UIBarButtonSystemItemReply,
107
- action: UIBarButtonSystemItemAction,
108
- organize: UIBarButtonSystemItemOrganize,
109
- bookmarks: UIBarButtonSystemItemBookmarks,
110
- search: UIBarButtonSystemItemSearch,
111
- refresh: UIBarButtonSystemItemRefresh,
112
- camera: UIBarButtonSystemItemCamera,
113
- trash: UIBarButtonSystemItemTrash,
114
- stop: UIBarButtonSystemItemStop,
115
- play: UIBarButtonSystemItemPlay,
116
- pause: UIBarButtonSystemItemPause,
117
- rewind: UIBarButtonSystemItemRewind,
118
- forward: UIBarButtonSystemItemFastForward,
119
- undor: UIBarButtonSystemItemUndo,
120
- redo: UIBarButtonSystemItemRedo,
121
- curl: UIBarButtonSystemItemPageCurl,
122
- }
123
- end
@@ -1,17 +0,0 @@
1
- class UnderOs::UI::Progress < UnderOs::UI::View
2
- wraps UIProgressView, tag: :progress
3
-
4
- def initialize(options={})
5
- super
6
-
7
- self.value = options[:value] if options[:value]
8
- end
9
-
10
- def value
11
- @_.progress
12
- end
13
-
14
- def value=(value)
15
- @_.setProgress value.to_f, animated: true
16
- end
17
- end
@@ -1,41 +0,0 @@
1
- class UnderOs::UI::Scroll < UnderOs::UI::View
2
- wraps UIScrollView, tag: :scroll
3
-
4
- def initialize(options={})
5
- super
6
-
7
- self.paging = options.delete(:paging)
8
- end
9
-
10
- def paging
11
- @paging == nil ? false : @paging
12
- end
13
-
14
- def paging=(value)
15
- @paging = value == true ? true : nil
16
- @_.pagingEnabled = paging
17
- end
18
-
19
- def contentSize
20
- UnderOs::Point.new(x: @_.contentSize.width, y: @_.contentSize.height)
21
- end
22
-
23
- def contentSize=(*args)
24
- size = UnderOs::Point.new(*args)
25
- @_.contentSize = CGSizeMake(size.x, size.y)
26
- end
27
-
28
- def repaint(*args)
29
- content_size = {}
30
-
31
- super *args do |styles|
32
- styles.reject do |key, value|
33
- if [:contentWidth, :contentHeight].include?(key)
34
- content_size[key] = value
35
- end
36
- end
37
- end
38
-
39
- self.style = content_size unless content_size.empty?
40
- end
41
- end
@@ -1,95 +0,0 @@
1
- class UnderOs::UI::Select < UnderOs::UI::Input
2
- wraps UIPickerView, tag: :select
3
-
4
- def initialize(options={})
5
- super
6
-
7
- self.options = options.delete(:options) if options[:options]
8
- @_.showsSelectionIndicator = true if options[:lense]
9
-
10
- @_.dataSource = self
11
- end
12
-
13
- def optgroups
14
- @optgroups ||= [{}]
15
- end
16
-
17
- def optgroups=(list)
18
- @optgroups = list.map do |hash|
19
- {}.tap do |clean_hash|
20
- hash.each do |key, value|
21
- clean_hash[key.to_s] = value if key && value
22
- end
23
- end
24
- end
25
- end
26
-
27
- def options
28
- optgroups.size == 1 ? optgroups[0] : optgroups
29
- end
30
-
31
- def options=(value)
32
- self.optgroups = value.is_a?(Array) ? value : [value]
33
- @_.reloadAllComponents
34
- end
35
-
36
- def value
37
- @value ||= []
38
- optgroups.size == 1 ? @value[0] : @value
39
- end
40
-
41
- def value=(value)
42
- prev_val = @value
43
- @value = Array(value).map(&:to_s)
44
- handle_change if @value != prev_val
45
-
46
- @value.each_with_index do |value, group|
47
- i = 0;
48
- optgroups[group].each do |v, label|
49
- if value == v
50
- @_.selectRow i, inComponent: group, animated: false
51
- else
52
- i += 1
53
- end
54
- end
55
- end
56
- end
57
-
58
- def show
59
- page.find('select').each do |select|
60
- select.hide if select.visible && select != self
61
- end
62
-
63
- self.style = {bottom: -size.y, display: :block}
64
-
65
- animate bottom: 0
66
- end
67
-
68
- def hide
69
- animate bottom: -size.y, complete: -> {
70
- style.display = :none
71
- }
72
- end
73
-
74
-
75
- # UIPickerView delegate
76
-
77
- def numberOfComponentsInPickerView(picker)
78
- optgroups.size
79
- end
80
-
81
- def pickerView(picker, numberOfRowsInComponent: group)
82
- optgroups[group].size
83
- end
84
-
85
- def pickerView(picker, titleForRow:index, forComponent:group)
86
- optgroups[group].to_a[index][1]
87
- end
88
-
89
- def pickerView(picker, didSelectRow:index, inComponent:group)
90
- value = (@value || []).dup
91
- value[group] = optgroups[group].to_a[index][0]
92
-
93
- self.value = value
94
- end
95
- end