Skip to content

Commit 3f25810

Browse files
committed
OnboardingView: Always on top
1 parent ba984c8 commit 3f25810

File tree

6 files changed

+68
-6
lines changed

6 files changed

+68
-6
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.DS_Store
22
cmd/update-release/venv*
3-
*.xcodeproj/xcuserdata
4-
*.xcodeproj/project.xcworkspace
3+
*.xcodeproj/xcuserdata*
4+
*.xcworkspace/xcuserdata
5+
*.xcodeproj/*.xcworkspace*

syncthing.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
C4A4156A1D0D579D00DC6018 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C4A415691D0D579D00DC6018 /* Assets.xcassets */; };
3737
C4A4156D1D0D579D00DC6018 /* STApplication.xib in Resources */ = {isa = PBXBuildFile; fileRef = C4A4156B1D0D579D00DC6018 /* STApplication.xib */; };
3838
C4D434FE2E5CFF3600B91C7F /* OnboardingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D434FD2E5CFF3600B91C7F /* OnboardingView.swift */; };
39+
C4D435022E5D067C00B91C7F /* OnboardingViewFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D435012E5D067600B91C7F /* OnboardingViewFactory.swift */; };
3940
C4F0E82E1DA1B9CF00435310 /* STPreferencesWindowGeneralViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4F0E82C1DA1B9CF00435310 /* STPreferencesWindowGeneralViewController.m */; };
4041
C4F0E82F1DA1B9CF00435310 /* STPreferencesWindowGeneralView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C4F0E82D1DA1B9CF00435310 /* STPreferencesWindowGeneralView.xib */; };
4142
C4FFB0661D0D7F870015D14A /* XGSyncthing.m in Sources */ = {isa = PBXBuildFile; fileRef = C4FFB0641D0D7E4C0015D14A /* XGSyncthing.m */; };
@@ -94,6 +95,7 @@
9495
C4A4156C1D0D579D00DC6018 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/STApplication.xib; sourceTree = "<group>"; };
9596
C4A4156E1D0D579D00DC6018 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
9697
C4D434FD2E5CFF3600B91C7F /* OnboardingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = OnboardingView.swift; path = UI/OnboardingView.swift; sourceTree = "<group>"; };
98+
C4D435012E5D067600B91C7F /* OnboardingViewFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingViewFactory.swift; sourceTree = "<group>"; };
9799
C4D6DD581D0D93D80024D20A /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
98100
C4D896121D0DF90900D42F73 /* syncthing-resource.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = "syncthing-resource.sh"; path = "syncthing/Scripts/syncthing-resource.sh"; sourceTree = "<group>"; };
99101
C4F0E82B1DA1B9CF00435310 /* STPreferencesWindowGeneralViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = STPreferencesWindowGeneralViewController.h; sourceTree = "<group>"; };
@@ -230,6 +232,7 @@
230232
C4D6DD601D0DB18A0024D20A /* UI */ = {
231233
isa = PBXGroup;
232234
children = (
235+
C4D435012E5D067600B91C7F /* OnboardingViewFactory.swift */,
233236
C4D434FD2E5CFF3600B91C7F /* OnboardingView.swift */,
234237
C4A4156B1D0D579D00DC6018 /* STApplication.xib */,
235238
C4946B001D5877F2008447A2 /* STAboutWindow.xib */,
@@ -398,6 +401,7 @@
398401
isa = PBXSourcesBuildPhase;
399402
buildActionMask = 2147483647;
400403
files = (
404+
C4D435022E5D067C00B91C7F /* OnboardingViewFactory.swift in Sources */,
401405
29AF1BA3210F11BF004212DE /* DaemonProcess.swift in Sources */,
402406
C4FFB0661D0D7F870015D14A /* XGSyncthing.m in Sources */,
403407
298A5C45210DA6C40034B89F /* LocalhostTLSDelegate.m in Sources */,

syncthing/Base.lproj/STApplication.xib

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="17701" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="23727" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
33
<dependencies>
44
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17701"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="23727"/>
66
</dependencies>
77
<objects>
88
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//
2+
// OnboardingViewFactory.swift
3+
// syncthing
4+
//
5+
// Created by Jerry Jacobs on 25/08/2025.
6+
// Copyright © 2025 syncthing-macos authors. All rights reserved.
7+
//
8+
import SwiftUI
9+
import AppKit
10+
11+
// Use @objcMembers to expose this class and its methods to Objective-C.
12+
@objcMembers
13+
public final class OnboardingViewFactory: NSObject {
14+
15+
// This factory method returns an NSViewController that can be used in AppKit.
16+
public static func makeOnboardingViewController() -> NSViewController {
17+
// 1. Instantiate your SwiftUI view.
18+
let onboardingView = OnboardingView()
19+
20+
// 2. Wrap it in an NSHostingController.
21+
let hostingController = NSHostingController(rootView: onboardingView)
22+
23+
// 3. Return it as a standard NSViewController.
24+
return hostingController
25+
}
26+
}

syncthing/STApplication.m

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ @interface STAppDelegate ()
1919
@property (weak) IBOutlet NSMenuItem *daemonRestartMenuItem;
2020
@property (strong) STPreferencesWindowController *preferencesWindow;
2121
@property (strong) STAboutWindowController *aboutWindow;
22+
@property (strong) NSWindowController *myWindowController;
2223
@property (nonatomic, assign) BOOL devicesPaused;
2324
@property (nonatomic, assign) BOOL daemonOK;
2425
@property (nonatomic, assign) BOOL connectionOK;
@@ -29,9 +30,11 @@ @implementation STAppDelegate
2930

3031
- (void) applicationDidFinishLaunching:(NSNotification *)aNotification {
3132
_syncthing = [[XGSyncthing alloc] init];
32-
33+
3334
[self applicationLoadConfiguration];
3435

36+
[self showOnboardingView];
37+
3538
_process = [[DaemonProcess alloc] initWithPath:_executable arguments: _arguments delegate:self];
3639
[_process launch];
3740

@@ -46,6 +49,34 @@ - (void) clickedFolder:(id)sender {
4649
[[NSWorkspace sharedWorkspace] selectFile:path inFileViewerRootedAtPath:@""];
4750
}
4851

52+
- (void)showOnboardingView {
53+
// 1. Call the Swift factory method to get the NSViewController.
54+
NSViewController *onboardingViewController = [OnboardingViewFactory makeOnboardingViewController];
55+
56+
// 2. Create a new window instance.
57+
NSRect frame = NSMakeRect(0, 0, 500, 500);
58+
NSWindowStyleMask style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable;
59+
NSWindow *newWindow = [[NSWindow alloc] initWithContentRect:frame
60+
styleMask:style
61+
backing:NSBackingStoreBuffered
62+
defer:NO];
63+
[newWindow center];
64+
[newWindow setLevel:NSFloatingWindowLevel];
65+
66+
// 3. Set your view controller as the window's content view controller.
67+
// This is the key step that connects them.
68+
newWindow.contentViewController = onboardingViewController;
69+
70+
// 4. Create a window controller to manage the window.
71+
self.myWindowController = [[NSWindowController alloc] initWithWindow:newWindow];
72+
73+
// 5. Show the window.
74+
[self.myWindowController showWindow:nil];
75+
76+
NSLog(@"Frame %@", NSStringFromRect(frame));
77+
NSLog(@"Frame %@", NSStringFromRect(newWindow.frame));
78+
}
79+
4980
- (void) applicationWillTerminate:(NSNotification *)aNotification {
5081
[_process terminate];
5182
}

syncthing/UI/OnboardingView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ struct OnboardingView: View {
7777
title: String(localized: "Your devices, your data, your responsibility"),
7878
description: String(
7979
localized:
80-
"You decide with which devices you share which files. Syncthing is a selfhosted secure Peer-to-peer app without a central server or cloud service. This also means the app makers cannot help you access or recover any lost files."
80+
"You decide with which devices you share your data with. Syncthing is a selfhosted secure Peer-to-peer app without a central server or cloud service. This also means the app makers cannot help you access or recover any lost files."
8181
)
8282
)
8383

0 commit comments

Comments
 (0)