Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4주차] 실습 우상욱 #57

Open
wants to merge 1 commit into
base: week3-sangwook
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions sangwook/sangwook.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,24 @@
objects = {

/* Begin PBXBuildFile section */
8B5023452D05CDB1000B746D /* ObservableObjectExampleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B5023442D05CDB1000B746D /* ObservableObjectExampleView.swift */; };
8B5023472D05D0A0000B746D /* NavigationExampleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B5023462D05D0A0000B746D /* NavigationExampleView.swift */; };
8B5023492D05D508000B746D /* TabExampleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B5023482D05D508000B746D /* TabExampleView.swift */; };
8B50234B2D05D7CB000B746D /* ModalExampleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B50234A2D05D7CB000B746D /* ModalExampleView.swift */; };
8B74056D2CD796EC0067D101 /* sangwookApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B74056C2CD796EC0067D101 /* sangwookApp.swift */; };
8B74056F2CD796EC0067D101 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B74056E2CD796EC0067D101 /* ContentView.swift */; };
8B74056F2CD796EC0067D101 /* StateExampleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B74056E2CD796EC0067D101 /* StateExampleView.swift */; };
8B7405712CD796ED0067D101 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8B7405702CD796ED0067D101 /* Assets.xcassets */; };
8B7405742CD796ED0067D101 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8B7405732CD796ED0067D101 /* Preview Assets.xcassets */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
8B5023442D05CDB1000B746D /* ObservableObjectExampleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObservableObjectExampleView.swift; sourceTree = "<group>"; };
8B5023462D05D0A0000B746D /* NavigationExampleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationExampleView.swift; sourceTree = "<group>"; };
8B5023482D05D508000B746D /* TabExampleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabExampleView.swift; sourceTree = "<group>"; };
8B50234A2D05D7CB000B746D /* ModalExampleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalExampleView.swift; sourceTree = "<group>"; };
8B7405692CD796EC0067D101 /* sangwook.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = sangwook.app; sourceTree = BUILT_PRODUCTS_DIR; };
8B74056C2CD796EC0067D101 /* sangwookApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = sangwookApp.swift; sourceTree = "<group>"; };
8B74056E2CD796EC0067D101 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
8B74056E2CD796EC0067D101 /* StateExampleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StateExampleView.swift; sourceTree = "<group>"; };
8B7405702CD796ED0067D101 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
8B7405732CD796ED0067D101 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -52,7 +60,11 @@
isa = PBXGroup;
children = (
8B74056C2CD796EC0067D101 /* sangwookApp.swift */,
8B74056E2CD796EC0067D101 /* ContentView.swift */,
8B74056E2CD796EC0067D101 /* StateExampleView.swift */,
8B5023442D05CDB1000B746D /* ObservableObjectExampleView.swift */,
8B5023462D05D0A0000B746D /* NavigationExampleView.swift */,
8B5023482D05D508000B746D /* TabExampleView.swift */,
8B50234A2D05D7CB000B746D /* ModalExampleView.swift */,
8B7405702CD796ED0067D101 /* Assets.xcassets */,
8B7405722CD796ED0067D101 /* Preview Content */,
);
Expand Down Expand Up @@ -137,8 +149,12 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8B74056F2CD796EC0067D101 /* ContentView.swift in Sources */,
8B74056F2CD796EC0067D101 /* StateExampleView.swift in Sources */,
8B5023472D05D0A0000B746D /* NavigationExampleView.swift in Sources */,
8B5023492D05D508000B746D /* TabExampleView.swift in Sources */,
8B74056D2CD796EC0067D101 /* sangwookApp.swift in Sources */,
8B5023452D05CDB1000B746D /* ObservableObjectExampleView.swift in Sources */,
8B50234B2D05D7CB000B746D /* ModalExampleView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Binary file not shown.
71 changes: 0 additions & 71 deletions sangwook/sangwook/ContentView.swift

This file was deleted.

49 changes: 49 additions & 0 deletions sangwook/sangwook/ModalExampleView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// ModalExampleView.swift
// sangwook
//
// Created by 우상욱 on 12/8/24.
//

import SwiftUI

struct ModalExampleView: View {
@State private var showModal = false
@State private var message = ""

var body: some View {
VStack {
Text("Message: \(message)")
Button(action: {
showModal = true
}) {
Text("Show Modal")
}
}
.sheet(isPresented: $showModal) {
ModalView(message: $message)
}
}
}

struct ModalView: View {
@Binding var message: String
@Environment(\.dismiss) var dismiss

var body: some View {
VStack {
TextField("Enter your message", text: $message)
Button(action: {
dismiss()
}) {
Text("Close")
}
}
.padding()
.navigationTitle("Modal View")
}
}

#Preview {
ModalExampleView()
}
33 changes: 33 additions & 0 deletions sangwook/sangwook/NavigationExampleView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// NavigationExampleView.swift
// sangwook
//
// Created by 우상욱 on 12/8/24.
//

import SwiftUI
import Combine

struct NavigationExampleView: View {
var body: some View {
NavigationView {
VStack {
NavigationLink(destination: DestinationView()) {
Text("Go to Destination")
}.navigationTitle("Example")
}
}
}
}


struct DestinationView: View {
var body: some View {
Text("Destination View")
.navigationTitle("Destination")
}
}

#Preview {
NavigationExampleView()
}
38 changes: 38 additions & 0 deletions sangwook/sangwook/ObservableObjectExampleView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// Example1View.swift
// sangwook
//
// Created by 우상욱 on 12/8/24.
//

import SwiftUI
import Combine

class CounterObservable: ObservableObject {
@Published var count = 0
}

struct ObservableObjectExampleView: View {
@StateObject var model = CounterObservable()

var body: some View {
VStack {
countText(count: $model.count)
Button("Increment") {
model.count += 1
}
}
}

struct countText: View {
@Binding var count: Int

var body: some View {
Text("Count: \(count)")
}
}
}

#Preview {
ObservableObjectExampleView()
}
33 changes: 33 additions & 0 deletions sangwook/sangwook/StateExampleView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// ContentView.swift
// sangwook
//
// Created by 우상욱 on 11/3/24.
//

import SwiftUI

struct StateExampleView: View {
@State private var count = 0

var body: some View {
VStack {
countText(count: $count)
Button("Increment") {
count += 1
}
}
}

struct countText: View {
@Binding var count: Int

var body: some View {
Text("Count: \(count)")
}
}
}

#Preview {
StateExampleView()
}
57 changes: 57 additions & 0 deletions sangwook/sangwook/TabExampleView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//
// TabExampleView.swift
// sangwook
//
// Created by 우상욱 on 12/8/24.
//

import SwiftUI

struct TabExampleView: View {
var body: some View {
TabView {
HomeView()
.tabItem {
Label("Home", systemImage: "house.fill")
}

SettingsView()
.tabItem {
Label("Settings", systemImage: "gearshape.fill")
}

ProfileView()
.tabItem {
Label("Profile", systemImage: "person.fill")
}
}
.font(.title)
.accentColor(.blue)
.navigationTitle("Tabs")
}
}

struct HomeView: View {
var body: some View {
Text("Home View")
.navigationTitle("Home")
}
}

struct SettingsView: View {
var body: some View {
Text("Settings View")
.navigationTitle("Settings")
}
}

struct ProfileView: View {
var body: some View {
Text("Profile View")
.navigationTitle("Profile")
}
}

#Preview {
TabExampleView()
}
2 changes: 1 addition & 1 deletion sangwook/sangwook/sangwookApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import SwiftUI
struct sangwookApp: App {
var body: some Scene {
WindowGroup {
ContentView()
StateExampleView()
}
}
}