motion-prime 0.2.1 → 0.3.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.
- checksums.yaml +8 -8
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +14 -11
- data/README.md +8 -11
- data/Rakefile +2 -1
- data/bin/prime.rb +47 -0
- data/doc/FAQ.md +1 -1
- data/files/app/app_delegate.rb +1 -1
- data/files/app/config/base.rb +8 -4
- data/files/app/screens/application_screen.rb +1 -1
- data/files/app/screens/sidebar_screen.rb +1 -1
- data/files/app/sections/sidebar/action.rb +1 -1
- data/files/app/sections/sidebar/table.rb +1 -1
- data/files/app/styles/sidebar.rb +5 -5
- data/motion-prime.gemspec +1 -0
- data/motion-prime/api_client.rb +81 -0
- data/motion-prime/app_delegate.rb +22 -5
- data/motion-prime/config/base.rb +5 -0
- data/motion-prime/core_ext/kernel.rb +5 -0
- data/motion-prime/elements/_field_dimensions_mixin.rb +43 -0
- data/motion-prime/elements/_text_dimensions_mixin.rb +39 -0
- data/motion-prime/elements/base.rb +40 -17
- data/motion-prime/elements/button.rb +20 -0
- data/motion-prime/elements/draw.rb +2 -2
- data/motion-prime/elements/draw/image.rb +4 -2
- data/motion-prime/elements/draw/label.rb +1 -1
- data/motion-prime/elements/error_message.rb +3 -16
- data/motion-prime/elements/label.rb +13 -2
- data/motion-prime/elements/text_field.rb +1 -0
- data/motion-prime/helpers/cell_section.rb +9 -0
- data/motion-prime/helpers/has_authorization.rb +4 -3
- data/motion-prime/helpers/has_normalizer.rb +20 -6
- data/motion-prime/helpers/has_search_bar.rb +19 -7
- data/motion-prime/helpers/has_style_chain_builder.rb +7 -0
- data/motion-prime/models/association.rb +22 -9
- data/motion-prime/models/association_collection.rb +54 -23
- data/motion-prime/models/bag.rb +13 -12
- data/motion-prime/models/base.rb +2 -0
- data/motion-prime/models/errors.rb +23 -14
- data/motion-prime/models/finder.rb +4 -1
- data/motion-prime/models/model.rb +25 -5
- data/motion-prime/models/store_extension.rb +1 -7
- data/motion-prime/models/sync.rb +75 -43
- data/motion-prime/mp.rb +4 -0
- data/motion-prime/screens/_base_mixin.rb +18 -12
- data/motion-prime/screens/_navigation_bar_mixin.rb +15 -6
- data/motion-prime/screens/_navigation_mixin.rb +15 -16
- data/motion-prime/screens/base_screen.rb +5 -1
- data/motion-prime/screens/sidebar_container_screen.rb +37 -22
- data/motion-prime/sections/base.rb +82 -16
- data/motion-prime/sections/form.rb +144 -26
- data/motion-prime/sections/form/base_field_section.rb +62 -29
- data/motion-prime/sections/form/base_header_section.rb +27 -0
- data/motion-prime/sections/form/date_field_section.rb +2 -17
- data/motion-prime/sections/form/password_field_section.rb +3 -17
- data/motion-prime/sections/form/select_field_section.rb +4 -35
- data/motion-prime/sections/form/string_field_section.rb +3 -29
- data/motion-prime/sections/form/submit_field_section.rb +1 -7
- data/motion-prime/sections/form/switch_field_section.rb +3 -23
- data/motion-prime/sections/form/text_field_section.rb +3 -33
- data/motion-prime/sections/form/text_with_button_field_section.rb +4 -40
- data/motion-prime/sections/tabbed.rb +25 -5
- data/motion-prime/sections/table.rb +86 -22
- data/motion-prime/sections/table/refresh_mixin.rb +3 -1
- data/motion-prime/styles/base.rb +7 -89
- data/motion-prime/styles/form.rb +116 -0
- data/motion-prime/support/dm_button.rb +32 -5
- data/motion-prime/support/dm_text_field.rb +31 -7
- data/motion-prime/support/dm_text_view.rb +6 -3
- data/motion-prime/support/dm_view_controller.rb +3 -3
- data/motion-prime/support/ui_search_bar_custom.rb +1 -1
- data/motion-prime/version.rb +1 -1
- data/motion-prime/views/layout.rb +18 -10
- data/motion-prime/views/styles.rb +19 -9
- data/motion-prime/views/view_builder.rb +18 -2
- data/motion-prime/views/view_styler.rb +59 -5
- data/spec/models/errors_spec.rb +3 -3
- data/travis.sh +3 -2
- metadata +28 -5
- data/motion-prime/elements/_text_height_mixin.rb +0 -17
- data/motion-prime/sections/form/table_field_section.rb +0 -51
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NGYzMDBjMjExMDIwYjViMzBkYjJjNGRjMGY2ZWY3YjFhZjljNGE3Nw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OWI5ZjA0OThkNzg3NDc5OWFmODBhNWJiNmM2NWFjOTk4YWE3Nzc4Nw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZWJhZDkzYjNmOGEzYjJjN2E2ODQ3M2I2MTc3ZjcwYWExMjM2MDA5MGI5ZjNh
|
10
|
+
NGRhNzM1YmQ1YTcwMTFkM2Y3NmM5YTFiZDI1NDEzZmFiZDI2NWYzOTYyNjAw
|
11
|
+
Y2U2MzljNDNiNmNkMTYwOTE0MGFiYjk0ZmExYmQzZWIwODgzMDI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MzliOWY4M2M4ZmNkYTJmNGQ0OTU5Yzc4ZDQ4YzA3MzU5ZWUwMWM3ZjViOTFl
|
14
|
+
MjU5NzFlNGM2NzA5MmNmZWVkZTM4OGUwMTU4NzBmNWMwYzAxMGZjMGE5MWUy
|
15
|
+
N2M0YjQ4ODcxNWJhZWNkZjU3MGJiMTAzOGJjYmZmMWM1MzQ4YjY=
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
motion-prime (0.
|
4
|
+
motion-prime (0.3.0)
|
5
5
|
bubble-wrap
|
6
6
|
cocoapods
|
7
|
+
methadone
|
7
8
|
motion-cocoapods
|
8
9
|
motion-require
|
9
10
|
motion-support
|
@@ -13,8 +14,8 @@ PATH
|
|
13
14
|
GEM
|
14
15
|
remote: http://rubygems.org/
|
15
16
|
specs:
|
16
|
-
activesupport (3.2.
|
17
|
-
i18n (
|
17
|
+
activesupport (3.2.15)
|
18
|
+
i18n (~> 0.6, >= 0.6.4)
|
18
19
|
multi_json (~> 1.0)
|
19
20
|
addressable (2.3.5)
|
20
21
|
bubble-wrap (1.3.0)
|
@@ -35,24 +36,26 @@ GEM
|
|
35
36
|
cocoapods-core (0.19.1)
|
36
37
|
activesupport (~> 3.2.13)
|
37
38
|
rake (~> 10.0.0)
|
38
|
-
cocoapods-downloader (0.1.
|
39
|
+
cocoapods-downloader (0.1.2)
|
39
40
|
colored (1.2)
|
40
41
|
escape (0.0.4)
|
41
|
-
faraday (0.8.
|
42
|
-
multipart-post (~> 1.
|
42
|
+
faraday (0.8.8)
|
43
|
+
multipart-post (~> 1.2.0)
|
43
44
|
faraday_middleware (0.9.0)
|
44
45
|
faraday (>= 0.7.4, < 0.9)
|
45
46
|
hashie (2.0.5)
|
46
|
-
i18n (0.6.
|
47
|
+
i18n (0.6.5)
|
47
48
|
json (1.7.7)
|
48
|
-
|
49
|
+
methadone (1.3.1)
|
50
|
+
bundler
|
51
|
+
motion-cocoapods (1.3.7)
|
49
52
|
cocoapods (>= 0.17.0)
|
50
53
|
motion-redgreen (0.1.0)
|
51
54
|
motion-require (0.0.7)
|
52
55
|
motion-stump (0.3.0)
|
53
|
-
motion-support (0.2.
|
56
|
+
motion-support (0.2.5)
|
54
57
|
motion-require (>= 0.0.6)
|
55
|
-
multi_json (1.
|
58
|
+
multi_json (1.8.2)
|
56
59
|
multipart-post (1.2.0)
|
57
60
|
nano-store (0.6.3)
|
58
61
|
motion-cocoapods (>= 1.2.1)
|
@@ -66,7 +69,7 @@ GEM
|
|
66
69
|
netrc (~> 0.7.7)
|
67
70
|
open4 (1.3.0)
|
68
71
|
rake (10.0.4)
|
69
|
-
sugarcube (0.20.
|
72
|
+
sugarcube (0.20.25)
|
70
73
|
xcodeproj (0.5.5)
|
71
74
|
activesupport (~> 3.2.13)
|
72
75
|
colored (~> 1.2)
|
data/README.md
CHANGED
@@ -11,31 +11,28 @@ The main feature of MotionPrime is one more layer on UI elements: Section.
|
|
11
11
|
|
12
12
|
### 1. Create MotionPrime project:
|
13
13
|
|
14
|
-
$
|
14
|
+
$ prime new myapp
|
15
15
|
|
16
|
-
### 2.
|
17
|
-
|
18
|
-
$ bundle
|
19
|
-
|
20
|
-
### 3. Setup application
|
16
|
+
### 2. Setup application
|
21
17
|
|
22
18
|
# edit Rakefile
|
23
19
|
|
24
|
-
###
|
20
|
+
### 3. Run application
|
25
21
|
|
26
22
|
$ rake
|
27
23
|
|
28
24
|
## Hello World (Sample)
|
25
|
+
|
29
26
|
```ruby
|
30
27
|
# app/app_delegate.rb
|
31
|
-
class AppDelegate <
|
28
|
+
class AppDelegate < Prime::BaseAppDelegate
|
32
29
|
def on_load(app, options)
|
33
30
|
open_root_screen MainScreen.new
|
34
31
|
end
|
35
32
|
end
|
36
33
|
|
37
34
|
# app/screens/main_screen.rb
|
38
|
-
class MainScreen <
|
35
|
+
class MainScreen < Prime::BaseScreen
|
39
36
|
title 'Main screen'
|
40
37
|
|
41
38
|
def render
|
@@ -45,13 +42,13 @@ The main feature of MotionPrime is one more layer on UI elements: Section.
|
|
45
42
|
end
|
46
43
|
|
47
44
|
# app/sections/my_profile.rb
|
48
|
-
class MyProfileSection <
|
45
|
+
class MyProfileSection < Prime::BaseSection
|
49
46
|
element :title, text: "Hello World"
|
50
47
|
element :avatar, image: "images/avatar.png", type: :image
|
51
48
|
end
|
52
49
|
|
53
50
|
# app/styles/my_profile.rb
|
54
|
-
|
51
|
+
Prime::Styles.define :my_profile do
|
55
52
|
style :title,
|
56
53
|
width: 300, height: 20, color: :black,
|
57
54
|
top: 10, left: 5, background_color: :white
|
data/Rakefile
CHANGED
@@ -18,14 +18,15 @@ require 'motion-support'
|
|
18
18
|
require 'motion-prime'
|
19
19
|
require 'motion-stump'
|
20
20
|
require 'motion-redgreen'
|
21
|
+
require 'bubble-wrap/reactor'
|
21
22
|
|
22
23
|
Motion::Project::App.setup do |app|
|
23
24
|
app.name = 'MotionPrime'
|
24
25
|
app.pods do
|
25
|
-
pod 'PKRevealController'
|
26
26
|
pod 'NanoStore', '~> 2.7.7'
|
27
27
|
pod 'SDWebImage'
|
28
28
|
pod 'SVPullToRefresh'
|
29
29
|
pod 'MBAlertView'
|
30
|
+
pod 'RESideMenu', git: 'https://github.com/feklistov/RESideMenu.git'
|
30
31
|
end
|
31
32
|
end
|
data/bin/prime.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'methadone'
|
5
|
+
require_relative '../motion-prime/version'
|
6
|
+
|
7
|
+
class App
|
8
|
+
include Methadone::Main
|
9
|
+
include Methadone::CLILogging
|
10
|
+
include Methadone::SH
|
11
|
+
|
12
|
+
main do |command, opt|
|
13
|
+
case command.to_sym
|
14
|
+
when :new then create(opt)
|
15
|
+
else help
|
16
|
+
end
|
17
|
+
0
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.help
|
21
|
+
info "Command line tools for MotionPrime"
|
22
|
+
info "Commands:"
|
23
|
+
info " new <appname>"
|
24
|
+
info " Creates a new MotionPrime app from a template."
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.create(name)
|
28
|
+
return puts "Usage: prime new <appname>" unless name.to_s.length > 0
|
29
|
+
info "Creating new MotionPrime iOS app: #{name}"
|
30
|
+
sh "motion create --template=git@github.com:droidlabs/motion-prime.git #{name}"
|
31
|
+
sh "cd ./#{name}"
|
32
|
+
info "Command: bundle instal"
|
33
|
+
sh "bundle install"
|
34
|
+
info "Command: pod setup"
|
35
|
+
sh "pod setup"
|
36
|
+
sh "cd .."
|
37
|
+
end
|
38
|
+
|
39
|
+
description "Command line tools for MotionPrime"
|
40
|
+
|
41
|
+
arg :command
|
42
|
+
arg :opt, :optional
|
43
|
+
|
44
|
+
version MotionPrime::VERSION
|
45
|
+
|
46
|
+
go!
|
47
|
+
end
|
data/doc/FAQ.md
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
Q: Error: `Unable to find a specification for `Something``
|
2
|
-
A: Try running `pod
|
2
|
+
A: Try running `pod setup`
|
data/files/app/app_delegate.rb
CHANGED
data/files/app/config/base.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
MP::Config.color do |color|
|
1
|
+
Prime::Config.color do |color|
|
4
2
|
color.base = 0x3aa9b6
|
5
3
|
color.dark = 0x41929c
|
6
4
|
end
|
7
5
|
|
6
|
+
Prime::Config.api do |api|
|
7
|
+
api.base = "http://example.com"
|
8
|
+
api.client_id = ""
|
9
|
+
api.client_secret = ""
|
10
|
+
end
|
11
|
+
|
8
12
|
# setup model's store
|
9
|
-
|
13
|
+
Prime::Store.connect
|
data/files/app/styles/sidebar.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
|
1
|
+
Prime::Styles.define :sidebar do
|
2
2
|
# navigation layout
|
3
3
|
# ----------
|
4
4
|
style :screen,
|
5
|
-
background_color:
|
5
|
+
background_color: Prime::Config.color.base,
|
6
6
|
opaque: true
|
7
7
|
|
8
8
|
style :table,
|
@@ -10,8 +10,8 @@ MotionPrime::Styles.define :sidebar do
|
|
10
10
|
left: 0,
|
11
11
|
width: 320,
|
12
12
|
bottom: 0,
|
13
|
-
background_color:
|
14
|
-
separator_color:
|
13
|
+
background_color: Prime::Config.color.base,
|
14
|
+
separator_color: Prime::Config.color.dark,
|
15
15
|
opaque: true
|
16
16
|
|
17
17
|
style :table_cell,
|
@@ -19,7 +19,7 @@ MotionPrime::Styles.define :sidebar do
|
|
19
19
|
opaque: true
|
20
20
|
|
21
21
|
style :action_title,
|
22
|
-
background_color:
|
22
|
+
background_color: Prime::Config.color.base,
|
23
23
|
text_color: :white,
|
24
24
|
top: 10,
|
25
25
|
width: 320,
|
data/motion-prime.gemspec
CHANGED
@@ -0,0 +1,81 @@
|
|
1
|
+
class ApiClient
|
2
|
+
attr_accessor :access_token
|
3
|
+
|
4
|
+
def initialize(options = {})
|
5
|
+
self.access_token = options[:access_token]
|
6
|
+
end
|
7
|
+
|
8
|
+
def parse_json(text)
|
9
|
+
BW::JSON.parse(text)
|
10
|
+
rescue
|
11
|
+
puts "Can't parse json: #{text}"
|
12
|
+
false
|
13
|
+
end
|
14
|
+
|
15
|
+
def request_params(data)
|
16
|
+
files = data.delete(:files)
|
17
|
+
params = {payload: data, no_redirect: true, format: :form_data}
|
18
|
+
if files.present?
|
19
|
+
params.merge!(files: files)
|
20
|
+
end
|
21
|
+
if MotionPrime::Config.api.http_auth.present?
|
22
|
+
params.merge!(credentials: MotionPrime::Config.api.http_auth.to_hash)
|
23
|
+
end
|
24
|
+
params
|
25
|
+
end
|
26
|
+
|
27
|
+
def authenticate(username, password, &block)
|
28
|
+
data = {
|
29
|
+
grant_type: "password",
|
30
|
+
username: username,
|
31
|
+
password: password,
|
32
|
+
client_id: MotionPrime::Config.api.client_id,
|
33
|
+
client_secret: MotionPrime::Config.api.client_secret
|
34
|
+
}
|
35
|
+
use_callback = block_given?
|
36
|
+
BW::HTTP.post("#{MotionPrime::Config.api.base}/oauth/token", request_params(data)) do |response|
|
37
|
+
access_token = if response.ok?
|
38
|
+
json = parse_json(response.body)
|
39
|
+
json[:access_token]
|
40
|
+
else
|
41
|
+
false
|
42
|
+
end
|
43
|
+
self.access_token = access_token
|
44
|
+
block.call(access_token) if use_callback
|
45
|
+
end
|
46
|
+
true
|
47
|
+
end
|
48
|
+
|
49
|
+
def api_url(path)
|
50
|
+
return path if path =~ /^http(s)?:\/\//
|
51
|
+
"#{MotionPrime::Config.api.base}/api/v1#{path}"
|
52
|
+
end
|
53
|
+
|
54
|
+
def resource_url(path)
|
55
|
+
"#{MotionPrime::Config.api.base}#{path}"
|
56
|
+
end
|
57
|
+
|
58
|
+
def request(method, path, params = {}, &block)
|
59
|
+
params.merge!(access_token: access_token)
|
60
|
+
BW::HTTP.send method, api_url(path), request_params(params) do |response|
|
61
|
+
json = parse_json(response.body.to_s)
|
62
|
+
block.call(json, response.status_code)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def get(path, params = {}, &block)
|
67
|
+
request(:get, path, params, &block)
|
68
|
+
end
|
69
|
+
|
70
|
+
def put(path, params = {}, &block)
|
71
|
+
request(:put, path, params, &block)
|
72
|
+
end
|
73
|
+
|
74
|
+
def post(path, params = {}, &block)
|
75
|
+
request(:post, path, params, &block)
|
76
|
+
end
|
77
|
+
|
78
|
+
def delete(path, params = {}, &block)
|
79
|
+
request(:delete, path, params, &block)
|
80
|
+
end
|
81
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
include EM::Eventable
|
1
2
|
motion_require './helpers/has_authorization'
|
2
3
|
module MotionPrime
|
3
4
|
class BaseAppDelegate
|
@@ -5,21 +6,24 @@ module MotionPrime
|
|
5
6
|
|
6
7
|
attr_accessor :window, :sidebar_container
|
7
8
|
|
9
|
+
def application(application, willFinishLaunchingWithOptions:opts)
|
10
|
+
application.setStatusBarStyle UIStatusBarStyleLightContent
|
11
|
+
application.setStatusBarHidden false
|
12
|
+
end
|
13
|
+
|
8
14
|
def application(application, didFinishLaunchingWithOptions:launch_options)
|
9
15
|
on_load(application, launch_options)
|
10
16
|
true
|
11
17
|
end
|
12
18
|
|
13
|
-
def app_delegate
|
14
|
-
UIApplication.sharedApplication.delegate
|
15
|
-
end
|
16
|
-
|
17
19
|
def app_window
|
18
20
|
self.app_delegate.window
|
19
21
|
end
|
20
22
|
|
21
23
|
def open_root_screen(screen)
|
22
24
|
screen.send(:on_screen_load) if screen.respond_to?(:on_screen_load)
|
25
|
+
screen.ensure_wrapper_controller_in_place if screen.respond_to?(:ensure_wrapper_controller_in_place)
|
26
|
+
|
23
27
|
screen = screen.main_controller if screen.respond_to?(:main_controller)
|
24
28
|
|
25
29
|
self.window ||= UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
|
@@ -37,11 +41,12 @@ module MotionPrime
|
|
37
41
|
end
|
38
42
|
|
39
43
|
def sidebar?
|
40
|
-
|
44
|
+
self.window.rootViewController.is_a?(SidebarContainerScreen)
|
41
45
|
end
|
42
46
|
|
43
47
|
def open_with_sidebar(content, menu, options={})
|
44
48
|
self.sidebar_container = SidebarContainerScreen.new(menu, content, options)
|
49
|
+
self.sidebar_container.delegate = self
|
45
50
|
open_root_screen(sidebar_container)
|
46
51
|
end
|
47
52
|
|
@@ -52,5 +57,17 @@ module MotionPrime
|
|
52
57
|
def hide_sidebar
|
53
58
|
sidebar_container.hide_sidebar
|
54
59
|
end
|
60
|
+
|
61
|
+
def current_user
|
62
|
+
@current_user ||= if defined?(User) && User.respond_to?(:current)
|
63
|
+
User.current
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def update_current_user
|
68
|
+
user_was = @current_user
|
69
|
+
@current_user = nil
|
70
|
+
NSNotificationCenter.defaultCenter.postNotificationName(:current_user_updated, object: user_was)
|
71
|
+
end
|
55
72
|
end
|
56
73
|
end
|