Skip to content

Commit 1d5820d

Browse files
committed
Merge branch 'vapidinfinity-main'
2 parents 3bf5863 + 110f236 commit 1d5820d

File tree

3 files changed

+35
-27
lines changed

3 files changed

+35
-27
lines changed

Discord/ContentView.swift

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,45 +20,49 @@ struct ContentView: View {
2020
}
2121

2222
struct DraggableView: NSViewRepresentable {
23+
class Coordinator: NSObject {
24+
@objc func handlePanGesture(_ gesture: NSPanGestureRecognizer) {
25+
guard let window = gesture.view?.window, let event = NSApp.currentEvent else { return }
26+
27+
switch gesture.state {
28+
case .began, .changed:
29+
window.performDrag(with: event)
30+
default:
31+
break
32+
}
33+
}
34+
}
35+
2336
func makeNSView(context: Context) -> NSView {
24-
let view = DragView()
37+
let view = NSView()
2538
view.wantsLayer = true
2639
view.layer?.backgroundColor = .clear
27-
40+
2841
// Ensure the view is above others and can receive mouse events
2942
view.translatesAutoresizingMaskIntoConstraints = false
3043
view.layer?.zPosition = 999
44+
45+
let panGesture = NSPanGestureRecognizer(
46+
target: context.coordinator,
47+
action: #selector(Coordinator.handlePanGesture(_:))
48+
)
49+
panGesture.allowedTouchTypes = [.direct]
50+
view.addGestureRecognizer(panGesture)
51+
3152
return view
3253
}
33-
54+
3455
func updateNSView(_ nsView: NSView, context: Context) {}
35-
}
3656

37-
class DragView: NSView {
38-
// Allow dragging the window from this view
39-
override var mouseDownCanMoveWindow: Bool { true }
40-
41-
override var allowsVibrancy: Bool { true }
42-
43-
override func hitTest(_ point: NSPoint) -> NSView? {
44-
if let currentEvent = NSApplication.shared.currentEvent,
45-
currentEvent.type == .leftMouseDown ||
46-
(currentEvent.type == .leftMouseDragged && NSEvent.pressedMouseButtons == 1) {
47-
return self
48-
}
49-
// Pass through all other events
50-
return nil
51-
}
52-
53-
override func mouseDown(with event: NSEvent) {
54-
window?.performDrag(with: event)
57+
func makeCoordinator() -> Coordinator {
58+
Coordinator()
5559
}
5660
}
5761

5862
struct VisualEffectView: NSViewRepresentable {
5963
let material: NSVisualEffectView.Material
6064
let blendingMode: NSVisualEffectView.BlendingMode
61-
65+
6266
func makeNSView(context: Context) -> NSVisualEffectView {
6367
let visualEffectView = NSVisualEffectView()
6468
visualEffectView.material = material

Discord/DiscordWindowContent.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct DiscordWindowContent: View {
2323
customCSS: customCSS,
2424
webViewReference: $webViewReference)
2525
.frame(maxWidth: .infinity, maxHeight: .infinity)
26-
.onChange(of: fakeNitro) { fakeNitro in
26+
.onChange(of: fakeNitro) {
2727
guard let webView = webViewReference else { return }
2828
if fakeNitro {
2929
enableFakeNitro(webView)
@@ -35,7 +35,7 @@ struct DiscordWindowContent: View {
3535

3636
// Draggable area for traffic lights
3737
DraggableView()
38-
.frame(width: 70, height: 48)
38+
.frame(height: 48)
3939
}
4040
.ignoresSafeArea()
4141
.frame(maxWidth: .infinity, maxHeight: .infinity)
@@ -57,3 +57,7 @@ func enableFakeNitro(_ webView: WKWebView) {
5757
webView.reload()
5858
webView.configuration.userContentController.addUserScript(WKUserScript(source: script, injectionTime: .atDocumentEnd, forMainFrameOnly: true))
5959
}
60+
61+
#Preview {
62+
DiscordWindowContent(channelClickWidth: 1000)
63+
}

Voxa.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@
286286
CURRENT_PROJECT_VERSION = 1;
287287
DEAD_CODE_STRIPPING = YES;
288288
DEVELOPMENT_ASSET_PATHS = "\"Discord/Preview Content\"";
289-
DEVELOPMENT_TEAM = 7BRPLLH5D4;
289+
DEVELOPMENT_TEAM = "";
290290
ENABLE_HARDENED_RUNTIME = YES;
291291
ENABLE_PREVIEWS = YES;
292292
GENERATE_INFOPLIST_FILE = YES;
@@ -324,7 +324,7 @@
324324
CURRENT_PROJECT_VERSION = 1;
325325
DEAD_CODE_STRIPPING = YES;
326326
DEVELOPMENT_ASSET_PATHS = "\"Discord/Preview Content\"";
327-
DEVELOPMENT_TEAM = 7BRPLLH5D4;
327+
DEVELOPMENT_TEAM = "";
328328
ENABLE_HARDENED_RUNTIME = YES;
329329
ENABLE_PREVIEWS = YES;
330330
GENERATE_INFOPLIST_FILE = YES;

0 commit comments

Comments
 (0)