From 23e7e76e36c2b86fe39e7758cdded5cfa1ef2745 Mon Sep 17 00:00:00 2001 From: rlarldud1234 Date: Fri, 24 Feb 2023 12:40:07 +0900 Subject: [PATCH 1/8] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20SDBottomSheet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/BottomSheet/SDBottomSheet.swift | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 SemicolonDesign/Sources/BottomSheet/SDBottomSheet.swift diff --git a/SemicolonDesign/Sources/BottomSheet/SDBottomSheet.swift b/SemicolonDesign/Sources/BottomSheet/SDBottomSheet.swift new file mode 100644 index 00000000..80166b4a --- /dev/null +++ b/SemicolonDesign/Sources/BottomSheet/SDBottomSheet.swift @@ -0,0 +1,43 @@ +import SwiftUI + +struct SDBottomSheet: View { + @Binding var isPresented: Bool + var buttons: [(text: String, action: () -> Void)] + + init( + isPresented: Binding, + buttons: [(text: String, action: () -> Void)] + ) { + self.buttons = buttons + self._isPresented = isPresented + } + + var body: some View { + VStack(alignment: .leading, spacing: 0) { + ForEach(buttons, id: \.text) { button in + Button{ + self.isPresented = false + button.action() + } label: { + HStack { + Text(button.text) + Spacer() + } + } + .padding(.bottom, 26) + } + } + .foregroundColor(.black) + .padding(.leading, 29) + .padding(.top, 38) + .padding(.bottom, 4) + .background(Color.white) + .cornerRadius(16, [.topLeft, .topRight]) + } +} + +struct SwiftUIView_Previews: PreviewProvider { + static var previews: some View { + SDBottomSheetPreview() + } +} From f6e785cb8d6f32f6dee4574bee632066675f2e6a Mon Sep 17 00:00:00 2001 From: rlarldud1234 Date: Fri, 24 Feb 2023 12:40:20 +0900 Subject: [PATCH 2/8] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20SDBottomSheetModi?= =?UTF-8?q?fier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BottomSheet/SDBottomSheetModifier.swift | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 SemicolonDesign/Sources/BottomSheet/SDBottomSheetModifier.swift diff --git a/SemicolonDesign/Sources/BottomSheet/SDBottomSheetModifier.swift b/SemicolonDesign/Sources/BottomSheet/SDBottomSheetModifier.swift new file mode 100644 index 00000000..e58dce4d --- /dev/null +++ b/SemicolonDesign/Sources/BottomSheet/SDBottomSheetModifier.swift @@ -0,0 +1,23 @@ +import SwiftUI + +struct SDBottomSheetModifier: ViewModifier { + + var isPresented: Binding + var buttons: [(text: String, action: () -> Void)] + + func body(content: Content) -> some View { + ZStack { + content + if isPresented.wrappedValue { + Color.black.opacity(0.4) + .ignoresSafeArea() + VStack { + Spacer() + SDBottomSheet(isPresented: isPresented, buttons: buttons) + } + .ignoresSafeArea() + .animation(.easeOut, value: isPresented.wrappedValue) + } + } + } +} From 9007f603fd06392a010956d8d729f94e16be876b Mon Sep 17 00:00:00 2001 From: rlarldud1234 Date: Fri, 24 Feb 2023 12:40:32 +0900 Subject: [PATCH 3/8] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20View+sdBottomShee?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/BottomSheet/View+sdBottomSheet.swift | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 SemicolonDesign/Sources/BottomSheet/View+sdBottomSheet.swift diff --git a/SemicolonDesign/Sources/BottomSheet/View+sdBottomSheet.swift b/SemicolonDesign/Sources/BottomSheet/View+sdBottomSheet.swift new file mode 100644 index 00000000..1ddb0dba --- /dev/null +++ b/SemicolonDesign/Sources/BottomSheet/View+sdBottomSheet.swift @@ -0,0 +1,7 @@ +import SwiftUI + +public extension View { + func sdBottomSheet(isPresented: Binding, buttons: [(text: String, action: () -> Void)]) -> some View { + self.modifier(SDBottomSheetModifier(isPresented: isPresented, buttons: buttons)) + } +} From 83619583d97e0e1b55f2d05ededab1839bb99cf1 Mon Sep 17 00:00:00 2001 From: rlarldud1234 Date: Fri, 24 Feb 2023 12:40:42 +0900 Subject: [PATCH 4/8] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20sdBottomSheetPrev?= =?UTF-8?q?iew?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Preview/SDBottomSheetPreview.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 SemicolonDesign/Sources/BottomSheet/Preview/SDBottomSheetPreview.swift diff --git a/SemicolonDesign/Sources/BottomSheet/Preview/SDBottomSheetPreview.swift b/SemicolonDesign/Sources/BottomSheet/Preview/SDBottomSheetPreview.swift new file mode 100644 index 00000000..c2a3fd17 --- /dev/null +++ b/SemicolonDesign/Sources/BottomSheet/Preview/SDBottomSheetPreview.swift @@ -0,0 +1,17 @@ +import SwiftUI + +struct SDBottomSheetPreview: View { + @State var isPresented: Bool = false + var body: some View { + Button { + isPresented = true + } label: { + Text("Test BottomSheet") + } + .sdBottomSheet(isPresented: $isPresented, buttons: [ + (text: "수정하기", action: { print("!!!!!") }), + (text: "삭제하기", action: { print("반가워요") }) + ]) + } +} + From 310c3aaf8de628823b0a6f5b6f1291913419ca4c Mon Sep 17 00:00:00 2001 From: rlarldud1234 Date: Fri, 24 Feb 2023 12:40:55 +0900 Subject: [PATCH 5/8] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20View=20cornerRadi?= =?UTF-8?q?us=20=EC=9B=90=ED=95=98=EB=8A=94=20=EA=B3=B3=EB=A7=8C=20?= =?UTF-8?q?=EC=A3=BC=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Extension/View+cornerRadius.swift | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 SemicolonDesign/Sources/Extension/View+cornerRadius.swift diff --git a/SemicolonDesign/Sources/Extension/View+cornerRadius.swift b/SemicolonDesign/Sources/Extension/View+cornerRadius.swift new file mode 100644 index 00000000..49e822b0 --- /dev/null +++ b/SemicolonDesign/Sources/Extension/View+cornerRadius.swift @@ -0,0 +1,23 @@ +import SwiftUI + +extension View { + func cornerRadius(_ radius: CGFloat, _ corners: UIRectCorner) -> some View { + clipShape(RoundedCorner(radius: radius, corners: corners)) + } +} + +struct RoundedCorner: Shape { + + var radius: CGFloat = .infinity + var corners: UIRectCorner = .allCorners + + func path(in rect: CGRect) -> Path { + let path = UIBezierPath( + roundedRect: rect, + byRoundingCorners: corners, + cornerRadii: CGSize(width: radius, height: radius) + ) + return Path(path.cgPath) + } + +} From 700a0ada808ad5e7b57cabc595932eb192233d22 Mon Sep 17 00:00:00 2001 From: rlarldud1234 Date: Fri, 24 Feb 2023 18:55:00 +0900 Subject: [PATCH 6/8] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EB=B0=91?= =?UTF-8?q?=EC=97=90=20=ED=95=98=EB=8B=A8=EC=9D=84=20color=EB=A1=9C=20?= =?UTF-8?q?=EA=B3=A0=EC=A0=95=20=EC=8B=9C=ED=82=A4=EA=B3=A0=20=EB=B2=84?= =?UTF-8?q?=ED=8A=BC=EC=9D=84=20=EB=94=B0=EB=A1=9C=20=EB=B6=80=EB=A6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SemicolonDesign/Sources/BottomSheet/SDBottomSheet.swift | 4 ++-- .../Sources/BottomSheet/SDBottomSheetModifier.swift | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/SemicolonDesign/Sources/BottomSheet/SDBottomSheet.swift b/SemicolonDesign/Sources/BottomSheet/SDBottomSheet.swift index 80166b4a..e85f5892 100644 --- a/SemicolonDesign/Sources/BottomSheet/SDBottomSheet.swift +++ b/SemicolonDesign/Sources/BottomSheet/SDBottomSheet.swift @@ -24,12 +24,12 @@ struct SDBottomSheet: View { Spacer() } } - .padding(.bottom, 26) + .padding(.top, 26) } } .foregroundColor(.black) .padding(.leading, 29) - .padding(.top, 38) + .padding(.top, 12) .padding(.bottom, 4) .background(Color.white) .cornerRadius(16, [.topLeft, .topRight]) diff --git a/SemicolonDesign/Sources/BottomSheet/SDBottomSheetModifier.swift b/SemicolonDesign/Sources/BottomSheet/SDBottomSheetModifier.swift index e58dce4d..41b8d6af 100644 --- a/SemicolonDesign/Sources/BottomSheet/SDBottomSheetModifier.swift +++ b/SemicolonDesign/Sources/BottomSheet/SDBottomSheetModifier.swift @@ -11,9 +11,11 @@ struct SDBottomSheetModifier: ViewModifier { if isPresented.wrappedValue { Color.black.opacity(0.4) .ignoresSafeArea() - VStack { + VStack(spacing: 0) { Spacer() SDBottomSheet(isPresented: isPresented, buttons: buttons) + Color.white + .frame(height: 30) } .ignoresSafeArea() .animation(.easeOut, value: isPresented.wrappedValue) From 15f520fbf66c37400ec3103554299cb2d8f2bcdc Mon Sep 17 00:00:00 2001 From: rlarldud1234 Date: Fri, 24 Feb 2023 21:38:00 +0900 Subject: [PATCH 7/8] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EA=B8=B0?= =?UTF-8?q?=EC=A2=85=EC=9D=98=20=EB=94=B0=EB=9D=BC=20=EC=98=81=ED=96=A5=20?= =?UTF-8?q?=EB=B0=9B=EC=A7=80=20=EC=95=8A=EA=B3=A0=20=EC=9C=84=EC=B9=98=20?= =?UTF-8?q?=EB=98=91=EA=B0=99=EA=B2=8C=20=EC=A7=80=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SemicolonDesign/Sources/BottomSheet/SDBottomSheet.swift | 4 ++-- .../Sources/BottomSheet/SDBottomSheetModifier.swift | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/SemicolonDesign/Sources/BottomSheet/SDBottomSheet.swift b/SemicolonDesign/Sources/BottomSheet/SDBottomSheet.swift index e85f5892..b4930664 100644 --- a/SemicolonDesign/Sources/BottomSheet/SDBottomSheet.swift +++ b/SemicolonDesign/Sources/BottomSheet/SDBottomSheet.swift @@ -24,12 +24,12 @@ struct SDBottomSheet: View { Spacer() } } - .padding(.top, 26) + .padding(.bottom, 26) } } .foregroundColor(.black) .padding(.leading, 29) - .padding(.top, 12) + .padding(.top, 36) .padding(.bottom, 4) .background(Color.white) .cornerRadius(16, [.topLeft, .topRight]) diff --git a/SemicolonDesign/Sources/BottomSheet/SDBottomSheetModifier.swift b/SemicolonDesign/Sources/BottomSheet/SDBottomSheetModifier.swift index 41b8d6af..26a0e12e 100644 --- a/SemicolonDesign/Sources/BottomSheet/SDBottomSheetModifier.swift +++ b/SemicolonDesign/Sources/BottomSheet/SDBottomSheetModifier.swift @@ -11,13 +11,16 @@ struct SDBottomSheetModifier: ViewModifier { if isPresented.wrappedValue { Color.black.opacity(0.4) .ignoresSafeArea() + VStack { + Spacer() + Color.white + .edgesIgnoringSafeArea(.bottom) + .frame(height: CGFloat(buttons.count * 15)) + } VStack(spacing: 0) { Spacer() SDBottomSheet(isPresented: isPresented, buttons: buttons) - Color.white - .frame(height: 30) } - .ignoresSafeArea() .animation(.easeOut, value: isPresented.wrappedValue) } } From 06fb2b9a4bfc90bf8f23f9104a1fd26f10463dde Mon Sep 17 00:00:00 2001 From: rlarldud1234 Date: Sat, 25 Feb 2023 12:41:59 +0900 Subject: [PATCH 8/8] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=ED=81=AC?= =?UTF-8?q?=EA=B8=B0=20=EA=B3=A0=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SemicolonDesign/Sources/BottomSheet/SDBottomSheetModifier.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SemicolonDesign/Sources/BottomSheet/SDBottomSheetModifier.swift b/SemicolonDesign/Sources/BottomSheet/SDBottomSheetModifier.swift index 26a0e12e..9082e71a 100644 --- a/SemicolonDesign/Sources/BottomSheet/SDBottomSheetModifier.swift +++ b/SemicolonDesign/Sources/BottomSheet/SDBottomSheetModifier.swift @@ -15,7 +15,7 @@ struct SDBottomSheetModifier: ViewModifier { Spacer() Color.white .edgesIgnoringSafeArea(.bottom) - .frame(height: CGFloat(buttons.count * 15)) + .frame(height: CGFloat(40)) } VStack(spacing: 0) { Spacer()