Remove deprecation warnings for Xcode beta4

This commit is contained in:
John Holdsworth
2019-07-28 12:10:01 +01:00
parent 57e72ec52c
commit 7af0a711da
40 changed files with 63 additions and 61 deletions

View File

@@ -86,7 +86,7 @@ struct BlockView : View {
Text(numberText)
.font(Font.system(size: fontSize).bold())
.color(colorPair.1)
.foregroundColor(colorPair.1)
.id(numberText)
.transition(AnyTransition.scale(scale: 0.5, anchor: .center).combined(with: .opacity))
.animation(.fluidSpring())

View File

@@ -94,7 +94,7 @@ struct GameView : View {
ZStack(alignment: layoutTraits.containerAlignment) {
Text("2048")
.font(Font.system(size: 48).weight(.black))
.color(Color(red:0.47, green:0.43, blue:0.40, opacity:1.00))
.foregroundColor(Color(red:0.47, green:0.43, blue:0.40, opacity:1.00))
.offset(layoutTraits.bannerOffset)
ZStack(alignment: .top) {

View File

@@ -35,7 +35,7 @@ struct LandmarkList: View {
#if DEBUG
struct LandmarksList_Previews: PreviewProvider {
static var previews: some View {
ForEach(["iPhone SE", "iPhone XS Max"].identified(by: \.self)) { deviceName in
ForEach(["iPhone SE", "iPhone XS Max"], id: \.self) { deviceName in
LandmarkList()
.previewDevice(PreviewDevice(rawValue: deviceName))
.previewDisplayName(deviceName)

View File

@@ -23,7 +23,7 @@ struct LandmarkList: View {
#if DEBUG
struct LandmarkList_Previews: PreviewProvider {
static var previews: some View {
ForEach(["iPhone SE", "iPhone XS Max"].identified(by: \.self)) { deviceName in
ForEach(["iPhone SE", "iPhone XS Max"], id: \.self) { deviceName in
LandmarkList()
.previewDevice(PreviewDevice(rawValue: deviceName))
.previewDisplayName(deviceName)

View File

@@ -33,13 +33,13 @@ struct Calculator: View {
.padding(margin)
VStack(alignment: .center, spacing: margin) {
ForEach(data.identified(by: \.description)) { items in
ForEach(data, id: \.description) { items in
HStack(alignment: .center, spacing: margin) {
ForEach(items.identified(by: \.description)) { item in
ForEach(items, id: \.description) { item in
Text(item)
.font(.title)
.bold()
.color(Color.blue)
.foregroundColor(Color.blue)
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
.background(Color(red: 234 / 255.0, green: 240 / 255.0, blue: 241 / 255.0))
.tapAction {

View File

@@ -10,7 +10,7 @@ struct SearchUserBar: View {
TextField(
$text,
placeholder: Text("Search User")
.color(Color.gray)
.foregroundColor(Color.gray)
)
.padding([.leading, .trailing], 8)
.frame(height: 32)

View File

@@ -20,7 +20,7 @@ struct CategoryRow: View {
ScrollView(.horizontal) {
HStack(alignment: .top, spacing: 0) {
ForEach(self.items.identified(by: \.name)) { landmark in
ForEach(self.items, id: \.name) { landmark in
NavigationLink(
destination: LandmarkDetail(
landmark: landmark
@@ -45,7 +45,7 @@ struct CategoryItem: View {
.renderingMode(.original)
.cornerRadius(5)
Text(landmark.name)
.color(.primary)
.foregroundColor(.primary)
.font(.caption)
}
.padding(.leading, 15)

View File

@@ -23,13 +23,13 @@ struct HikeDetail: View {
.frame(height: 200, alignment: .center)
HStack(spacing: 25) {
ForEach(buttons.identified(by: \.0)) { value in
ForEach(buttons, id: \.0) { value in
Button(action: {
self.dataToShow = value.1
}) {
Text(verbatim: value.0)
.font(.system(size: 15))
.color(value.1 == self.dataToShow
.foregroundColor(value.1 == self.dataToShow
? Color.gray
: Color.accentColor)
.animation(nil)

View File

@@ -28,7 +28,7 @@ struct CategoryHome: View {
.clipped()
.listRowInsets(EdgeInsets())
ForEach(categories.keys.sorted().identified(by: \.self)) { key in
ForEach(categories.keys.sorted(), id: \.self) { key in
CategoryRow(categoryName: key, items: self.categories[key]!)
}
.listRowInsets(EdgeInsets())

View File

@@ -35,7 +35,7 @@ struct LandmarkList: View {
#if DEBUG
struct LandmarksList_Previews: PreviewProvider {
static var previews: some View {
ForEach(["iPhone SE", "iPhone XS Max"].identified(by: \.self)) { deviceName in
ForEach(["iPhone SE", "iPhone XS Max"], id: \.self) { deviceName in
LandmarkList()
.previewDevice(PreviewDevice(rawValue: deviceName))
.previewDisplayName(deviceName)

View File

@@ -39,14 +39,14 @@ struct ConverterView : View {
return ZStack(alignment: Alignment.bottomTrailing) {
NavigationView {
VStack(alignment: .leading){
Text("From:").bold().color(.gray)
Text("From:").bold().foregroundColor(.gray)
HStack{
// Flag
Text("\(userData.baseCurrency.flag)").padding(5)
// Code and name
VStack(alignment: .leading){
Text(userData.baseCurrency.code).color(.white)
Text(userData.baseCurrency.name).color(.white)
Text(userData.baseCurrency.code).foregroundColor(.white)
Text(userData.baseCurrency.name).foregroundColor(.white)
}
Spacer()
// Amount and conversion
@@ -60,7 +60,7 @@ struct ConverterView : View {
.padding(inset)
)
}.background(Color.blue).cornerRadius(5)
Text("To:").bold().color(.gray)
Text("To:").bold().foregroundColor(.gray)
List {
// TODO: should filter out BaseCurrency from list
ForEach(userData.userCurrency) { currency in
@@ -79,7 +79,8 @@ struct ConverterView : View {
}
})
HStack {
Text("Last updated: \(self.lastUpdated)").color(.gray).bold()
Text("Last updated: \(self.lastUpdated)")
.foregroundColor(.gray).bold()
Spacer()
NavigationLink(destination: AddCurrencyView().environmentObject(self.userData)) {

View File

@@ -49,7 +49,7 @@ struct CurrencyItemView: View {
Text(currency.flag).font(.title)
VStack(alignment: .leading){
Text(currency.code)
Text(currency.name).color(.gray)
Text(currency.name).foregroundColor(.gray)
}
}
}
@@ -61,14 +61,15 @@ struct CurrencyItemView: View {
// Code and name
VStack(alignment: .leading){
Text(currency.code).font(.headline)
Text(currency.name).font(.footnote).color(.gray)
Text(currency.name).font(.footnote).foregroundColor(.gray)
}
Spacer()
// Amount and conversion
VStack(alignment: .trailing){
Text("\(totalAmount)")
// Would be 1 this currency = xxx base currency
Text("1 \(currency.code) = \(converstionRate) \(userData.baseCurrency.code)").color(.gray)
Text("1 \(currency.code) = \(converstionRate) \(userData.baseCurrency.code)")
.foregroundColor(.gray)
}
}
}

View File

@@ -32,13 +32,13 @@ private let defaultCurrencies: [Currency] = [
Currency(name: "Canadian dollar", rate: 1.0, symbol: "CA", code: "CAD")
]
@propertyDelegate
@propertyWrapper
struct UserDefaultValue<Value: Codable> {
let key: String
let defaultValue: Value
var value: Value {
var wrappedValue: Value {
get {
let data = UserDefaults.standard.data(forKey: key)
let value = data.flatMap { try? JSONDecoder().decode(Value.self, from: $0) }

View File

@@ -35,7 +35,7 @@ struct LandmarkList: View {
#if DEBUG
struct LandmarksList_Previews: PreviewProvider {
static var previews: some View {
ForEach(["iPhone SE", "iPhone XS Max"].identified(by: \.self)) { deviceName in
ForEach(["iPhone SE", "iPhone XS Max"], id: \.self) { deviceName in
LandmarkList()
.previewDevice(PreviewDevice(rawValue: deviceName))
.previewDisplayName(deviceName)

View File

@@ -8,13 +8,13 @@
import Foundation
@propertyDelegate
@propertyWrapper
struct UserDefaultValue<Value: Codable> {
let key: String
let defaultValue: Value
var value: Value {
var wrappedValue: Value {
get {
let data = UserDefaults.standard.data(forKey: key)
let value = data.flatMap { try? JSONDecoder().decode(Value.self, from: $0) }

View File

@@ -35,7 +35,7 @@ struct LandmarkList: View {
#if DEBUG
struct LandmarksList_Previews: PreviewProvider {
static var previews: some View {
ForEach(["iPhone SE", "iPhone XS Max"].identified(by: \.self)) { deviceName in
ForEach(["iPhone SE", "iPhone XS Max"], id: \.self) { deviceName in
LandmarkList()
.previewDevice(PreviewDevice(rawValue: deviceName))
.previewDisplayName(deviceName)

View File

@@ -16,7 +16,7 @@ struct ContentView : View {
var body: some View {
NavigationView {
List {
ForEach(instaPhotos.identified(by: \.id)) {
ForEach(instaPhotos, id: \.id) {
ImageCell(photo: $0)
}
}.navigationBarTitle("WWDC").navigationBarItems(trailing: PresentationLink("Camera", destination: CameraView()))

View File

@@ -20,7 +20,7 @@ struct CategoryRow: View {
ScrollView(.horizontal) {
HStack(alignment: .top, spacing: 0) {
ForEach(self.items.identified(by: \.name)) { landmark in
ForEach(self.items, id: \.name) { landmark in
NavigationLink(
destination: LandmarkDetail(
landmark: landmark
@@ -45,7 +45,7 @@ struct CategoryItem: View {
.renderingMode(.original)
.cornerRadius(5)
Text(landmark.name)
.color(.primary)
.foregroundColor(.primary)
.font(.caption)
}
.padding(.leading, 15)

View File

@@ -23,13 +23,13 @@ struct HikeDetail: View {
.frame(height: 200, alignment: .center)
HStack(spacing: 25) {
ForEach(buttons.identified(by: \.0)) { value in
ForEach(buttons, id: \.0) { value in
Button(action: {
self.dataToShow = value.1
}) {
Text(verbatim: value.0)
.font(.system(size: 15))
.color(value.1 == self.dataToShow
.foregroundColor(value.1 == self.dataToShow
? Color.gray
: Color.accentColor)
.animation(nil)

View File

@@ -28,7 +28,7 @@ struct CategoryHome: View {
.clipped()
.listRowInsets(EdgeInsets())
ForEach(categories.keys.sorted().identified(by: \.self)) { key in
ForEach(categories.keys.sorted(), id: \.self) { key in
CategoryRow(categoryName: key, items: self.categories[key]!)
}
.listRowInsets(EdgeInsets())

View File

@@ -35,7 +35,7 @@ struct LandmarkList: View {
#if DEBUG
struct LandmarksList_Previews: PreviewProvider {
static var previews: some View {
ForEach(["iPhone SE", "iPhone XS Max"].identified(by: \.self)) { deviceName in
ForEach(["iPhone SE", "iPhone XS Max"], id: \.self) { deviceName in
LandmarkList()
.previewDevice(PreviewDevice(rawValue: deviceName))
.previewDisplayName(deviceName)

View File

@@ -31,7 +31,7 @@ struct ActivityView : View {
CircleImage(imgName: "subIcon")
.padding(.leading, 10)
Text("发布动态...")
.color(Color.gray)
.foregroundColor(Color.gray)
Spacer()
}
HStack{

View File

@@ -32,7 +32,7 @@ struct ActivityCell : View {
}
Text(timeStamp)
.font(Font.system(size: 12))
.color(Color.gray)
.foregroundColor(Color.gray)
.padding(.bottom, 2)
Text(content)

View File

@@ -14,7 +14,7 @@ struct CategoryRow: View {
VStack(alignment: .leading) {
ScrollView(.horizontal) {
HStack(alignment: .top, spacing: 0) {
ForEach(self.items.identified(by: \.id)) { zone in
ForEach(self.items, id: \.id) { zone in
CategoryItem(zone: zone)
}
}

View File

@@ -20,7 +20,7 @@ struct ChatCell : View {
.bold()
.padding(.top, 4)
Text(subTitle)
.color(Color.gray)
.foregroundColor(Color.gray)
.padding(.bottom, 8)
}
Spacer()

View File

@@ -32,7 +32,7 @@ struct HomeCell : View {
.bold()
Text(timeStamp)
.font(Font.system(size: 12))
.color(Color.gray)
.foregroundColor(Color.gray)
.padding(.top, 8)
}
Spacer()
@@ -57,7 +57,7 @@ struct HomeCell : View {
.bold()
Text("发布")
.font(Font.system(size: 13))
.color(Color.gray)
.foregroundColor(Color.gray)
Spacer()
}

View File

@@ -16,7 +16,7 @@ struct ZoneCell : View {
Image(imgName)
Text(title)
.font(Font.system(size: 10))
.color(Color.gray)
.foregroundColor(Color.gray)
.frame(alignment: .center)
}

View File

@@ -25,7 +25,7 @@ struct HomeView : View {
.padding(EdgeInsets(top: 5, leading: 5, bottom: 5, trailing: 5))
Text("优衣库KAWS遭疯抢")
.font(Font.system(size: 14))
.color(Color.gray)
.foregroundColor(Color.gray)
Spacer()
}
.background(

View File

@@ -21,7 +21,7 @@ struct Badge : View {
var body: some View {
Text(text)
.color(.white)
.foregroundColor(.white)
.padding()
.background(color)
.cornerRadius(8)

View File

@@ -19,7 +19,7 @@ struct UserRow : View {
VStack {
Text(user.name)
Text(user.username)
.color(.secondary)
.foregroundColor(.secondary)
.lineLimit(0)
}
}

View File

@@ -17,7 +17,7 @@ struct ContentView: View {
Text("Learning SwiftUI")
.font(.largeTitle)
.fontWeight(.semibold)
.color(.black)
.foregroundColor(.black)
.padding(4)
.animation(.basic(duration: 0.3, curve: .easeOut))
@@ -33,7 +33,7 @@ struct ContentView: View {
Text("A course focused on UI")
.font(.subheadline)
.fontWeight(.regular)
.color(.gray)
.foregroundColor(.gray)
.padding(4)
.animation(.basic(duration: 0.4, curve: .easeIn))

View File

@@ -19,19 +19,19 @@ struct ContentView : View {
}) {
VStack() {
Text("Learn SwiftUI")
.color(.white)
.foregroundColor(.white)
.fontWeight(.bold)
.font(.largeTitle)
.padding(.top, show ? 100 : 20)
Text("A course on UI and animations")
.color(Color(hue: 0.567, saturation: 0.158, brightness: 0.943))
.foregroundColor(Color(hue: 0.567, saturation: 0.158, brightness: 0.943))
.lineLimit(-1)
Spacer()
Text("Card Animation")
.color(Color(hue: 0.498, saturation: 0.609, brightness: 1.0))
.foregroundColor(Color(hue: 0.498, saturation: 0.609, brightness: 1.0))
.fontWeight(.bold)
.font(.title)
.padding(.bottom, show ? 100 : 20)

View File

@@ -33,7 +33,7 @@ struct NoteList : View {
#if DEBUG
struct NoteList_Previews : PreviewProvider {
static var previews: some View {
ForEach(["iPhone SE", "iPhone XS Max"].identified(by: \.self)) { deviceName in
ForEach(["iPhone SE", "iPhone XS Max"], id: \.self) { deviceName in
NoteList()
.environmentObject(UserData())
.previewDevice(PreviewDevice(rawValue: deviceName))

View File

@@ -71,7 +71,7 @@ struct TitleText: View {
let text: String
var body: some View {
return Text(text)
.color(.primary)
.foregroundColor(.primary)
.bold()
}
}
@@ -81,6 +81,6 @@ struct DescriptionText : View {
var body: some View {
return Text(text)
.font(.footnote).fontWeight(.semibold)
.color(.secondary)
.foregroundColor(.secondary)
}
}

View File

@@ -20,7 +20,7 @@ struct CategoryRow: View {
ScrollView(.horizontal) {
HStack(alignment: .top, spacing: 0) {
ForEach(self.items.identified(by: \.name)) { landmark in
ForEach(self.items, id: \.name) { landmark in
NavigationLink(
destination: LandmarkDetail(
landmark: landmark
@@ -45,7 +45,7 @@ struct CategoryItem: View {
.renderingMode(.original)
.cornerRadius(5)
Text(landmark.name)
.color(.primary)
.foregroundColor(.primary)
.font(.caption)
}
.padding(.leading, 15)

View File

@@ -23,13 +23,13 @@ struct HikeDetail: View {
.frame(height: 200, alignment: .center)
HStack(spacing: 25) {
ForEach(buttons.identified(by: \.0)) { value in
ForEach(buttons, id: \.0) { value in
Button(action: {
self.dataToShow = value.1
}) {
Text(verbatim: value.0)
.font(.system(size: 15))
.color(value.1 == self.dataToShow
.foregroundColor(value.1 == self.dataToShow
? Color.gray
: Color.accentColor)
.animation(nil)

View File

@@ -28,7 +28,7 @@ struct CategoryHome: View {
.clipped()
.listRowInsets(EdgeInsets())
ForEach(categories.keys.sorted().identified(by: \.self)) { key in
ForEach(categories.keys.sorted(), id: \.self) { key in
CategoryRow(categoryName: key, items: self.categories[key]!)
}
.listRowInsets(EdgeInsets())

View File

@@ -35,7 +35,7 @@ struct LandmarkList: View {
#if DEBUG
struct LandmarksList_Previews: PreviewProvider {
static var previews: some View {
ForEach(["iPhone SE", "iPhone XS Max"].identified(by: \.self)) { deviceName in
ForEach(["iPhone SE", "iPhone XS Max"], id: \.self) { deviceName in
LandmarkList()
.previewDevice(PreviewDevice(rawValue: deviceName))
.previewDisplayName(deviceName)

View File

@@ -26,7 +26,7 @@ struct ProfileEditor: View {
Text("Seasonal Photo").bold()
SegmentedControl(selection: $profile.seasonalPhoto) {
ForEach(Profile.Season.allCases.identified(by: \.self)) { season in
ForEach(Profile.Season.allCases, id: \.self) { season in
Text(season.rawValue).tag(season)
}
}

View File

@@ -54,7 +54,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
}
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
print("Continuing \(userActivity.userInfo?["count"])")
print("Continuing \(String(describing: userActivity.userInfo?["count"]))")
}
func scene(_ scene: UIScene, didUpdate userActivity: NSUserActivity) {