motion-kit 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c567bd9815d3e05e231e5ad9c823bb7800ad5e7
4
- data.tar.gz: a815960a60ed988df0a3c0b9732492dbb04359d5
3
+ metadata.gz: 03fe5d5549262f60c5bdd3f134c540c484ac038d
4
+ data.tar.gz: 2f8f044bf5a3724101f66abc81d92e8d479c7785
5
5
  SHA512:
6
- metadata.gz: be917bdbdf07b9fe387c08d4ff4cbcdc98c81d7156180e7fae3f2f798041bba3398085c5692a2b9a5264054d342f3d7415a1b6bfdbc3fa324fc048249d12426b
7
- data.tar.gz: 5a11a4d4ddc081d2e09f6fce3cd485d442c457019456e6e3a957dce24c03a32d54f10a57ab9a9cd4b74adad76609aa08beb7c985d6f0e2041a74e830c69cb1f8
6
+ metadata.gz: 9712cb0d52df40684046c7d8eb96221554cf8aa75a48ff9680fb03ab34d3facabebacd1d0515cb154ed2f0257310ab332cdc60bb5a25b0bb68767e41664bfe18
7
+ data.tar.gz: ad61b27f06f9fb5cd3a1882a780caf3fbc3b8d033e5f344d731ca4a8f497ea5169f24ce2f9e8c9c8fc46b22a33b252bf6586f7276abe2a24c0550dd70b4bc946
@@ -6,6 +6,14 @@ module MotionKit
6
6
  UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPhone
7
7
  end
8
8
 
9
+ def iphone55?
10
+ iphone? && UIScreen.mainScreen.bounds.size.width == 414 && UIScreen.mainScreen.bounds.size.height == 736
11
+ end
12
+
13
+ def iphone47?
14
+ iphone? && UIScreen.mainScreen.bounds.size.width == 375 && UIScreen.mainScreen.bounds.size.height == 667
15
+ end
16
+
9
17
  def iphone4?
10
18
  iphone? && UIScreen.mainScreen.bounds.size.width == 320 && UIScreen.mainScreen.bounds.size.height == 568
11
19
  end
@@ -92,6 +92,8 @@ module MotionKit
92
92
  return new_target unless block
93
93
  # this little line is incredibly important; the context is only set on
94
94
  # the top-level Layout object.
95
+
96
+ # mp "MOTIONKIT CONTEXT is #{new_target} meta: #{new_target.motion_kit_meta}"
95
97
  return parent_layout.context(new_target, &block) unless is_parent_layout?
96
98
 
97
99
  if new_target.is_a?(Symbol)
@@ -432,6 +432,19 @@ module MotionKit
432
432
  removed
433
433
  end
434
434
 
435
+ def remove_view(element_id, view)
436
+ unless is_parent_layout?
437
+ return parent_layout.remove_view(element_id, view)
438
+ end
439
+ removed = forget_tree(element_id, view)
440
+ if removed
441
+ context(self.view) do
442
+ self.apply(:remove_child, removed)
443
+ end
444
+ end
445
+ removed
446
+ end
447
+
435
448
  # Removes a view from the list of elements this layout is "tracking", but
436
449
  # leaves it in the view hierarchy. Returns the views that were removed.
437
450
  def forget(element_id)
@@ -446,6 +459,33 @@ module MotionKit
446
459
  removed
447
460
  end
448
461
 
462
+ def forget_view(element_id, view)
463
+ unless is_parent_layout?
464
+ return parent_layout.remove_view(element_id, view)
465
+ end
466
+ # mp "forgetting #{element_id}, #{view}"
467
+ removed = nil
468
+ context(self.view) do
469
+ removed = @elements[element_id].delete(view) if @elements[element_id]
470
+ end
471
+ removed
472
+ end
473
+
474
+ # returns the root view that was removed, if any
475
+ def forget_tree(element_id, view)
476
+ removed = forget_view(element_id, view)
477
+ if view.subviews
478
+ view.subviews.each do | sub |
479
+ if (sub_ids = sub.motion_kit_meta[:motion_kit_ids])
480
+ sub_ids.each do | sub_id |
481
+ forget_tree(sub_id, sub) || []
482
+ end
483
+ end
484
+ end
485
+ end
486
+ removed
487
+ end
488
+
449
489
  def create_default_root_context
