under-os-ui 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +26 -0
- data/lib/assets/fontawesome-webfont.ttf +0 -0
- data/lib/assets/under-os.css +115 -0
- data/lib/core/kernel.rb +16 -0
- data/lib/under-os-ui.rb +6 -0
- data/lib/under_os/app.rb +26 -0
- data/lib/under_os/config.rb +25 -0
- data/lib/under_os/history.rb +53 -0
- data/lib/under_os/page.rb +178 -0
- data/lib/under_os/page/builder.rb +96 -0
- data/lib/under_os/page/layout.rb +43 -0
- data/lib/under_os/page/matcher.rb +128 -0
- data/lib/under_os/page/stylesheet.rb +67 -0
- data/lib/under_os/parser.rb +24 -0
- data/lib/under_os/parser/css.rb +37 -0
- data/lib/under_os/parser/html.rb +97 -0
- data/lib/under_os/ui.rb +3 -0
- data/lib/under_os/ui/alert.rb +52 -0
- data/lib/under_os/ui/button.rb +42 -0
- data/lib/under_os/ui/collection.rb +65 -0
- data/lib/under_os/ui/collection/cell.rb +21 -0
- data/lib/under_os/ui/collection/delegate.rb +70 -0
- data/lib/under_os/ui/collection/item.rb +32 -0
- data/lib/under_os/ui/collection/layout.rb +43 -0
- data/lib/under_os/ui/collection/styles.rb +15 -0
- data/lib/under_os/ui/div.rb +3 -0
- data/lib/under_os/ui/form.rb +60 -0
- data/lib/under_os/ui/icon.rb +61 -0
- data/lib/under_os/ui/icon/awesome.rb +376 -0
- data/lib/under_os/ui/icon/engine.rb +9 -0
- data/lib/under_os/ui/image.rb +31 -0
- data/lib/under_os/ui/input.rb +140 -0
- data/lib/under_os/ui/label.rb +21 -0
- data/lib/under_os/ui/locker.rb +42 -0
- data/lib/under_os/ui/navbar.rb +123 -0
- data/lib/under_os/ui/progress.rb +17 -0
- data/lib/under_os/ui/scroll.rb +102 -0
- data/lib/under_os/ui/select.rb +95 -0
- data/lib/under_os/ui/sidebar.rb +45 -0
- data/lib/under_os/ui/slider.rb +37 -0
- data/lib/under_os/ui/spinner.rb +23 -0
- data/lib/under_os/ui/style.rb +21 -0
- data/lib/under_os/ui/style/fonts.rb +56 -0
- data/lib/under_os/ui/style/margins.rb +164 -0
- data/lib/under_os/ui/style/outlining.rb +170 -0
- data/lib/under_os/ui/style/positioning.rb +183 -0
- data/lib/under_os/ui/switch.rb +26 -0
- data/lib/under_os/ui/textarea.rb +19 -0
- data/lib/under_os/ui/utils/animation.rb +101 -0
- data/lib/under_os/ui/utils/commons.rb +70 -0
- data/lib/under_os/ui/utils/dimensions.rb +37 -0
- data/lib/under_os/ui/utils/events.rb +210 -0
- data/lib/under_os/ui/utils/manipulation.rb +44 -0
- data/lib/under_os/ui/utils/position.rb +21 -0
- data/lib/under_os/ui/utils/size.rb +21 -0
- data/lib/under_os/ui/utils/styles.rb +89 -0
- data/lib/under_os/ui/utils/traversing.rb +44 -0
- data/lib/under_os/ui/utils/wrap.rb +77 -0
- data/lib/under_os/ui/view.rb +31 -0
- data/spec/assets/app.css +13 -0
- data/spec/assets/test.css +7 -0
- data/spec/assets/test.html +3 -0
- data/spec/assets/test.png +0 -0
- data/spec/assets/test_page.rb +2 -0
- data/spec/under_os/page/builder_spec.rb +128 -0
- data/spec/under_os/page/layout_spec.rb +18 -0
- data/spec/under_os/page/matcher_spec.rb +260 -0
- data/spec/under_os/page/stylesheet_spec.rb +83 -0
- data/spec/under_os/page_spec.rb +5 -0
- data/spec/under_os/parser/css_spec.rb +77 -0
- data/spec/under_os/parser/html_spec.rb +152 -0
- data/spec/under_os/parser_spec.rb +16 -0
- data/spec/under_os/ui/button_spec.rb +50 -0
- data/spec/under_os/ui/collection_spec.rb +19 -0
- data/spec/under_os/ui/div_spec.rb +24 -0
- data/spec/under_os/ui/form_spec.rb +156 -0
- data/spec/under_os/ui/icon_spec.rb +57 -0
- data/spec/under_os/ui/image_spec.rb +39 -0
- data/spec/under_os/ui/input_spec.rb +109 -0
- data/spec/under_os/ui/label_spec.rb +22 -0
- data/spec/under_os/ui/locker_spec.rb +31 -0
- data/spec/under_os/ui/progress_spec.rb +31 -0
- data/spec/under_os/ui/scroll_spec.rb +75 -0
- data/spec/under_os/ui/select_spec.rb +135 -0
- data/spec/under_os/ui/sidebar_spec.rb +35 -0
- data/spec/under_os/ui/slider_spec.rb +69 -0
- data/spec/under_os/ui/spinner_spec.rb +57 -0
- data/spec/under_os/ui/style/fonts_spec.rb +111 -0
- data/spec/under_os/ui/style/margins_spec.rb +106 -0
- data/spec/under_os/ui/style/outlining_spec.rb +101 -0
- data/spec/under_os/ui/style/positioning_spec.rb +69 -0
- data/spec/under_os/ui/style_spec.rb +19 -0
- data/spec/under_os/ui/switch_spec.rb +60 -0
- data/spec/under_os/ui/textarea_spec.rb +34 -0
- data/spec/under_os/ui/utils/commons_spec.rb +81 -0
- data/spec/under_os/ui/utils/events_spec.rb +87 -0
- data/spec/under_os/ui/utils/manipulation_spec.rb +130 -0
- data/spec/under_os/ui/utils/styles_spec.rb +140 -0
- data/spec/under_os/ui/utils/traversing_spec.rb +124 -0
- data/spec/under_os/ui/utils/wrap_spec.rb +69 -0
- data/spec/under_os/ui/view_spec.rb +39 -0
- data/under-os-ui.gemspec +23 -0
- metadata +216 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 61976f0a26b5845bc6feaed1d8f24d03dbc0d57d
|
4
|
+
data.tar.gz: 507fb867ef0fe5ad4e45fa8d3a9f5d954aa9b800
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1089eb31723d9480500064911b2c0b8ec6a978963f4e4f2bd67bb47fe9a6b206633423ab0e1c17ee3a9744c00c306466417b1010a6706af16bad5c6f11c9adda
|
7
|
+
data.tar.gz: 13c52f56728173e05fbc0ac3864b328667ad068d7cab5d601e96da9111ab9cc4e881229c539d0f6d47c4c4a54ca2f265393a99306499d3acaae8e740b1bfd0e9
|
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# UnderOs Core
|
2
|
+
|
3
|
+
This is the actual UI magick part of the [UnderOs](http://under-os.com) project
|
4
|
+
|
5
|
+
## Copyright & License
|
6
|
+
|
7
|
+
All code in this library is released under the terms of the MIT license
|
8
|
+
|
9
|
+
Copyright (C) 2013-2014 Nikolay Nemshilov
|
10
|
+
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
13
|
+
in the Software without restriction, including without limitation the rights
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
15
|
+
of the Software, and to permit persons to whom the Software is furnished to do so,
|
16
|
+
subject to the following conditions:
|
17
|
+
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
19
|
+
copies or substantial portions of the Software.
|
20
|
+
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
22
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
23
|
+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
24
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
25
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
26
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
Binary file
|
@@ -0,0 +1,115 @@
|
|
1
|
+
/**
|
2
|
+
* The under-os stock stylesheet
|
3
|
+
*/
|
4
|
+
|
5
|
+
button {
|
6
|
+
color: black;
|
7
|
+
background: #ddd;
|
8
|
+
border-radius: 5;
|
9
|
+
}
|
10
|
+
|
11
|
+
image.uos-background-image {
|
12
|
+
top: 0;
|
13
|
+
left: 0;
|
14
|
+
width: 100%;
|
15
|
+
height: 100%;
|
16
|
+
}
|
17
|
+
|
18
|
+
icon {
|
19
|
+
color: black;
|
20
|
+
}
|
21
|
+
icon.navbar-item {
|
22
|
+
color: #007AFF;
|
23
|
+
font-size: 24;
|
24
|
+
width: 24;
|
25
|
+
height: 24;
|
26
|
+
text-align: right;
|
27
|
+
padding-top: 4;
|
28
|
+
}
|
29
|
+
|
30
|
+
input, textarea {
|
31
|
+
border-width: 1;
|
32
|
+
border-color: #ddd;
|
33
|
+
border-radius: 2;
|
34
|
+
}
|
35
|
+
|
36
|
+
slider {
|
37
|
+
height: 30;
|
38
|
+
}
|
39
|
+
|
40
|
+
sidebar {
|
41
|
+
display: none;
|
42
|
+
z-index: 1000;
|
43
|
+
}
|
44
|
+
|
45
|
+
sidebar.left, sidebar.right {
|
46
|
+
height: 100%;
|
47
|
+
top: 0;
|
48
|
+
}
|
49
|
+
|
50
|
+
sidebar.top, sidebar.bottom {
|
51
|
+
width: 100%;
|
52
|
+
left: 0;
|
53
|
+
}
|
54
|
+
|
55
|
+
select {
|
56
|
+
display: none;
|
57
|
+
background: white;
|
58
|
+
bottom: 0;
|
59
|
+
}
|
60
|
+
|
61
|
+
scroll {
|
62
|
+
content-width: auto;
|
63
|
+
content-height: auto;
|
64
|
+
}
|
65
|
+
|
66
|
+
spinner {
|
67
|
+
color: black;
|
68
|
+
}
|
69
|
+
|
70
|
+
locker {
|
71
|
+
top: 0;
|
72
|
+
left: 0;
|
73
|
+
width: 100%;
|
74
|
+
height: 100%;
|
75
|
+
background: rgba(0,0,0,0.5);
|
76
|
+
z-index: 10000;
|
77
|
+
}
|
78
|
+
|
79
|
+
locker view.locker-dialog {
|
80
|
+
width: 60;
|
81
|
+
height: 60;
|
82
|
+
left: 130;
|
83
|
+
top: 254;
|
84
|
+
background: rgba(0,0,0,0.8);
|
85
|
+
border-radius: 5;
|
86
|
+
}
|
87
|
+
|
88
|
+
locker spinner {
|
89
|
+
color: white;
|
90
|
+
width: 100%;
|
91
|
+
height: 100%;
|
92
|
+
background: transparent;
|
93
|
+
}
|
94
|
+
|
95
|
+
locker label {
|
96
|
+
color: white;
|
97
|
+
width: 80%;
|
98
|
+
height: 15;
|
99
|
+
bottom: 8;
|
100
|
+
left: 8;
|
101
|
+
text-align: center;
|
102
|
+
font-size: 12;
|
103
|
+
}
|
104
|
+
|
105
|
+
|
106
|
+
locker.with-label view.locker-dialog {
|
107
|
+
width: 80;
|
108
|
+
height: 80;
|
109
|
+
left: 120;
|
110
|
+
top: 244;
|
111
|
+
}
|
112
|
+
|
113
|
+
locker.with-label spinner {
|
114
|
+
height: 90%;
|
115
|
+
}
|
data/lib/core/kernel.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Kernel
|
2
|
+
def u(css_rule)
|
3
|
+
return UnderOs::App.history.current_page if css_rule == 'page'
|
4
|
+
return UnderOs::App.history.navbar if css_rule == 'navbar'
|
5
|
+
|
6
|
+
elements = UnderOs::App.history.current_page.find(css_rule)
|
7
|
+
|
8
|
+
if elements.size == 0
|
9
|
+
nil
|
10
|
+
elsif elements.size == 1
|
11
|
+
elements[0]
|
12
|
+
else
|
13
|
+
elements
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/under-os-ui.rb
ADDED
data/lib/under_os/app.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
UnderOs::App.instance_eval do
|
2
|
+
|
3
|
+
def self.history
|
4
|
+
@history ||= UnderOs::History.new
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.stylesheet
|
8
|
+
@stylesheet ||= UnderOs::Page::Stylesheet.new.tap do |stylesheet|
|
9
|
+
stylesheets.each { |filename| stylesheet.load(filename) }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.stylesheets
|
14
|
+
($stylesheets ||= []).tap do |files|
|
15
|
+
files << "under-os.css" unless files.include?("under-os.css")
|
16
|
+
files << "application.css" unless files.include?("application.css")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
protected
|
21
|
+
|
22
|
+
def self.root_controller
|
23
|
+
history._
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class UnderOs::Config
|
2
|
+
def root_page
|
3
|
+
@app.history.root_page
|
4
|
+
end
|
5
|
+
|
6
|
+
def root_page=(page)
|
7
|
+
@app.history.root_page = page
|
8
|
+
end
|
9
|
+
|
10
|
+
def status_bar
|
11
|
+
@status_bar
|
12
|
+
end
|
13
|
+
|
14
|
+
def status_bar=(visible)
|
15
|
+
@status_bar = visible
|
16
|
+
end
|
17
|
+
|
18
|
+
def navbar
|
19
|
+
@app.history.navbar.visible
|
20
|
+
end
|
21
|
+
|
22
|
+
def navbar=(visible)
|
23
|
+
@app.history.navbar.__send__ visible ? :show : :hide, false
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
class UnderOs::History
|
2
|
+
attr_reader :_, :navbar
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@_ = UINavigationController.alloc
|
6
|
+
@navbar = UnderOs::UI::Navbar.new(@_)
|
7
|
+
end
|
8
|
+
|
9
|
+
def root_page
|
10
|
+
@_.topViewController.wrapper
|
11
|
+
end
|
12
|
+
|
13
|
+
def root_page=(page)
|
14
|
+
@_.initWithRootViewController(page._)
|
15
|
+
end
|
16
|
+
|
17
|
+
def current_page
|
18
|
+
controller = @_.topViewController
|
19
|
+
|
20
|
+
controller.is_a?(UnderOs::Page::UIViewControllerWrap) ?
|
21
|
+
controller.wrapper : root_page
|
22
|
+
end
|
23
|
+
|
24
|
+
def push(page, animated=true)
|
25
|
+
if pages.include?(page)
|
26
|
+
pop_to(page)
|
27
|
+
else
|
28
|
+
@_.pushViewController(page._, animated: animated)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
alias :<< :push
|
33
|
+
|
34
|
+
def pop(page=nil, animated=true)
|
35
|
+
if page
|
36
|
+
@_.popToViewController(page._, animated: animated)
|
37
|
+
else
|
38
|
+
@_.popViewControllerAnimated(animated)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def pages
|
43
|
+
@_.viewControllers.map{|c| c.wrapper rescue nil }.compact
|
44
|
+
end
|
45
|
+
|
46
|
+
def pop_to(page, animated=true)
|
47
|
+
pop(page, animated)
|
48
|
+
end
|
49
|
+
|
50
|
+
def pop_to_root(animated=true)
|
51
|
+
@_.popToRootViewControllerAnimated(animated)
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
#
|
2
|
+
# UOS::Page is kind of a wrap over an iOS controller
|
3
|
+
# but instead of the controller, it presents more the
|
4
|
+
# main (root) view of the controller in a sence you've
|
5
|
+
# got for DOM documents in web
|
6
|
+
#
|
7
|
+
class UnderOs::Page
|
8
|
+
include UnderOs::Events
|
9
|
+
include UnderOs::UI
|
10
|
+
|
11
|
+
attr_reader :_, :stylesheet
|
12
|
+
|
13
|
+
def self.new(*args)
|
14
|
+
alloc.setup_wrap(*args)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.layout(name=nil)
|
18
|
+
name ? (@layout = name) : @layout
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize
|
22
|
+
# page building goes in here
|
23
|
+
end
|
24
|
+
|
25
|
+
def view
|
26
|
+
@_view
|
27
|
+
end
|
28
|
+
|
29
|
+
def view=(view)
|
30
|
+
@_view = view
|
31
|
+
end
|
32
|
+
|
33
|
+
%w[insert append prepend find first].each do |method|
|
34
|
+
define_method method do |*args|
|
35
|
+
@_view.__send__ method, *args
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def alert(*args)
|
40
|
+
Alert.new(*args)
|
41
|
+
end
|
42
|
+
|
43
|
+
def history
|
44
|
+
UnderOs::App.history
|
45
|
+
end
|
46
|
+
|
47
|
+
def navbar
|
48
|
+
history.navbar
|
49
|
+
end
|
50
|
+
|
51
|
+
def title
|
52
|
+
@_.navigationItem.title
|
53
|
+
end
|
54
|
+
|
55
|
+
def title=(text)
|
56
|
+
@_.navigationItem.title = text
|
57
|
+
end
|
58
|
+
|
59
|
+
def name
|
60
|
+
self.class.name.underscore.sub(/_page$/, '')
|
61
|
+
end
|
62
|
+
|
63
|
+
def setup_wrap(*args)
|
64
|
+
@_ = UIViewControllerWrap.alloc.init(self, {
|
65
|
+
on_load_view: Proc.new{ emit('init') },
|
66
|
+
on_view_loaded: Proc.new{ emit('load') },
|
67
|
+
on_view_preappear: Proc.new{ emit('preappear') },
|
68
|
+
on_view_appear: Proc.new{ emit('appear') },
|
69
|
+
on_view_disappear: Proc.new{ emit('disappear') },
|
70
|
+
on_view_rerender: Proc.new{ emit('rerender') },
|
71
|
+
on_view_rotate: Proc.new{ emit('rotate') }
|
72
|
+
})
|
73
|
+
|
74
|
+
on 'init' do
|
75
|
+
build_layout
|
76
|
+
compile_styles
|
77
|
+
end
|
78
|
+
|
79
|
+
on 'load' do
|
80
|
+
repaint
|
81
|
+
initialize(*args)
|
82
|
+
end
|
83
|
+
|
84
|
+
on 'preappear' do
|
85
|
+
repaint
|
86
|
+
end
|
87
|
+
|
88
|
+
on 'rotate' do
|
89
|
+
repaint
|
90
|
+
end
|
91
|
+
|
92
|
+
self
|
93
|
+
end
|
94
|
+
|
95
|
+
def build_layout
|
96
|
+
@_layout = Layout.new(self)
|
97
|
+
end
|
98
|
+
|
99
|
+
def compile_styles
|
100
|
+
@stylesheet = Stylesheet.new
|
101
|
+
@stylesheet << UnderOs::App.stylesheet
|
102
|
+
@stylesheet.load("#{name}.css")
|
103
|
+
end
|
104
|
+
|
105
|
+
def repaint
|
106
|
+
view.repaint(stylesheet) if view
|
107
|
+
navbar.repaint(stylesheet) if navbar
|
108
|
+
end
|
109
|
+
|
110
|
+
#
|
111
|
+
# A simple wrap over UIViewController to intercept
|
112
|
+
# the iOS events
|
113
|
+
#
|
114
|
+
class UIViewControllerWrap < UIViewController
|
115
|
+
attr_reader :wrapper
|
116
|
+
|
117
|
+
def init(wrapper, options)
|
118
|
+
@wrapper = wrapper
|
119
|
+
@options = options
|
120
|
+
initWithNibName(nil, bundle: nil)
|
121
|
+
end
|
122
|
+
|
123
|
+
def loadView
|
124
|
+
super
|
125
|
+
@options[:on_load_view].call
|
126
|
+
end
|
127
|
+
|
128
|
+
def viewDidLoad
|
129
|
+
super
|
130
|
+
@options[:on_view_loaded].call
|
131
|
+
end
|
132
|
+
|
133
|
+
def viewWillAppear(animated)
|
134
|
+
super(animated)
|
135
|
+
@options[:on_view_preappear].call
|
136
|
+
end
|
137
|
+
|
138
|
+
def viewDidAppear(animated)
|
139
|
+
super
|
140
|
+
@options[:on_view_appear].call
|
141
|
+
end
|
142
|
+
|
143
|
+
def viewDidDisappear(animated)
|
144
|
+
super
|
145
|
+
@options[:on_view_disappear].call
|
146
|
+
end
|
147
|
+
|
148
|
+
def viewWillLayoutSubviews
|
149
|
+
super
|
150
|
+
@options[:on_view_rerender].call
|
151
|
+
end
|
152
|
+
|
153
|
+
def didRotateFromInterfaceOrientation(orientation)
|
154
|
+
super
|
155
|
+
@options[:on_view_rotate].call
|
156
|
+
end
|
157
|
+
|
158
|
+
def prefersStatusBarHidden
|
159
|
+
!UnderOs::App.config.status_bar
|
160
|
+
end
|
161
|
+
|
162
|
+
def touchesBegan(touches, withEvent:event)
|
163
|
+
UnderOs::UI::Events::TouchListeners.notify :touchstart, event
|
164
|
+
end
|
165
|
+
|
166
|
+
def touchesMoved(touches, withEvent:event)
|
167
|
+
UnderOs::UI::Events::TouchListeners.notify :touchmove, event
|
168
|
+
end
|
169
|
+
|
170
|
+
def touchesEnded(touches, withEvent: event)
|
171
|
+
UnderOs::UI::Events::TouchListeners.notify :touchend, event
|
172
|
+
end
|
173
|
+
|
174
|
+
def touchesCancelled(touches, withEvent: event)
|
175
|
+
UnderOs::UI::Events::TouchListeners.notify :touchcancel, event
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|