@breakside/jskit 2021.42.0 → 2021.46.1

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 (86) hide show
  1. package/Frameworks/DOM.jsframework/Info.json +2 -2
  2. package/Frameworks/DOM.jsframework/io.breakside.JSKit.DOM-bundle.js +2 -2
  3. package/Frameworks/FontKit.jsframework/Info.json +2 -2
  4. package/Frameworks/FontKit.jsframework/io.breakside.JSKit.FontKit-bundle.js +2 -2
  5. package/Frameworks/Foundation.jsframework/Info.json +2 -2
  6. package/Frameworks/Foundation.jsframework/JS/Deflate.js +2 -3
  7. package/Frameworks/Foundation.jsframework/JS/Error+JS.js +10 -0
  8. package/Frameworks/Foundation.jsframework/JS/JSClass.js +8 -5
  9. package/Frameworks/Foundation.jsframework/JS/JSColor.js +15 -0
  10. package/Frameworks/Foundation.jsframework/JS/JSDate.js +6 -0
  11. package/Frameworks/Foundation.jsframework/JS/JSDateFormatter.js +2 -2
  12. package/Frameworks/Foundation.jsframework/JS/JSImage.js +1 -0
  13. package/Frameworks/Foundation.jsframework/JS/JSTimeZone.js +6 -2
  14. package/Frameworks/Foundation.jsframework/JS/JSURLResponse.js +60 -1
  15. package/Frameworks/Foundation.jsframework/JS/Zlib.js +2 -3
  16. package/Frameworks/Foundation.jsframework/io.breakside.JSKit.Foundation-bundle.js +2 -2
  17. package/Frameworks/SecurityKit.jsframework/Info.json +2 -2
  18. package/Frameworks/SecurityKit.jsframework/io.breakside.JSKit.SecurityKit-bundle.js +2 -2
  19. package/Info.json +2 -2
  20. package/Node/HTMLBuilder.js +2 -1
  21. package/Node/JavascriptCompilation.js +1 -1
  22. package/Node/io.breakside.jskit-bundle.js +2 -2
  23. package/Root/Frameworks/APIKit/APIError.js +2 -3
  24. package/Root/Frameworks/APIKit/Info.yaml +1 -1
  25. package/Root/Frameworks/APIKitTesting/Info.yaml +1 -1
  26. package/Root/Frameworks/AuthKit/Info.yaml +1 -1
  27. package/Root/Frameworks/CSSOM/Info.yaml +1 -1
  28. package/Root/Frameworks/ChartKit/Info.yaml +1 -1
  29. package/Root/Frameworks/ConferenceKit/Info.yaml +1 -1
  30. package/Root/Frameworks/DBKit/DBObjectDatabase.js +6 -5
  31. package/Root/Frameworks/DBKit/Info.yaml +1 -1
  32. package/Root/Frameworks/DOM/Info.yaml +1 -1
  33. package/Root/Frameworks/Dispatch/Info.yaml +1 -1
  34. package/Root/Frameworks/FontKit/Info.yaml +1 -1
  35. package/Root/Frameworks/Foundation/Deflate.js +2 -3
  36. package/Root/Frameworks/Foundation/Error+JS.js +10 -0
  37. package/Root/Frameworks/Foundation/Info.yaml +1 -1
  38. package/Root/Frameworks/Foundation/JSClass.js +8 -5
  39. package/Root/Frameworks/Foundation/JSColor.js +15 -0
  40. package/Root/Frameworks/Foundation/JSDate.js +6 -0
  41. package/Root/Frameworks/Foundation/JSDateFormatter.js +2 -2
  42. package/Root/Frameworks/Foundation/JSImage.js +1 -0
  43. package/Root/Frameworks/Foundation/JSTimeZone.js +6 -2
  44. package/Root/Frameworks/Foundation/JSURLResponse.js +60 -1
  45. package/Root/Frameworks/Foundation/Zlib.js +2 -3
  46. package/Root/Frameworks/ImageKit/IKDecoderPNG.js +1 -3
  47. package/Root/Frameworks/ImageKit/Info.yaml +1 -1
  48. package/Root/Frameworks/MediaKit/Info.yaml +1 -1
  49. package/Root/Frameworks/MediaKitUI/Info.yaml +1 -1
  50. package/Root/Frameworks/NotificationKit/Info.yaml +1 -1
  51. package/Root/Frameworks/PDFKit/Info.yaml +1 -1
  52. package/Root/Frameworks/QRKit/Info.yaml +1 -1
  53. package/Root/Frameworks/SearchKit/Info.yaml +1 -1
  54. package/Root/Frameworks/SecurityKit/Info.yaml +1 -1
  55. package/Root/Frameworks/ServerKit/Info.yaml +1 -1
  56. package/Root/Frameworks/ServerKit/SKFileJobQueue.js +3 -1
  57. package/Root/Frameworks/ServerKit/SKHTTPError.js +2 -3
  58. package/Root/Frameworks/ServerKit/SKHTTPRequest.js +7 -0
  59. package/Root/Frameworks/ServerKit/SKHTTPResponder.js +9 -2
  60. package/Root/Frameworks/ServerKit/SKUserAgent.js +130 -0
  61. package/Root/Frameworks/ServerKit/SKValidatingObject.js +1 -3
  62. package/Root/Frameworks/ServerKit/ServerKit.js +1 -0
  63. package/Root/Frameworks/ServerKitTesting/Info.yaml +1 -1
  64. package/Root/Frameworks/TestKit/Info.yaml +1 -1
  65. package/Root/Frameworks/UIKit/Info.yaml +1 -1
  66. package/Root/Frameworks/UIKit/UIAnimation.js +4 -0
  67. package/Root/Frameworks/UIKit/UIContainerView.js +1 -1
  68. package/Root/Frameworks/UIKit/UIContainerViewController.js +3 -35
  69. package/Root/Frameworks/UIKit/UIHTMLDisplayServerCanvasContext.js +6 -1
  70. package/Root/Frameworks/UIKit/UIImageLayer.js +12 -14
  71. package/Root/Frameworks/UIKit/UILayer.js +20 -0
  72. package/Root/Frameworks/UIKit/UIListView.js +52 -12
  73. package/Root/Frameworks/UIKit/UIListViewHeaderFooterView.js +34 -0
  74. package/Root/Frameworks/UIKit/UINavigationBar.js +4 -2
  75. package/Root/Frameworks/UIKit/UINavigationBarItem.js +11 -0
  76. package/Root/Frameworks/UIKit/UINavigationController.js +2 -2
  77. package/Root/Frameworks/UIKit/UISplitViewController.js +9 -87
  78. package/Root/Frameworks/UIKit/UITabView.js +2 -2
  79. package/Root/Frameworks/UIKit/UITabViewController.js +6 -5
  80. package/Root/Frameworks/UIKit/UITextLayer.js +11 -10
  81. package/Root/Frameworks/UIKit/UIView.js +16 -0
  82. package/Root/Frameworks/UIKit/UIViewController.js +36 -0
  83. package/Root/Frameworks/UIKit/UIWindow.js +37 -3
  84. package/Root/Frameworks/UIKit/UIWindowServer.js +2 -2
  85. package/Root/Frameworks/UIKitTesting/Info.yaml +1 -1
  86. package/package.json +1 -1
