Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
3FFCF0EB2AD603530030C7B6 /* InClassActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FFCF0EA2AD603530030C7B6 /* InClassActivity.swift */; };
3FFCF0ED2AD606F00030C7B6 /* toggleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FFCF0EC2AD606F00030C7B6 /* toggleView.swift */; };
E4554F8B2AC3E9CA00644AB6 /* ProIPhone_Ch07_SharingDataBetweenStructuresApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4554F8A2AC3E9CA00644AB6 /* ProIPhone_Ch07_SharingDataBetweenStructuresApp.swift */; };
E4554F8D2AC3E9CA00644AB6 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4554F8C2AC3E9CA00644AB6 /* ContentView.swift */; };
E4554F8F2AC3E9CE00644AB6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E4554F8E2AC3E9CE00644AB6 /* Assets.xcassets */; };
Expand All @@ -19,6 +21,8 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
3FFCF0EA2AD603530030C7B6 /* InClassActivity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InClassActivity.swift; sourceTree = "<group>"; };
3FFCF0EC2AD606F00030C7B6 /* toggleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = toggleView.swift; sourceTree = "<group>"; };
E4554F872AC3E9CA00644AB6 /* ProIPhone_Ch07_SharingDataBetweenStructures.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ProIPhone_Ch07_SharingDataBetweenStructures.app; sourceTree = BUILT_PRODUCTS_DIR; };
E4554F8A2AC3E9CA00644AB6 /* ProIPhone_Ch07_SharingDataBetweenStructuresApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProIPhone_Ch07_SharingDataBetweenStructuresApp.swift; sourceTree = "<group>"; };
E4554F8C2AC3E9CA00644AB6 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -68,6 +72,8 @@
E4554F9C2AC3EE8F00644AB6 /* DisplayTextField.swift */,
E4554F9E2AC3FF2C00644AB6 /* StateObjectandObservedObject.swift */,
E4554FA02AC403B000644AB6 /* EnvironmentObjectView.swift */,
3FFCF0EA2AD603530030C7B6 /* InClassActivity.swift */,
3FFCF0EC2AD606F00030C7B6 /* toggleView.swift */,
E4554F8E2AC3E9CE00644AB6 /* Assets.xcassets */,
E4554F902AC3E9CE00644AB6 /* Preview Content */,
);
Expand Down Expand Up @@ -154,10 +160,12 @@
files = (
E4554F9D2AC3EE8F00644AB6 /* DisplayTextField.swift in Sources */,
E4554F8D2AC3E9CA00644AB6 /* ContentView.swift in Sources */,
3FFCF0ED2AD606F00030C7B6 /* toggleView.swift in Sources */,
E4554F8B2AC3E9CA00644AB6 /* ProIPhone_Ch07_SharingDataBetweenStructuresApp.swift in Sources */,
E4554F992AC3EB0C00644AB6 /* RandomBackgroundColor.swift in Sources */,
E4554F9B2AC3EDD600644AB6 /* StateAndBinding.swift in Sources */,
E4554F9F2AC3FF2C00644AB6 /* StateObjectandObservedObject.swift in Sources */,
3FFCF0EB2AD603530030C7B6 /* InClassActivity.swift in Sources */,
E4554FA12AC403B000644AB6 /* EnvironmentObjectView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>ProIPhone_Ch07_SharingDataBetweenStructures.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
4 changes: 4 additions & 0 deletions ProIPhone_Ch07_SharingDataBetweenStructures/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ struct ContentView: View {
.tabItem {
Image(systemName: "4.circle")
}
InClassActivity()
.tabItem {
Image(systemName: "5.circle")
}
}
.tabViewStyle(DefaultTabViewStyle())

Expand Down
95 changes: 95 additions & 0 deletions ProIPhone_Ch07_SharingDataBetweenStructures/InClassActivity.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
//
// BackgroundColorView.swift
// ProIPhone_Ch07_SharingDataBetweenStructures
//
// Created by Student Account on 10/10/23.
//

import SwiftUI

struct InClassActivity: View {
@State private var darkMode: Bool = false
@StateObject private var student = Student()
@StateObject private var course = Course()
var body: some View {
VStack{
toggleView(mode: $darkMode)
.padding(50)
.cornerRadius(20)


VStack{
HStack{
Text("Student: ")
Text(student.first)
Text(student.last)
}
.padding(.bottom)
Text("Course: ")
Text(course.courseTitle)
HStack{
Text(course.area)
Text(String(course.courseNumber))
}
HStack{
Text(course.quarter)
Text(String(course.year))
}
}
.padding(50)
.cornerRadius(20)
EditClasses(student: student, course: course)
.padding(50)
.cornerRadius(20)
.background(darkMode ? Color(.white): Color(.gray))
.foregroundColor(darkMode ? Color(.black): Color(.white))
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(darkMode ? Color(.gray): Color(.white))
.foregroundColor(darkMode ? Color(.white): Color(.black))
}
}

#Preview {
InClassActivity()
}
struct EditClasses: View {
@ObservedObject var student: Student
@ObservedObject var course: Course
var body: some View {
VStack {
HStack {
Text("First Name:")
TextField("Type a name here", text: $student.first)
}
HStack {
Text("Last Name:")
TextField("Type a breed here", text: $student.last)
}
TextField("Course Title", text: $course.courseTitle)
HStack{
TextField("Area", text: $course.area)
TextField("Course Number", value: $course.courseNumber, formatter: NumberFormatter())
}
HStack{
TextField("Quarter", text: $course.quarter)
TextField("Year", value: $course.year, formatter: NumberFormatter())
}
}
.environmentObject(student)
.environmentObject(course)
}
}

class Student: ObservableObject{
@Published var first: String = "Jane"
@Published var last: String = "Doe"
}

class Course: ObservableObject{
@Published var year: Int = 2023
@Published var quarter: String = "Fall"
@Published var area: String = "IT-MOB"
@Published var courseNumber: Int = 382
@Published var courseTitle: String = "iOS App Development II"
}
19 changes: 19 additions & 0 deletions ProIPhone_Ch07_SharingDataBetweenStructures/toggleView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// toggleView.swift
// ProIPhone_Ch07_SharingDataBetweenStructures
//
// Created by Student Account on 10/10/23.
//

import SwiftUI

struct toggleView: View {
@Binding var mode: Bool
var body: some View {
Toggle("Dark Mode", isOn: $mode)
}
}

#Preview {
toggleView(mode: .constant(false))
}