Created
March 17, 2020 18:30
-
-
Save dbolella/7b326fe2bd76a13576c1ec35d4132221 to your computer and use it in GitHub Desktop.
SwiftUI: Lists, Navigation, and Detail Views
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Profile: Identifiable{ | |
var name: String = "" | |
var subtitle: String = "" | |
var description: String = "" | |
var profilePic: String = "" | |
init(name: String, subtitle: String, description: String, profilePic: String) { | |
self.name = name | |
self.subtitle = subtitle | |
self.description = description | |
self.profilePic = profilePic | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ProfileInformation: View { | |
var profile: Profile | |
var body: some View { | |
VStack{ | |
Text(profile.name) | |
.font(.largeTitle) | |
Text(profile.subtitle) | |
.font(.title) | |
Text(profile.description) | |
.font(.body) | |
} | |
} | |
} | |
struct ProfilePage: View { | |
var profile: Profile | |
var body: some View { | |
VStack { | |
Image(profile.profilePic) | |
.resizable() | |
.aspectRatio(contentMode: .fit) | |
.frame(width:200.0) | |
.clipShape(Circle()) | |
.overlay(Circle().stroke(Color.gray, lineWidth: 10)) | |
ProfileInformation(profile: profile) | |
} | |
.padding() | |
} | |
} | |
struct ProfilePage_Previews: PreviewProvider { | |
static var previews: some View { | |
ProfilePage(profile: Profile(name: "Danny", subtitle: "Awesome iOS Developer", description: "Danny loves SwiftUI and thinks it's the future of iOS Development!", profilePic: "profilepic")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment