@legendapp/spark 0.0.1-next.3 → 0.0.1-next.5
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.
- package/README.md +1 -1
- package/camera.ts +13 -0
- package/customize.ts +2 -0
- package/html.ts +1 -0
- package/markdown.ts +1 -0
- package/package.json +34 -15
- package/patches/camera/react-native-nitro-image.patch +320 -0
- package/patches/camera/react-native-nitro-modules.patch +50 -0
- package/patches/camera/react-native-vision-camera.patch +2662 -0
- package/patches/camera/upstream.json +22 -0
- package/patches/dependencies.json +14 -0
- package/patches/react-native-enriched-html@1.1.1.patch +854 -0
- package/patches/react-native-enriched-markdown@1.1.1.patch +9261 -0
- package/postinstall.cjs +1 -0
- package/schema.json +104 -0
- package/skills/spark/SKILL.md +56 -0
- package/skills/spark/UPGRADING.md +246 -0
- package/ui-swipe.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-ai/package.json +4 -4
- package/vendor/node_modules/@legendapp/spark-ai/src/invocation-command.cjs +11 -0
- package/vendor/node_modules/@legendapp/spark-ai/src/invocation-command.d.cts +2 -0
- package/vendor/node_modules/@legendapp/spark-ai/src/invocations.ts +2 -19
- package/vendor/node_modules/@legendapp/spark-audio/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-auth-session/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-cli/dist/add-desktop.js +4 -4
- package/vendor/node_modules/@legendapp/spark-cli/dist/build.js +65 -11
- package/vendor/node_modules/@legendapp/spark-cli/dist/cli-arguments.js +2 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/commands.js +3 -2
- package/vendor/node_modules/@legendapp/spark-cli/dist/create.js +36 -13
- package/vendor/node_modules/@legendapp/spark-cli/dist/credentials.js +41 -26
- package/vendor/node_modules/@legendapp/spark-cli/dist/customize-ai.cjs +108 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/customize-artifacts.js +315 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/customize-cli.cjs +75 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/customize-github.cjs +133 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/customize-policy.cjs +102 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/customize-provider.cjs +2 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/customize-worker.cjs +273 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/dependency-pins.js +157 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/dev-command.js +3 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/dev.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/enriched-html-pins.js +128 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/errors.js +100 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/examples.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/expo-dev-patch.cjs +30 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/expo-native.cjs +5 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/helpers.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/index.js +52 -7
- package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.d.cts +1 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/js-runtime.cjs +96 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/json.js +16 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.cjs +152 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.d.cts +15 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/migrations.cjs +184 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/migrations.d.cts +16 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/native-patch-preflight.js +5 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/package-manager-config.js +41 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/package-manager.js +13 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/process.js +7 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/project-version.js +12 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/project.js +66 -30
- package/vendor/node_modules/@legendapp/spark-cli/dist/release.js +2 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/release.json +20 -20
- package/vendor/node_modules/@legendapp/spark-cli/dist/runtime-bootstrap.ps1 +87 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/runtime-bootstrap.sh +107 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/runtime-downloads.tsv +13 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/sdk-install.js +8 -3
- package/vendor/node_modules/@legendapp/spark-cli/dist/universal.cjs +2 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/upgrade.js +102 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/windows.js +1 -8
- package/vendor/node_modules/@legendapp/spark-cli/package.json +6 -4
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/.claude/skills/spark/SKILL.md +9 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/AGENTS.md +4 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/CLAUDE.md +4 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/README.md +15 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/package.json +47 -3
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/.claude/skills/spark/SKILL.md +9 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/AGENTS.md +4 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/CLAUDE.md +4 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/README.md +15 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/package.json +46 -3
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/.claude/skills/spark/SKILL.md +9 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/AGENTS.md +4 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/CLAUDE.md +4 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/README.md +15 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/package.json +47 -3
- package/vendor/node_modules/@legendapp/spark-clipboard/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-codex/package.json +4 -4
- package/vendor/node_modules/@legendapp/spark-commands/package.json +6 -6
- package/vendor/node_modules/@legendapp/spark-context-menu/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/RNDesktopApp.mm +14 -1
- package/vendor/node_modules/@legendapp/spark-desktop-app/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/contracts/menu.ts +6 -4
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/customize-hooks.ts +17 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/customize.ts +117 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/app.plugin.cjs +20 -1
- package/vendor/node_modules/@legendapp/spark-desktop-config/config.cjs +5 -2
- package/vendor/node_modules/@legendapp/spark-desktop-config/config.d.cts +14 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/customize-provider.cjs +16 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/customize.cjs +16 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/expo.cjs +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.cjs +106 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.d.cts +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/package.json +5 -4
- package/vendor/node_modules/@legendapp/spark-desktop-config/schema.json +104 -0
- package/vendor/node_modules/@legendapp/spark-desktop-host/SparkCustomize.mm +517 -0
- package/vendor/node_modules/@legendapp/spark-desktop-host/package.json +4 -3
- package/vendor/node_modules/@legendapp/spark-desktop-links/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/macos/RNDesktopShortcuts.mm +3 -1
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/macos/keyboard-manager/RNKeyboardManager.h +3 -0
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/macos/keyboard-manager/RNKeyboardManager.mm +1 -1
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManager.mm +44 -4
- package/vendor/node_modules/@legendapp/spark-desktop-windows/package.json +4 -4
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/api.ts +65 -26
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/macos-adapter.ts +8 -6
- package/vendor/node_modules/@legendapp/spark-documents/package.json +8 -8
- package/vendor/node_modules/@legendapp/spark-drag-drop/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-file-dialog/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-file-system/macos/SparkFileMutations.h +1 -0
- package/vendor/node_modules/@legendapp/spark-file-system/macos/SparkFileMutations.mm +11 -10
- package/vendor/node_modules/@legendapp/spark-file-system/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-html/package.json +24 -0
- package/vendor/node_modules/@legendapp/spark-html/src/Html.tsx +22 -0
- package/vendor/node_modules/@legendapp/spark-html/src/HtmlInput.tsx +102 -0
- package/vendor/node_modules/@legendapp/spark-html/src/index.ts +4 -0
- package/vendor/node_modules/@legendapp/spark-html/src/types.ts +4 -0
- package/vendor/node_modules/@legendapp/spark-markdown/package.json +24 -0
- package/vendor/node_modules/@legendapp/spark-markdown/src/Markdown.tsx +24 -0
- package/vendor/node_modules/@legendapp/spark-markdown/src/MarkdownInput.tsx +111 -0
- package/vendor/node_modules/@legendapp/spark-markdown/src/index.ts +4 -0
- package/vendor/node_modules/@legendapp/spark-message-dialog/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-native-menu/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-notifications/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/SparkNotifications.h +16 -11
- package/vendor/node_modules/@legendapp/spark-processes/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-rich-text/package.json +18 -0
- package/vendor/node_modules/@legendapp/spark-rich-text/src/components.tsx +52 -0
- package/vendor/node_modules/@legendapp/spark-rich-text/src/index.ts +4 -0
- package/vendor/node_modules/@legendapp/spark-rich-text/src/types.ts +24 -0
- package/vendor/node_modules/@legendapp/spark-rich-text/src/useInputShortcuts.macos.ts +55 -0
- package/vendor/node_modules/@legendapp/spark-rich-text/src/useInputShortcuts.ts +13 -0
- package/vendor/node_modules/@legendapp/spark-rich-text/src/useInputValue.ts +14 -0
- package/vendor/node_modules/@legendapp/spark-rich-text/src/value.ts +16 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-settings/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-settings-ui/package.json +5 -5
- package/vendor/node_modules/@legendapp/spark-sqlite/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-system/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-tray/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSidebarSplitViewComponent.mm +360 -35
- package/vendor/node_modules/@legendapp/spark-ui/macos/swipe-actions/RNSwipeActions.h +10 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/swipe-actions/RNSwipeActions.mm +422 -0
- package/vendor/node_modules/@legendapp/spark-ui/package.json +4 -3
- package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SidebarSplitViewNativeComponent.ts +11 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/index.tsx +30 -13
- package/vendor/node_modules/@legendapp/spark-ui/src/swipe-actions/SwipeActionsNativeComponent.ts +11 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/swipe-actions/index.tsx +41 -0
- package/vendor/node_modules/@legendapp/spark-updates/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-webview/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-window-options/package.json +1 -1
|
@@ -203,8 +203,97 @@ static void RNSidebarSplitViewApplyColorOverlay(NSView *view, NSColor *color, CG
|
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
+
// Pane containers are transparent, so a thin divider showed the window's (white) background through it,
|
|
207
|
+
// which is invisible in light mode and a bright stripe in dark mode. Paint it opaquely with semantic colors
|
|
208
|
+
// that resolve against the drawing appearance.
|
|
209
|
+
@interface RNSidebarSplitViewNativeSplitView : NSSplitView
|
|
210
|
+
/// YES while the user drags a divider.
|
|
211
|
+
@property (nonatomic, readonly) BOOL trackingDivider;
|
|
212
|
+
@end
|
|
213
|
+
|
|
214
|
+
@implementation RNSidebarSplitViewNativeSplitView
|
|
215
|
+
|
|
216
|
+
// NSSplitView only receives mouseDown: on a divider, and tracks the whole drag inside it.
|
|
217
|
+
- (void)mouseDown:(NSEvent *)event
|
|
218
|
+
{
|
|
219
|
+
_trackingDivider = YES;
|
|
220
|
+
[super mouseDown:event];
|
|
221
|
+
_trackingDivider = NO;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// While a divider drags, panes resize under a still cursor and pane edges pass beneath it. React views take
|
|
225
|
+
// hover from a window hit test, so claiming the hit here keeps rows from flickering hover states (and starting
|
|
226
|
+
// their hover animations) every frame of the drag.
|
|
227
|
+
- (NSView *)hitTest:(NSPoint)point
|
|
228
|
+
{
|
|
229
|
+
if (_trackingDivider) {
|
|
230
|
+
return NSPointInRect([self convertPoint:point fromView:self.superview], self.bounds) ? self : nil;
|
|
231
|
+
}
|
|
232
|
+
return [super hitTest:point];
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
- (NSColor *)dividerColor
|
|
236
|
+
{
|
|
237
|
+
return NSColor.separatorColor;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
- (void)drawDividerInRect:(NSRect)rect
|
|
241
|
+
{
|
|
242
|
+
// AppKit hands a sidebar's divider a 0.5pt hairline rect but still reserves the full dividerThickness. The
|
|
243
|
+
// other half of the gap is left to the split view's own backing, which shows as a bright column in dark mode.
|
|
244
|
+
// Paint the whole gap, then the hairline.
|
|
245
|
+
NSRect gap = rect;
|
|
246
|
+
if (self.vertical) {
|
|
247
|
+
gap.size.width = MAX(rect.size.width, self.dividerThickness);
|
|
248
|
+
} else {
|
|
249
|
+
gap.size.height = MAX(rect.size.height, self.dividerThickness);
|
|
250
|
+
}
|
|
251
|
+
[NSColor.windowBackgroundColor setFill];
|
|
252
|
+
NSRectFill(gap);
|
|
253
|
+
[self.dividerColor setFill];
|
|
254
|
+
NSRectFillUsingOperation(rect, NSCompositingOperationSourceOver);
|
|
255
|
+
}
|
|
256
|
+
@end
|
|
257
|
+
|
|
258
|
+
// List and content panes are opaque in the window background color, as AppKit panes are. React content
|
|
259
|
+
// follows a native resize one commit later; until then the newly exposed strip matches the window instead
|
|
260
|
+
// of showing a white stripe. The sidebar container stays clear so its native material shows.
|
|
261
|
+
@interface RNSidebarSplitViewPaneView : NSView
|
|
262
|
+
@end
|
|
263
|
+
|
|
264
|
+
@implementation RNSidebarSplitViewPaneView
|
|
265
|
+
- (BOOL)wantsUpdateLayer
|
|
266
|
+
{
|
|
267
|
+
return YES;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
- (void)updateLayer
|
|
271
|
+
{
|
|
272
|
+
self.layer.backgroundColor = NSColor.windowBackgroundColor.CGColor;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
- (void)viewDidChangeEffectiveAppearance
|
|
276
|
+
{
|
|
277
|
+
[super viewDidChangeEffectiveAppearance];
|
|
278
|
+
self.needsDisplay = YES;
|
|
279
|
+
}
|
|
280
|
+
@end
|
|
281
|
+
|
|
206
282
|
static char RNSidebarSplitViewStartupKey;
|
|
207
283
|
|
|
284
|
+
// NSSplitViewController answers a divider double-click by snapping the pane beside it to its minimum or maximum
|
|
285
|
+
// thickness (the shouldCollapse...forDoubleClick delegate is deprecated and never called). The snap bypasses the
|
|
286
|
+
// layout flow React panes follow, and a sidebar here collapses only through the explicit toggle, so swallow it.
|
|
287
|
+
// Dragging a divider is unaffected.
|
|
288
|
+
@interface RNSidebarSplitViewController : NSSplitViewController
|
|
289
|
+
@end
|
|
290
|
+
|
|
291
|
+
@implementation RNSidebarSplitViewController
|
|
292
|
+
- (void)splitView:(NSSplitView *)splitView doubleClickedOnDividerAtIndex:(NSInteger)dividerIndex
|
|
293
|
+
{
|
|
294
|
+
}
|
|
295
|
+
@end
|
|
296
|
+
|
|
208
297
|
// Startup must stay entirely in AppKit: constructing a Fabric view here would
|
|
209
298
|
// read React feature flags before RCTReactNativeFactory configures them.
|
|
210
299
|
@interface RNSidebarSplitViewStartupView : NSView
|
|
@@ -258,7 +347,7 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
258
347
|
sidebarItem.allowsFullHeightLayout = YES;
|
|
259
348
|
contentItem.allowsFullHeightLayout = YES;
|
|
260
349
|
|
|
261
|
-
_controller = [
|
|
350
|
+
_controller = [RNSidebarSplitViewController new];
|
|
262
351
|
_controller.minimumThicknessForInlineSidebars = 0;
|
|
263
352
|
_controller.splitView.vertical = YES;
|
|
264
353
|
_controller.splitView.dividerStyle = NSSplitViewDividerStyleThin;
|
|
@@ -356,22 +445,40 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
356
445
|
NSSplitViewController *_splitViewController;
|
|
357
446
|
NSViewController *_sidebarViewController;
|
|
358
447
|
NSViewController *_contentViewController;
|
|
448
|
+
NSViewController *_listViewController;
|
|
359
449
|
NSSplitViewItem *_sidebarItem;
|
|
360
450
|
NSSplitViewItem *_contentItem;
|
|
451
|
+
NSSplitViewItem *_listItem;
|
|
361
452
|
NSView *_sidebarContainer;
|
|
362
453
|
NSView *_contentContainer;
|
|
454
|
+
NSView *_listContainer;
|
|
363
455
|
RCTUIView<RCTComponentViewProtocol> *_sidebarReactView;
|
|
364
456
|
RCTUIView<RCTComponentViewProtocol> *_contentReactView;
|
|
457
|
+
RCTUIView<RCTComponentViewProtocol> *_listReactView;
|
|
365
458
|
id _resizeObserver;
|
|
366
459
|
LayoutMetrics _currentLayoutMetrics;
|
|
367
460
|
LayoutMetrics _sidebarReactLayoutMetrics;
|
|
368
461
|
LayoutMetrics _contentReactLayoutMetrics;
|
|
462
|
+
LayoutMetrics _listReactLayoutMetrics;
|
|
369
463
|
CGFloat _sidebarMinWidth;
|
|
370
464
|
CGFloat _sidebarWidth;
|
|
371
465
|
CGFloat _contentMinWidth;
|
|
466
|
+
CGFloat _listMinWidth;
|
|
467
|
+
CGFloat _listWidth;
|
|
468
|
+
BOOL _hasList;
|
|
469
|
+
// Effective collapsed state, which React knows. Follows the prop when the prop changes and the sidebar item when
|
|
470
|
+
// AppKit collapses it (toggleSidebar:, the toolbar button, ...); the latter is reported via onSidebarCollapsedChange.
|
|
372
471
|
BOOL _sidebarCollapsed;
|
|
472
|
+
// The last sidebarCollapsed prop. Only a change of the prop overrides the effective state, so a stale prop never
|
|
473
|
+
// undoes a native toggle.
|
|
474
|
+
BOOL _sidebarCollapsedProp;
|
|
475
|
+
// Preferred widths seed the dividers once; afterwards the user's drag owns them.
|
|
476
|
+
BOOL _needsPreferredDividerPositions;
|
|
477
|
+
// Our own layout pass resizes subviews several times; only its final state is published.
|
|
478
|
+
BOOL _layingOutSplitView;
|
|
373
479
|
CGFloat _lastSidebarWidth;
|
|
374
480
|
CGFloat _lastContentWidth;
|
|
481
|
+
CGFloat _lastListWidth;
|
|
375
482
|
CGFloat _lastHeight;
|
|
376
483
|
BOOL _lastLayoutReady;
|
|
377
484
|
BOOL _didPublishMount;
|
|
@@ -401,12 +508,20 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
401
508
|
_currentLayoutMetrics = EmptyLayoutMetrics;
|
|
402
509
|
_sidebarReactLayoutMetrics = EmptyLayoutMetrics;
|
|
403
510
|
_contentReactLayoutMetrics = EmptyLayoutMetrics;
|
|
511
|
+
_listReactLayoutMetrics = EmptyLayoutMetrics;
|
|
404
512
|
_sidebarMinWidth = 180;
|
|
405
513
|
_sidebarWidth = 0;
|
|
406
514
|
_contentMinWidth = 320;
|
|
515
|
+
_listMinWidth = 240;
|
|
516
|
+
_listWidth = 0;
|
|
517
|
+
_hasList = NO;
|
|
407
518
|
_sidebarCollapsed = NO;
|
|
519
|
+
_sidebarCollapsedProp = NO;
|
|
520
|
+
_needsPreferredDividerPositions = YES;
|
|
521
|
+
_layingOutSplitView = NO;
|
|
408
522
|
_lastSidebarWidth = -1;
|
|
409
523
|
_lastContentWidth = -1;
|
|
524
|
+
_lastListWidth = -1;
|
|
410
525
|
_lastHeight = -1;
|
|
411
526
|
_lastLayoutReady = NO;
|
|
412
527
|
_appearanceName = @"system";
|
|
@@ -415,33 +530,47 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
415
530
|
_contentTitlebarOverlayOpacity = 0;
|
|
416
531
|
_sidebarTitlebarOverlayOpacity = 0;
|
|
417
532
|
_sidebarContainer = [NSView new];
|
|
418
|
-
_contentContainer = [
|
|
533
|
+
_contentContainer = [RNSidebarSplitViewPaneView new];
|
|
534
|
+
_listContainer = [RNSidebarSplitViewPaneView new];
|
|
419
535
|
_sidebarContainer.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
|
|
420
536
|
_contentContainer.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
|
|
537
|
+
_listContainer.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
|
|
421
538
|
_sidebarContainer.wantsLayer = YES;
|
|
422
539
|
_contentContainer.wantsLayer = YES;
|
|
540
|
+
_listContainer.wantsLayer = YES;
|
|
423
541
|
_sidebarContainer.layer.masksToBounds = NO;
|
|
424
542
|
_contentContainer.layer.masksToBounds = NO;
|
|
543
|
+
_listContainer.layer.masksToBounds = YES;
|
|
425
544
|
_sidebarContainer.layer.zPosition = 10;
|
|
426
545
|
_contentContainer.layer.zPosition = 0;
|
|
546
|
+
_listContainer.layer.zPosition = 0;
|
|
427
547
|
|
|
428
548
|
_sidebarViewController = [NSViewController new];
|
|
429
549
|
_contentViewController = [NSViewController new];
|
|
550
|
+
_listViewController = [NSViewController new];
|
|
430
551
|
_sidebarViewController.view = _sidebarContainer;
|
|
431
552
|
_contentViewController.view = _contentContainer;
|
|
553
|
+
_listViewController.view = _listContainer;
|
|
432
554
|
|
|
433
555
|
_sidebarItem = [NSSplitViewItem sidebarWithViewController:_sidebarViewController];
|
|
434
556
|
_contentItem = [NSSplitViewItem splitViewItemWithViewController:_contentViewController];
|
|
557
|
+
// Mail-style middle column. Inserted between sidebar and content only while a list pane is supplied.
|
|
558
|
+
_listItem = [NSSplitViewItem contentListWithViewController:_listViewController];
|
|
435
559
|
_sidebarItem.canCollapse = YES;
|
|
436
560
|
_contentItem.canCollapse = NO;
|
|
561
|
+
_listItem.canCollapse = NO;
|
|
562
|
+
// Window resizes go to the content column; sidebar (260) and list keep their widths.
|
|
563
|
+
_listItem.holdingPriority = NSLayoutPriorityDefaultLow + 1;
|
|
437
564
|
[self updateSplitItemSizing];
|
|
438
565
|
|
|
439
566
|
if (@available(macOS 11.0, *)) {
|
|
440
567
|
_sidebarItem.allowsFullHeightLayout = YES;
|
|
441
568
|
_contentItem.allowsFullHeightLayout = YES;
|
|
569
|
+
_listItem.allowsFullHeightLayout = YES;
|
|
442
570
|
}
|
|
443
571
|
|
|
444
|
-
_splitViewController = [
|
|
572
|
+
_splitViewController = [RNSidebarSplitViewController new];
|
|
573
|
+
_splitViewController.splitView = [RNSidebarSplitViewNativeSplitView new];
|
|
445
574
|
_splitViewController.minimumThicknessForInlineSidebars = 0;
|
|
446
575
|
_splitViewController.splitView.vertical = YES;
|
|
447
576
|
_splitViewController.splitView.dividerStyle = NSSplitViewDividerStyleThin;
|
|
@@ -450,12 +579,13 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
450
579
|
[_splitViewController addSplitViewItem:_contentItem];
|
|
451
580
|
[self applyAppearance];
|
|
452
581
|
|
|
582
|
+
__weak RNSidebarSplitViewComponent *weakSelf = self;
|
|
453
583
|
_resizeObserver = [[NSNotificationCenter defaultCenter]
|
|
454
584
|
addObserverForName:NSSplitViewDidResizeSubviewsNotification
|
|
455
585
|
object:_splitViewController.splitView
|
|
456
586
|
queue:NSOperationQueue.mainQueue
|
|
457
587
|
usingBlock:^(__unused NSNotification *notification) {
|
|
458
|
-
[
|
|
588
|
+
[weakSelf splitViewDidResize];
|
|
459
589
|
}];
|
|
460
590
|
|
|
461
591
|
[self addSubview:_splitViewController.view];
|
|
@@ -480,17 +610,46 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
480
610
|
_sidebarItem.minimumThickness = MAX(120, _sidebarMinWidth);
|
|
481
611
|
_sidebarItem.preferredThicknessFraction = 0.26;
|
|
482
612
|
_contentItem.minimumThickness = MAX(240, _contentMinWidth);
|
|
613
|
+
_listItem.minimumThickness = MAX(120, _listMinWidth);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
- (void)updateListItem
|
|
617
|
+
{
|
|
618
|
+
BOOL installed = [_splitViewController.splitViewItems containsObject:_listItem];
|
|
619
|
+
if (_hasList && !installed) {
|
|
620
|
+
[_splitViewController insertSplitViewItem:_listItem atIndex:1];
|
|
621
|
+
} else if (!_hasList && installed) {
|
|
622
|
+
[_splitViewController removeSplitViewItem:_listItem];
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
- (CGFloat)listReserveWidth
|
|
627
|
+
{
|
|
628
|
+
return _hasList ? _listItem.minimumThickness + _splitViewController.splitView.dividerThickness : 0;
|
|
483
629
|
}
|
|
484
630
|
|
|
485
631
|
- (CGFloat)preferredSidebarWidthForBounds:(CGRect)bounds
|
|
486
632
|
{
|
|
487
633
|
CGFloat dividerThickness = _splitViewController.splitView.dividerThickness;
|
|
488
|
-
CGFloat maxSidebarWidth = bounds.size.width -
|
|
634
|
+
CGFloat maxSidebarWidth = bounds.size.width - _contentItem.minimumThickness - dividerThickness - [self listReserveWidth];
|
|
489
635
|
CGFloat preferredSidebarWidth = _sidebarWidth > 0 ? _sidebarWidth : _sidebarMinWidth;
|
|
490
|
-
CGFloat sidebarWidth = MIN(MAX(
|
|
636
|
+
CGFloat sidebarWidth = MIN(MAX(_sidebarItem.minimumThickness, preferredSidebarWidth), maxSidebarWidth);
|
|
491
637
|
return MAX(0, sidebarWidth);
|
|
492
638
|
}
|
|
493
639
|
|
|
640
|
+
- (CGFloat)preferredListWidthForBounds:(CGRect)bounds sidebarExtent:(CGFloat)sidebarExtent
|
|
641
|
+
{
|
|
642
|
+
if (!_hasList) {
|
|
643
|
+
return 0;
|
|
644
|
+
}
|
|
645
|
+
CGFloat dividerThickness = _splitViewController.splitView.dividerThickness;
|
|
646
|
+
CGFloat maxListWidth = bounds.size.width - sidebarExtent - _contentItem.minimumThickness - dividerThickness;
|
|
647
|
+
CGFloat preferredListWidth = _listWidth > 0 ? _listWidth : _listMinWidth;
|
|
648
|
+
return MAX(0, MIN(MAX(_listItem.minimumThickness, preferredListWidth), maxListWidth));
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/// Pushes the effective collapsed state to AppKit. Only updateProps and recycling call this: layout passes must
|
|
652
|
+
/// adopt the native state instead, or a stale prop would re-expand a sidebar AppKit just collapsed.
|
|
494
653
|
- (void)updateSidebarCollapsed
|
|
495
654
|
{
|
|
496
655
|
if (_sidebarItem.collapsed != _sidebarCollapsed) {
|
|
@@ -498,6 +657,35 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
498
657
|
}
|
|
499
658
|
}
|
|
500
659
|
|
|
660
|
+
/// Adopts a collapse or expand AppKit performed itself and tells React. Idempotent, so every layout and resize
|
|
661
|
+
/// notification can call it: AppKit posts NSSplitViewDidResizeSubviewsNotification as soon as the sidebar item's
|
|
662
|
+
/// state flips and then once per animation step, and only the first call sees a difference.
|
|
663
|
+
- (void)adoptNativeSidebarCollapsed
|
|
664
|
+
{
|
|
665
|
+
BOOL collapsed = _sidebarItem.collapsed;
|
|
666
|
+
if (collapsed == _sidebarCollapsed) {
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
_sidebarCollapsed = collapsed;
|
|
670
|
+
const auto eventEmitter = std::static_pointer_cast<const SidebarSplitViewEventEmitter>(_eventEmitter);
|
|
671
|
+
if (eventEmitter) {
|
|
672
|
+
eventEmitter->onSidebarCollapsedChange(SidebarSplitViewEventEmitter::OnSidebarCollapsedChange{
|
|
673
|
+
.collapsed = static_cast<bool>(collapsed),
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/// A collapsed item keeps its container at the width it had (the container is only hidden), so the item, not the
|
|
679
|
+
/// container, says whether the sidebar pane is open.
|
|
680
|
+
- (CGRect)sidebarPaneBounds
|
|
681
|
+
{
|
|
682
|
+
CGRect bounds = _sidebarContainer.bounds;
|
|
683
|
+
if (_sidebarItem.collapsed) {
|
|
684
|
+
bounds.size.width = 0;
|
|
685
|
+
}
|
|
686
|
+
return bounds;
|
|
687
|
+
}
|
|
688
|
+
|
|
501
689
|
- (void)applyAppearance
|
|
502
690
|
{
|
|
503
691
|
NSAppearance *appearance = RNSidebarSplitViewAppearanceForName(_appearanceName);
|
|
@@ -506,6 +694,7 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
506
694
|
_splitViewController.splitView.appearance = appearance;
|
|
507
695
|
_sidebarContainer.appearance = appearance;
|
|
508
696
|
_contentContainer.appearance = appearance;
|
|
697
|
+
_listContainer.appearance = appearance;
|
|
509
698
|
[_splitViewController.view setNeedsDisplay:YES];
|
|
510
699
|
[_splitViewController.splitView setNeedsDisplay:YES];
|
|
511
700
|
[_sidebarContainer setNeedsDisplay:YES];
|
|
@@ -644,7 +833,7 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
644
833
|
|
|
645
834
|
- (void)syncReactSubviewFrames
|
|
646
835
|
{
|
|
647
|
-
CGRect sidebarBounds =
|
|
836
|
+
CGRect sidebarBounds = [self sidebarPaneBounds];
|
|
648
837
|
CGRect contentBounds = _contentContainer.bounds;
|
|
649
838
|
|
|
650
839
|
[self syncReactSubview:_sidebarReactView
|
|
@@ -653,6 +842,9 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
653
842
|
[self syncReactSubview:_contentReactView
|
|
654
843
|
nativeBounds:contentBounds
|
|
655
844
|
previousLayoutMetrics:&_contentReactLayoutMetrics];
|
|
845
|
+
[self syncReactSubview:_listReactView
|
|
846
|
+
nativeBounds:_hasList ? _listContainer.bounds : CGRectZero
|
|
847
|
+
previousLayoutMetrics:&_listReactLayoutMetrics];
|
|
656
848
|
}
|
|
657
849
|
|
|
658
850
|
- (void)syncReactSubview:(nullable RCTUIView<RCTComponentViewProtocol> *)subview
|
|
@@ -692,6 +884,8 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
692
884
|
sidebarHeight:(CGFloat)sidebarHeight
|
|
693
885
|
contentHeight:(CGFloat)contentHeight
|
|
694
886
|
height:(CGFloat)height
|
|
887
|
+
listWidth:(CGFloat)listWidth
|
|
888
|
+
listX:(CGFloat)listX
|
|
695
889
|
layoutReady:(BOOL)layoutReady
|
|
696
890
|
{
|
|
697
891
|
const auto eventEmitter = std::static_pointer_cast<const SidebarSplitViewEventEmitter>(_eventEmitter);
|
|
@@ -703,7 +897,7 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
703
897
|
return;
|
|
704
898
|
}
|
|
705
899
|
|
|
706
|
-
BOOL panesReady = layoutReady && _sidebarReactView && _contentReactView;
|
|
900
|
+
BOOL panesReady = layoutReady && _sidebarReactView && _contentReactView && (!_hasList || _listReactView);
|
|
707
901
|
if (panesReady && self.window && !_didPublishMount) {
|
|
708
902
|
// This also runs when an already-laid-out Fabric tree joins its window.
|
|
709
903
|
// Keep it before metrics deduplication so the startup cover cannot linger.
|
|
@@ -713,6 +907,7 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
713
907
|
}
|
|
714
908
|
if (fabs(sidebarWidth - _lastSidebarWidth) < 0.5 &&
|
|
715
909
|
fabs(contentWidth - _lastContentWidth) < 0.5 &&
|
|
910
|
+
fabs(listWidth - _lastListWidth) < 0.5 &&
|
|
716
911
|
fabs(height - _lastHeight) < 0.5 &&
|
|
717
912
|
panesReady == _lastLayoutReady) {
|
|
718
913
|
return;
|
|
@@ -720,6 +915,7 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
720
915
|
|
|
721
916
|
_lastSidebarWidth = sidebarWidth;
|
|
722
917
|
_lastContentWidth = contentWidth;
|
|
918
|
+
_lastListWidth = listWidth;
|
|
723
919
|
_lastHeight = height;
|
|
724
920
|
_lastLayoutReady = panesReady;
|
|
725
921
|
|
|
@@ -730,6 +926,9 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
730
926
|
.height = height,
|
|
731
927
|
.isLayoutReady = static_cast<bool>(panesReady),
|
|
732
928
|
.isVertical = true,
|
|
929
|
+
.listHeight = listWidth > 0 ? height : 0,
|
|
930
|
+
.listWidth = listWidth,
|
|
931
|
+
.listX = listX,
|
|
733
932
|
.sidebarHeight = sidebarHeight,
|
|
734
933
|
.sidebarWidth = sidebarWidth,
|
|
735
934
|
});
|
|
@@ -746,16 +945,20 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
746
945
|
if (!_sidebarCollapsed) {
|
|
747
946
|
sidebarWidth = [self preferredSidebarWidthForBounds:bounds];
|
|
748
947
|
}
|
|
749
|
-
CGFloat
|
|
948
|
+
CGFloat listX = sidebarWidth > 0 ? sidebarWidth + dividerThickness : 0;
|
|
949
|
+
CGFloat listWidth = [self preferredListWidthForBounds:bounds sidebarExtent:listX];
|
|
950
|
+
CGFloat contentX = listWidth > 0 ? listX + listWidth + dividerThickness : listX;
|
|
750
951
|
CGFloat contentWidth = MAX(0, bounds.size.width - contentX);
|
|
751
952
|
if (contentWidth <= 0) {
|
|
752
953
|
contentWidth = bounds.size.width;
|
|
753
954
|
contentX = 0;
|
|
955
|
+
listWidth = 0;
|
|
754
956
|
}
|
|
755
957
|
|
|
756
958
|
_splitViewController.view.frame = bounds;
|
|
757
959
|
_splitViewController.splitView.frame = bounds;
|
|
758
960
|
_sidebarContainer.frame = CGRectMake(0, 0, sidebarWidth, bounds.size.height);
|
|
961
|
+
_listContainer.frame = CGRectMake(listX, 0, listWidth, bounds.size.height);
|
|
759
962
|
_contentContainer.frame = CGRectMake(contentX, 0, contentWidth, bounds.size.height);
|
|
760
963
|
|
|
761
964
|
CGRect sidebarBounds = CGRectMake(0, 0, sidebarWidth, bounds.size.height);
|
|
@@ -766,33 +969,51 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
766
969
|
[self syncReactSubview:_contentReactView
|
|
767
970
|
nativeBounds:contentBounds
|
|
768
971
|
previousLayoutMetrics:&_contentReactLayoutMetrics];
|
|
972
|
+
[self syncReactSubview:_listReactView
|
|
973
|
+
nativeBounds:CGRectMake(0, 0, listWidth, bounds.size.height)
|
|
974
|
+
previousLayoutMetrics:&_listReactLayoutMetrics];
|
|
769
975
|
[self layoutContentTitlebarMaterial];
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
976
|
+
if (!_layingOutSplitView) {
|
|
977
|
+
[self emitSplitViewDidResizeWithSidebarWidth:sidebarWidth
|
|
978
|
+
contentWidth:contentWidth
|
|
979
|
+
contentX:contentX
|
|
980
|
+
sidebarHeight:bounds.size.height
|
|
981
|
+
contentHeight:bounds.size.height
|
|
982
|
+
height:bounds.size.height
|
|
983
|
+
listWidth:listWidth
|
|
984
|
+
listX:_hasList ? listX : 0
|
|
985
|
+
layoutReady:layoutReady];
|
|
986
|
+
}
|
|
777
987
|
|
|
778
988
|
return YES;
|
|
779
989
|
}
|
|
780
990
|
|
|
781
991
|
- (void)publishSplitViewLayoutAllowEstimatedReady:(BOOL)allowEstimatedReady
|
|
782
992
|
{
|
|
783
|
-
|
|
993
|
+
[self adoptNativeSidebarCollapsed];
|
|
994
|
+
CGFloat sidebarWidth = [self sidebarPaneBounds].size.width;
|
|
784
995
|
CGFloat contentWidth = _contentContainer.bounds.size.width;
|
|
785
996
|
CGFloat contentX = [_contentContainer convertRect:_contentContainer.bounds toView:self].origin.x;
|
|
786
997
|
CGFloat sidebarHeight = _sidebarContainer.bounds.size.height;
|
|
787
998
|
CGFloat contentHeight = _contentContainer.bounds.size.height;
|
|
999
|
+
CGFloat listWidth = _hasList ? _listContainer.bounds.size.width : 0;
|
|
1000
|
+
CGFloat listX = _hasList ? [_listContainer convertRect:_listContainer.bounds toView:self].origin.x : 0;
|
|
788
1001
|
CGFloat height = MAX(sidebarHeight, contentHeight);
|
|
789
1002
|
CGRect bounds = [self currentLayoutBounds];
|
|
790
1003
|
|
|
791
|
-
if (contentWidth <= 0 || height <= 0 ||
|
|
792
|
-
|
|
1004
|
+
if (contentWidth <= 0 || height <= 0 || (_hasList && listWidth <= 0)) {
|
|
1005
|
+
[self applyEstimatedSplitViewLayoutForBounds:bounds layoutReady:allowEstimatedReady];
|
|
1006
|
+
return;
|
|
1007
|
+
}
|
|
1008
|
+
// AppKit may publish an animation target origin before its size catches up. Keep its owned frames;
|
|
1009
|
+
// estimating here would overwrite dragged widths and interrupt the native transition.
|
|
1010
|
+
if (contentX < -0.5 ||
|
|
793
1011
|
contentX + contentWidth > bounds.size.width + 0.5 ||
|
|
794
1012
|
fabs(_contentContainer.bounds.size.height - bounds.size.height) >= 0.5) {
|
|
795
|
-
|
|
1013
|
+
if (!allowEstimatedReady) {
|
|
1014
|
+
// Expansion may send only this target-frame notification; request a layout to publish settled metrics.
|
|
1015
|
+
[self setNeedsLayout:YES];
|
|
1016
|
+
}
|
|
796
1017
|
return;
|
|
797
1018
|
}
|
|
798
1019
|
|
|
@@ -804,6 +1025,8 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
804
1025
|
sidebarHeight:sidebarHeight
|
|
805
1026
|
contentHeight:contentHeight
|
|
806
1027
|
height:height
|
|
1028
|
+
listWidth:listWidth
|
|
1029
|
+
listX:listX
|
|
807
1030
|
layoutReady:YES];
|
|
808
1031
|
}
|
|
809
1032
|
|
|
@@ -820,35 +1043,74 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
820
1043
|
return bounds;
|
|
821
1044
|
}
|
|
822
1045
|
|
|
1046
|
+
/// Seeds dividers from the preferred widths. Runs only until it succeeds once (and again when those props
|
|
1047
|
+
/// change), so a later layout pass never snaps a divider the user dragged back to its preferred position.
|
|
823
1048
|
- (void)applyDividerPositionForBounds:(CGRect)bounds
|
|
824
1049
|
{
|
|
825
|
-
if (
|
|
1050
|
+
if (!_needsPreferredDividerPositions || bounds.size.width <= 0 || _splitViewController.splitView.subviews.count < 2) {
|
|
826
1051
|
return;
|
|
827
1052
|
}
|
|
1053
|
+
CGFloat dividerThickness = _splitViewController.splitView.dividerThickness;
|
|
1054
|
+
CGFloat sidebarExtent = 0;
|
|
1055
|
+
if (!_sidebarCollapsed) {
|
|
1056
|
+
CGFloat sidebarWidth = [self preferredSidebarWidthForBounds:bounds];
|
|
1057
|
+
if (sidebarWidth <= 0) {
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
1060
|
+
[_splitViewController.splitView setPosition:sidebarWidth ofDividerAtIndex:0];
|
|
1061
|
+
sidebarExtent = sidebarWidth + dividerThickness;
|
|
1062
|
+
}
|
|
1063
|
+
if (_hasList) {
|
|
1064
|
+
if (_splitViewController.splitView.subviews.count < 3) {
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
1067
|
+
CGFloat listWidth = [self preferredListWidthForBounds:bounds sidebarExtent:sidebarExtent];
|
|
1068
|
+
if (listWidth <= 0) {
|
|
1069
|
+
return;
|
|
1070
|
+
}
|
|
1071
|
+
[_splitViewController.splitView setPosition:sidebarExtent + listWidth ofDividerAtIndex:1];
|
|
1072
|
+
}
|
|
1073
|
+
// A small startup frame can clamp a preference. Retry on later layouts until it fits,
|
|
1074
|
+
// unless a real divider drag takes ownership in splitViewDidResize.
|
|
1075
|
+
CGFloat desiredSidebarWidth = MAX(_sidebarItem.minimumThickness, _sidebarWidth > 0 ? _sidebarWidth : _sidebarMinWidth);
|
|
1076
|
+
CGFloat desiredListWidth = MAX(_listItem.minimumThickness, _listWidth > 0 ? _listWidth : _listMinWidth);
|
|
1077
|
+
_needsPreferredDividerPositions =
|
|
1078
|
+
(!_sidebarCollapsed && [self preferredSidebarWidthForBounds:bounds] < desiredSidebarWidth - 0.5) ||
|
|
1079
|
+
(_hasList && [self preferredListWidthForBounds:bounds sidebarExtent:sidebarExtent] < desiredListWidth - 0.5);
|
|
1080
|
+
}
|
|
828
1081
|
|
|
829
|
-
|
|
830
|
-
|
|
1082
|
+
- (void)splitViewDidResize
|
|
1083
|
+
{
|
|
1084
|
+
if (_layingOutSplitView) {
|
|
831
1085
|
return;
|
|
832
1086
|
}
|
|
833
|
-
|
|
834
|
-
|
|
1087
|
+
if (((RNSidebarSplitViewNativeSplitView *)_splitViewController.splitView).trackingDivider) {
|
|
1088
|
+
_needsPreferredDividerPositions = NO;
|
|
1089
|
+
}
|
|
1090
|
+
[self publishSplitViewLayoutAllowEstimatedReady:NO];
|
|
835
1091
|
}
|
|
836
1092
|
|
|
837
1093
|
- (void)layoutSplitView
|
|
838
1094
|
{
|
|
1095
|
+
if (_layingOutSplitView) {
|
|
1096
|
+
return;
|
|
1097
|
+
}
|
|
1098
|
+
_layingOutSplitView = YES;
|
|
839
1099
|
CGRect bounds = [self currentLayoutBounds];
|
|
840
1100
|
_splitViewController.view.frame = bounds;
|
|
841
1101
|
_splitViewController.splitView.frame = bounds;
|
|
842
|
-
[self
|
|
1102
|
+
[self updateSplitItemSizing];
|
|
1103
|
+
[self updateListItem];
|
|
1104
|
+
[self adoptNativeSidebarCollapsed];
|
|
843
1105
|
if (_contentContainer.bounds.size.width <= 0 ||
|
|
844
1106
|
_contentContainer.bounds.size.height <= 0 ||
|
|
845
1107
|
fabs(_contentContainer.bounds.size.height - bounds.size.height) >= 0.5) {
|
|
846
1108
|
[self applyEstimatedSplitViewLayoutForBounds:bounds layoutReady:NO];
|
|
847
1109
|
}
|
|
848
1110
|
[self applyDividerPositionForBounds:bounds];
|
|
849
|
-
[_splitViewController.splitView adjustSubviews];
|
|
850
1111
|
[_splitViewController.view layoutSubtreeIfNeeded];
|
|
851
1112
|
[self layoutContentTitlebarMaterial];
|
|
1113
|
+
_layingOutSplitView = NO;
|
|
852
1114
|
[self publishSplitViewLayoutAllowEstimatedReady:YES];
|
|
853
1115
|
}
|
|
854
1116
|
|
|
@@ -876,7 +1138,7 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
876
1138
|
[self applyEstimatedSplitViewLayoutForBounds:[self currentLayoutBounds] layoutReady:NO];
|
|
877
1139
|
} else {
|
|
878
1140
|
[self syncReactSubview:_sidebarReactView
|
|
879
|
-
nativeBounds:
|
|
1141
|
+
nativeBounds:[self sidebarPaneBounds]
|
|
880
1142
|
previousLayoutMetrics:&_sidebarReactLayoutMetrics];
|
|
881
1143
|
}
|
|
882
1144
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
@@ -903,13 +1165,28 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
903
1165
|
});
|
|
904
1166
|
return;
|
|
905
1167
|
}
|
|
1168
|
+
|
|
1169
|
+
if (index == 2) {
|
|
1170
|
+
[_listReactView removeFromSuperview];
|
|
1171
|
+
_listReactView = childComponentView;
|
|
1172
|
+
_listReactLayoutMetrics = EmptyLayoutMetrics;
|
|
1173
|
+
childComponentView.hidden = YES;
|
|
1174
|
+
[_listContainer addSubview:childComponentView];
|
|
1175
|
+
[self syncReactSubview:_listReactView
|
|
1176
|
+
nativeBounds:_hasList ? _listContainer.bounds : CGRectZero
|
|
1177
|
+
previousLayoutMetrics:&_listReactLayoutMetrics];
|
|
1178
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
1179
|
+
[self publishSplitViewLayoutAllowEstimatedReady:NO];
|
|
1180
|
+
});
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
906
1183
|
#else
|
|
907
1184
|
if (index == 0) {
|
|
908
1185
|
[_sidebarContainer addSubview:childComponentView];
|
|
909
1186
|
return;
|
|
910
1187
|
}
|
|
911
1188
|
|
|
912
|
-
if (index == 1) {
|
|
1189
|
+
if (index == 1 || index == 2) {
|
|
913
1190
|
[_contentContainer addSubview:childComponentView];
|
|
914
1191
|
return;
|
|
915
1192
|
}
|
|
@@ -935,8 +1212,15 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
935
1212
|
[childComponentView removeFromSuperview];
|
|
936
1213
|
return;
|
|
937
1214
|
}
|
|
1215
|
+
|
|
1216
|
+
if (childComponentView == _listReactView) {
|
|
1217
|
+
_listReactView = nil;
|
|
1218
|
+
_listReactLayoutMetrics = EmptyLayoutMetrics;
|
|
1219
|
+
[childComponentView removeFromSuperview];
|
|
1220
|
+
return;
|
|
1221
|
+
}
|
|
938
1222
|
#else
|
|
939
|
-
if (index == 0 || index == 1) {
|
|
1223
|
+
if (index == 0 || index == 1 || index == 2) {
|
|
940
1224
|
[childComponentView removeFromSuperview];
|
|
941
1225
|
return;
|
|
942
1226
|
}
|
|
@@ -950,15 +1234,32 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
950
1234
|
const auto &newProps = *std::static_pointer_cast<SidebarSplitViewProps const>(props);
|
|
951
1235
|
|
|
952
1236
|
#if TARGET_OS_OSX
|
|
1237
|
+
// Collapse and accessory mutations can synchronously resize AppKit before list membership and sizing settle.
|
|
1238
|
+
// Publish only after this prop transaction has completed, preserving any enclosing layout's guard.
|
|
1239
|
+
BOOL wasLayingOutSplitView = _layingOutSplitView;
|
|
1240
|
+
_layingOutSplitView = YES;
|
|
953
1241
|
NSString *nextAppearanceName = [NSString stringWithUTF8String:newProps.appearance.c_str()];
|
|
954
1242
|
if (nextAppearanceName.length == 0) {
|
|
955
1243
|
nextAppearanceName = @"system";
|
|
956
1244
|
}
|
|
1245
|
+
// A changed prop is the last writer and wins over a native toggle React has not heard about yet (no event is
|
|
1246
|
+
// sent for it: the app just set a newer value). An unchanged prop never overrides the native state.
|
|
1247
|
+
BOOL collapsedPropChanged = _sidebarCollapsedProp != newProps.sidebarCollapsed;
|
|
1248
|
+
if (!collapsedPropChanged) {
|
|
1249
|
+
[self adoptNativeSidebarCollapsed];
|
|
1250
|
+
}
|
|
1251
|
+
// Echoing an adopted native state acknowledges it; it must not reseed user-dragged dividers.
|
|
1252
|
+
BOOL effectiveCollapsedChanged = collapsedPropChanged && _sidebarCollapsed != newProps.sidebarCollapsed;
|
|
1253
|
+
BOOL preferredWidthsChanged =
|
|
1254
|
+
fabs(_sidebarWidth - newProps.sidebarWidth) >= 0.5 ||
|
|
1255
|
+
fabs(_listWidth - newProps.listWidth) >= 0.5 ||
|
|
1256
|
+
_hasList != newProps.hasList ||
|
|
1257
|
+
effectiveCollapsedChanged;
|
|
957
1258
|
BOOL shouldRelayout =
|
|
1259
|
+
preferredWidthsChanged ||
|
|
958
1260
|
fabs(_sidebarMinWidth - newProps.sidebarMinWidth) >= 0.5 ||
|
|
959
|
-
fabs(_sidebarWidth - newProps.sidebarWidth) >= 0.5 ||
|
|
960
1261
|
fabs(_contentMinWidth - newProps.contentMinWidth) >= 0.5 ||
|
|
961
|
-
|
|
1262
|
+
fabs(_listMinWidth - newProps.listMinWidth) >= 0.5 ||
|
|
962
1263
|
fabs(_contentTitlebarHeight - newProps.contentTitlebarHeight) >= 0.5;
|
|
963
1264
|
NSString *nextContentTitlebarMaterialName = [NSString stringWithUTF8String:newProps.contentTitlebarMaterial.c_str()];
|
|
964
1265
|
if (nextContentTitlebarMaterialName.length == 0) {
|
|
@@ -988,7 +1289,20 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
988
1289
|
_sidebarMinWidth = newProps.sidebarMinWidth;
|
|
989
1290
|
_sidebarWidth = newProps.sidebarWidth;
|
|
990
1291
|
_contentMinWidth = newProps.contentMinWidth;
|
|
991
|
-
|
|
1292
|
+
_listMinWidth = newProps.listMinWidth;
|
|
1293
|
+
_listWidth = newProps.listWidth;
|
|
1294
|
+
_hasList = newProps.hasList;
|
|
1295
|
+
_sidebarCollapsedProp = newProps.sidebarCollapsed;
|
|
1296
|
+
if (collapsedPropChanged) {
|
|
1297
|
+
_sidebarCollapsed = newProps.sidebarCollapsed;
|
|
1298
|
+
}
|
|
1299
|
+
// Apply the winning prop before accessory/list mutations can trigger resize observers. A prop can match the
|
|
1300
|
+
// adopted effective state while overriding a newer, unobserved native toggle; that still needs final metrics.
|
|
1301
|
+
shouldRelayout = shouldRelayout || _sidebarItem.collapsed != _sidebarCollapsed;
|
|
1302
|
+
[self updateSidebarCollapsed];
|
|
1303
|
+
if (preferredWidthsChanged) {
|
|
1304
|
+
_needsPreferredDividerPositions = YES;
|
|
1305
|
+
}
|
|
992
1306
|
_contentTitlebarHeight = newProps.contentTitlebarHeight;
|
|
993
1307
|
_contentTitlebarMaterialName = nextContentTitlebarMaterialName;
|
|
994
1308
|
_contentTitlebarOverlayColorValue = nextContentTitlebarOverlayColorValue;
|
|
@@ -1005,16 +1319,16 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
1005
1319
|
_appearanceName = nextAppearanceName;
|
|
1006
1320
|
[self applyAppearance];
|
|
1007
1321
|
}
|
|
1008
|
-
[self updateSidebarCollapsed];
|
|
1009
|
-
[self updateSplitItemSizing];
|
|
1010
1322
|
#endif
|
|
1011
1323
|
|
|
1012
1324
|
[super updateProps:props oldProps:oldProps];
|
|
1013
1325
|
|
|
1014
1326
|
#if TARGET_OS_OSX
|
|
1327
|
+
_layingOutSplitView = wasLayingOutSplitView;
|
|
1015
1328
|
if (shouldRelayout || shouldRecreateContentTitlebarMaterial || shouldRecreateSidebarTitlebarMaterial) {
|
|
1016
1329
|
_lastSidebarWidth = -1;
|
|
1017
1330
|
_lastContentWidth = -1;
|
|
1331
|
+
_lastListWidth = -1;
|
|
1018
1332
|
_lastHeight = -1;
|
|
1019
1333
|
_lastLayoutReady = NO;
|
|
1020
1334
|
[self layoutSplitView];
|
|
@@ -1086,17 +1400,27 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
1086
1400
|
#if TARGET_OS_OSX
|
|
1087
1401
|
[_sidebarReactView removeFromSuperview];
|
|
1088
1402
|
[_contentReactView removeFromSuperview];
|
|
1403
|
+
[_listReactView removeFromSuperview];
|
|
1089
1404
|
_sidebarReactView = nil;
|
|
1090
1405
|
_contentReactView = nil;
|
|
1406
|
+
_listReactView = nil;
|
|
1091
1407
|
_currentLayoutMetrics = EmptyLayoutMetrics;
|
|
1092
1408
|
_sidebarReactLayoutMetrics = EmptyLayoutMetrics;
|
|
1093
1409
|
_contentReactLayoutMetrics = EmptyLayoutMetrics;
|
|
1410
|
+
_listReactLayoutMetrics = EmptyLayoutMetrics;
|
|
1094
1411
|
_sidebarMinWidth = 180;
|
|
1095
1412
|
_sidebarWidth = 0;
|
|
1096
1413
|
_contentMinWidth = 320;
|
|
1414
|
+
_listMinWidth = 240;
|
|
1415
|
+
_listWidth = 0;
|
|
1416
|
+
_hasList = NO;
|
|
1097
1417
|
_sidebarCollapsed = NO;
|
|
1418
|
+
_sidebarCollapsedProp = NO;
|
|
1419
|
+
_needsPreferredDividerPositions = YES;
|
|
1420
|
+
_layingOutSplitView = NO;
|
|
1098
1421
|
_lastSidebarWidth = -1;
|
|
1099
1422
|
_lastContentWidth = -1;
|
|
1423
|
+
_lastListWidth = -1;
|
|
1100
1424
|
_lastHeight = -1;
|
|
1101
1425
|
_lastLayoutReady = NO;
|
|
1102
1426
|
_appearanceName = @"system";
|
|
@@ -1110,6 +1434,7 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
1110
1434
|
[self removeContentTitlebarMaterial];
|
|
1111
1435
|
[self removeSidebarTitlebarMaterial];
|
|
1112
1436
|
[self applyAppearance];
|
|
1437
|
+
[self updateListItem];
|
|
1113
1438
|
[self updateSidebarCollapsed];
|
|
1114
1439
|
[self updateSplitItemSizing];
|
|
1115
1440
|
#else
|