@momo-kits/arrangement-view 0.167.1-duo.2 → 0.168.1-beta.2

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.
@@ -8,6 +8,7 @@ private final class ArrangementModel: ObservableObject {
8
8
  @Published var axes = "both"
9
9
  @Published var observeHinge = true
10
10
  @Published var forceSplit = false
11
+ @Published var primaryRatio: Double = 0
11
12
  var hingeChanged: ((Bool, Double, String) -> Void)?
12
13
  var paneLayout: ((UIView, CGRect) -> Void)?
13
14
  weak var host: UIView?
@@ -115,8 +116,12 @@ private struct ArrangementContent: View {
115
116
  ArrangementView { primary } secondary: { secondary }
116
117
  .arrangementViewStyle(.overlay.axes(model.supportedAxes))
117
118
  } else {
118
- ArrangementView { primary } secondary: { secondary }
119
- .arrangementViewStyle(.split.axes(model.supportedAxes))
119
+ ArrangementView {
120
+ primary.splitArrangementLayoutRatio(model.primaryRatio > 0 ? CGFloat(model.primaryRatio) : nil)
121
+ } secondary: {
122
+ secondary
123
+ }
124
+ .arrangementViewStyle(.split.axes(model.supportedAxes))
120
125
  }
121
126
  }
122
127
  #endif
@@ -158,8 +163,11 @@ public final class RNArrangementHost: UIView {
158
163
  if model.primary !== primary { model.primary = primary }
159
164
  if model.secondary !== secondary { model.secondary = secondary }
160
165
  }
161
- @objc public func configure(_ arrangement: String, axes: String, observeHinge: Bool, forceSplit: Bool) {
166
+ @objc public func configure(
167
+ _ arrangement: String, axes: String, observeHinge: Bool, forceSplit: Bool, primaryRatio: Double
168
+ ) {
162
169
  if model.forceSplit != forceSplit { model.forceSplit = forceSplit }
170
+ if model.primaryRatio != primaryRatio { model.primaryRatio = primaryRatio }
163
171
  if model.arrangement != arrangement { model.arrangement = arrangement }
164
172
  if model.axes != axes { model.axes = axes }
165
173
  if model.observeHinge != observeHinge {
@@ -67,7 +67,11 @@ using namespace facebook::react;
67
67
  NSString *axes = @"both";
68
68
  if (next.axes == RNArrangementViewAxes::Horizontal) axes = @"horizontal";
69
69
  if (next.axes == RNArrangementViewAxes::Vertical) axes = @"vertical";
70
- [_host configure:arrangement axes:axes observeHinge:next.observeHinge forceSplit:next.forceSplit];
70
+ [_host configure:arrangement
71
+ axes:axes
72
+ observeHinge:next.observeHinge
73
+ forceSplit:next.forceSplit
74
+ primaryRatio:next.primaryRatio];
71
75
  [super updateProps:props oldProps:oldProps];
72
76
  }
73
77
  @end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/arrangement-view",
3
- "version": "0.167.1-duo.2",
3
+ "version": "0.168.1-beta.2",
4
4
  "description": "Foldable-aware two-pane arrangement and hinge observation. Fork of react-native-arrangement-view 0.2.0 (MIT, Thiago Brezinski).",
5
5
  "main": "./src/index.tsx",
6
6
  "files": [
@@ -51,4 +51,4 @@
51
51
  }
52
52
  },
53
53
  "dependencies": {}
54
- }
54
+ }
@@ -36,6 +36,8 @@ export interface NativeProps extends ViewProps {
36
36
  observeHinge?: CodegenTypes.WithDefault<boolean, true>;
37
37
  /** iOS only: split side by side whatever the size classes. */
38
38
  forceSplit?: CodegenTypes.WithDefault<boolean, false>;
39
+ /** iOS only: share of the width the primary pane takes when split, 0 lets the system decide. */
40
+ primaryRatio?: CodegenTypes.WithDefault<CodegenTypes.Double, 0>;
39
41
  onHingeChange?: CodegenTypes.DirectEventHandler<HingeEvent>;
40
42
  /** Android only: the sizes and fold that arrange.ts lays the panes out by. */
41
43
  onGeometryChange?: CodegenTypes.DirectEventHandler<GeometryEvent>;
package/src/SplitView.tsx CHANGED
@@ -25,6 +25,12 @@ export interface SplitViewProps extends ViewProps {
25
25
  * screen while only `primary` is shown.
26
26
  */
27
27
  onSplitChange?: (isSplit: boolean) => void;
28
+
29
+ /**
30
+ * Optional. iOS only. Share of the width `primary` takes beside `secondary`, e.g. 0.35
31
+ * for a sidebar like Settings. Default: the system decides.
32
+ */
33
+ primaryRatio?: number;
28
34
  }
29
35
 
30
36
  // the iPhone Duo outer display is 466pt on its short side, the inner display 669pt
package/src/types.ts CHANGED
@@ -25,6 +25,11 @@ export interface ArrangementViewProps extends ViewProps {
25
25
  observeHinge?: boolean;
26
26
  /** iOS only. Split side by side whatever the size classes. Default false. */
27
27
  forceSplit?: boolean;
28
+ /**
29
+ * iOS only. Share of the width the primary pane takes when split side by side,
30
+ * e.g. 0.35 for a sidebar like Settings. Default: the system decides.
31
+ */
32
+ primaryRatio?: number;
28
33
  /**
29
34
  * Android only. Which hinges the panes keep clear of: `avoidSeparating`
30
35
  * (default) a half-open one, `alwaysAvoid` a flat one too, `neverAvoid` none.