Skip to content

Commit 1b6242b

Browse files
authored
Merge pull request #26 from opficdev/refactor/Architecture
update 2026.01.30
2 parents 4f4b958 + e607791 commit 1b6242b

5 files changed

Lines changed: 28 additions & 14 deletions

File tree

DevLog/Presentation/Extension/View+.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
import SwiftUI
99

1010
extension View {
11-
var screenWidth: CGFloat {
11+
var sceneWidth: CGFloat {
1212
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
1313
else { return UIScreen.main.bounds.width }
1414

1515
return windowScene.screen.bounds.width
1616
}
1717

18-
var screenHeight: CGFloat {
18+
var sceneHeight: CGFloat {
1919
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
2020
else { return UIScreen.main.bounds.height }
2121

DevLog/Presentation/ViewModel/PushNotificationSettingsViewModel.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ final class PushNotificationSettingsViewModel: Store {
1212
var pushNotificationEnable = false
1313
var pushNotificationTime = Date()
1414
var showTimePicker = false
15+
var sheetHeight = CGFloat.pi
1516
var pushNotificationHour: Int {
1617
Calendar.current.component(.hour, from: pushNotificationTime)
1718
}
@@ -23,6 +24,7 @@ final class PushNotificationSettingsViewModel: Store {
2324
case setPushNotificationHour(Int)
2425
case setPushNotificationTime(Date)
2526
case setShowTimePicker(Bool)
27+
case setSheetHeight(CGFloat)
2628
}
2729

2830
enum SideEffect {
@@ -66,6 +68,8 @@ final class PushNotificationSettingsViewModel: Store {
6668
return [.updatePushNotificationSettings]
6769
case .setShowTimePicker(let value):
6870
state.showTimePicker = value
71+
case .setSheetHeight(let value):
72+
state.sheetHeight = value
6973
}
7074
self.state = state
7175
return []

DevLog/UI/Home/HomeView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct HomeView: View {
3737
HStack {
3838
RoundedRectangle(cornerRadius: 8)
3939
.fill(kind.color)
40-
.frame(width: screenWidth * 0.08, height: screenWidth * 0.08)
40+
.frame(width: sceneWidth * 0.08, height: sceneWidth * 0.08)
4141
.overlay {
4242
Image(systemName: kind.symbolName)
4343
.foregroundStyle(Color.white)
@@ -83,7 +83,7 @@ struct HomeView: View {
8383
HStack {
8484
RoundedRectangle(cornerRadius: 8)
8585
.fill(todo.kind.color)
86-
.frame(width: screenWidth * 0.08, height: screenWidth * 0.08)
86+
.frame(width: sceneWidth * 0.08, height: sceneWidth * 0.08)
8787
.overlay {
8888
Image(systemName: todo.kind.symbolName)
8989
.foregroundStyle(Color.white)

DevLog/UI/Login/LoginView.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,23 @@ struct LoginView: View {
1818
Image("Primary")
1919
.resizable()
2020
.scaledToFit()
21-
.frame(width: screenWidth / 5)
21+
.frame(width: sceneWidth / 5)
2222
Spacer()
2323
VStack(spacing: 20) {
2424
LoginButton(logo: Image("Google"), text: "구글 계정으로 로그인") {
2525
viewModel.send(.tapSignInButton(.google))
2626
}
27-
.frame(width: screenWidth * 3 / 4, height: screenWidth / 10)
27+
.frame(width: sceneWidth * 3 / 4, height: sceneWidth / 10)
2828

2929
LoginButton(logo: Image("Github"), text: "깃헙 계정으로 로그인") {
3030
viewModel.send(.tapSignInButton(.github))
3131
}
32-
.frame(width: screenWidth * 3 / 4, height: screenWidth / 10)
32+
.frame(width: sceneWidth * 3 / 4, height: sceneWidth / 10)
3333

3434
LoginButton(logo: Image("Apple"), text: "애플 계정으로 로그인") {
3535
viewModel.send(.tapSignInButton(.apple))
3636
}
37-
.frame(width: screenWidth * 3 / 4, height: screenWidth / 10)
37+
.frame(width: sceneWidth * 3 / 4, height: sceneWidth / 10)
3838
}
3939
.padding(.bottom, 30)
4040
Text("로그인하면 사용 약관 및 개인 정보 취급 방침에 동의하게 됩니다.")

DevLog/UI/Setting/PushNotificationSettingsView.swift

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import SwiftUI
99

1010
struct PushNotificationSettingsView: View {
1111
@StateObject var viewModel: PushNotificationSettingsViewModel
12-
@State private var sheetHeight: CGFloat = 0 // 시트 높이 조정용
1312

1413
var body: some View {
1514
List {
@@ -42,7 +41,7 @@ struct PushNotificationSettingsView: View {
4241
HStack {
4342
Text("사용자 설정")
4443
Spacer()
45-
Text("\(viewModel.state.pushNotificationHour)")
44+
Text(formattedTimeString(viewModel.state.pushNotificationTime))
4645
.foregroundStyle(.secondary)
4746
if ![9, 15, 18, 21].contains(viewModel.state.pushNotificationHour) {
4847
Image(systemName: "checkmark")
@@ -77,7 +76,7 @@ struct PushNotificationSettingsView: View {
7776
.datePickerStyle(.wheel)
7877
.labelsHidden()
7978
.presentationDragIndicator(.hidden)
80-
.presentationDetents([.height(sheetHeight)])
79+
.presentationDetents([.height(viewModel.state.sheetHeight)])
8180
.onAppear {
8281
UIDatePicker.appearance().minuteInterval = 5
8382
}
@@ -87,12 +86,23 @@ struct PushNotificationSettingsView: View {
8786
.background(
8887
GeometryReader { geometry in
8988
Color.clear.onAppear {
90-
if sheetHeight == 0 {
91-
sheetHeight = geometry.size.height
92-
}
89+
viewModel.send(.setSheetHeight(geometry.size.height))
9390
}
9491
}
9592
)
9693
}
9794
}
95+
96+
private func formattedTimeString(_ date: Date) -> String {
97+
let minuteValue = Calendar.current.component(.minute, from: date)
98+
let formatStyle: Date.FormatStyle = .dateTime.hour(.twoDigits(amPM: .wide))
99+
100+
if minuteValue == 0 {
101+
return "\(date.formatted(formatStyle))"
102+
}
103+
104+
let hourText = date.formatted(formatStyle)
105+
let minuteText = date.formatted(.dateTime.minute(.twoDigits))
106+
return "\(hourText) \(minuteText)"
107+
}
98108
}

0 commit comments

Comments
 (0)