From a28f88df3a4b1b436974190fc77eb7895175e729 Mon Sep 17 00:00:00 2001 From: InhyeKang Date: Mon, 13 Mar 2023 20:19:20 +0900 Subject: [PATCH 01/11] =?UTF-8?q?feat=20::=20=EC=8B=A0=EC=B2=AD=20?= =?UTF-8?q?=EC=8B=9C=EA=B0=84=20sheet=20=EB=9D=84=EC=9A=B0=EB=8A=94=20?= =?UTF-8?q?=EB=B2=84=ED=8A=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StudyRoomListView.swift | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift index 714b3e78..d3ab83bd 100644 --- a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift +++ b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift @@ -26,8 +26,26 @@ struct StudyRoomListView: View { StudyRoomNoticeView(text: viewModel.rangeString) } LazyVStack(spacing: 16) { - Spacer() - .frame(height: 10) + Button { + print("clicked and will show the popup") + } label: { + HStack(alignment: .center) { + Image(systemName: "slider.horizontal.3") + .foregroundColor(.PrimaryVariant.primary) + .frame(width: 15) + .padding(.top, 4) + .padding(.trailing, 11) + + Text("10시 ~ 11시") + .dmsFont(.etc(.button), color: .PrimaryVariant.primary) + .frame(height: 22) + + Spacer() + } + } + .padding(.vertical, 9) + .padding(.leading, 27) + ForEach(viewModel.studyRoomList, id: \.self) { studyRoomList in Button { viewModel.isNavigateDetail.toggle() From 7fac4e65415cb9a9bf9ef7b01d0c95124db65e22 Mon Sep 17 00:00:00 2001 From: InhyeKang Date: Tue, 14 Mar 2023 09:07:08 +0900 Subject: [PATCH 02/11] =?UTF-8?q?feat=20::=20=EC=8B=9C=EA=B0=84=20?= =?UTF-8?q?=EC=84=A0=ED=83=9D=20Bottom=20Sheet=20=EB=9D=84=EC=9A=B0?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StudyRoomListView.swift | 7 ++++- .../StudyRoomListViewModel.swift | 1 + .../StudyroomTimeListView.swift | 31 +++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyroomTimeListView.swift diff --git a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift index d3ab83bd..c33d6d9a 100644 --- a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift +++ b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift @@ -27,7 +27,7 @@ struct StudyRoomListView: View { } LazyVStack(spacing: 16) { Button { - print("clicked and will show the popup") + viewModel.isShowingBottomSheet.toggle() } label: { HStack(alignment: .center) { Image(systemName: "slider.horizontal.3") @@ -70,6 +70,11 @@ struct StudyRoomListView: View { .navigationBarTitleDisplayMode(.inline) .dmsBackButton(dismiss: dismiss) .dmsBackground() + .dmsBottomSheet(isShowing: $viewModel.isShowingBottomSheet) { + DeferView { + StudyroomTimeListView() + } + } .dmsToast(isShowing: $viewModel.isErrorOcuured, message: viewModel.errorMessage, style: .error) .onAppear { viewModel.onAppear() diff --git a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListViewModel.swift b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListViewModel.swift index f18939e1..7c25f758 100644 --- a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListViewModel.swift +++ b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListViewModel.swift @@ -12,6 +12,7 @@ final class StudyRoomListViewModel: BaseViewModel { @Published var toastMessage = "" @Published var studyAvailableTime: StudyAvailableTimeEntity? @Published var isNavigateDetail: Bool = false + @Published var isShowingBottomSheet: Bool = false @Published var studyRoomDetail: StudyRoomEntity = .init( id: "", floor: 0, diff --git a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyroomTimeListView.swift b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyroomTimeListView.swift new file mode 100644 index 00000000..57c2f36a --- /dev/null +++ b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyroomTimeListView.swift @@ -0,0 +1,31 @@ +import Foundation +import DesignSystem +import SwiftUI + +struct StudyroomTimeListView: View { + @State var isClicked: Bool = false + var body: some View { + VStack { + Text("시간") + .dmsFont(.title(.subTitle1), color: .GrayScale.gray10) + .frame(height: 28) + .padding(.top, 40) + .padding(.leading, 24) + + ScrollView(.horizontal, showsIndicators: false) { + ForEach(0..<5) { _ in + Button { + isClicked.toggle() + } label: { + Text("10시 ~ 11시") + .dmsFont(.etc(.button), color: <#T##Color#>) + } + } + } + } + .frame(width: .infinity, height: .infinity) + .background( + Color.GrayScale.gray1 + ) + } +} From 2874451a7b5addee6f313ebd6380ec7ec18400bc Mon Sep 17 00:00:00 2001 From: InhyeKang Date: Wed, 15 Mar 2023 19:47:25 +0900 Subject: [PATCH 03/11] =?UTF-8?q?feat=20::=20=EC=9E=90=EC=8A=B5=EC=8B=A4?= =?UTF-8?q?=20=EC=9D=B4=EC=9A=A9=20=EC=8B=9C=EA=B0=84=20Bottom=20Sheet=20U?= =?UTF-8?q?I=20=ED=8D=BC=EB=B8=94=EB=A6=AC=EC=8B=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StudyRoomListView.swift | 6 +- .../StudyroomTimeListView.swift | 63 ++++++++++--- .../BottomSheet/DMSTimeBottomSheet.swift | 88 +++++++++++++++++++ 3 files changed, 143 insertions(+), 14 deletions(-) create mode 100644 Projects/UsertInterfaces/DesignSystem/Sources/BottomSheet/DMSTimeBottomSheet.swift diff --git a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift index c33d6d9a..4f6165a4 100644 --- a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift +++ b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift @@ -27,7 +27,9 @@ struct StudyRoomListView: View { } LazyVStack(spacing: 16) { Button { - viewModel.isShowingBottomSheet.toggle() + withAnimation { + viewModel.isShowingBottomSheet.toggle() + } } label: { HStack(alignment: .center) { Image(systemName: "slider.horizontal.3") @@ -70,7 +72,7 @@ struct StudyRoomListView: View { .navigationBarTitleDisplayMode(.inline) .dmsBackButton(dismiss: dismiss) .dmsBackground() - .dmsBottomSheet(isShowing: $viewModel.isShowingBottomSheet) { + .dmsTimeBottomSheet(isShowing: $viewModel.isShowingBottomSheet) { DeferView { StudyroomTimeListView() } diff --git a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyroomTimeListView.swift b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyroomTimeListView.swift index 57c2f36a..f3dc4e26 100644 --- a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyroomTimeListView.swift +++ b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyroomTimeListView.swift @@ -3,29 +3,68 @@ import DesignSystem import SwiftUI struct StudyroomTimeListView: View { + @State var isAvailable: Bool = true @State var isClicked: Bool = false var body: some View { - VStack { + VStack(alignment: .leading, spacing: 37) { Text("시간") .dmsFont(.title(.subTitle1), color: .GrayScale.gray10) .frame(height: 28) .padding(.top, 40) .padding(.leading, 24) - ScrollView(.horizontal, showsIndicators: false) { - ForEach(0..<5) { _ in - Button { - isClicked.toggle() - } label: { - Text("10시 ~ 11시") - .dmsFont(.etc(.button), color: <#T##Color#>) + if isAvailable { + ScrollView(.horizontal, showsIndicators: false) { + HStack { + ForEach(0..<5) { _ in + Button { + isClicked.toggle() + } label: { + Text("10시 ~ 11시") + .padding(.horizontal, 16) + .padding(.vertical, 14) + .dmsFont( + .etc(.button), + color: isClicked ? .GrayScale.gray1 : .GrayScale.gray4 + ) + .background { + isClicked ? Color.PrimaryVariant.primary : Color.GrayScale.gray1 + } + } + .overlay( + RoundedRectangle(cornerRadius: 5) + .inset(by: 1) + .stroke( + isClicked ? Color.System.primary : Color.GrayScale.gray4, + lineWidth: 2 + ) + ) + .cornerRadius(5) + .padding(.horizontal, 5) + } } } + .padding(.horizontal, 19) + .padding(.bottom, 10) + } + + DMSWideButton( + text: "확인", + style: .contained, + color: .PrimaryVariant.primary, + action: { + print("OK") + } + ) + .padding(.horizontal, 24) + .padding(.bottom) + } + .onAppear { + DispatchQueue.main.asyncAfter(deadline: .now() + 0.15) { + withAnimation { + isAvailable = true + } } } - .frame(width: .infinity, height: .infinity) - .background( - Color.GrayScale.gray1 - ) } } diff --git a/Projects/UsertInterfaces/DesignSystem/Sources/BottomSheet/DMSTimeBottomSheet.swift b/Projects/UsertInterfaces/DesignSystem/Sources/BottomSheet/DMSTimeBottomSheet.swift new file mode 100644 index 00000000..190b09a3 --- /dev/null +++ b/Projects/UsertInterfaces/DesignSystem/Sources/BottomSheet/DMSTimeBottomSheet.swift @@ -0,0 +1,88 @@ +import SwiftUI + +struct DMSTimeBottomSheet: ViewModifier { + @Binding var isShowing: Bool + @State var dragHeight: CGFloat = 0 + var content: () -> T + var height: CGFloat + var sheetDragging: some Gesture { + DragGesture(minimumDistance: 0, coordinateSpace: .global) + .onChanged { value in + withAnimation(.spring()) { + dragHeight = min(30, -value.translation.height) + } + } + .onEnded { value in + withAnimation(.spring()) { + dragHeight = 0 + } + let verticalAmount = value.translation.height + if verticalAmount > 100 { + withAnimation { + isShowing = false + } + } + } + } + + init( + isShowing: Binding, + height: CGFloat = .infinity, + content: @escaping () -> T + ) { + _isShowing = isShowing + self.height = height + self.content = content + } + + func body(content: Content) -> some View { + ZStack { + content + + ZStack(alignment: .bottom) { + if isShowing { + Color.GrayScale.gray9 + .opacity(0.10) + .ignoresSafeArea() + .onTapGesture { + withAnimation { + isShowing = false + } + } + .gesture(sheetDragging) + .transition(.opacity) + + ZStack { + Color.GrayScale.gray1 + .cornerRadius(8, corners: [.topLeft, .topRight]) + .padding(.top, -dragHeight) + .gesture(sheetDragging) + + VStack { + self.content() + .frame(maxWidth: .infinity) + } + .padding(.bottom, 42) + .offset(y: -dragHeight) + } + .fixedSize(horizontal: false, vertical: true) + .transition(.move(edge: .bottom)) + .if(height != .infinity) { + $0.frame(height: height) + } + } + } + .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottom) + .ignoresSafeArea() + } + } +} + +public extension View { + func dmsTimeBottomSheet( + isShowing: Binding, + content: @escaping () -> Content + ) -> some View { + modifier(DMSTimeBottomSheet(isShowing: isShowing, content: content)) + } +} From 244931680f7eced54d8d295088bc05d39d1233c0 Mon Sep 17 00:00:00 2001 From: InhyeKang Date: Wed, 15 Mar 2023 23:24:07 +0900 Subject: [PATCH 04/11] =?UTF-8?q?refactor=20::=20=EC=93=B8=20=EB=8D=B0=20?= =?UTF-8?q?=EC=97=86=EB=8A=94=20=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StudyroomTimeListView.swift | 66 ++++++++----------- 1 file changed, 28 insertions(+), 38 deletions(-) diff --git a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyroomTimeListView.swift b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyroomTimeListView.swift index f3dc4e26..27ead202 100644 --- a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyroomTimeListView.swift +++ b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyroomTimeListView.swift @@ -3,7 +3,6 @@ import DesignSystem import SwiftUI struct StudyroomTimeListView: View { - @State var isAvailable: Bool = true @State var isClicked: Bool = false var body: some View { VStack(alignment: .leading, spacing: 37) { @@ -13,40 +12,38 @@ struct StudyroomTimeListView: View { .padding(.top, 40) .padding(.leading, 24) - if isAvailable { - ScrollView(.horizontal, showsIndicators: false) { - HStack { - ForEach(0..<5) { _ in - Button { - isClicked.toggle() - } label: { - Text("10시 ~ 11시") - .padding(.horizontal, 16) - .padding(.vertical, 14) - .dmsFont( - .etc(.button), - color: isClicked ? .GrayScale.gray1 : .GrayScale.gray4 - ) - .background { - isClicked ? Color.PrimaryVariant.primary : Color.GrayScale.gray1 - } - } - .overlay( - RoundedRectangle(cornerRadius: 5) - .inset(by: 1) - .stroke( - isClicked ? Color.System.primary : Color.GrayScale.gray4, - lineWidth: 2 - ) - ) - .cornerRadius(5) - .padding(.horizontal, 5) + ScrollView(.horizontal, showsIndicators: false) { + HStack { + ForEach(0..<5) { _ in + Button { + isClicked.toggle() + } label: { + Text("10시 ~ 11시") + .padding(.horizontal, 16) + .padding(.vertical, 14) + .dmsFont( + .etc(.button), + color: isClicked ? .GrayScale.gray1 : .GrayScale.gray4 + ) + .background { + isClicked ? Color.PrimaryVariant.primary : Color.GrayScale.gray1 + } } + .overlay( + RoundedRectangle(cornerRadius: 5) + .inset(by: 1) + .stroke( + isClicked ? Color.System.primary : Color.GrayScale.gray4, + lineWidth: 2 + ) + ) + .cornerRadius(5) + .padding(.horizontal, 5) } } - .padding(.horizontal, 19) - .padding(.bottom, 10) } + .padding(.horizontal, 19) + .padding(.bottom, 10) DMSWideButton( text: "확인", @@ -59,12 +56,5 @@ struct StudyroomTimeListView: View { .padding(.horizontal, 24) .padding(.bottom) } - .onAppear { - DispatchQueue.main.asyncAfter(deadline: .now() + 0.15) { - withAnimation { - isAvailable = true - } - } - } } } From 9feba48b694f22baba75eaa1cb1ad771349aa7d8 Mon Sep 17 00:00:00 2001 From: InhyeKang Date: Thu, 16 Mar 2023 16:30:25 +0900 Subject: [PATCH 05/11] =?UTF-8?q?feat=20::=20=ED=99=95=EC=9D=B8=20?= =?UTF-8?q?=EB=B2=84=ED=8A=BC=20=EB=88=84=EB=A5=B4=EB=A9=B4=20sheet=20?= =?UTF-8?q?=EB=8B=AB=ED=9E=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StudyroomApplication/StudyRoomListView.swift | 9 ++++++++- .../StudyroomApplication/StudyroomTimeListView.swift | 11 ++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift index 4f6165a4..ebe013c5 100644 --- a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift +++ b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift @@ -74,7 +74,14 @@ struct StudyRoomListView: View { .dmsBackground() .dmsTimeBottomSheet(isShowing: $viewModel.isShowingBottomSheet) { DeferView { - StudyroomTimeListView() + StudyroomTimeListView( + isClicked: false, + okButtonAction: { + withAnimation { + viewModel.isShowingBottomSheet = false + } + } + ) } } .dmsToast(isShowing: $viewModel.isErrorOcuured, message: viewModel.errorMessage, style: .error) diff --git a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyroomTimeListView.swift b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyroomTimeListView.swift index 27ead202..a1556f19 100644 --- a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyroomTimeListView.swift +++ b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyroomTimeListView.swift @@ -4,6 +4,15 @@ import SwiftUI struct StudyroomTimeListView: View { @State var isClicked: Bool = false + let okButtonAction: () -> Void + public init( + isClicked: Bool, + okButtonAction: @escaping () -> Void + ) { + self.isClicked = isClicked + self.okButtonAction = okButtonAction + } + var body: some View { VStack(alignment: .leading, spacing: 37) { Text("시간") @@ -50,7 +59,7 @@ struct StudyroomTimeListView: View { style: .contained, color: .PrimaryVariant.primary, action: { - print("OK") + okButtonAction() } ) .padding(.horizontal, 24) From a49182990b2b8a7da096cb058a2de87d126a5693 Mon Sep 17 00:00:00 2001 From: InhyeKang Date: Thu, 16 Mar 2023 18:55:52 +0900 Subject: [PATCH 06/11] =?UTF-8?q?refactor=20::=20frame=20=EB=86=92?= =?UTF-8?q?=EC=9D=B4=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/StudyroomApplication/StudyRoomListView.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift index ebe013c5..5803453d 100644 --- a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift +++ b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift @@ -40,7 +40,6 @@ struct StudyRoomListView: View { Text("10시 ~ 11시") .dmsFont(.etc(.button), color: .PrimaryVariant.primary) - .frame(height: 22) Spacer() } From 062d55a2959d178ca9cb20b07294f23cf1c9c8a1 Mon Sep 17 00:00:00 2001 From: InhyeKang Date: Thu, 16 Mar 2023 19:03:29 +0900 Subject: [PATCH 07/11] =?UTF-8?q?refactor=20::=20=EC=BD=94=EB=A9=98?= =?UTF-8?q?=ED=8A=B8=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/StudyroomApplication/StudyRoomListView.swift | 6 +++--- .../StudyroomApplication/StudyRoomListViewModel.swift | 2 +- .../StudyroomApplication/StudyroomTimeListView.swift | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift index 5803453d..183697f4 100644 --- a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift +++ b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift @@ -28,7 +28,7 @@ struct StudyRoomListView: View { LazyVStack(spacing: 16) { Button { withAnimation { - viewModel.isShowingBottomSheet.toggle() + viewModel.isStudyTimeBottomSheet.toggle() } } label: { HStack(alignment: .center) { @@ -71,13 +71,13 @@ struct StudyRoomListView: View { .navigationBarTitleDisplayMode(.inline) .dmsBackButton(dismiss: dismiss) .dmsBackground() - .dmsTimeBottomSheet(isShowing: $viewModel.isShowingBottomSheet) { + .dmsTimeBottomSheet(isShowing: $viewModel.isStudyTimeBottomSheet) { DeferView { StudyroomTimeListView( isClicked: false, okButtonAction: { withAnimation { - viewModel.isShowingBottomSheet = false + viewModel.isStudyTimeBottomSheet = false } } ) diff --git a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListViewModel.swift b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListViewModel.swift index 7c25f758..87dbd2bd 100644 --- a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListViewModel.swift +++ b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListViewModel.swift @@ -12,7 +12,7 @@ final class StudyRoomListViewModel: BaseViewModel { @Published var toastMessage = "" @Published var studyAvailableTime: StudyAvailableTimeEntity? @Published var isNavigateDetail: Bool = false - @Published var isShowingBottomSheet: Bool = false + @Published var isStudyTimeBottomSheet: Bool = false @Published var studyRoomDetail: StudyRoomEntity = .init( id: "", floor: 0, diff --git a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyroomTimeListView.swift b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyroomTimeListView.swift index a1556f19..e85dcc99 100644 --- a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyroomTimeListView.swift +++ b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyroomTimeListView.swift @@ -22,7 +22,7 @@ struct StudyroomTimeListView: View { .padding(.leading, 24) ScrollView(.horizontal, showsIndicators: false) { - HStack { + LazyHStack { ForEach(0..<5) { _ in Button { isClicked.toggle() From ff9e841a78438070ca7765959a620474c0755aab Mon Sep 17 00:00:00 2001 From: InhyeKang Date: Thu, 16 Mar 2023 23:12:33 +0900 Subject: [PATCH 08/11] =?UTF-8?q?feat=20::=20dmsBottomSheet=20=EA=B3=B5?= =?UTF-8?q?=ED=86=B5=EC=9C=BC=EB=A1=9C=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HomeFeature/Sources/HomeView.swift | 6 ++++- .../StudyRoomListView.swift | 6 ++++- .../Sources/BottomSheet/DMSBottomSheet.swift | 27 ++++++++++++++----- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/Projects/Features/HomeFeature/Sources/HomeView.swift b/Projects/Features/HomeFeature/Sources/HomeView.swift index 4c96ecb4..8d1e499b 100644 --- a/Projects/Features/HomeFeature/Sources/HomeView.swift +++ b/Projects/Features/HomeFeature/Sources/HomeView.swift @@ -86,7 +86,11 @@ struct HomeView: View { } } .dmsBackground() - .dmsBottomSheet(isShowing: $isShowingCalendar) { + .dmsBottomSheet( + isShowing: $isShowingCalendar, + isGrabberOn: true, + sheetCornerRadiusValue: 25 + ) { DeferView { CalendarSheetView(selectedDate: $viewModel.selectedDate) .padding(.top, 24) diff --git a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift index 183697f4..f20a64b1 100644 --- a/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift +++ b/Projects/Features/StudyRoomFeature/Sources/StudyroomApplication/StudyRoomListView.swift @@ -71,7 +71,11 @@ struct StudyRoomListView: View { .navigationBarTitleDisplayMode(.inline) .dmsBackButton(dismiss: dismiss) .dmsBackground() - .dmsTimeBottomSheet(isShowing: $viewModel.isStudyTimeBottomSheet) { + .dmsBottomSheet( + isShowing: $viewModel.isStudyTimeBottomSheet, + isGrabberOn: false, + sheetCornerRadiusValue: 8 + ) { DeferView { StudyroomTimeListView( isClicked: false, diff --git a/Projects/UsertInterfaces/DesignSystem/Sources/BottomSheet/DMSBottomSheet.swift b/Projects/UsertInterfaces/DesignSystem/Sources/BottomSheet/DMSBottomSheet.swift index ec67d563..c843729f 100644 --- a/Projects/UsertInterfaces/DesignSystem/Sources/BottomSheet/DMSBottomSheet.swift +++ b/Projects/UsertInterfaces/DesignSystem/Sources/BottomSheet/DMSBottomSheet.swift @@ -2,6 +2,8 @@ import SwiftUI struct DMSBottomSheet: ViewModifier { @Binding var isShowing: Bool + @State var isGrabberOn: Bool = true + @State var sheetCornerRadiusValue: CGFloat = 0 @State var dragHeight: CGFloat = 0 var content: () -> T var height: CGFloat @@ -27,10 +29,14 @@ struct DMSBottomSheet: ViewModifier { init( isShowing: Binding, + isGrabberOn: Bool, + sheetCornerRadiusValue: CGFloat, height: CGFloat = .infinity, content: @escaping () -> T ) { _isShowing = isShowing + self.isGrabberOn = isGrabberOn + self.sheetCornerRadiusValue = sheetCornerRadiusValue self.height = height self.content = content } @@ -54,15 +60,17 @@ struct DMSBottomSheet: ViewModifier { ZStack { Color.GrayScale.gray1 - .cornerRadius(25, corners: [.topLeft, .topRight]) + .cornerRadius(CGFloat(sheetCornerRadiusValue), corners: [.topLeft, .topRight]) .padding(.top, -dragHeight) .gesture(sheetDragging) VStack { - RoundedRectangle(cornerRadius: 5) - .fill(Color.GrayScale.gray4) - .frame(width: 100, height: 4) - .padding(.top, 12) + if isGrabberOn { + RoundedRectangle(cornerRadius: 5) + .fill(Color.GrayScale.gray4) + .frame(width: 100, height: 4) + .padding(.top, 12) + } self.content() .frame(maxWidth: .infinity) @@ -86,8 +94,15 @@ struct DMSBottomSheet: ViewModifier { public extension View { func dmsBottomSheet( isShowing: Binding, + isGrabberOn: Bool, + sheetCornerRadiusValue: CGFloat, content: @escaping () -> Content ) -> some View { - modifier(DMSBottomSheet(isShowing: isShowing, content: content)) + modifier(DMSBottomSheet( + isShowing: isShowing, + isGrabberOn: isGrabberOn, + sheetCornerRadiusValue: sheetCornerRadiusValue, + content: content + )) } } From ce4291789076490be060794de6b60297ae6b0ec1 Mon Sep 17 00:00:00 2001 From: InhyeKang Date: Thu, 16 Mar 2023 23:15:23 +0900 Subject: [PATCH 09/11] =?UTF-8?q?refactor=20::=20=EC=93=B8=20=EB=8D=B0=20?= =?UTF-8?q?=EC=97=86=EB=8A=94=20=ED=8C=8C=EC=9D=BC=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BottomSheet/DMSTimeBottomSheet.swift | 88 ------------------- 1 file changed, 88 deletions(-) delete mode 100644 Projects/UsertInterfaces/DesignSystem/Sources/BottomSheet/DMSTimeBottomSheet.swift diff --git a/Projects/UsertInterfaces/DesignSystem/Sources/BottomSheet/DMSTimeBottomSheet.swift b/Projects/UsertInterfaces/DesignSystem/Sources/BottomSheet/DMSTimeBottomSheet.swift deleted file mode 100644 index 190b09a3..00000000 --- a/Projects/UsertInterfaces/DesignSystem/Sources/BottomSheet/DMSTimeBottomSheet.swift +++ /dev/null @@ -1,88 +0,0 @@ -import SwiftUI - -struct DMSTimeBottomSheet: ViewModifier { - @Binding var isShowing: Bool - @State var dragHeight: CGFloat = 0 - var content: () -> T - var height: CGFloat - var sheetDragging: some Gesture { - DragGesture(minimumDistance: 0, coordinateSpace: .global) - .onChanged { value in - withAnimation(.spring()) { - dragHeight = min(30, -value.translation.height) - } - } - .onEnded { value in - withAnimation(.spring()) { - dragHeight = 0 - } - let verticalAmount = value.translation.height - if verticalAmount > 100 { - withAnimation { - isShowing = false - } - } - } - } - - init( - isShowing: Binding, - height: CGFloat = .infinity, - content: @escaping () -> T - ) { - _isShowing = isShowing - self.height = height - self.content = content - } - - func body(content: Content) -> some View { - ZStack { - content - - ZStack(alignment: .bottom) { - if isShowing { - Color.GrayScale.gray9 - .opacity(0.10) - .ignoresSafeArea() - .onTapGesture { - withAnimation { - isShowing = false - } - } - .gesture(sheetDragging) - .transition(.opacity) - - ZStack { - Color.GrayScale.gray1 - .cornerRadius(8, corners: [.topLeft, .topRight]) - .padding(.top, -dragHeight) - .gesture(sheetDragging) - - VStack { - self.content() - .frame(maxWidth: .infinity) - } - .padding(.bottom, 42) - .offset(y: -dragHeight) - } - .fixedSize(horizontal: false, vertical: true) - .transition(.move(edge: .bottom)) - .if(height != .infinity) { - $0.frame(height: height) - } - } - } - .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottom) - .ignoresSafeArea() - } - } -} - -public extension View { - func dmsTimeBottomSheet( - isShowing: Binding, - content: @escaping () -> Content - ) -> some View { - modifier(DMSTimeBottomSheet(isShowing: isShowing, content: content)) - } -} From 4af28af067bff8b5286bad9de1c9c32dc487b80d Mon Sep 17 00:00:00 2001 From: InhyeKang Date: Fri, 17 Mar 2023 14:59:35 +0900 Subject: [PATCH 10/11] =?UTF-8?q?refactor=20::=20=EC=BD=94=EB=A9=98?= =?UTF-8?q?=ED=8A=B8=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/BottomSheet/DMSBottomSheet.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Projects/UsertInterfaces/DesignSystem/Sources/BottomSheet/DMSBottomSheet.swift b/Projects/UsertInterfaces/DesignSystem/Sources/BottomSheet/DMSBottomSheet.swift index c843729f..b4db7fd3 100644 --- a/Projects/UsertInterfaces/DesignSystem/Sources/BottomSheet/DMSBottomSheet.swift +++ b/Projects/UsertInterfaces/DesignSystem/Sources/BottomSheet/DMSBottomSheet.swift @@ -2,8 +2,8 @@ import SwiftUI struct DMSBottomSheet: ViewModifier { @Binding var isShowing: Bool - @State var isGrabberOn: Bool = true - @State var sheetCornerRadiusValue: CGFloat = 0 + @State var isGrabberOn: Bool + @State var sheetCornerRadiusValue: CGFloat @State var dragHeight: CGFloat = 0 var content: () -> T var height: CGFloat @@ -29,8 +29,8 @@ struct DMSBottomSheet: ViewModifier { init( isShowing: Binding, - isGrabberOn: Bool, - sheetCornerRadiusValue: CGFloat, + isGrabberOn: Bool = false, + sheetCornerRadiusValue: CGFloat = 25, height: CGFloat = .infinity, content: @escaping () -> T ) { @@ -60,7 +60,7 @@ struct DMSBottomSheet: ViewModifier { ZStack { Color.GrayScale.gray1 - .cornerRadius(CGFloat(sheetCornerRadiusValue), corners: [.topLeft, .topRight]) + .cornerRadius(sheetCornerRadiusValue, corners: [.topLeft, .topRight]) .padding(.top, -dragHeight) .gesture(sheetDragging) From 32779c4de40dc9bb3cc34c6993f886d28442e391 Mon Sep 17 00:00:00 2001 From: InhyeKang Date: Fri, 17 Mar 2023 15:07:33 +0900 Subject: [PATCH 11/11] =?UTF-8?q?refactor=20::=20default=20=EA=B0=92=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DesignSystem/Sources/BottomSheet/DMSBottomSheet.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Projects/UsertInterfaces/DesignSystem/Sources/BottomSheet/DMSBottomSheet.swift b/Projects/UsertInterfaces/DesignSystem/Sources/BottomSheet/DMSBottomSheet.swift index b4db7fd3..fdcbccab 100644 --- a/Projects/UsertInterfaces/DesignSystem/Sources/BottomSheet/DMSBottomSheet.swift +++ b/Projects/UsertInterfaces/DesignSystem/Sources/BottomSheet/DMSBottomSheet.swift @@ -94,8 +94,8 @@ struct DMSBottomSheet: ViewModifier { public extension View { func dmsBottomSheet( isShowing: Binding, - isGrabberOn: Bool, - sheetCornerRadiusValue: CGFloat, + isGrabberOn: Bool = false, + sheetCornerRadiusValue: CGFloat = 25, content: @escaping () -> Content ) -> some View { modifier(DMSBottomSheet(