@@ -14,92 +14,106 @@ struct LoginView: View {
1414 @State private var stayLoggedIn : Bool = false
1515 @State private var loginError : String ? = nil
1616 @State private var isLoading : Bool = false
17- @State private var isLoggedIn : Bool = false
17+ @State private var navigateToMain : Bool = false
18+
19+ @Environment ( \. dismiss) private var dismiss
1820
1921 var body : some View {
20- VStack {
21- Image ( " title " )
22- . resizable ( )
23- . scaledToFit ( )
24- . frame ( maxWidth: UIScreen . main. bounds. width * 0.7 )
25- . clipped ( )
26-
27- Spacer ( )
28- . frame ( height: 30 )
29-
30- TextField ( " 아이디를 입력해주세요 " , text: $id)
31- . padding ( )
32- . background ( Color ( hex: " #F2F2F2 " ) )
33- . cornerRadius ( 10 )
34- . padding ( . bottom, 10 )
35-
36- SecureField ( " 비밀번호를 입력해주세요 " , text: $password)
37- . padding ( )
38- . background ( Color ( hex: " #F2F2F2 " ) )
39- . cornerRadius ( 10 )
40-
41- Spacer ( )
42- . frame ( height: 20 )
43-
44- Button ( action: login) {
45- Text ( " 로그인 " )
46- . fontWeight ( . bold)
47- . frame ( maxWidth: . infinity)
22+ NavigationView {
23+ VStack {
24+ Image ( " title " )
25+ . resizable ( )
26+ . scaledToFit ( )
27+ . frame ( maxWidth: UIScreen . main. bounds. width * 0.7 )
28+ . clipped ( )
29+
30+ Spacer ( )
31+ . frame ( height: 30 )
32+
33+ TextField ( " 아이디를 입력해주세요 " , text: $id)
4834 . padding ( )
49- . background ( Color ( hex: " #636363 " ) )
50- . foregroundColor ( . white)
35+ . background ( Color ( hex: " #F2F2F2 " ) )
5136 . cornerRadius ( 10 )
52- }
53- . disabled ( isLoading)
37+ . padding ( . bottom, 10 )
5438
55- if let error = loginError {
56- Text ( error)
57- . foregroundColor ( Color ( hex: " #FE3939 " ) )
58- . font ( . caption)
59- }
39+ SecureField ( " 비밀번호를 입력해주세요 " , text: $password)
40+ . padding ( )
41+ . background ( Color ( hex: " #F2F2F2 " ) )
42+ . cornerRadius ( 10 )
6043
61- HStack {
62- Toggle ( isOn: $stayLoggedIn) {
63- Text ( " 로그인 상태 유지 " )
64- . font ( . system( size: 14 ) )
65- . foregroundColor ( . black)
66- }
67- . toggleStyle ( CheckboxToggleStyle ( ) )
6844 Spacer ( )
69- }
70- . padding ( . top, 3 )
45+ . frame ( height: 20 )
46+
47+ Button ( action: login) {
48+ Text ( " 로그인 " )
49+ . fontWeight ( . bold)
50+ . frame ( maxWidth: . infinity)
51+ . padding ( )
52+ . background ( Color ( hex: " #636363 " ) )
53+ . foregroundColor ( . white)
54+ . cornerRadius ( 10 )
55+ }
56+ . disabled ( isLoading)
7157
72- HStack ( spacing: 8 ) {
73- NavigationLink ( destination: ChangeCheckView ( ) ) {
74- Text ( " 비밀번호 변경 " )
75- . font ( . system( size: 14 ) )
76- . foregroundColor ( . black)
58+ if let error = loginError {
59+ Text ( error)
60+ . foregroundColor ( Color ( hex: " #FE3939 " ) )
61+ . font ( . caption)
62+ }
63+
64+ HStack {
65+ Toggle ( isOn: $stayLoggedIn) {
66+ Text ( " 로그인 상태 유지 " )
67+ . font ( . system( size: 14 ) )
68+ . foregroundColor ( . black)
69+ }
70+ . toggleStyle ( CheckboxToggleStyle ( ) )
71+ Spacer ( )
7772 }
73+ . padding ( . top, 3 )
7874
79- Text ( " | " )
80- . font ( . system( size: 14 ) )
81- . foregroundColor ( Color ( hex: " #BFBFBF " ) )
75+ HStack ( spacing: 8 ) {
76+ NavigationLink ( destination: ChangeCheckView ( ) ) {
77+ Text ( " 비밀번호 변경 " )
78+ . font ( . system( size: 14 ) )
79+ . foregroundColor ( . black)
80+ }
8281
83- NavigationLink ( destination: RegisterIdView ( ) ) {
84- Text ( " 회원가입 " )
82+ Text ( " | " )
8583 . font ( . system( size: 14 ) )
86- . foregroundColor ( . black)
84+ . foregroundColor ( Color ( hex: " #BFBFBF " ) )
85+
86+ NavigationLink ( destination: RegisterIdView ( ) ) {
87+ Text ( " 회원가입 " )
88+ . font ( . system( size: 14 ) )
89+ . foregroundColor ( . black)
90+ }
8791 }
88- }
89- . padding ( . top, 16 )
92+ . padding ( . top, 16 )
9093
91- Spacer ( )
92- . frame ( height: 30 )
94+ Spacer ( )
95+ . frame ( height: 30 )
9396
94- Image ( " eating_woman " )
95- . resizable ( )
96- . scaledToFit ( )
97- . clipped ( )
97+ Image ( " eating_woman " )
98+ . resizable ( )
99+ . scaledToFit ( )
100+ . clipped ( )
101+ }
102+ . padding ( . init( top: 16 , leading: 32 , bottom: 0 , trailing: 32 ) )
103+ . background (
104+ NavigationLink (
105+ destination: BottomNavigationView ( )
106+ . navigationBarBackButtonHidden ( true )
107+ . onAppear {
108+ dismiss ( )
109+ } ,
110+ isActive: $navigateToMain
111+ ) {
112+ EmptyView ( )
113+ }
114+ )
115+ . navigationBarBackButtonHidden ( )
98116 }
99- . padding ( . init( top: 16 , leading: 32 , bottom: 0 , trailing: 32 ) )
100- . background (
101- NavigationLink ( destination: BottomNavigationView ( ) , isActive: $isLoggedIn) { EmptyView ( ) }
102- )
103117 . navigationBarBackButtonHidden ( )
104118 }
105119
@@ -133,9 +147,9 @@ struct LoginView: View {
133147 print ( accessToken)
134148 print ( " --- " )
135149 print ( refreshToken)
136- isLoggedIn = true
150+ navigateToMain = true
137151 }
138- case . failure( let error ) :
152+ case . failure:
139153 loginError = " 아이디와 비밀번호를 확인해주세요 "
140154 }
141155 }
0 commit comments