Essential changes for Xcode 11 beta4

This commit is contained in:
John Holdsworth
2019-07-28 12:07:10 +01:00
parent 8018d0c2a0
commit 57e72ec52c
24 changed files with 58 additions and 57 deletions

View File

@@ -38,14 +38,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
gameLogic.newGame() gameLogic.newGame()
} }
override func buildCommands(with builder: UICommandBuilder) { override func buildMenu(with builder: UIMenuBuilder) {
builder.remove(menu: .edit) builder.remove(menu: .edit)
builder.remove(menu: .format) builder.remove(menu: .format)
builder.remove(menu: .view) builder.remove(menu: .view)
builder.replaceChildren(ofMenu: .file) { oldChildren in builder.replaceChildren(ofMenu: .file) { oldChildren in
var newChildren = oldChildren var newChildren = oldChildren
let newGameItem = UIMutableKeyCommand(input: "N", let newGameItem = UIKeyCommand(input: "N",
modifierFlags: .command, modifierFlags: .command,
action: #selector(newGame(_:))) action: #selector(newGame(_:)))
newGameItem.title = "New Game" newGameItem.title = "New Game"

View File

@@ -21,7 +21,7 @@ final class GameLogic : BindableObject {
typealias BlockMatrixType = BlockMatrix<IdentifiedBlock> typealias BlockMatrixType = BlockMatrix<IdentifiedBlock>
let didChange = PassthroughSubject<GameLogic, Never>() let willChange = PassthroughSubject<GameLogic, Never>()
fileprivate var _blockMatrix: BlockMatrixType! fileprivate var _blockMatrix: BlockMatrixType!
var blockMatrix: BlockMatrixType { var blockMatrix: BlockMatrixType {
@@ -42,12 +42,12 @@ final class GameLogic : BindableObject {
_blockMatrix = BlockMatrixType() _blockMatrix = BlockMatrixType()
generateNewBlocks() generateNewBlocks()
didChange.send(self) willChange.send(self)
} }
func move(_ direction: Direction) { func move(_ direction: Direction) {
defer { defer {
didChange.send(self) willChange.send(self)
} }
var moved = false var moved = false
@@ -136,7 +136,7 @@ final class GameLogic : BindableObject {
// Don't forget to sync data. // Don't forget to sync data.
defer { defer {
didChange.send(self) willChange.send(self)
} }
// Place the first block. // Place the first block.

View File

@@ -14,7 +14,7 @@ struct HikeView: View {
var transition: AnyTransition { var transition: AnyTransition {
let insertion = AnyTransition.move(edge: .trailing) let insertion = AnyTransition.move(edge: .trailing)
.combined(with: .opacity) .combined(with: .opacity)
let removal = AnyTransition.scale() let removal = AnyTransition.scale(scale: 0.0)
.combined(with: .opacity) .combined(with: .opacity)
return .asymmetric(insertion: insertion, removal: removal) return .asymmetric(insertion: insertion, removal: removal)
} }

View File

@@ -9,17 +9,17 @@ import Combine
import SwiftUI import SwiftUI
final class UserData: BindableObject { final class UserData: BindableObject {
let didChange = PassthroughSubject<UserData, Never>() let willChange = PassthroughSubject<UserData, Never>()
var showFavoritesOnly = false { var showFavoritesOnly = false {
didSet { didSet {
didChange.send(self) willChange.send(self)
} }
} }
var landmarks = landmarkData { var landmarks = landmarkData {
didSet { didSet {
didChange.send(self) willChange.send(self)
} }
} }
} }

View File

@@ -40,7 +40,7 @@ extension Publisher {
extension Publisher { extension Publisher {
static func empty() -> AnyPublisher<Output, Failure> { static func empty() -> AnyPublisher<Output, Failure> {
return Publishers.Empty() return Empty()
.eraseToAnyPublisher() .eraseToAnyPublisher()
} }
@@ -51,7 +51,7 @@ extension Publisher {
} }
static func fail(_ error: Failure) -> AnyPublisher<Output, Failure> { static func fail(_ error: Failure) -> AnyPublisher<Output, Failure> {
return Publishers.Fail(error: error) return Fail(error: error)
.eraseToAnyPublisher() .eraseToAnyPublisher()
} }
} }

View File

@@ -2,17 +2,17 @@ import SwiftUI
import Combine import Combine
final class SearchUserViewModel: BindableObject { final class SearchUserViewModel: BindableObject {
var didChange = PassthroughSubject<SearchUserViewModel, Never>() var willChange = PassthroughSubject<SearchUserViewModel, Never>()
private(set) var users = [User]() { private(set) var users = [User]() {
didSet { didSet {
didChange.send(self) willChange.send(self)
} }
} }
private(set) var userImages = [User: UIImage]() { private(set) var userImages = [User: UIImage]() {
didSet { didSet {
didChange.send(self) willChange.send(self)
} }
} }

View File

@@ -14,7 +14,7 @@ struct HikeView: View {
var transition: AnyTransition { var transition: AnyTransition {
let insertion = AnyTransition.move(edge: .trailing) let insertion = AnyTransition.move(edge: .trailing)
.combined(with: .opacity) .combined(with: .opacity)
let removal = AnyTransition.scale() let removal = AnyTransition.scale(scale: 0.0)
.combined(with: .opacity) .combined(with: .opacity)
return .asymmetric(insertion: insertion, removal: removal) return .asymmetric(insertion: insertion, removal: removal)
} }

View File

@@ -9,17 +9,17 @@ import Combine
import SwiftUI import SwiftUI
final class UserData: BindableObject { final class UserData: BindableObject {
let didChange = PassthroughSubject<UserData, Never>() let willChange = PassthroughSubject<UserData, Never>()
var showFavoritesOnly = false { var showFavoritesOnly = false {
didSet { didSet {
didChange.send(self) willChange.send(self)
} }
} }
var landmarks = landmarkData { var landmarks = landmarkData {
didSet { didSet {
didChange.send(self) willChange.send(self)
} }
} }
} }

View File

@@ -52,26 +52,26 @@ struct UserDefaultValue<Value: Codable> {
} }
final class UserData: BindableObject { final class UserData: BindableObject {
let didChange = PassthroughSubject<UserData, Never>() let willChange = PassthroughSubject<UserData, Never>()
@UserDefaultValue(key: "allCurrencies", defaultValue: defaultCurrencies) @UserDefaultValue(key: "allCurrencies", defaultValue: defaultCurrencies)
var allCurrencies: [Currency] { var allCurrencies: [Currency] {
didSet { didSet {
didChange.send(self) willChange.send(self)
} }
} }
@UserDefaultValue(key: "baseCurrency", defaultValue: defaultCurrencies[0]) @UserDefaultValue(key: "baseCurrency", defaultValue: defaultCurrencies[0])
var baseCurrency: Currency { var baseCurrency: Currency {
didSet { didSet {
didChange.send(self) willChange.send(self)
} }
} }
@UserDefaultValue(key: "userCurrency", defaultValue: defaultCurrencies) @UserDefaultValue(key: "userCurrency", defaultValue: defaultCurrencies)
var userCurrency: [Currency] { var userCurrency: [Currency] {
didSet { didSet {
didChange.send(self) willChange.send(self)
} }
} }
} }

View File

@@ -9,17 +9,17 @@ import Combine
import SwiftUI import SwiftUI
final class UserData: BindableObject { final class UserData: BindableObject {
let didChange = PassthroughSubject<UserData, Never>() let willChange = PassthroughSubject<UserData, Never>()
var showFavoritesOnly = false { var showFavoritesOnly = false {
didSet { didSet {
didChange.send(self) willChange.send(self)
} }
} }
var landmarks = landmarkData { var landmarks = landmarkData {
didSet { didSet {
didChange.send(self) willChange.send(self)
} }
} }
} }

View File

@@ -15,12 +15,12 @@ private let defaultTasks: [Task] = [
] ]
final class UserData: BindableObject { final class UserData: BindableObject {
let didChange = PassthroughSubject<UserData, Never>() let willChange = PassthroughSubject<UserData, Never>()
@UserDefaultValue(key: "Tasks", defaultValue: defaultTasks) @UserDefaultValue(key: "Tasks", defaultValue: defaultTasks)
var tasks: [Task] { var tasks: [Task] {
didSet { didSet {
didChange.send(self) willChange.send(self)
} }
} }
} }

View File

@@ -4,7 +4,7 @@ import Combine
final class Store<State, Action>: BindableObject { final class Store<State, Action>: BindableObject {
typealias Reducer = (State, Action) -> State typealias Reducer = (State, Action) -> State
let didChange = PassthroughSubject<State, Never>() let willChange = PassthroughSubject<State, Never>()
var state: State { var state: State {
lock.lock() lock.lock()
@@ -29,6 +29,6 @@ final class Store<State, Action>: BindableObject {
lock.unlock() lock.unlock()
didChange.send(newState) willChange.send(newState)
} }
} }

View File

@@ -19,7 +19,7 @@ extension Publisher {
extension Publisher { extension Publisher {
static func empty() -> AnyPublisher<Output, Failure> { static func empty() -> AnyPublisher<Output, Failure> {
return Publishers.Empty() return Empty()
.eraseToAnyPublisher() .eraseToAnyPublisher()
} }
@@ -30,7 +30,7 @@ extension Publisher {
} }
static func fail(_ error: Failure) -> AnyPublisher<Output, Failure> { static func fail(_ error: Failure) -> AnyPublisher<Output, Failure> {
return Publishers.Fail(error: error) return Fail(error: error)
.eraseToAnyPublisher() .eraseToAnyPublisher()
} }
} }

View File

@@ -13,7 +13,7 @@ import SwiftUI
final class RepositoryListViewModel: BindableObject { final class RepositoryListViewModel: BindableObject {
typealias SearchRepositories = (String) -> AnyPublisher<Result<[Repository], ErrorResponse>, Never> typealias SearchRepositories = (String) -> AnyPublisher<Result<[Repository], ErrorResponse>, Never>
let didChange: AnyPublisher<RepositoryListViewModel, Never> let willChange: AnyPublisher<RepositoryListViewModel, Never>
private let _didChange = PassthroughSubject<RepositoryListViewModel, Never>() private let _didChange = PassthroughSubject<RepositoryListViewModel, Never>()
private let _searchWithQuery = PassthroughSubject<String, Never>() private let _searchWithQuery = PassthroughSubject<String, Never>()
@@ -34,7 +34,7 @@ final class RepositoryListViewModel: BindableObject {
init<S: Scheduler>(searchRepositories: @escaping SearchRepositories = RepositoryAPI.search, init<S: Scheduler>(searchRepositories: @escaping SearchRepositories = RepositoryAPI.search,
mainScheduler: S) { mainScheduler: S) {
self.didChange = _didChange.eraseToAnyPublisher() self.willChange = _didChange.eraseToAnyPublisher()
let response = _searchWithQuery let response = _searchWithQuery
.filter { !$0.isEmpty } .filter { !$0.isEmpty }

View File

@@ -9,17 +9,17 @@ import Combine
import SwiftUI import SwiftUI
final class UserData: BindableObject { final class UserData: BindableObject {
let didChange = PassthroughSubject<UserData, Never>() let willChange = PassthroughSubject<UserData, Never>()
var showFavoritesOnly = false { var showFavoritesOnly = false {
didSet { didSet {
didChange.send(self) willChange.send(self)
} }
} }
var landmarks = landmarkData { var landmarks = landmarkData {
didSet { didSet {
didChange.send(self) willChange.send(self)
} }
} }
} }

View File

@@ -14,7 +14,7 @@ struct HikeView: View {
var transition: AnyTransition { var transition: AnyTransition {
let insertion = AnyTransition.move(edge: .trailing) let insertion = AnyTransition.move(edge: .trailing)
.combined(with: .opacity) .combined(with: .opacity)
let removal = AnyTransition.scale() let removal = AnyTransition.scale(scale: 0.0)
.combined(with: .opacity) .combined(with: .opacity)
return .asymmetric(insertion: insertion, removal: removal) return .asymmetric(insertion: insertion, removal: removal)
} }

View File

@@ -9,17 +9,17 @@ import Combine
import SwiftUI import SwiftUI
final class UserData: BindableObject { final class UserData: BindableObject {
let didChange = PassthroughSubject<UserData, Never>() let willChange = PassthroughSubject<UserData, Never>()
var showFavoritesOnly = false { var showFavoritesOnly = false {
didSet { didSet {
didChange.send(self) willChange.send(self)
} }
} }
var landmarks = landmarkData { var landmarks = landmarkData {
didSet { didSet {
didChange.send(self) willChange.send(self)
} }
} }
} }

View File

@@ -11,7 +11,7 @@ import SwiftUI
import Combine import Combine
final class AppState: BindableObject { final class AppState: BindableObject {
var didChange = PassthroughSubject<AppState, Never>() var willChange = PassthroughSubject<AppState, Never>()
var moviesState: MoviesState var moviesState: MoviesState
@@ -22,7 +22,7 @@ final class AppState: BindableObject {
func dispatch(action: Action) { func dispatch(action: Action) {
moviesState = MoviesStateReducer().reduce(state: moviesState, action: action) moviesState = MoviesStateReducer().reduce(state: moviesState, action: action)
DispatchQueue.main.async { DispatchQueue.main.async {
self.didChange.send(self) self.willChange.send(self)
} }
} }
} }

View File

@@ -11,7 +11,7 @@ import SwiftUI
import Combine import Combine
final class AppState: BindableObject { final class AppState: BindableObject {
var didChange = PassthroughSubject<AppState, Never>() var willChange = PassthroughSubject<AppState, Never>()
var usersState: UsersState var usersState: UsersState
@@ -21,7 +21,7 @@ final class AppState: BindableObject {
func dispatch(action: Action) { func dispatch(action: Action) {
usersState = UserStateReducer().reduce(state: usersState, action: action) usersState = UserStateReducer().reduce(state: usersState, action: action)
didChange.send(self) willChange.send(self)
} }
} }

View File

@@ -6,7 +6,7 @@ public final class Store<StateType>: BindableObject where StateType: StateMachin
private let initialState: StateType private let initialState: StateType
private var subsequentStates: [StateType] = [] private var subsequentStates: [StateType] = []
public let didChange = PassthroughSubject<Void, Never>() public let willChange = PassthroughSubject<Void, Never>()
public init(state: StateType) { public init(state: StateType) {
initialState = state initialState = state
@@ -23,7 +23,7 @@ public final class Store<StateType>: BindableObject where StateType: StateMachin
var currentStateIndex: Int = 0 { var currentStateIndex: Int = 0 {
didSet { didSet {
withAnimation { withAnimation {
didChange.send(()) willChange.send(())
} }
} }
} }

View File

@@ -10,11 +10,11 @@ import SwiftUI
import Combine import Combine
final class UserData: BindableObject { final class UserData: BindableObject {
let didChange = PassthroughSubject<UserData, Never>() let willChange = PassthroughSubject<UserData, Never>()
var notes = NoteData.shared.notes { var notes = NoteData.shared.notes {
didSet { didSet {
didChange.send(self) willChange.send(self)
NoteData.shared.notes = notes NoteData.shared.notes = notes
} }
} }

View File

@@ -9,23 +9,23 @@ import SwiftUI
import Combine import Combine
final class UserData: BindableObject { final class UserData: BindableObject {
let didChange = PassthroughSubject<UserData, Never>() let willChange = PassthroughSubject<UserData, Never>()
var showFavoriteOnly = false { var showFavoriteOnly = false {
didSet { didSet {
didChange.send(self) willChange.send(self)
} }
} }
var videos = videoList { var videos = videoList {
didSet { didSet {
didChange.send(self) willChange.send(self)
} }
} }
var currentVideo = videoList[0] { var currentVideo = videoList[0] {
didSet { didSet {
didChange.send(self) willChange.send(self)
} }
} }
} }

View File

@@ -14,7 +14,7 @@ struct HikeView: View {
var transition: AnyTransition { var transition: AnyTransition {
let insertion = AnyTransition.move(edge: .trailing) let insertion = AnyTransition.move(edge: .trailing)
.combined(with: .opacity) .combined(with: .opacity)
let removal = AnyTransition.scale() let removal = AnyTransition.scale(scale: 0.0)
.combined(with: .opacity) .combined(with: .opacity)
return .asymmetric(insertion: insertion, removal: removal) return .asymmetric(insertion: insertion, removal: removal)
} }

View File

@@ -9,17 +9,18 @@ import Combine
import SwiftUI import SwiftUI
final class UserData: BindableObject { final class UserData: BindableObject {
let didChange = PassthroughSubject<UserData, Never>()
let willChange = PassthroughSubject<UserData, Never>()
var showFavoritesOnly = false { var showFavoritesOnly = false {
didSet { didSet {
didChange.send(self) willChange.send(self)
} }
} }
var landmarks = landmarkData { var landmarks = landmarkData {
didSet { didSet {
didChange.send(self) willChange.send(self)
} }
} }
} }