mirror of
https://github.com/ivanvorobei/SwiftUI.git
synced 2026-04-17 06:19:48 +02:00
Essential changes for Xcode 11 beta4
This commit is contained in:
@@ -38,14 +38,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
gameLogic.newGame()
|
||||
}
|
||||
|
||||
override func buildCommands(with builder: UICommandBuilder) {
|
||||
override func buildMenu(with builder: UIMenuBuilder) {
|
||||
builder.remove(menu: .edit)
|
||||
builder.remove(menu: .format)
|
||||
builder.remove(menu: .view)
|
||||
|
||||
builder.replaceChildren(ofMenu: .file) { oldChildren in
|
||||
var newChildren = oldChildren
|
||||
let newGameItem = UIMutableKeyCommand(input: "N",
|
||||
let newGameItem = UIKeyCommand(input: "N",
|
||||
modifierFlags: .command,
|
||||
action: #selector(newGame(_:)))
|
||||
newGameItem.title = "New Game"
|
||||
|
||||
@@ -21,7 +21,7 @@ final class GameLogic : BindableObject {
|
||||
|
||||
typealias BlockMatrixType = BlockMatrix<IdentifiedBlock>
|
||||
|
||||
let didChange = PassthroughSubject<GameLogic, Never>()
|
||||
let willChange = PassthroughSubject<GameLogic, Never>()
|
||||
|
||||
fileprivate var _blockMatrix: BlockMatrixType!
|
||||
var blockMatrix: BlockMatrixType {
|
||||
@@ -42,12 +42,12 @@ final class GameLogic : BindableObject {
|
||||
_blockMatrix = BlockMatrixType()
|
||||
generateNewBlocks()
|
||||
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
}
|
||||
|
||||
func move(_ direction: Direction) {
|
||||
defer {
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
}
|
||||
|
||||
var moved = false
|
||||
@@ -136,7 +136,7 @@ final class GameLogic : BindableObject {
|
||||
|
||||
// Don't forget to sync data.
|
||||
defer {
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
}
|
||||
|
||||
// Place the first block.
|
||||
|
||||
@@ -14,7 +14,7 @@ struct HikeView: View {
|
||||
var transition: AnyTransition {
|
||||
let insertion = AnyTransition.move(edge: .trailing)
|
||||
.combined(with: .opacity)
|
||||
let removal = AnyTransition.scale()
|
||||
let removal = AnyTransition.scale(scale: 0.0)
|
||||
.combined(with: .opacity)
|
||||
return .asymmetric(insertion: insertion, removal: removal)
|
||||
}
|
||||
|
||||
@@ -9,17 +9,17 @@ import Combine
|
||||
import SwiftUI
|
||||
|
||||
final class UserData: BindableObject {
|
||||
let didChange = PassthroughSubject<UserData, Never>()
|
||||
let willChange = PassthroughSubject<UserData, Never>()
|
||||
|
||||
var showFavoritesOnly = false {
|
||||
didSet {
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
}
|
||||
}
|
||||
|
||||
var landmarks = landmarkData {
|
||||
didSet {
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ extension Publisher {
|
||||
extension Publisher {
|
||||
|
||||
static func empty() -> AnyPublisher<Output, Failure> {
|
||||
return Publishers.Empty()
|
||||
return Empty()
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ extension Publisher {
|
||||
}
|
||||
|
||||
static func fail(_ error: Failure) -> AnyPublisher<Output, Failure> {
|
||||
return Publishers.Fail(error: error)
|
||||
return Fail(error: error)
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,17 @@ import SwiftUI
|
||||
import Combine
|
||||
|
||||
final class SearchUserViewModel: BindableObject {
|
||||
var didChange = PassthroughSubject<SearchUserViewModel, Never>()
|
||||
var willChange = PassthroughSubject<SearchUserViewModel, Never>()
|
||||
|
||||
private(set) var users = [User]() {
|
||||
didSet {
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
}
|
||||
}
|
||||
|
||||
private(set) var userImages = [User: UIImage]() {
|
||||
didSet {
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ struct HikeView: View {
|
||||
var transition: AnyTransition {
|
||||
let insertion = AnyTransition.move(edge: .trailing)
|
||||
.combined(with: .opacity)
|
||||
let removal = AnyTransition.scale()
|
||||
let removal = AnyTransition.scale(scale: 0.0)
|
||||
.combined(with: .opacity)
|
||||
return .asymmetric(insertion: insertion, removal: removal)
|
||||
}
|
||||
|
||||
@@ -9,17 +9,17 @@ import Combine
|
||||
import SwiftUI
|
||||
|
||||
final class UserData: BindableObject {
|
||||
let didChange = PassthroughSubject<UserData, Never>()
|
||||
let willChange = PassthroughSubject<UserData, Never>()
|
||||
|
||||
var showFavoritesOnly = false {
|
||||
didSet {
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
}
|
||||
}
|
||||
|
||||
var landmarks = landmarkData {
|
||||
didSet {
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,26 +52,26 @@ struct UserDefaultValue<Value: Codable> {
|
||||
}
|
||||
|
||||
final class UserData: BindableObject {
|
||||
let didChange = PassthroughSubject<UserData, Never>()
|
||||
let willChange = PassthroughSubject<UserData, Never>()
|
||||
|
||||
@UserDefaultValue(key: "allCurrencies", defaultValue: defaultCurrencies)
|
||||
var allCurrencies: [Currency] {
|
||||
didSet {
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
}
|
||||
}
|
||||
|
||||
@UserDefaultValue(key: "baseCurrency", defaultValue: defaultCurrencies[0])
|
||||
var baseCurrency: Currency {
|
||||
didSet {
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
}
|
||||
}
|
||||
|
||||
@UserDefaultValue(key: "userCurrency", defaultValue: defaultCurrencies)
|
||||
var userCurrency: [Currency] {
|
||||
didSet {
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,17 +9,17 @@ import Combine
|
||||
import SwiftUI
|
||||
|
||||
final class UserData: BindableObject {
|
||||
let didChange = PassthroughSubject<UserData, Never>()
|
||||
let willChange = PassthroughSubject<UserData, Never>()
|
||||
|
||||
var showFavoritesOnly = false {
|
||||
didSet {
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
}
|
||||
}
|
||||
|
||||
var landmarks = landmarkData {
|
||||
didSet {
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@ private let defaultTasks: [Task] = [
|
||||
]
|
||||
|
||||
final class UserData: BindableObject {
|
||||
let didChange = PassthroughSubject<UserData, Never>()
|
||||
let willChange = PassthroughSubject<UserData, Never>()
|
||||
|
||||
@UserDefaultValue(key: "Tasks", defaultValue: defaultTasks)
|
||||
var tasks: [Task] {
|
||||
didSet {
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import Combine
|
||||
final class Store<State, Action>: BindableObject {
|
||||
typealias Reducer = (State, Action) -> State
|
||||
|
||||
let didChange = PassthroughSubject<State, Never>()
|
||||
let willChange = PassthroughSubject<State, Never>()
|
||||
|
||||
var state: State {
|
||||
lock.lock()
|
||||
@@ -29,6 +29,6 @@ final class Store<State, Action>: BindableObject {
|
||||
|
||||
lock.unlock()
|
||||
|
||||
didChange.send(newState)
|
||||
willChange.send(newState)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ extension Publisher {
|
||||
extension Publisher {
|
||||
|
||||
static func empty() -> AnyPublisher<Output, Failure> {
|
||||
return Publishers.Empty()
|
||||
return Empty()
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ extension Publisher {
|
||||
}
|
||||
|
||||
static func fail(_ error: Failure) -> AnyPublisher<Output, Failure> {
|
||||
return Publishers.Fail(error: error)
|
||||
return Fail(error: error)
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import SwiftUI
|
||||
final class RepositoryListViewModel: BindableObject {
|
||||
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 _searchWithQuery = PassthroughSubject<String, Never>()
|
||||
@@ -34,7 +34,7 @@ final class RepositoryListViewModel: BindableObject {
|
||||
init<S: Scheduler>(searchRepositories: @escaping SearchRepositories = RepositoryAPI.search,
|
||||
mainScheduler: S) {
|
||||
|
||||
self.didChange = _didChange.eraseToAnyPublisher()
|
||||
self.willChange = _didChange.eraseToAnyPublisher()
|
||||
|
||||
let response = _searchWithQuery
|
||||
.filter { !$0.isEmpty }
|
||||
|
||||
@@ -9,17 +9,17 @@ import Combine
|
||||
import SwiftUI
|
||||
|
||||
final class UserData: BindableObject {
|
||||
let didChange = PassthroughSubject<UserData, Never>()
|
||||
let willChange = PassthroughSubject<UserData, Never>()
|
||||
|
||||
var showFavoritesOnly = false {
|
||||
didSet {
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
}
|
||||
}
|
||||
|
||||
var landmarks = landmarkData {
|
||||
didSet {
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ struct HikeView: View {
|
||||
var transition: AnyTransition {
|
||||
let insertion = AnyTransition.move(edge: .trailing)
|
||||
.combined(with: .opacity)
|
||||
let removal = AnyTransition.scale()
|
||||
let removal = AnyTransition.scale(scale: 0.0)
|
||||
.combined(with: .opacity)
|
||||
return .asymmetric(insertion: insertion, removal: removal)
|
||||
}
|
||||
|
||||
@@ -9,17 +9,17 @@ import Combine
|
||||
import SwiftUI
|
||||
|
||||
final class UserData: BindableObject {
|
||||
let didChange = PassthroughSubject<UserData, Never>()
|
||||
let willChange = PassthroughSubject<UserData, Never>()
|
||||
|
||||
var showFavoritesOnly = false {
|
||||
didSet {
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
}
|
||||
}
|
||||
|
||||
var landmarks = landmarkData {
|
||||
didSet {
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import SwiftUI
|
||||
import Combine
|
||||
|
||||
final class AppState: BindableObject {
|
||||
var didChange = PassthroughSubject<AppState, Never>()
|
||||
var willChange = PassthroughSubject<AppState, Never>()
|
||||
|
||||
var moviesState: MoviesState
|
||||
|
||||
@@ -22,7 +22,7 @@ final class AppState: BindableObject {
|
||||
func dispatch(action: Action) {
|
||||
moviesState = MoviesStateReducer().reduce(state: moviesState, action: action)
|
||||
DispatchQueue.main.async {
|
||||
self.didChange.send(self)
|
||||
self.willChange.send(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import SwiftUI
|
||||
import Combine
|
||||
|
||||
final class AppState: BindableObject {
|
||||
var didChange = PassthroughSubject<AppState, Never>()
|
||||
var willChange = PassthroughSubject<AppState, Never>()
|
||||
|
||||
var usersState: UsersState
|
||||
|
||||
@@ -21,7 +21,7 @@ final class AppState: BindableObject {
|
||||
|
||||
func dispatch(action: Action) {
|
||||
usersState = UserStateReducer().reduce(state: usersState, action: action)
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ public final class Store<StateType>: BindableObject where StateType: StateMachin
|
||||
private let initialState: StateType
|
||||
private var subsequentStates: [StateType] = []
|
||||
|
||||
public let didChange = PassthroughSubject<Void, Never>()
|
||||
public let willChange = PassthroughSubject<Void, Never>()
|
||||
|
||||
public init(state: StateType) {
|
||||
initialState = state
|
||||
@@ -23,7 +23,7 @@ public final class Store<StateType>: BindableObject where StateType: StateMachin
|
||||
var currentStateIndex: Int = 0 {
|
||||
didSet {
|
||||
withAnimation {
|
||||
didChange.send(())
|
||||
willChange.send(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@ import SwiftUI
|
||||
import Combine
|
||||
|
||||
final class UserData: BindableObject {
|
||||
let didChange = PassthroughSubject<UserData, Never>()
|
||||
let willChange = PassthroughSubject<UserData, Never>()
|
||||
|
||||
var notes = NoteData.shared.notes {
|
||||
didSet {
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
NoteData.shared.notes = notes
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,23 +9,23 @@ import SwiftUI
|
||||
import Combine
|
||||
|
||||
final class UserData: BindableObject {
|
||||
let didChange = PassthroughSubject<UserData, Never>()
|
||||
let willChange = PassthroughSubject<UserData, Never>()
|
||||
|
||||
var showFavoriteOnly = false {
|
||||
didSet {
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
}
|
||||
}
|
||||
|
||||
var videos = videoList {
|
||||
didSet {
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
}
|
||||
}
|
||||
|
||||
var currentVideo = videoList[0] {
|
||||
didSet {
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ struct HikeView: View {
|
||||
var transition: AnyTransition {
|
||||
let insertion = AnyTransition.move(edge: .trailing)
|
||||
.combined(with: .opacity)
|
||||
let removal = AnyTransition.scale()
|
||||
let removal = AnyTransition.scale(scale: 0.0)
|
||||
.combined(with: .opacity)
|
||||
return .asymmetric(insertion: insertion, removal: removal)
|
||||
}
|
||||
|
||||
@@ -9,17 +9,18 @@ import Combine
|
||||
import SwiftUI
|
||||
|
||||
final class UserData: BindableObject {
|
||||
let didChange = PassthroughSubject<UserData, Never>()
|
||||
|
||||
let willChange = PassthroughSubject<UserData, Never>()
|
||||
|
||||
var showFavoritesOnly = false {
|
||||
didSet {
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
}
|
||||
}
|
||||
|
||||
var landmarks = landmarkData {
|
||||
didSet {
|
||||
didChange.send(self)
|
||||
willChange.send(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user