Minimum changes for Xcode 11 beta 5

This commit is contained in:
John Holdsworth
2019-07-31 14:11:25 +01:00
parent 7af0a711da
commit a36ff1b7ca
48 changed files with 209 additions and 114 deletions

View File

@@ -11,10 +11,11 @@ struct HikeBadge: View {
var name: String
var body: some View {
VStack(alignment: .center) {
Badge()
.frame(width: 300, height: 300)
.scaleEffect(1.0 / 3.0)
.frame(width: 100, height: 100)
// crashes in Beta 5
// Badge()
// .frame(width: 300, height: 300)
// .scaleEffect(1.0 / 3.0)
// .frame(width: 100, height: 100)
Text(name)
.font(.caption)
.accessibility(label: Text("Badge for \(name)."))

View File

@@ -8,6 +8,8 @@ A view showing featured landmarks above a list of all of the landmarks.
import SwiftUI
struct CategoryHome: View {
@State private var isProfilePresented = false
var categories: [String: [Landmark]] {
.init(
grouping: landmarkData,
@@ -39,13 +41,16 @@ struct CategoryHome: View {
}
.navigationBarTitle(Text("Featured"))
.navigationBarItems(trailing:
PresentationLink(destination: ProfileHost()) {
Button(action: {
self.isProfilePresented = true
}) {
Image(systemName: "person.crop.circle")
.imageScale(.large)
.accessibility(label: Text("User Profile"))
.padding()
}
)
).sheet(isPresented: $isProfilePresented,
content: { ProfileHost().environmentObject(UserData()) })
}
}
}

View File

@@ -52,7 +52,7 @@ final class ImageStore {
?? _sizeImage(images.values[index][ImageStore.originalSize]!, to: size * ImageStore.scale)
images.values[index][size] = sizedImage
return Image(sizedImage, scale: Length(ImageStore.scale), label: Text(verbatim: name))
return Image(sizedImage, scale: CGFloat(ImageStore.scale), label: Text(verbatim: name))
}
static func loadImage(name: String) -> CGImage {

View File

@@ -15,7 +15,7 @@ struct ProfileEditor: View {
HStack {
Text("Username").bold()
Divider()
TextField($profile.username)
TextField("", text: $profile.username)
}
Toggle(isOn: $profile.prefersNotifications) {
@@ -25,20 +25,19 @@ struct ProfileEditor: View {
VStack(alignment: .leading, spacing: 20) {
Text("Seasonal Photo").bold()
SegmentedControl(selection: $profile.seasonalPhoto) {
ForEach(Profile.Season.allCases.identified(by: \.self)) { season in
Picker("", selection: $profile.seasonalPhoto) {
ForEach(Profile.Season.allCases, id: \.self) { season in
Text(season.rawValue).tag(season)
}
}
}.pickerStyle(SegmentedPickerStyle())
}
.padding(.top)
VStack(alignment: .leading, spacing: 20) {
Text("Goal Date").bold()
DatePicker(
$profile.goalDate,
minimumDate: Calendar.current.date(byAdding: .year, value: -1, to: profile.goalDate),
maximumDate: Calendar.current.date(byAdding: .year, value: 1, to: profile.goalDate),
"", selection: $profile.goalDate,
in: Calendar.current.date(byAdding: .year, value: -1, to: profile.goalDate)! ... Calendar.current.date(byAdding: .year, value: 1, to: profile.goalDate)!,
displayedComponents: .date
)
}

View File

@@ -17,7 +17,7 @@ struct ProfileHost: View {
HStack {
if self.mode?.value == .active {
Button(action: {
self.profile = self.draftProfile
self.draftProfile = self.profile
self.mode?.animation().value = .inactive
}) {
Text("Done")
@@ -33,7 +33,7 @@ struct ProfileHost: View {
} else {
ProfileEditor(profile: $draftProfile)
.onDisappear {
self.draftProfile = self.profile
self.profile = self.draftProfile
}
}
}

View File

@@ -22,7 +22,7 @@ struct ProfileSummary: View {
.bold()
.font(.title)
Text("Notifications: \(self.profile.prefersNotifications ? "On": "Off" )")
Text("Notifications: \(self.profile.prefersNotifications ? "Onn": "Off" )")
Text("Seasonal Photos: \(self.profile.seasonalPhoto.rawValue)")
@@ -37,7 +37,7 @@ struct ProfileSummary: View {
HikeBadge(name: "Earth Day")
.hueRotation(Angle(degrees: 90))
HikeBadge(name: "Tenth Hike")
.grayscale(0.5)
.hueRotation(Angle(degrees: 45))

View File

@@ -9,20 +9,20 @@ import SwiftUI
struct GraphCapsule: View {
var index: Int
var height: Length
var height: CGFloat
var range: Range<Double>
var overallRange: Range<Double>
var heightRatio: Length {
max(Length(magnitude(of: range) / magnitude(of: overallRange)), 0.15)
var heightRatio: CGFloat {
max(CGFloat(magnitude(of: range) / magnitude(of: overallRange)), 0.15)
}
var offsetRatio: Length {
Length((range.lowerBound - overallRange.lowerBound) / magnitude(of: overallRange))
var offsetRatio: CGFloat {
CGFloat((range.lowerBound - overallRange.lowerBound) / magnitude(of: overallRange))
}
var animation: Animation {
Animation.spring(initialVelocity: 5)
Animation.spring()
.speed(2)
.delay(0.03 * Double(index))
}

View File

@@ -40,7 +40,7 @@ struct HikeGraph: View {
let data = hike.observations
let overallRange = rangeOfRanges(data.lazy.map { $0[keyPath: self.path] })
let maxMagnitude = data.map { magnitude(of: $0[keyPath: path]) }.max()!
let heightRatio = 1 - Length(maxMagnitude / magnitude(of: overallRange))
let heightRatio = 1 - CGFloat(maxMagnitude / magnitude(of: overallRange))
return GeometryReader { proxy in
HStack(alignment: .bottom, spacing: proxy.size.width / 120) {