Skip to content

Commit

Permalink
feat: onAppear/onDisappear 사용 (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
minnnidev committed Oct 29, 2022
1 parent 4ae5a86 commit fa8a3c2
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
AB206DD8290D52FA00EA4A65 /* MyLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB206DD7290D52FA00EA4A65 /* MyLabel.swift */; };
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 */; };
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 @@ -35,6 +36,7 @@
AB206DD7290D52FA00EA4A65 /* MyLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyLabel.swift; sourceTree = "<group>"; };
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>"; };
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 @@ -91,6 +93,7 @@
AB206DD7290D52FA00EA4A65 /* MyLabel.swift */,
AB206DD9290D548A00EA4A65 /* MyNavigationView.swift */,
AB206DDB290D55F300EA4A65 /* MyNavigationStack.swift */,
AB206DDD290D56F400EA4A65 /* MyAppear.swift */,
);
path = "Inflearn-SwiftUI-Lv2";
sourceTree = "<group>";
Expand Down Expand Up @@ -173,6 +176,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
AB206DDE290D56F400EA4A65 /* MyAppear.swift in Sources */,
AB8CFF1C2907D740009C3479 /* MyDarkColor.swift in Sources */,
AB206DD6290D4F5C00EA4A65 /* MyProgress.swift in Sources */,
AB206DD8290D52FA00EA4A65 /* MyLabel.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import SwiftUI
struct Inflearn_SwiftUI_Lv2App: App {
var body: some Scene {
WindowGroup {
ContentView()
MyAppear()
}
}
}
67 changes: 67 additions & 0 deletions Inflearn-SwiftUI-Lv2/Inflearn-SwiftUI-Lv2/MyAppear.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// MyAppear.swift
// Inflearn-SwiftUI-Lv2
//
// Created by 김민 on 2022/10/29.
//

import SwiftUI

struct MyAppear: View {

@State var name: String = "No name"
@State var isPresented: Bool = false

var body: some View {

NavigationView {
NavigationLink("Test") {
Text("Sample")
.onAppear {
print("On Appear Sample")
}
.onDisappear {
print("On Disappear Sample")
}
}
}
.onAppear {
print("On Appear")
}
.onDisappear {
print("On Disappear")
}

// VStack {
// Text(name)
// .onAppear {
// print("On Appear")
// }
// .onDisappear {
// print("On Disappear")
// }
// .sheet(isPresented: $isPresented) {
// Text("Modal")
// }
//
// Button {
// isPresented.toggle()
// } label: {
// Text("Change")
// .onAppear {
// print("On Appear Modal")
// }
// .onDisappear {
// print("On Disappear Modal")
// }
// }
//
// }
}
}

struct MyAppear_Previews: PreviewProvider {
static var previews: some View {
MyAppear()
}
}

0 comments on commit fa8a3c2

Please sign in to comment.