diff --git a/Other Projects/2048 Game/SwiftUI2048/Views/BlockView.swift b/Other Projects/2048 Game/SwiftUI2048/Views/BlockView.swift index 3ea6dd1..fe12dfa 100755 --- a/Other Projects/2048 Game/SwiftUI2048/Views/BlockView.swift +++ b/Other Projects/2048 Game/SwiftUI2048/Views/BlockView.swift @@ -89,7 +89,7 @@ struct BlockView : View { .foregroundColor(colorPair.1) .id(numberText) .transition(AnyTransition.scale(scale: 0.5, anchor: .center).combined(with: .opacity)) - .animation(.fluidSpring()) +// .animation(.fluidSpring()) } .clipped() .cornerRadius(6) @@ -104,7 +104,7 @@ struct BlockView_Previews : PreviewProvider { static var previews: some View { Group { - ForEach((1...11).map { Int(pow(2, Double($0))) }) { i in + ForEach((1...11).map { Int(pow(2.0, Double($0))) }, id: \.self) { i in BlockView(number: i) .previewLayout(.sizeThatFits) } diff --git a/Other Projects/Animating Views And Transitions/Complete/Landmarks/Landmarks/HikeDetail.swift b/Other Projects/Animating Views And Transitions/Complete/Landmarks/Landmarks/HikeDetail.swift index 3406a6d..1d63904 100755 --- a/Other Projects/Animating Views And Transitions/Complete/Landmarks/Landmarks/HikeDetail.swift +++ b/Other Projects/Animating Views And Transitions/Complete/Landmarks/Landmarks/HikeDetail.swift @@ -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) diff --git a/Other Projects/Animating Views And Transitions/Complete/Landmarks/Landmarks/Models/Data.swift b/Other Projects/Animating Views And Transitions/Complete/Landmarks/Landmarks/Models/Data.swift index 248d3b2..cfe5a4a 100755 --- a/Other Projects/Animating Views And Transitions/Complete/Landmarks/Landmarks/Models/Data.swift +++ b/Other Projects/Animating Views And Transitions/Complete/Landmarks/Landmarks/Models/Data.swift @@ -51,7 +51,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)) } fileprivate func _guaranteeInitialImage(name: String) -> _ImageDictionary.Index { diff --git a/Other Projects/Animating Views And Transitions/Complete/Landmarks/Landmarks/Supporting Views/GraphCapsule.swift b/Other Projects/Animating Views And Transitions/Complete/Landmarks/Landmarks/Supporting Views/GraphCapsule.swift index ea128e0..98b9ac0 100755 --- a/Other Projects/Animating Views And Transitions/Complete/Landmarks/Landmarks/Supporting Views/GraphCapsule.swift +++ b/Other Projects/Animating Views And Transitions/Complete/Landmarks/Landmarks/Supporting Views/GraphCapsule.swift @@ -9,20 +9,20 @@ import SwiftUI struct GraphCapsule: View { var index: Int - var height: Length + var height: CGFloat var range: Range var overallRange: Range - 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)) } diff --git a/Other Projects/Animating Views And Transitions/Complete/Landmarks/Landmarks/Supporting Views/HikeGraph.swift b/Other Projects/Animating Views And Transitions/Complete/Landmarks/Landmarks/Supporting Views/HikeGraph.swift index 7df5194..2a4ff27 100755 --- a/Other Projects/Animating Views And Transitions/Complete/Landmarks/Landmarks/Supporting Views/HikeGraph.swift +++ b/Other Projects/Animating Views And Transitions/Complete/Landmarks/Landmarks/Supporting Views/HikeGraph.swift @@ -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) { diff --git a/Other Projects/Building Lists And Navigation/Complete/Landmarks/Landmarks/Models/Data.swift b/Other Projects/Building Lists And Navigation/Complete/Landmarks/Landmarks/Models/Data.swift index 78837f6..7248384 100755 --- a/Other Projects/Building Lists And Navigation/Complete/Landmarks/Landmarks/Models/Data.swift +++ b/Other Projects/Building Lists And Navigation/Complete/Landmarks/Landmarks/Models/Data.swift @@ -49,7 +49,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)) } fileprivate func _guaranteeInitialImage(name: String) -> _ImageDictionary.Index { diff --git a/Other Projects/Combine using GitHub API/SwiftUI-Combine-Example/SearchUserBar.swift b/Other Projects/Combine using GitHub API/SwiftUI-Combine-Example/SearchUserBar.swift index 855e652..87e9ea0 100755 --- a/Other Projects/Combine using GitHub API/SwiftUI-Combine-Example/SearchUserBar.swift +++ b/Other Projects/Combine using GitHub API/SwiftUI-Combine-Example/SearchUserBar.swift @@ -8,9 +8,7 @@ struct SearchUserBar: View { ZStack { HStack { TextField( - $text, - placeholder: Text("Search User") - .foregroundColor(Color.gray) + "Search User", text: $text ) .padding([.leading, .trailing], 8) .frame(height: 32) diff --git a/Other Projects/Combine using GitHub API/SwiftUI-Combine-Example/SearchUserViewModel.swift b/Other Projects/Combine using GitHub API/SwiftUI-Combine-Example/SearchUserViewModel.swift index 1594c4f..b8b07b9 100755 --- a/Other Projects/Combine using GitHub API/SwiftUI-Combine-Example/SearchUserViewModel.swift +++ b/Other Projects/Combine using GitHub API/SwiftUI-Combine-Example/SearchUserViewModel.swift @@ -54,7 +54,7 @@ final class SearchUserViewModel: BindableObject { .replaceError(with: nil) .eraseToAnyPublisher() .receive(on: DispatchQueue.main) - .receive(subscriber: Subscribers.Sink { [weak self] image in + .receive(subscriber: Subscribers.Sink(receiveCompletion: {_ in}) { [weak self] image in self?.userImages[user] = image }) } diff --git a/Other Projects/Composing Complex Interfaces/Complete/Landmarks/Landmarks/Home.swift b/Other Projects/Composing Complex Interfaces/Complete/Landmarks/Landmarks/Home.swift index f6f3112..a40b74d 100755 --- a/Other Projects/Composing Complex Interfaces/Complete/Landmarks/Landmarks/Home.swift +++ b/Other Projects/Composing Complex Interfaces/Complete/Landmarks/Landmarks/Home.swift @@ -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: Text("User Profile")) { + Button(action: { + self.isProfilePresented = true + }) { Image(systemName: "person.crop.circle") .imageScale(.large) .accessibility(label: Text("User Profile")) .padding() } - ) + ).sheet(isPresented: $isProfilePresented, + content: { Text("User Profile") }) } } } diff --git a/Other Projects/Composing Complex Interfaces/Complete/Landmarks/Landmarks/Models/Data.swift b/Other Projects/Composing Complex Interfaces/Complete/Landmarks/Landmarks/Models/Data.swift index 248d3b2..cfe5a4a 100755 --- a/Other Projects/Composing Complex Interfaces/Complete/Landmarks/Landmarks/Models/Data.swift +++ b/Other Projects/Composing Complex Interfaces/Complete/Landmarks/Landmarks/Models/Data.swift @@ -51,7 +51,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)) } fileprivate func _guaranteeInitialImage(name: String) -> _ImageDictionary.Index { diff --git a/Other Projects/Composing Complex Interfaces/Complete/Landmarks/Landmarks/Supporting Views/GraphCapsule.swift b/Other Projects/Composing Complex Interfaces/Complete/Landmarks/Landmarks/Supporting Views/GraphCapsule.swift index ea128e0..98b9ac0 100755 --- a/Other Projects/Composing Complex Interfaces/Complete/Landmarks/Landmarks/Supporting Views/GraphCapsule.swift +++ b/Other Projects/Composing Complex Interfaces/Complete/Landmarks/Landmarks/Supporting Views/GraphCapsule.swift @@ -9,20 +9,20 @@ import SwiftUI struct GraphCapsule: View { var index: Int - var height: Length + var height: CGFloat var range: Range var overallRange: Range - 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)) } diff --git a/Other Projects/Composing Complex Interfaces/Complete/Landmarks/Landmarks/Supporting Views/HikeGraph.swift b/Other Projects/Composing Complex Interfaces/Complete/Landmarks/Landmarks/Supporting Views/HikeGraph.swift index 7df5194..2a4ff27 100755 --- a/Other Projects/Composing Complex Interfaces/Complete/Landmarks/Landmarks/Supporting Views/HikeGraph.swift +++ b/Other Projects/Composing Complex Interfaces/Complete/Landmarks/Landmarks/Supporting Views/HikeGraph.swift @@ -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) { diff --git a/Other Projects/Currency-SwiftUI/Currency-SwiftUI/ConverterView.swift b/Other Projects/Currency-SwiftUI/Currency-SwiftUI/ConverterView.swift index 1a5e351..22e3069 100644 --- a/Other Projects/Currency-SwiftUI/Currency-SwiftUI/ConverterView.swift +++ b/Other Projects/Currency-SwiftUI/Currency-SwiftUI/ConverterView.swift @@ -50,7 +50,7 @@ struct ConverterView : View { } Spacer() // Amount and conversion - TextField($baseAmount, placeholder: Text("1.0"), onCommit: { + TextField("1.0", text: $baseAmount, onCommit: { // TODO: update all currencies on the following list }).foregroundColor(.white) .background( diff --git a/Other Projects/Drawing Paths And Shapes/Complete/Landmarks/Landmarks/Models/Data.swift b/Other Projects/Drawing Paths And Shapes/Complete/Landmarks/Landmarks/Models/Data.swift index 78837f6..7248384 100755 --- a/Other Projects/Drawing Paths And Shapes/Complete/Landmarks/Landmarks/Models/Data.swift +++ b/Other Projects/Drawing Paths And Shapes/Complete/Landmarks/Landmarks/Models/Data.swift @@ -49,7 +49,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)) } fileprivate func _guaranteeInitialImage(name: String) -> _ImageDictionary.Index { diff --git a/Other Projects/Example To-Do App/SwiftUITodo/TaskEditView.swift b/Other Projects/Example To-Do App/SwiftUITodo/TaskEditView.swift index 81d3da2..7561526 100755 --- a/Other Projects/Example To-Do App/SwiftUITodo/TaskEditView.swift +++ b/Other Projects/Example To-Do App/SwiftUITodo/TaskEditView.swift @@ -22,8 +22,7 @@ struct TaskEditView: View { let inset = EdgeInsets(top: -8, leading: -10, bottom: -7, trailing: -10) return VStack(alignment: .leading, spacing: 0) { TextField( - self.draftTitle.binding, - placeholder: Text("Enter New Title..."), + "Enter New Title...", text: self.draftTitle.binding, onEditingChanged: { _ in self.updateTask() }, onCommit: {} ) diff --git a/Other Projects/Example To-Do App/SwiftUITodo/TaskListView.swift b/Other Projects/Example To-Do App/SwiftUITodo/TaskListView.swift index 99d9965..1fe1013 100755 --- a/Other Projects/Example To-Do App/SwiftUITodo/TaskListView.swift +++ b/Other Projects/Example To-Do App/SwiftUITodo/TaskListView.swift @@ -16,7 +16,7 @@ struct TaskListView: View { var body: some View { NavigationView { List { - TextField($draftTitle, placeholder: Text("Create a New Task..."), onCommit: self.createTask) + TextField("Create a New Task...", text: $draftTitle, onCommit: self.createTask) ForEach(self.userData.tasks) { task in TaskItemView(task: task, isEditing: self.$isEditing) } diff --git a/Other Projects/GitHub Search/GitHubSearchWithSwiftUI.xcodeproj/xcshareddata/xcschemes/GitHubSearchWithSwiftUI.xcscheme b/Other Projects/GitHub Search/GitHubSearchWithSwiftUI.xcodeproj/xcshareddata/xcschemes/GitHubSearchWithSwiftUI.xcscheme new file mode 100644 index 0000000..9dfd1ef --- /dev/null +++ b/Other Projects/GitHub Search/GitHubSearchWithSwiftUI.xcodeproj/xcshareddata/xcschemes/GitHubSearchWithSwiftUI.xcscheme @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Other Projects/GitHub Search/GitHubSearchWithSwiftUI/View/RepositoryListView.swift b/Other Projects/GitHub Search/GitHubSearchWithSwiftUI/View/RepositoryListView.swift index a9a5086..bd26fea 100755 --- a/Other Projects/GitHub Search/GitHubSearchWithSwiftUI/View/RepositoryListView.swift +++ b/Other Projects/GitHub Search/GitHubSearchWithSwiftUI/View/RepositoryListView.swift @@ -20,8 +20,7 @@ struct RepositoryListView : View { VStack { HStack { - TextField($viewModel.text, - placeholder: Text("Search reposipories..."), + TextField("Search repositories...", text: $viewModel.text, onCommit: { self.viewModel.search() }) .frame(height: 40) .padding(EdgeInsets(top: 0, leading: 8, bottom: 0, trailing: 8)) @@ -43,7 +42,7 @@ struct RepositoryListView : View { .lineLimit(nil) .multilineTextAlignment(.center) - ForEach(viewModel.repositories.identified(by: \.id)) { repository in + ForEach(viewModel.repositories, id: \.id) { repository in NavigationLink(destination: WebView(url: repository.htmlUrl) diff --git a/Other Projects/Handling User Input/Complete/Landmarks/Landmarks/Models/Data.swift b/Other Projects/Handling User Input/Complete/Landmarks/Landmarks/Models/Data.swift index 78837f6..7248384 100755 --- a/Other Projects/Handling User Input/Complete/Landmarks/Landmarks/Models/Data.swift +++ b/Other Projects/Handling User Input/Complete/Landmarks/Landmarks/Models/Data.swift @@ -49,7 +49,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)) } fileprivate func _guaranteeInitialImage(name: String) -> _ImageDictionary.Index { diff --git a/Other Projects/InstaFake/Instagram-SWUI/ContentView.swift b/Other Projects/InstaFake/Instagram-SWUI/ContentView.swift index 5a422de..ddbcd02 100755 --- a/Other Projects/InstaFake/Instagram-SWUI/ContentView.swift +++ b/Other Projects/InstaFake/Instagram-SWUI/ContentView.swift @@ -11,6 +11,7 @@ import AVKit import CoreLocation struct ContentView : View { + @State private var isCameraPresented = false var instaPhotos: [InstaPhoto] var body: some View { @@ -19,7 +20,17 @@ struct ContentView : View { ForEach(instaPhotos, id: \.id) { ImageCell(photo: $0) } - }.navigationBarTitle("WWDC").navigationBarItems(trailing: PresentationLink("Camera", destination: CameraView())) + }.navigationBarTitle("WWDC").navigationBarItems(trailing: + Button(action: { + self.isCameraPresented = true + }) { + Image(systemName: "person.crop.circle") + .imageScale(.large) + .accessibility(label: Text("User Profile")) + .padding() + } + ).sheet(isPresented: $isCameraPresented, + content: { CameraView() }) } } diff --git a/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/HikeBadge.swift b/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/HikeBadge.swift index 52716cf..78e9ad3 100755 --- a/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/HikeBadge.swift +++ b/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/HikeBadge.swift @@ -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).")) diff --git a/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Home.swift b/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Home.swift index 3072860..9614cf6 100755 --- a/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Home.swift +++ b/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Home.swift @@ -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()) }) } } } diff --git a/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Models/Data.swift b/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Models/Data.swift index 761ce0a..5fd193e 100755 --- a/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Models/Data.swift +++ b/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Models/Data.swift @@ -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 { diff --git a/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Profiles/ProfileEditor.swift b/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Profiles/ProfileEditor.swift index ca4cdda..e0fc032 100755 --- a/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Profiles/ProfileEditor.swift +++ b/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Profiles/ProfileEditor.swift @@ -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 ) } diff --git a/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Profiles/ProfileHost.swift b/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Profiles/ProfileHost.swift index 534c771..dde2cdd 100755 --- a/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Profiles/ProfileHost.swift +++ b/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Profiles/ProfileHost.swift @@ -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 } } } diff --git a/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Profiles/ProfileSummary.swift b/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Profiles/ProfileSummary.swift index c6eca8f..b63ac4e 100755 --- a/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Profiles/ProfileSummary.swift +++ b/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Profiles/ProfileSummary.swift @@ -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)) diff --git a/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Supporting Views/GraphCapsule.swift b/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Supporting Views/GraphCapsule.swift index ea128e0..98b9ac0 100755 --- a/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Supporting Views/GraphCapsule.swift +++ b/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Supporting Views/GraphCapsule.swift @@ -9,20 +9,20 @@ import SwiftUI struct GraphCapsule: View { var index: Int - var height: Length + var height: CGFloat var range: Range var overallRange: Range - 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)) } diff --git a/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Supporting Views/HikeGraph.swift b/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Supporting Views/HikeGraph.swift index 7df5194..2a4ff27 100755 --- a/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Supporting Views/HikeGraph.swift +++ b/Other Projects/Interfacing With UIKit/Complete/Landmarks/Landmarks/Supporting Views/HikeGraph.swift @@ -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) { diff --git a/Other Projects/Jike/SwiftUI_Jike/Tools/UITool.swift b/Other Projects/Jike/SwiftUI_Jike/Tools/UITool.swift index 6cf4077..4330c02 100755 --- a/Other Projects/Jike/SwiftUI_Jike/Tools/UITool.swift +++ b/Other Projects/Jike/SwiftUI_Jike/Tools/UITool.swift @@ -70,7 +70,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)) } fileprivate func _guaranteeInitialImage(name: String) -> _ImageDictionary.Index { diff --git a/Other Projects/Movie/MovieSwift/MovieSwift/views/ContentView.swift b/Other Projects/Movie/MovieSwift/MovieSwift/views/ContentView.swift index 4f5a73d..30af701 100755 --- a/Other Projects/Movie/MovieSwift/MovieSwift/views/ContentView.swift +++ b/Other Projects/Movie/MovieSwift/MovieSwift/views/ContentView.swift @@ -17,7 +17,7 @@ struct ContentView : View { var body: some View { List { - ForEach(state.moviesState.popular) { id in + ForEach(state.moviesState.popular, id: \.self) { id in Text(self.state.moviesState.movies[id]?.original_title ?? "No title") } } diff --git a/Other Projects/SwiftUI + Redux/SwiftUIDemo/views/TabbarView.swift b/Other Projects/SwiftUI + Redux/SwiftUIDemo/views/TabbarView.swift index 9f0ba72..ff9e9e6 100755 --- a/Other Projects/SwiftUI + Redux/SwiftUIDemo/views/TabbarView.swift +++ b/Other Projects/SwiftUI + Redux/SwiftUIDemo/views/TabbarView.swift @@ -15,9 +15,9 @@ struct TabbarView : View { var body: some View { TabbedView(selection: $selectedIndex) { UsersListView() - .tabItemLabel(Text("Users")) + .tabItem({ Text("Users") }) MapView() - .tabItemLabel(Text("Map")) + .tabItem({ Text("Map") }) } } } diff --git a/Other Projects/SwiftUI + Redux/SwiftUIDemo/views/users/UserDetailView.swift b/Other Projects/SwiftUI + Redux/SwiftUIDemo/views/users/UserDetailView.swift index 0393fe8..b623d01 100755 --- a/Other Projects/SwiftUI + Redux/SwiftUIDemo/views/users/UserDetailView.swift +++ b/Other Projects/SwiftUI + Redux/SwiftUIDemo/views/users/UserDetailView.swift @@ -13,15 +13,6 @@ struct UserDetailView : View { @EnvironmentObject var state: AppState let userId: Int - var editModal: Modal { - let user = state.usersState.users[userId] - return Modal(UserEditForm(userId: user.id, saveHandler: { saved in - self.state.dispatch(action: UserActions.stopEditUser) - }).environmentObject(state)) { - self.state.dispatch(action: UserActions.stopEditUser) - } - } - var body: some View { let user = state.usersState.users[userId] return VStack { @@ -36,7 +27,11 @@ struct UserDetailView : View { }) { Text("Edit user") } - .presentation(self.state.usersState.isEditingUser ? self.editModal : nil)) + .sheet(isPresented: $state.usersState.isEditingUser) { + UserEditForm(userId: user.id, saveHandler: { saved in + self.state.dispatch(action: UserActions.stopEditUser) + }) + }) } } diff --git a/Other Projects/SwiftUI + Redux/SwiftUIDemo/views/users/UserEditForm.swift b/Other Projects/SwiftUI + Redux/SwiftUIDemo/views/users/UserEditForm.swift index b8092b3..c10244e 100755 --- a/Other Projects/SwiftUI + Redux/SwiftUIDemo/views/users/UserEditForm.swift +++ b/Other Projects/SwiftUI + Redux/SwiftUIDemo/views/users/UserEditForm.swift @@ -24,11 +24,11 @@ return NavigationView { VStack(alignment: .leading, spacing: 10) { Text("User name") - TextField($newUserName, placeholder: Text("New name")) + TextField("New name", text: $newUserName) .textFieldStyle(.roundedBorder) Divider() Text("Username") - TextField($newUserUsername, placeholder: Text("New username")) + TextField("New username", text: $newUserUsername) .textFieldStyle(.roundedBorder) }.padding(16) Button(action: save) { diff --git a/Other Projects/SwiftUI + Redux/SwiftUIDemo/views/users/component/Badge.swift b/Other Projects/SwiftUI + Redux/SwiftUIDemo/views/users/component/Badge.swift index 4c53e5a..15e71bf 100755 --- a/Other Projects/SwiftUI + Redux/SwiftUIDemo/views/users/component/Badge.swift +++ b/Other Projects/SwiftUI + Redux/SwiftUIDemo/views/users/component/Badge.swift @@ -15,7 +15,7 @@ struct Badge : View { var animation: Animation { Animation - .spring(initialVelocity: 5) + .spring() .speed(2) } diff --git a/Other Projects/Time Travel/SwiftUITimeTravel/TimeTravelView/TimeTravelBarView.swift b/Other Projects/Time Travel/SwiftUITimeTravel/TimeTravelView/TimeTravelBarView.swift index 9bae914..22edc95 100755 --- a/Other Projects/Time Travel/SwiftUITimeTravel/TimeTravelView/TimeTravelBarView.swift +++ b/Other Projects/Time Travel/SwiftUITimeTravel/TimeTravelView/TimeTravelBarView.swift @@ -9,7 +9,7 @@ struct TimeTravelBarView : View { getValue: { Double(self.store.currentStateIndex) }, setValue: { self.store.currentStateIndex = Int($0) }) - return Slider(value: indexBinding, from: 0, through: Double(store.stateCount-1)) + return Slider(value: indexBinding, in: 0...Double(store.stateCount-1)) .background(Color.white) .frame(height: 44.0, alignment: .bottom) .padding() diff --git a/Other Projects/Time Travel/SwiftUITimeTravel/TodoList/Internal Views/AddItemView.swift b/Other Projects/Time Travel/SwiftUITimeTravel/TodoList/Internal Views/AddItemView.swift index 7a9f9a4..ce5f5c7 100755 --- a/Other Projects/Time Travel/SwiftUITimeTravel/TodoList/Internal Views/AddItemView.swift +++ b/Other Projects/Time Travel/SwiftUITimeTravel/TodoList/Internal Views/AddItemView.swift @@ -11,7 +11,7 @@ struct AddItemView: View { setValue: { self.store.dispatch(event: .changePartialItemName($0)) }) return VStack(spacing: 16) { - TextField(textBinding, placeholder: Text("Title")) + TextField("Title", text: textBinding) Button(action: { self.store.dispatch(event: .addItem) }) { @@ -22,7 +22,7 @@ struct AddItemView: View { } } - .relativeWidth(1.0) +// .relativeWidth(1.0) .background(Color.accentColor) .disabled(store.state.partialItemName.isEmpty) .foregroundColor(.white) diff --git a/Other Projects/Time Travel/SwiftUITimeTravel/TodoList/Internal Views/ModalDimmingView.swift b/Other Projects/Time Travel/SwiftUITimeTravel/TodoList/Internal Views/ModalDimmingView.swift index 7981f86..5c0f814 100755 --- a/Other Projects/Time Travel/SwiftUITimeTravel/TodoList/Internal Views/ModalDimmingView.swift +++ b/Other Projects/Time Travel/SwiftUITimeTravel/TodoList/Internal Views/ModalDimmingView.swift @@ -7,8 +7,8 @@ struct ModalDimmingView : View { var body: some View { Color .black - .relativeWidth(1.0) - .relativeHeight(1.0) +// .relativeWidth(1.0) +// .relativeHeight(1.0) .opacity(0.3) .edgesIgnoringSafeArea([.bottom, .top]) .transition(.opacity) diff --git a/Other Projects/Time Travel/SwiftUITimeTravel/TodoList/Internal Views/TodoListItemView.swift b/Other Projects/Time Travel/SwiftUITimeTravel/TodoList/Internal Views/TodoListItemView.swift index 0eb443d..b315a27 100755 --- a/Other Projects/Time Travel/SwiftUITimeTravel/TodoList/Internal Views/TodoListItemView.swift +++ b/Other Projects/Time Travel/SwiftUITimeTravel/TodoList/Internal Views/TodoListItemView.swift @@ -8,8 +8,8 @@ struct TodoListItemView : View { var body: some View { let binding = Binding( - getValue: { self.item.isFinished }, - setValue: { self.store.dispatch(event: .setItemDone(identifier: self.item.id, isDone: $0)) }) + get: { self.item.isFinished }, + set: { self.store.dispatch(event: .setItemDone(identifier: self.item.id, isDone: $0)) }) return Toggle(isOn: binding) { Text(item.title) diff --git a/Other Projects/Time Travel/SwiftUITimeTravel/TodoList/TodoListView.swift b/Other Projects/Time Travel/SwiftUITimeTravel/TodoList/TodoListView.swift index b8e67fb..4d20d7d 100755 --- a/Other Projects/Time Travel/SwiftUITimeTravel/TodoList/TodoListView.swift +++ b/Other Projects/Time Travel/SwiftUITimeTravel/TodoList/TodoListView.swift @@ -22,7 +22,7 @@ struct TodoListView : View { VStack { Spacer() AddItemView() - .relativeWidth(1.0) +// .relativeWidth(1.0) .background(Color.white) .cornerRadius(12.0) .shadow(radius: 16.0) diff --git a/Other Projects/Transition and Blur/Basic Animation/SwiftUI-BasicAnimation/ContentView.swift b/Other Projects/Transition and Blur/Basic Animation/SwiftUI-BasicAnimation/ContentView.swift index 911087d..e788fc5 100644 --- a/Other Projects/Transition and Blur/Basic Animation/SwiftUI-BasicAnimation/ContentView.swift +++ b/Other Projects/Transition and Blur/Basic Animation/SwiftUI-BasicAnimation/ContentView.swift @@ -19,7 +19,7 @@ struct ContentView: View { .fontWeight(.semibold) .foregroundColor(.black) .padding(4) - .animation(.basic(duration: 0.3, curve: .easeOut)) +// .animation(.basic(duration: 0.3, curve: .easeOut)) Image("ui") .frame(width: show ? 414 : 300, height: show ? 600 : 300) @@ -35,7 +35,7 @@ struct ContentView: View { .fontWeight(.regular) .foregroundColor(.gray) .padding(4) - .animation(.basic(duration: 0.4, curve: .easeIn)) +// .animation(.basic(duration: 0.4, curve: .easeIn)) Button(action: { withAnimation { diff --git a/Other Projects/UINote/SwiftUINote/Views/NoteDetail.swift b/Other Projects/UINote/SwiftUINote/Views/NoteDetail.swift index 4f6c3fd..52ebc28 100755 --- a/Other Projects/UINote/SwiftUINote/Views/NoteDetail.swift +++ b/Other Projects/UINote/SwiftUINote/Views/NoteDetail.swift @@ -24,8 +24,7 @@ struct NoteDetail : View { var body: some View { VStack { - TextField(self.text.binding, - placeholder: nil, + TextField("", text: self.text.binding, onEditingChanged: { _ in self.updateNote()}, onCommit: {}) Spacer() diff --git a/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/HikeBadge.swift b/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/HikeBadge.swift index 52716cf..78e9ad3 100755 --- a/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/HikeBadge.swift +++ b/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/HikeBadge.swift @@ -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).")) diff --git a/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/Home.swift b/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/Home.swift index 4306d0d..9614cf6 100755 --- a/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/Home.swift +++ b/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/Home.swift @@ -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,12 +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()) }) } } } diff --git a/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/Models/Data.swift b/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/Models/Data.swift index 248d3b2..cfe5a4a 100755 --- a/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/Models/Data.swift +++ b/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/Models/Data.swift @@ -51,7 +51,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)) } fileprivate func _guaranteeInitialImage(name: String) -> _ImageDictionary.Index { diff --git a/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/Profiles/ProfileEditor.swift b/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/Profiles/ProfileEditor.swift index 4f5e2c7..57c933b 100755 --- a/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/Profiles/ProfileEditor.swift +++ b/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/Profiles/ProfileEditor.swift @@ -15,7 +15,7 @@ struct ProfileEditor: View { HStack { Text("Username").bold() Divider() - TextField($profile.username) + TextField("", text: $profile.username) } Toggle(isOn: $profile.prefersNotifications) { @@ -24,21 +24,20 @@ struct ProfileEditor: View { VStack(alignment: .leading, spacing: 20) { Text("Seasonal Photo").bold() - - SegmentedControl(selection: $profile.seasonalPhoto) { + + 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 ) } diff --git a/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/Profiles/ProfileHost.swift b/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/Profiles/ProfileHost.swift index 534c771..dde2cdd 100755 --- a/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/Profiles/ProfileHost.swift +++ b/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/Profiles/ProfileHost.swift @@ -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 } } } diff --git a/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/Supporting Views/GraphCapsule.swift b/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/Supporting Views/GraphCapsule.swift index ea128e0..98b9ac0 100755 --- a/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/Supporting Views/GraphCapsule.swift +++ b/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/Supporting Views/GraphCapsule.swift @@ -9,20 +9,20 @@ import SwiftUI struct GraphCapsule: View { var index: Int - var height: Length + var height: CGFloat var range: Range var overallRange: Range - 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)) } diff --git a/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/Supporting Views/HikeGraph.swift b/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/Supporting Views/HikeGraph.swift index 7df5194..2a4ff27 100755 --- a/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/Supporting Views/HikeGraph.swift +++ b/Other Projects/Working With UIControls/Complete/Landmarks/Landmarks/Supporting Views/HikeGraph.swift @@ -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) {