From 4ebd8608da5d8656f85771f6e08dbaac2ce2e272 Mon Sep 17 00:00:00 2001 From: opficdev <162981733+opficdev@users.noreply.github.com> Date: Tue, 23 Jun 2026 23:02:27 +0900 Subject: [PATCH] =?UTF-8?q?ui:=20=EB=A7=A5=20=ED=99=98=EA=B2=BD=EC=9D=BC?= =?UTF-8?q?=20=EC=8B=9C=20=ED=86=A0=EC=8A=A4=ED=8A=B8=EA=B0=80=20=EC=83=81?= =?UTF-8?q?=EB=8B=A8=EC=97=90=EC=84=9C=20=EB=9C=A8=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Common/Component/Toast.swift | 45 +++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/Application/DevLogPresentation/Sources/Common/Component/Toast.swift b/Application/DevLogPresentation/Sources/Common/Component/Toast.swift index 7e09ec5d..c774fc0e 100644 --- a/Application/DevLogPresentation/Sources/Common/Component/Toast.swift +++ b/Application/DevLogPresentation/Sources/Common/Component/Toast.swift @@ -88,6 +88,7 @@ private struct ToastHostModifier: ViewModifier { @Environment(\.safeAreaInsets) private var safeAreaInsets @State private var tabBarHeight = CGFloat.zero private let toastPresenter = ToastPresenter.presenter + private let placement = ToastPresentationPlacement.current func body(content: Content) -> some View { content @@ -98,7 +99,7 @@ private struct ToastHostModifier: ViewModifier { .onChange(of: toastPresenter.item?.id) { _, _ in updateTabBarHeight() } - .overlay(alignment: .bottom) { + .overlay(alignment: placement.alignment) { if let item = toastPresenter.item { ToastOverlayView( isPresented: Binding( @@ -110,6 +111,7 @@ private struct ToastHostModifier: ViewModifier { } ), duration: item.duration, + presentedOffset: placement.presentedOffset, action: item.action, onDismiss: item.onDismiss ) { @@ -117,7 +119,7 @@ private struct ToastHostModifier: ViewModifier { } .id(item.id) .padding(.horizontal, 12) - .padding(.bottom, toastBottomInset) + .padding(.bottom, placement.bottomPadding(toastBottomInset)) } } } @@ -141,6 +143,42 @@ private struct ToastHostModifier: ViewModifier { } } +private enum ToastPresentationPlacement { + case top + case bottom + + static var current: ToastPresentationPlacement { + ProcessInfo.processInfo.isiOSAppOnMac ? .top : .bottom + } + + var alignment: Alignment { + switch self { + case .top: + return .top + case .bottom: + return .bottom + } + } + + var presentedOffset: CGFloat { + switch self { + case .top: + return 50 + case .bottom: + return -50 + } + } + + func bottomPadding(_ inset: CGFloat) -> CGFloat { + switch self { + case .top: + return 0 + case .bottom: + return inset + } + } +} + private struct ToastItemLabel: View { let item: ToastItem @@ -161,6 +199,7 @@ private struct ToastItemLabel: View { private struct ToastOverlayView: View { @Binding var isPresented: Bool let duration: TimeInterval + let presentedOffset: CGFloat let action: (() -> Void)? let onDismiss: (() -> Void)? @ViewBuilder let label: () -> Label @@ -209,7 +248,7 @@ private struct ToastOverlayView: View { guard opacityValue == 0 else { return } withAnimation(.spring(response: 0.5, dampingFraction: 1, blendDuration: 0.0)) { - yOffset = -50 + yOffset = presentedOffset opacityValue = 1 } }