@@ -101,6 +101,7 @@ JSClass("UIHTMLDisplayServerCanvasContext", UIHTMLDisplayServerContext, {
101
101
  // MARK: - Display Lifecycle
102
102
 
103
103
  layerDidChangeProperty: function(layer, property){
104
+ var methodName = 'updateHTMLProperty_' + property;
104
105
  switch (property){
105
106
  case 'shadowColor':
106
107
  case 'shadowOffset':
@@ -120,7 +121,11 @@ JSClass("UIHTMLDisplayServerCanvasContext", UIHTMLDisplayServerContext, {
120
121
  }
121
122
  break;
122
123
  default:
123
- this.propertiesNeedingUpdate[property] = true;
124
+ if (methodName in this){
125
+ this.propertiesNeedingUpdate[property] = true;
126
+ }else{
127
+ this.needsCustomDisplay = true;
128
+ }
124
129
  break;
125
130
  }
126
131
  },
@@ -20,13 +20,13 @@ JSClass("UIImageLayer", UILayer, {
20
20
 
21
21
  image: JSDynamicProperty('_image', null),
22
22
  imageFrame: JSDynamicProperty('_imageFrame', null),
23
- templateColor: JSDynamicProperty('_templateColor', null),
23
+ templateColor: UILayerAnimatedProperty(),
24
24
  automaticRenderMode: JSDynamicProperty('_automaticRenderMode', JSImage.RenderMode.original),
25
25
 
26
26
  init: function(){
27
27
  UIImageLayer.$super.init.call(this);
28
28
  this._imageFrame = JSRect.Zero;
29
- this._templateColor = JSColor.black;
29
+ this.model.templateColor = JSColor.black;
30
30
  },
31
31
 
32
32
  getImage: function(){
@@ -49,7 +49,7 @@ JSClass("UIImageLayer", UILayer, {
49
49
  drawInContext: function(context){
50
50
  if (this._image !== null && this._imageFrame.size.width > 0 && this._imageFrame.size.height > 0){
51
51
  if (this._image.renderMode === JSImage.RenderMode.template || (this._image.renderMode === JSImage.RenderMode.automatic && this._automaticRenderMode === JSImage.RenderMode.template)){
52
- context.setFillColor(this._templateColor);
52
+ context.setFillColor(this.presentation.templateColor);
53
53
  context.fillMaskedRect(this._imageFrame, this._image);
54
54
  }else{
55
55
  context.drawImage(this._image, this._imageFrame);
@@ -65,21 +65,19 @@ JSClass("UIImageLayer", UILayer, {
65
65
  this.setNeedsDisplay();
66
66
  },
67
67
 
68
- setTemplateColor: function(templateColor){
69
- if (templateColor === null && this._templateColor === null){
70
- return;
71
- }
72
- if (templateColor !== null && this._templateColor !== null && templateColor.isEqual(this._templateColor)){
73
- return;
74
- }
75
- this._templateColor = templateColor;
76
- this.setNeedsDisplay();
77
- },
78
-
79
68
  sizeToFit: function(){
80
69
  if (this._image !== null){
81
70
  this.bounds = JSRect(JSPoint.Zero, this._image.size);
82
71
  }
83
72
  }
84
73
 
74
+ });
75
+
76
+ UIImageLayer.Properties = Object.create(UILayer.Properties, {
77
+
78
+ templateColor: {
79
+ writable: true,
80
+ value: null
81
+ }
82
+
85
83
  });
@@ -40,6 +40,9 @@ UILayerAnimatedProperty.prototype.define = function(C, key, extensions){
40
40
  if (value === this.model[key]){
41
41
  return;
42
42
  }
43
+ if (value !== null && this.model[key] !== null && value.isEqual && value.isEqual(this.model[key])){
44
+ return;
45
+ }
43
46
  this._addImplicitAnimationForKey(key);
44
47
  this.model[key] = value;
45
48
  this.didChangeProperty(key);
@@ -145,6 +148,23 @@ JSClass("UILayer", JSObject, {
145
148
  this.didChangeProperty('position');
146
149
  },
147
150
 
151
+ untransformedFrame: JSDynamicProperty(),
152
+
153
+ getUntransformedFrame: function(){
154
+ var bounds = this.model.bounds;
155
+ var anchorPoint = this.model.anchorPoint;
156
+ var offset = JSPoint(anchorPoint.x * bounds.size.width, anchorPoint.y * bounds.size.height);
157
+ return JSRect(this.model.position.subtracting(offset), bounds.size);
158
+ },
159
+
160
+ setUntransformedFrame: function(frame){
161
+ var bounds = this.model.bounds;
162
+ var anchorPoint = this.model.anchorPoint;
163
+ var offset = JSPoint(anchorPoint.x * frame.size.width, anchorPoint.y * frame.size.height);
164
+ this.bounds = JSRect(bounds.origin, frame.size);
165
+ this.position = frame.origin.adding(offset);
166
+ },
167
+
148
168
  setBounds: function(bounds){
149
169
  // When the bounds origin changes, it's like a scrolling view, and we need to update the sublayers
150
170
  // When the bounds change size, the position and frame both need to be recalculated accordingly
@@ -142,6 +142,12 @@ JSClass("UIListView", UIScrollView, {
142
142
  if (spec.containsKey("showsFocusRing")){
143
143
  this._showsFocusRing = spec.valueForKey("showsFocusRing");
144
144
  }
145
+ if (spec.containsKey("listHeaderView")){
146
+ this.listHeaderView = spec.valueForKey("listHeaderView", UIView);
147
+ }
148
+ if (spec.containsKey("listFooterView")){
149
+ this.listFooterView = spec.valueForKey("listFooterView", UIView);
150
+ }
145
151
  },
146
152
 
147
153
  _commonListInit: function(){
@@ -920,6 +926,17 @@ JSClass("UIListView", UIScrollView, {
920
926
  this._cellsContainerView.insertSubviewAtIndex(item.view, viewIndex);
921
927
  },
922
928
 
929
+ sizeToFitSize: function(maxSize){
930
+ var bounds = JSRect(this.bounds.origin, this.contentSize);
931
+ if (maxSize.width < Number.MAX_VALUE){
932
+ bounds.size.width = maxSize.width;
933
+ }
934
+ if (bounds.size.height > maxSize.height){
935
+ bounds.size.height = maxSize.height;
936
+ }
937
+ this.bounds = bounds;
938
+ },
939
+
923
940
  // --------------------------------------------------------------------
924
941
  // MARK: - List Header and Footer
925
942
 
@@ -1544,17 +1561,19 @@ JSClass("UIListView", UIScrollView, {
1544
1561
 
1545
1562
  _createCellAtIndexPath: function(indexPath, rect){
1546
1563
  indexPath = JSIndexPath(indexPath);
1564
+ if (!this.delegate.cellForListViewAtIndexPath){
1565
+ throw new Error("%s must implement cellForListViewAtIndexPath()".sprintf(this.delegate.$class.className));
1566
+ }
1547
1567
  var cell = this.delegate.cellForListViewAtIndexPath(this, indexPath);
1548
1568
  if (cell === null || cell === undefined){
1549
- throw new Error("Got null/undefined cell for indexPath: %s".sprintf(indexPath));
1569
+ throw new Error("%s.cellForListViewAtIndexPath() returned null/undefined cell for indexPath: %s".sprintf(this.delegate.$class.className, indexPath));
1550
1570
  }
1551
1571
  this._adoptCell(cell, indexPath);
1552
1572
  cell.bounds = JSRect(JSPoint.Zero, rect.size);
1553
1573
  cell.position = JSPoint(rect.origin.x + cell.bounds.size.width * cell.anchorPoint.x, rect.origin.y + cell.bounds.size.height * cell.anchorPoint.y);
1554
1574
  cell.active = false;
1555
1575
  this._updateCellState(cell);
1556
- var styler = cell._styler || this._styler;
1557
- styler.updateCell(cell, indexPath);
1576
+ cell.update();
1558
1577
  cell.setNeedsLayout();
1559
1578
  return cell;
1560
1579
  },
@@ -1572,9 +1591,12 @@ JSClass("UIListView", UIScrollView, {
1572
1591
  header = this._stickyHeader;
1573
1592
  this._stickyHeader = null;
1574
1593
  }else{
1594
+ if (!this.delegate.headerViewForListViewSection){
1595
+ throw new Error("%s must implement headerViewForListViewSection() when headerHeight is non-zero".sprintf(this.delegate.$class.className));
1596
+ }
1575
1597
  header = this.delegate.headerViewForListViewSection(this, section);
1576
1598
  if (header === null || header === undefined){
1577
- throw new Error("Got null/undefined header for section: %d".sprintf(section));
1599
+ throw new Error("%s.headerViewForListViewSection() returned null/undefined header for section: %d".sprintf(this.delegate.$class.className, section));
1578
1600
  }
1579
1601
  }
1580
1602
  header.kind = UIListViewHeaderFooterView.Kind.header;
@@ -1582,19 +1604,24 @@ JSClass("UIListView", UIScrollView, {
1582
1604
  header.bounds = JSRect(JSPoint.Zero, rect.size);
1583
1605
  header.position = JSPoint(rect.origin.x + header.bounds.size.width * header.anchorPoint.x, rect.origin.y + header.bounds.size.height * header.anchorPoint.y);
1584
1606
  this._styler.updateHeader(header, section);
1607
+ header.setNeedsLayout();
1585
1608
  return header;
1586
1609
  },
1587
1610
 
1588
1611
  _createFooterAtSection: function(section, rect){
1612
+ if (!this.delegate.footerViewForListViewSection){
1613
+ throw new Error("%s must implement footerViewForListViewSection() when footerHeight is non-zero".sprintf(this.delegate.$class.className));
1614
+ }
1589
1615
  var footer = this.delegate.footerViewForListViewSection(this, section);
1590
1616
  if (footer === null || footer === undefined){
1591
- throw new Error("Got null/undefined footer for section: %d".sprintf(section));
1617
+ throw new Error("%s.headerViewForListViewSection() returned null/undefined header for section: %d".sprintf(this.delegate.$class.className, section));
1592
1618
  }
1593
1619
  footer.kind = UIListViewHeaderFooterView.Kind.footer;
1594
1620
  footer.section = section;
1595
1621
  footer.bounds = JSRect(JSPoint.Zero, rect.size);
1596
1622
  footer.position = JSPoint(rect.origin.x + footer.bounds.size.width * footer.anchorPoint.x, rect.origin.y + footer.bounds.size.height * footer.anchorPoint.y);
1597
1623
  this._styler.updateFooter(footer, section);
1624
+ footer.setNeedsLayout();
1598
1625
  return footer;
1599
1626
  },
1600
1627
 
@@ -1961,12 +1988,10 @@ JSClass("UIListView", UIScrollView, {
1961
1988
 
1962
1989
  _updateVisibleCellStyles: function(){
1963
1990
  var item;
1964
- var styler;
1965
1991
  for (var i = 0, l = this._visibleItems.length; i < l; ++i){
1966
1992
  item = this._visibleItems[i];
1967
1993
  if (item.kind === VisibleItem.Kind.cell){
1968
- styler = item.view._styler || this._styler;
1969
- styler.updateCell(item.view, item.view.indexPath);
1994
+ item.view.update();
1970
1995
  }
1971
1996
  }
1972
1997
  },
@@ -2578,6 +2603,20 @@ JSClass("UIListView", UIScrollView, {
2578
2603
  return indexPaths;
2579
2604
  },
2580
2605
 
2606
+ visibleCells: JSReadOnlyProperty(),
2607
+
2608
+ getVisibleCells: function(){
2609
+ var cells = [];
2610
+ var item;
2611
+ for (var i = 0, l = this._visibleItems.length; i < l; ++i){
2612
+ item = this._visibleItems[i];
2613
+ if (item.kind === VisibleItem.Kind.cell){
2614
+ cells.push(item.view);
2615
+ }
2616
+ }
2617
+ return cells;
2618
+ },
2619
+
2581
2620
  // --------------------------------------------------------------------
2582
2621
  // MARK: - Scrolling
2583
2622
 
@@ -2766,7 +2805,7 @@ VisibleItemIterator.prototype = Object.create({}, {
2766
2805
  value: function(){
2767
2806
  var height;
2768
2807
  var item;
2769
- if (this.item !== null && this.item.Kind === VisibleItem.Kind.footer){
2808
+ if (this.item !== null && this.item.kind === VisibleItem.Kind.footer){
2770
2809
  ++this.section;
2771
2810
  }
2772
2811
  while (this.section < this.listView.__numberOfSections){
@@ -2787,7 +2826,7 @@ VisibleItemIterator.prototype = Object.create({}, {
2787
2826
  item = new VisibleItem(VisibleItem.Kind.cell, JSRect(0, this.y, this.width, height), this.cellIterator.indexPath);
2788
2827
  return item;
2789
2828
  }
2790
- if (this.item === null || this.item.section <= this.section){
2829
+ if (this.item === null || this.item.indexPath.section <= this.section){
2791
2830
  height = this.listView._heightForFooterInSection(this.section);
2792
2831
  if (height > 0){
2793
2832
  item = new VisibleItem(VisibleItem.Kind.footer, JSRect(0, this.y, this.width, height), JSIndexPath([this.section]));
@@ -3130,7 +3169,8 @@ JSClass("UIListViewDefaultStyler", UIListViewStyler, {
3130
3169
  }
3131
3170
  if (cell.selected){
3132
3171
  cell.contentView.borderColor = this.contextSelectedCellBorderColor;
3133
- if (this.showsMutedState && !cell.listView.keyActive){
3172
+ var showsMutedState = this.showsMutedState && UIDevice.shared && UIDevice.shared.primaryPointerType != UIUserInterface.PointerType.touch;
3173
+ if (showsMutedState && !cell.listView.keyActive){
3134
3174
  cell.contentView.backgroundColor = this.mutedSelectedCellBackgroundColor;
3135
3175
  if (cell._titleLabel !== null){
3136
3176
  cell._titleLabel.textColor = this.mutedSelectedCellTextColor;
@@ -3211,7 +3251,7 @@ JSClass("UIListViewDefaultStyler", UIListViewStyler, {
3211
3251
 
3212
3252
  layoutCell: function(cell){
3213
3253
  cell._contentView.frame = cell.bounds.rectWithInsets(this.cellContentInsets);
3214
- var size = JSSize(cell.bounds.size.width - cell._titleInsets.left - cell._titleInsets.right, 0);
3254
+ var size = JSSize(cell._contentView.bounds.size.width - cell._titleInsets.width, 0);
3215
3255
  var origin = JSPoint(cell._titleInsets.left, 0);
3216
3256
  var indent = this._indentationForCell(cell);
3217
3257
  origin.x += indent;
@@ -41,10 +41,17 @@ JSClass("UIListViewHeaderFooterView", UIView, {
41
41
  initWithSpec: function(spec){
42
42
  UIListViewHeaderFooterView.$super.initWithSpec.call(this, spec);
43
43
  this._commonHeaderFooterInit();
44
+ if (spec.containsKey("accessorySize")){
45
+ this._accessorySize = spec.valueForKey("accessorySize", JSSize);
46
+ }
47
+ if (spec.containsKey("accessoryView")){
48
+ this.accessoryView = spec.valueForKey("accessoryView", UIView);
49
+ }
44
50
  },
45
51
 
46
52
  _commonHeaderFooterInit: function(){
47
53
  this.stylerProperties = {};
54
+ this._accessorySize = JSSize(20, 20);
48
55
  this._titleInsets = JSInsets(0, 10);
49
56
  this._contentView = UIView.init();
50
57
  this.addSubview(this._contentView);
@@ -66,12 +73,39 @@ JSClass("UIListViewHeaderFooterView", UIView, {
66
73
  this._titleInsets = JSInsets(titleInsets);
67
74
  this.setNeedsLayout();
68
75
  },
76
+
77
+ accessoryView: JSDynamicProperty("_accessoryView", null),
78
+ accessorySize: JSDynamicProperty("_accessorySize", null),
79
+
80
+ setAccessoryView: function(accessoryView){
81
+ if (accessoryView === this._accessoryView){
82
+ return;
83
+ }
84
+ if (this._accessoryView !== null){
85
+ this._accessoryView.removeFromSuperview();
86
+ }
87
+ this._accessoryView = accessoryView;
88
+ if (this._accessoryView !== null){
89
+ this.contentView.addSubview(this._accessoryView);
90
+ }
91
+ this.setNeedsLayout();
92
+ },
93
+
94
+ setAccessorySize: function(size){
95
+ this._accessorySize = JSSize(size);
96
+ this.setNeedsLayout();
97
+ },
69
98
 
70
99
  layoutSubviews: function(){
71
100
  UIListViewHeaderFooterView.$super.layoutSubviews.call(this);
72
101
  this._contentView.frame = this.bounds;
73
102
  var size = JSSize(this.bounds.size.width - this._titleInsets.left - this._titleInsets.right, 0);
74
103
  var origin = JSPoint(this._titleInsets.left, 0);
104
+ if (this._accessoryView !== null){
105
+ this._accessoryView.bounds = JSRect(JSPoint.Zero, this._accessorySize);
106
+ this._accessoryView.position = JSPoint(origin.x + size.width - this._accessorySize.width / 2, this._contentView.bounds.center.y);
107
+ size.width -= this._accessorySize.width + this._titleInsets.right;
108
+ }
75
109
  if (this._titleLabel !== null){
76
110
  if (this._detailLabel !== null){
77
111
  size.height = this._titleLabel.font.displayLineHeight + this._detailLabel.font.displayLineHeight;
@@ -90,11 +90,11 @@ JSClass("UINavigationBar", UIView, {
90
90
  pushAnimator: null,
91
91
 
92
92
  createPushAnimator: function(){
93
- return UIViewPropertyAnimator.initWithDuration(0.2, UIAnimation.Timing.easeInOut);
93
+ return UIViewPropertyAnimator.initWithDuration(UIAnimation.Duration.transition, UIAnimation.Timing.easeInOut);
94
94
  },
95
95
 
96
96
  createPopAnimator: function(){
97
- return UIViewPropertyAnimator.initWithDuration(0.2, UIAnimation.Timing.easeInOut);
97
+ return UIViewPropertyAnimator.initWithDuration(UIAnimation.Duration.transition, UIAnimation.Timing.easeInOut);
98
98
  },
99
99
 
100
100
  pushItem: function(item, animated){
@@ -776,6 +776,8 @@ JSClass("UINavigationBarDefaultStyler", UINavigationBarStyler, {
776
776
  button._imageView.automaticRenderMode = JSImage.RenderMode.template;
777
777
  }
778
778
  button.addAction(barItem.action, barItem.target);
779
+ button.enabled = barItem.enabled;
780
+ barItem._barButton = button;
779
781
  return button;
780
782
  }
781
783
 
@@ -28,6 +28,14 @@ JSClass("UINavigationBarItem", JSObject, {
28
28
  action: JSDynamicProperty('_action', null),
29
29
  enabled: JSDynamicProperty('_enabled', true),
30
30
  view: JSDynamicProperty('_view', null),
31
+ _barButton: null,
32
+
33
+ initWithTitle: function(title, action, target){
34
+ this._title = title;
35
+ this._target = target;
36
+ this._action = action;
37
+ this._commonItemInit();
38
+ },
31
39
 
32
40
  initWithImage: function(image, action, target){
33
41
  this._image = image;
@@ -81,6 +89,9 @@ JSClass("UINavigationBarItem", JSObject, {
81
89
  if (this._view !== null && this._view.isKindOfClass(UIControl)){
82
90
  this._view.enabled = this.enabled;
83
91
  }
92
+ if (this._barButton !== null){
93
+ this._barButton.enabled = this.enabled;
94
+ }
84
95
  }
85
96
 
86
97
  });
@@ -152,11 +152,11 @@ JSClass("UINavigationController", UIViewController, {
152
152
  pushAnimator: null,
153
153
 
154
154
  createPushAnimator: function(){
155
- return UIViewPropertyAnimator.initWithDuration(0.3, UIAnimation.Timing.easeInOut);
155
+ return UIViewPropertyAnimator.initWithDuration(UIAnimation.Duration.transition, UIAnimation.Timing.easeInOut);
156
156
  },
157
157
 
158
158
  createPopAnimator: function(){
159
- return UIViewPropertyAnimator.initWithDuration(0.3, UIAnimation.Timing.easeInOut);
159
+ return UIViewPropertyAnimator.initWithDuration(UIAnimation.Duration.transition, UIAnimation.Timing.easeInOut);
160
160
  },
161
161
 
162
162
  pushViewController: function(viewController, animated){
@@ -120,70 +120,18 @@ JSClass("UISplitViewController", UIViewController, {
120
120
  },
121
121
 
122
122
  setLeadingViewController: function(leadingViewController){
123
- var callAppearanceMethods = this.isViewVisible && this.leadingViewOpen;
124
- var disappearingViewController = null;
125
- if (this._leadingViewController !== null){
126
- if (callAppearanceMethods){
127
- this._leadingViewController.viewWillDisappear(false);
128
- disappearingViewController = this._leadingViewController;
129
- }
130
- this._leadingViewController.removeFromParentViewController();
131
- }
123
+ this.replaceChildViewController(this._leadingViewController, leadingViewController);
132
124
  this._leadingViewController = leadingViewController;
133
- if (this._leadingViewController){
134
- if (callAppearanceMethods){
135
- this._leadingViewController.viewWillAppear(false);
136
- }
137
- this.addChildViewController(this._leadingViewController);
138
- }
139
- if (this._view !== null){
140
- var view = null;
141
- if (this._leadingViewController !== null){
142
- view = this._leadingViewController.view;
143
- }
144
- this._view.leadingView = view;
145
- }
146
- if (callAppearanceMethods){
147
- if (disappearingViewController !== null){
148
- disappearingViewController.enqueueDidDisappear();
149
- }
150
- if (this._leadingViewController !== null){
151
- this._leadingViewController.enqueueDidAppear();
152
- }
125
+ if (this.isViewLoaded){
126
+ this.view.leadingView = leadingViewController !== null ? leadingViewController.view : null;
153
127
  }
154
128
  },
155
129
 
156
130
  setTrailingViewController: function(trailingViewController){
157
- var callAppearanceMethods = this.isViewVisible && this.trailingViewOpen;
158
- var disappearingViewController = null;
159
- if (this._trailingViewController !== null){
160
- if (callAppearanceMethods){
161
- this._trailingViewController.viewWillDisappear(false);
162
- disappearingViewController = this._trailingViewController;
163
- }
164
- this._trailingViewController.removeFromParentViewController();
165
- }
131
+ this.replaceChildViewController(this._trailingViewController, trailingViewController);
166
132
  this._trailingViewController = trailingViewController;
167
- if (this._trailingViewController){
168
- if (callAppearanceMethods){
169
- this._trailingViewController.viewWillAppear(false);
170
- }
171
- this.addChildViewController(this._trailingViewController);
172
- }
173
- if (this._view !== null){
174
- var view = null;
175
- if (this._trailingViewController !== null){
176
- view = this._trailingViewController.view;
177
- }
178
- this._view.trailingView = view;
179
- }
180
- if (callAppearanceMethods){
181
- if (disappearingViewController !== null){
182
- disappearingViewController.enqueueDidDisappear();
183
- }
184
- if (this._trailingViewController !== null){
185
- this._trailingViewController.enqueueDidAppear();
186
- }
133
+ if (this.isViewLoaded){
134
+ this.view.trailingView = trailingViewController !== null ? trailingViewController.view : null;
187
135
  }
188
136
  },
189
137
 
@@ -192,36 +140,10 @@ JSClass("UISplitViewController", UIViewController, {
192
140
  this._setMainViewControllerCollapsed(mainViewController);
193
141
  return;
194
142
  }
195
- var callAppearanceMethods = this.isViewVisible;
196
- var disappearingViewController = null;
197
- if (this._mainViewController !== null && this._mainViewController.parentViewController === this){
198
- if (callAppearanceMethods){
199
- this._mainViewController.viewWillDisappear(false);
200
- disappearingViewController = this._mainViewController;
201
- }
202
- this._mainViewController.removeFromParentViewController();
203
- }
143
+ this.replaceChildViewController(this._mainViewController, mainViewController);
204
144
  this._mainViewController = mainViewController;
205
- if (this._mainViewController){
206
- if (callAppearanceMethods){
207
- this._mainViewController.viewWillAppear(false);
208
- }
209
- this.addChildViewController(this._mainViewController);
210
- }
211
- if (this._view !== null){
212
- var view = null;
213
- if (this._mainViewController !== null){
214
- view = this._mainViewController.view;
215
- }
216
- this._view.mainView = view;
217
- }
218
- if (callAppearanceMethods){
219
- if (disappearingViewController !== null){
220
- disappearingViewController.enqueueDidDisappear();
221
- }
222
- if (this._mainViewController !== null){
223
- this._mainViewController.enqueueDidAppear();
224
- }
145
+ if (this.isViewLoaded){
146
+ this.view.mainView = mainViewController !== null ? mainViewController.view : null;
225
147
  }
226
148
  },
227
149
 
@@ -790,10 +790,10 @@ JSClass("UITabViewDefaultStyler", UITabViewStyler, {
790
790
  this.activeSelectedTitleColor = this.selectedTitleColor;
791
791
  }
792
792
  if (this.normalItemColor === null){
793
- this.normalItemColor = JSColor.highlight;
793
+ this.normalItemColor = JSColor.controlBackground;
794
794
  }
795
795
  if (this.selectedItemColor === null){
796
- this.selectedItemColor = JSColor.highlight.colorDarkenedByPercentage(0.2);
796
+ this.selectedItemColor = JSColor.highlight;
797
797
  }
798
798
  if (this.activeItemColor === null){
799
799
  this.activeItemColor = this.normalItemColor.colorDarkenedByPercentage(0.1);
@@ -30,11 +30,12 @@ JSClass("UITabViewController", UIViewController, {
30
30
  initWithViewControllers: function(viewControllers, styler){
31
31
  UITabViewController.$super.init.call(this);
32
32
  this._viewControllers = JSCopy(viewControllers);
33
- this._styler = styler || null;
33
+ this._tabViewStyler = styler || null;
34
34
  },
35
35
 
36
36
  initWithSpec: function(spec){
37
37
  this._viewControllers = [];
38
+ this._tabViewStyler = null;
38
39
  var viewController;
39
40
  var i, l;
40
41
  if (spec.containsKey('viewControllers')){
@@ -51,7 +52,7 @@ JSClass("UITabViewController", UIViewController, {
51
52
  },
52
53
 
53
54
  loadView: function(){
54
- this._view = UITabView.initWithStyler(this._styler);
55
+ this._view = UITabView.initWithStyler(this._tabViewStyler);
55
56
  },
56
57
 
57
58
  viewDidLoad: function(){
@@ -85,9 +86,9 @@ JSClass("UITabViewController", UIViewController, {
85
86
  selectedViewController.viewWillDisappear(animated);
86
87
  }
87
88
  },
88
-
89
- viewDisDisappear: function(animated){
90
- UITabViewController.$super.viewDisDisappear.call(this, animated);
89
+
90
+ viewDidDisappear: function(animated){
91
+ UITabViewController.$super.viewDidDisappear.call(this, animated);
91
92
  var selectedViewController = this.selectedViewController;
92
93
  if (selectedViewController !== null){
93
94
  selectedViewController.viewDidDisappear(animated);
@@ -45,7 +45,7 @@ JSClass("UITextLayer", UILayer, {
45
45
  text: JSDynamicProperty(),
46
46
  attributedText: JSDynamicProperty(),
47
47
  font: JSDynamicProperty(),
48
- textColor: JSDynamicProperty(),
48
+ textColor: UILayerAnimatedProperty(),
49
49
  lineBreakMode: UITextLayerContainerProperty(),
50
50
  textAlignment: UITextLayerContainerProperty(),
51
51
  lineSpacing: UITextLayerContainerProperty(),
@@ -74,6 +74,7 @@ JSClass("UITextLayer", UILayer, {
74
74
  this._textStorage = JSTextStorage.init();
75
75
  this._textStorage.addLayoutManager(this._textLayoutManager);
76
76
  this._textLayoutManager.addTextContainer(this._textContainer);
77
+ this.model.textColor = JSColor.black;
77
78
  this.font = JSFont.systemFontOfSize(JSFont.Size.normal);
78
79
  this.setNeedsLayout();
79
80
  },
@@ -95,15 +96,6 @@ JSClass("UITextLayer", UILayer, {
95
96
  }
96
97
  this._textLayoutManager.defaultFont = font;
97
98
  },
98
-
99
- getTextColor: function(){
100
- return this._textLayoutManager.defaultTextColor;
101
- },
102
-
103
- setTextColor: function(color){
104
- this._textLayoutManager.defaultTextColor = color;
105
- this.setNeedsDisplay();
106
- },
107
99
 
108
100
  setTextInsets: function(insets){
109
101
  this._textInsets = JSInsets(insets);
@@ -190,6 +182,7 @@ JSClass("UITextLayer", UILayer, {
190
182
 
191
183
  drawInContext: function(context){
192
184
  var textOrigin = JSPoint(this._textInsets.left, this._textInsets.top);
185
+ this._textLayoutManager.defaultTextColor = this.presentation.textColor;
193
186
  this._textLayoutManager.layoutIfNeeded();
194
187
  this._textLayoutManager.drawContainerInContextAtPoint(this._textContainer, context, textOrigin);
195
188
  this._displayQueued = false;
@@ -217,6 +210,7 @@ JSClass("UITextLayer", UILayer, {
217
210
  layoutSublayers: function(){
218
211
  UITextLayer.$super.layoutSublayers.call(this);
219
212
  this._textContainer.origin = JSPoint(this._textInsets.left, this._textInsets.top);
213
+ this._textLayoutManager.defaultTextColor = this.presentation.textColor;
220
214
  this._textLayoutManager.layoutIfNeeded();
221
215
  if ((this._widthTracksText || this._heightTracksText) && this._textContainer.textFrame !== null){
222
216
  var width = this.bounds.size.width;
@@ -268,4 +262,11 @@ JSClass("UITextLayer", UILayer, {
268
262
 
269
263
  });
270
264
 
265
+ UITextLayer.Properties = Object.create(UILayer.Properties, {
266
+ textColor: {
267
+ writable: true,
268
+ value: null,
269
+ }
270
+ });
271
+
271
272
  })();