From 32276280b1a257a33611f693831d9b3e2d09bbb2 Mon Sep 17 00:00:00 2001 From: Kai Azim <68963405+MrKai77@users.noreply.github.com> Date: Thu, 22 Jun 2023 20:57:20 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=AB=20Make=20Loop's=20preview=20able?= =?UTF-8?q?=20to=20show=20thirds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Loop/Preview Window/PreviewView.swift | 34 +++++++++++++++------------ 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/Loop/Preview Window/PreviewView.swift b/Loop/Preview Window/PreviewView.swift index 5cf365a5..f81eb993 100644 --- a/Loop/Preview Window/PreviewView.swift +++ b/Loop/Preview Window/PreviewView.swift @@ -13,7 +13,7 @@ struct PreviewView: View { // Used to preview inside the app's settings @State var previewMode = false - @State var currentResizingDirection: WindowDirection = .noAction + @State var currentResizeDirection: WindowDirection = .noAction @Default(.useSystemAccentColor) var useSystemAccentColor @Default(.accentColor) var accentColor @@ -28,19 +28,19 @@ struct PreviewView: View { var body: some View { GeometryReader { geo in VStack { - switch currentResizingDirection { + switch currentResizeDirection { case .bottomHalf, .bottomRightQuarter, .bottomLeftQuarter, .verticalCenterThird, .bottomThird, .bottomTwoThirds, .noAction: Rectangle() - .frame(width: currentResizingDirection == .bottomThird ? geo.size.height / 3 * 2 : nil) + .frame(width: currentResizeDirection == .bottomThird ? geo.size.height / 3 * 2 : nil) default: EmptyView() } HStack { - switch currentResizingDirection { + switch currentResizeDirection { case .rightHalf, .topRightQuarter, .bottomRightQuarter, .horizontalCenterThird, .rightThird, .rightTwoThirds, .noAction: Rectangle() - .frame(width: currentResizingDirection == .rightThird ? geo.size.width / 3 * 2 : nil) + .frame(width: currentResizeDirection == .rightThird ? geo.size.width / 3 * 2 : nil) default: EmptyView() } @@ -64,41 +64,45 @@ struct PreviewView: View { ) } .padding(previewPadding + previewBorderThickness/2) - .frame(width: currentResizingDirection == .noAction ? 0 : nil, - height: currentResizingDirection == .noAction ? 0 : nil) + .frame(width: currentResizeDirection == .noAction ? 0 : nil, + height: currentResizeDirection == .noAction ? 0 : nil) + .frame(width: currentResizeDirection == .topTwoThirds ? geo.size.height / 3 * 2 : nil) + .frame(width: currentResizeDirection == .bottomTwoThirds ? geo.size.height / 3 * 2 : nil) + .frame(width: currentResizeDirection == .rightTwoThirds ? geo.size.width / 3 * 2 : nil) + .frame(width: currentResizeDirection == .leftTwoThirds ? geo.size.width / 3 * 2 : nil) - switch currentResizingDirection { + switch currentResizeDirection { case .leftHalf, .topLeftQuarter, .bottomLeftQuarter, .horizontalCenterThird, .leftThird, .leftTwoThirds, .noAction: Rectangle() - .frame(width: currentResizingDirection == .leftThird ? geo.size.width / 3 * 2 : nil) + .frame(width: currentResizeDirection == .leftThird ? geo.size.width / 3 * 2 : nil) default: EmptyView() } } - switch currentResizingDirection { + switch currentResizeDirection { case .topHalf, .topRightQuarter, .topLeftQuarter, .verticalCenterThird, .topThird, .topTwoThirds, .noAction: Rectangle() - .frame(width: currentResizingDirection == .topThird ? geo.size.width / 3 * 2 : nil) + .frame(width: currentResizeDirection == .topThird ? geo.size.width / 3 * 2 : nil) default: EmptyView() } } } .foregroundColor(.clear) - .opacity(currentResizingDirection == .noAction ? 0 : 1) - .animation(.interpolatingSpring(stiffness: 250, damping: 25), value: currentResizingDirection) + .opacity(currentResizeDirection == .noAction ? 0 : 1) + .animation(.interpolatingSpring(stiffness: 250, damping: 25), value: currentResizeDirection) .onReceive(.currentDirectionChanged) { obj in if !previewMode { if let direction = obj.userInfo?["Direction"] as? WindowDirection { - currentResizingDirection = direction + currentResizeDirection = direction } } } .onAppear { if previewMode { - currentResizingDirection = .maximize + currentResizeDirection = .maximize } } }