Skip to content

Commit

Permalink
feat: 실습2 - 로그인 뷰 만들어 보기 (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
minnnidev committed Oct 29, 2022
1 parent fa8a3c2 commit 9174d1c
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
AB206DDA290D548A00EA4A65 /* MyNavigationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB206DD9290D548A00EA4A65 /* MyNavigationView.swift */; };
AB206DDC290D55F300EA4A65 /* MyNavigationStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB206DDB290D55F300EA4A65 /* MyNavigationStack.swift */; };
AB206DDE290D56F400EA4A65 /* MyAppear.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB206DDD290D56F400EA4A65 /* MyAppear.swift */; };
AB206DE0290D59C300EA4A65 /* MyPractice2.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB206DDF290D59C300EA4A65 /* MyPractice2.swift */; };
AB8CFF0E2907D6DC009C3479 /* Inflearn_SwiftUI_Lv2App.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB8CFF0D2907D6DC009C3479 /* Inflearn_SwiftUI_Lv2App.swift */; };
AB8CFF102907D6DC009C3479 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB8CFF0F2907D6DC009C3479 /* ContentView.swift */; };
AB8CFF122907D6DE009C3479 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AB8CFF112907D6DE009C3479 /* Assets.xcassets */; };
Expand All @@ -37,6 +38,7 @@
AB206DD9290D548A00EA4A65 /* MyNavigationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyNavigationView.swift; sourceTree = "<group>"; };
AB206DDB290D55F300EA4A65 /* MyNavigationStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyNavigationStack.swift; sourceTree = "<group>"; };
AB206DDD290D56F400EA4A65 /* MyAppear.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyAppear.swift; sourceTree = "<group>"; };
AB206DDF290D59C300EA4A65 /* MyPractice2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPractice2.swift; sourceTree = "<group>"; };
AB8CFF0A2907D6DC009C3479 /* Inflearn-SwiftUI-Lv2.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Inflearn-SwiftUI-Lv2.app"; sourceTree = BUILT_PRODUCTS_DIR; };
AB8CFF0D2907D6DC009C3479 /* Inflearn_SwiftUI_Lv2App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Inflearn_SwiftUI_Lv2App.swift; sourceTree = "<group>"; };
AB8CFF0F2907D6DC009C3479 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -94,6 +96,7 @@
AB206DD9290D548A00EA4A65 /* MyNavigationView.swift */,
AB206DDB290D55F300EA4A65 /* MyNavigationStack.swift */,
AB206DDD290D56F400EA4A65 /* MyAppear.swift */,
AB206DDF290D59C300EA4A65 /* MyPractice2.swift */,
);
path = "Inflearn-SwiftUI-Lv2";
sourceTree = "<group>";
Expand Down Expand Up @@ -191,6 +194,7 @@
AB206DCC290C119400EA4A65 /* MyAlert.swift in Sources */,
AB8CFF202907DA8A009C3479 /* MyModal.swift in Sources */,
AB206DCE290C149700EA4A65 /* MyTabView.swift in Sources */,
AB206DE0290D59C300EA4A65 /* MyPractice2.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
74 changes: 74 additions & 0 deletions Inflearn-SwiftUI-Lv2/Inflearn-SwiftUI-Lv2/MyPractice2.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//
// MyPractice2.swift
// Inflearn-SwiftUI-Lv2
//
// Created by 김민 on 2022/10/29.
//

import SwiftUI

struct MyPractice2: View {

@State var userID: String = ""
@State var userPassword: String = ""
@State var isLogin: Bool = false
@State var isShowingPW: Bool = false


var body: some View {
VStack {
HStack {
Label {
Text("ID")
} icon: {
Image(systemName: "heart.fill")
}
TextField("enter ID", text: $userID)
.textFieldStyle(.roundedBorder)
}
Divider()
HStack {
Label {
Text("PW")
} icon: {
Image(systemName: "lock.fill")
}

if isShowingPW {
TextField("enter password", text: $userPassword)
.textFieldStyle(.roundedBorder)
Spacer()
} else {
SecureField("enter password", text: $userPassword)
.textFieldStyle(.roundedBorder)
}

Spacer()
Toggle(isOn: $isShowingPW) {
Text("Show")
}
}
Button {
if userID == "Mini" && userPassword == "1234" {
isLogin = true
} else {
isLogin = false
}
} label: {
Text("로그인")
.background(.orange)
.foregroundColor(.black)
}
}
.padding()
.sheet(isPresented: $isLogin) {
Text("로그인되었습니다")
}
}
}

struct MyPractice2_Previews: PreviewProvider {
static var previews: some View {
MyPractice2()
}
}

0 comments on commit 9174d1c

Please sign in to comment.