mirror of
https://github.com/ivanvorobei/SwiftUI.git
synced 2026-03-12 05:21:47 +01:00
66 lines
1.8 KiB
Swift
Executable File
66 lines
1.8 KiB
Swift
Executable File
/*
|
||
See LICENSE folder for this sample’s licensing information.
|
||
|
||
Abstract:
|
||
A view that summarizes a profile.
|
||
*/
|
||
|
||
import SwiftUI
|
||
|
||
struct ProfileSummary: View {
|
||
var profile: Profile
|
||
|
||
static var goalFormat: DateFormatter {
|
||
let formatter = DateFormatter()
|
||
formatter.dateFormat = "MMMM d, yyyy"
|
||
return formatter
|
||
}
|
||
|
||
var body: some View {
|
||
List {
|
||
Text(profile.username)
|
||
.bold()
|
||
.font(.title)
|
||
|
||
Text("Notifications: \(self.profile.prefersNotifications ? "On": "Off" )")
|
||
|
||
Text("Seasonal Photos: \(self.profile.seasonalPhoto.rawValue)")
|
||
|
||
Text("Goal Date: \(self.profile.goalDate, formatter: Self.goalFormat)")
|
||
|
||
VStack(alignment: .leading) {
|
||
Text("Completed Badges")
|
||
.font(.headline)
|
||
ScrollView {
|
||
HStack {
|
||
HikeBadge(name: "First Hike")
|
||
|
||
HikeBadge(name: "Earth Day")
|
||
.hueRotation(Angle(degrees: 90))
|
||
|
||
HikeBadge(name: "Tenth Hike")
|
||
.grayscale(0.5)
|
||
.hueRotation(Angle(degrees: 45))
|
||
}
|
||
}
|
||
.frame(height: 140)
|
||
}
|
||
|
||
VStack(alignment: .leading) {
|
||
Text("Recent Hikes")
|
||
.font(.headline)
|
||
|
||
HikeView(hike: hikeData[0])
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
#if DEBUG
|
||
struct ProfileSummary_Previews: PreviewProvider {
|
||
static var previews: some View {
|
||
ProfileSummary(profile: Profile.default)
|
||
}
|
||
}
|
||
#endif
|