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
2 changes: 1 addition & 1 deletion Contacts-SwiftUI/Model/UserData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import SwiftUI
import Combine

final class UserData: BindableObject {
final class UserData: ObservableObject {
let didChange = PassthroughSubject<UserData, Never>()

var contacts = contactData {
Expand Down
17 changes: 8 additions & 9 deletions Contacts-SwiftUI/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,19 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?


func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).

// Use a UIHostingController as window root view controller
let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = UIHostingController(
rootView: ContactList()
.environmentObject(UserData())
)
self.window = window
window.makeKeyAndVisible()
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
window.rootViewController = UIHostingController(rootView: ContactList().environmentObject(UserData())
)
self.window = window
window.makeKeyAndVisible()
}
}

func sceneDidDisconnect(_ scene: UIScene) {
Expand Down
20 changes: 10 additions & 10 deletions Contacts-SwiftUI/View/ContactDetail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ struct ContactDetail : View {
Image(contact.imageName)
.resizable()
.clipShape(Circle())
.frame(width: 200, height: 200)
.overlay(Circle().stroke(Color.white, lineWidth: 4))
.shadow(radius: 10)
.frame(width: CGFloat(200), height: CGFloat(200))
.overlay(Circle().stroke(Color.white, lineWidth: CGFloat(4)))
.shadow(radius: CGFloat(10))

HStack {
Text("\(contact.firstName) \(contact.lastName)")
Expand All @@ -45,24 +45,24 @@ struct ContactDetail : View {
HStack {
Text("Phone")
Spacer()
Text(contact.phone).color(.gray)
}.padding(.bottom, 5)
Text(contact.phone).foregroundColor(.gray)
}.padding(.bottom, CGFloat(5))

HStack {
Text("Email")
Spacer()
Text(contact.email).color(.gray)
}.padding(.bottom, 5)
Text(contact.email).foregroundColor(.gray)
}.padding(.bottom, CGFloat(5))

HStack {
Text("Address")
Spacer()

VStack(alignment: .trailing) {
Text(contact.street).color(.gray)
Text("\(contact.city), \(contact.state) \(contact.zip)").color(.gray)
Text(contact.street).foregroundColor(.gray)
Text("\(contact.city), \(contact.state) \(contact.zip)").foregroundColor(.gray)
}
}.padding(.bottom, 5)
}.padding(.bottom, CGFloat(5))

Spacer()
}.padding(40)
Expand Down
2 changes: 1 addition & 1 deletion Contacts-SwiftUI/View/ContactList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct ContactList : View {
var body: some View {
NavigationView {
List(userData.contacts) { contact in
NavigationButton(destination: ContactDetail(contact: contact)) {
NavigationLink(destination: ContactDetail(contact: contact)) {
ContactRow(contact: contact)
}
}.navigationBarTitle(Text("Contacts"))
Expand Down