@@ -9,7 +9,6 @@ import SwiftUI
99
1010struct 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