450
490
  if @assign_root
451
491
  # Originally I thought default_root should be `apply`ied like other
@@ -458,7 +498,7 @@ module MotionKit
458
498
  end
459
499
  end
460
500
 
461
- protected
501
+ protected
462
502
 
463
503
  # This method builds the layout and returns the root view.
464
504
  def build_view
@@ -1,3 +1,3 @@
1
1
  module MotionKit
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
@@ -7,7 +7,21 @@ describe 'Device helpers' do
7
7
  it 'should have device helpers' do
8
8
  @layout.context({}) do
9
9
  @layout.iphone?.should == true
10
- @layout.iphone4?.should == true
10
+ if UIScreen.mainScreen.bounds.size.width == 320
11
+ @layout.iphone4?.should == true
12
+ else
13
+ @layout.iphone4?.should == false
14
+ end
15
+ if UIScreen.mainScreen.bounds.size.width == 375
16
+ @layout.iphone47?.should == true
17
+ else
18
+ @layout.iphone47?.should == false
19
+ end
20
+ if UIScreen.mainScreen.bounds.size.width == 375
21
+ @layout.iphone55?.should == true
22
+ else
23
+ @layout.iphone55?.should == false
24
+ end
11
25
  @layout.iphone35?.should == false
12
26
  @layout.ipad?.should == false
13
27
  @layout.retina?.should == true
@@ -9,6 +9,23 @@ describe 'Remove views' do
9
9
  @subject.get(:label).should.be.nil
10
10
  end
11
11
 
12
+ it 'should remove the first label view' do
13
+ labels = @subject.all(:multi_label)
14
+ labels.count.should == 2
15
+ @subject.remove_first_multi_label
16
+ @subject.all(:multi_label).count.should == 1
17
+ @subject.get(:multi_label).should == labels.last
18
+ end
19
+
20
+ it 'should remove the last label view' do
21
+ labels = @subject.all(:multi_label)
22
+ labels.count.should == 2
23
+ @subject.remove_last_multi_label
24
+ @subject.all(:multi_label).count.should == 1
25
+ @subject.get(:multi_label).should == labels.first
26
+ end
27
+
28
+
12
29
  it 'should forget the #image view' do
13
30
  image = @subject.get(:image)
14
31
  image.should.be.kind_of(UIImageView)
@@ -17,10 +34,20 @@ describe 'Remove views' do
17
34
  image.superview.should.not.be.nil
18
35
  end
19
36
 
37
+ it 'should forget the first label view' do
38
+ labels = @subject.all(:multi_label)
39
+ labels.count.should == 2
40
+ @subject.forget_first_multi_label
41
+ @subject.all(:multi_label).count.should == 1
42
+ @subject.get(:multi_label).should == labels.last
43
+ labels.first.superview.should.not.be.nil
44
+ end
45
+
46
+
20
47
  it 'should remove the #view from the hierarchy' do
21
48
  view = @subject.get(:view)
22
49
  view.should.be.kind_of(UIView)
23
- @subject.remove_view
50
+ @subject.remove_main_view
24
51
  @subject.get(:view).should.be.nil
25
52
  view.superview.should.be.nil
26
53
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin T.A. Gray
@@ -9,28 +9,28 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-01-05 00:00:00.000000000 Z
12
+ date: 2016-05-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dbt
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
19
- - !ruby/object:Gem::Version
20
- version: '1.1'
21
18
  - - ">="
22
19
  - !ruby/object:Gem::Version
23
20
  version: 1.1.5
21
+ - - "~>"
22
+ - !ruby/object:Gem::Version
23
+ version: '1.1'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
- - - "~>"
29
- - !ruby/object:Gem::Version
30
- version: '1.1'
31
28
  - - ">="
32
29
  - !ruby/object:Gem::Version
33
30
  version: 1.1.5
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.1'
34
34
  description: |
35
35
  MotionKit, for RubyMotion, is a DSL for creating and styling views in iOS and OS X.
36
36
  email: