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

Changes requested #1

Open
wants to merge 2 commits into
base: main
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
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>
83 changes: 72 additions & 11 deletions ProIPhone_Ch07_SharingDataBetweenStructures/ContentView.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
//
// ContentView.swift
// ProIPhone_Ch07_SharingDataBetweenStructures
//
// Created by Mike Panitz on 9/26/23.
//

import SwiftUI

import SwiftUI

struct ContentView: View {
@State private var isDarkMode = false
@State private var student = Student(firstName: "John", lastName: "Doe")
@State private var course = Course(year: "2023", quarter: "Q1", area: "IT-MOB", courseNumber: "101", courseTitle: "Introduction to Programming")

var body: some View {
TabView {
RandomBackgroundColor()
Expand All @@ -26,13 +21,15 @@ struct ContentView: View {
.tabItem {
Image(systemName: "3.circle")
}
EnvironmentObjectView()

// New View with Dark Mode Toggle and Student & Course Information
DarkModeAndDataView(isDarkMode: $isDarkMode, student: $student, course: $course)
.tabItem {
Image(systemName: "4.circle")
}
}
.tabViewStyle(DefaultTabViewStyle())

.environment(\.colorScheme, isDarkMode ? .dark : .light)
}
}

Expand All @@ -41,3 +38,67 @@ struct ContentView_Previews: PreviewProvider {
ContentView()
}
}

struct Student {
var firstName: String
var lastName: String
}

struct Course {
var year: String
var quarter: String
var area: String
var courseNumber: String
var courseTitle: String
}

struct DarkModeAndDataView: View {
@Binding var isDarkMode: Bool
@Binding var student: Student
@Binding var course: Course

var body: some View {
VStack {
Toggle("Dark Mode", isOn: $isDarkMode)
.padding()

Text("Student Information:")
.font(.headline)

// Subcomponent for editing student information
StudentInfoView(student: $student)

Text("Course Information:")
.font(.headline)

// Subcomponent for editing course information
CourseInfoView(course: $course)
}
.padding()
}
}

struct StudentInfoView: View {
@Binding var student: Student

var body: some View {
VStack {
TextField("First Name", text: $student.firstName)
TextField("Last Name", text: $student.lastName)
}
}
}

struct CourseInfoView: View {
@Binding var course: Course

var body: some View {
VStack {
TextField("Year", text: $course.year)
TextField("Quarter", text: $course.quarter)
TextField("Area", text: $course.area)
TextField("Course Number", text: $course.courseNumber)
TextField("Course Title", text: $course.courseTitle)
}
}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Pro-IPhone-Ch07-SharingDataBetweenStructures