mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-23 18:01:23 +01:00
fix for SR-13069
This commit is contained in:
@@ -32,31 +32,46 @@ extension Modern.PokedexDemo {
|
|||||||
// MARK: View
|
// MARK: View
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ScrollView {
|
ZStack {
|
||||||
ForEach(self.pokedexEntries.snapshot, id: \.self) { pokedexEntry in
|
ScrollView {
|
||||||
LazyView {
|
ForEach(self.pokedexEntries.snapshot.prefix(self.visibleItems), id: \.self) { pokedexEntry in
|
||||||
Text(pokedexEntry.snapshot?.$name ?? "")
|
LazyView {
|
||||||
|
Text(pokedexEntry.snapshot?.$name ?? "")
|
||||||
|
}
|
||||||
|
.frame(height: 100)
|
||||||
|
.frame(minWidth: 0, maxWidth: /*@START_MENU_TOKEN@*/.infinity/*@END_MENU_TOKEN@*/)
|
||||||
}
|
}
|
||||||
.frame(height: 100)
|
Button(
|
||||||
|
action: {
|
||||||
|
self.visibleItems = min(
|
||||||
|
self.visibleItems + 50,
|
||||||
|
self.pokedexEntries.snapshot.count
|
||||||
|
)
|
||||||
|
},
|
||||||
|
label: { Text("Load more") }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if self.service.isLoading {
|
||||||
|
Color(.sRGB, white: 0, opacity: 0.3)
|
||||||
|
.overlay(
|
||||||
|
Text("Fetching Pokedex…")
|
||||||
|
.foregroundColor(.white),
|
||||||
|
alignment: .center
|
||||||
|
)
|
||||||
|
.edgesIgnoringSafeArea(.bottom)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.frame(minWidth: 0, maxWidth: /*@START_MENU_TOKEN@*/.infinity/*@END_MENU_TOKEN@*/)
|
|
||||||
.overlay(
|
|
||||||
InstructionsView(
|
|
||||||
("Random", "Sets random coordinate"),
|
|
||||||
("Tap", "Sets to tapped coordinate")
|
|
||||||
)
|
|
||||||
.padding(.leading, 10)
|
|
||||||
.padding(.bottom, 40),
|
|
||||||
alignment: .bottomLeading
|
|
||||||
)
|
|
||||||
.navigationBarTitle("Pokedex")
|
.navigationBarTitle("Pokedex")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// MARK: Private
|
// MARK: Private
|
||||||
|
|
||||||
private let service: Modern.PokedexDemo.Service = .init()
|
@ObservedObject
|
||||||
|
private var service: Modern.PokedexDemo.Service = .init()
|
||||||
|
|
||||||
|
@State
|
||||||
|
private var visibleItems: Int = 50
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,15 +13,25 @@ extension Modern.PokedexDemo {
|
|||||||
|
|
||||||
// MARK: - Modern.PokedexDemo.Service
|
// MARK: - Modern.PokedexDemo.Service
|
||||||
|
|
||||||
final class Service {
|
final class Service: ObservableObject {
|
||||||
|
|
||||||
// MARK: Internal
|
// MARK: Internal
|
||||||
|
|
||||||
@Published
|
private(set) var isLoading: Bool = true {
|
||||||
var isLoading: Bool = true
|
|
||||||
|
willSet {
|
||||||
@Published
|
|
||||||
var lastError: (error: Modern.PokedexDemo.Service.Error, retry: () -> Void)?
|
self.objectWillChange.send()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private(set) var lastError: (error: Modern.PokedexDemo.Service.Error, retry: () -> Void)? {
|
||||||
|
|
||||||
|
willSet {
|
||||||
|
|
||||||
|
self.objectWillChange.send()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
|
||||||
@@ -49,7 +59,6 @@ extension Modern.PokedexDemo {
|
|||||||
.handleEvents(
|
.handleEvents(
|
||||||
receiveSubscription: { [weak self] _ in
|
receiveSubscription: { [weak self] _ in
|
||||||
|
|
||||||
print("Fetching Pokedex Entries")
|
|
||||||
guard let self = self else {
|
guard let self = self else {
|
||||||
|
|
||||||
return
|
return
|
||||||
@@ -61,7 +70,6 @@ extension Modern.PokedexDemo {
|
|||||||
.sink(
|
.sink(
|
||||||
receiveCompletion: { [weak self] completion in
|
receiveCompletion: { [weak self] completion in
|
||||||
|
|
||||||
print("Result (Fetching Pokedex Entries): \(completion)")
|
|
||||||
guard let self = self else {
|
guard let self = self else {
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -76,10 +76,10 @@ extension FieldContainer {
|
|||||||
*/
|
*/
|
||||||
public init<Coder: FieldCoderType>(
|
public init<Coder: FieldCoderType>(
|
||||||
wrappedValue initial: @autoclosure @escaping () -> V,
|
wrappedValue initial: @autoclosure @escaping () -> V,
|
||||||
_ keyPath: KeyPathString,
|
_ keyPath: KeyPathString = { fatalError("'keyPath' argument required (SR-13069 workaround)") }(),
|
||||||
versionHashModifier: @autoclosure @escaping () -> String? = nil,
|
versionHashModifier: @autoclosure @escaping () -> String? = nil,
|
||||||
previousVersionKeyPath: @autoclosure @escaping () -> String? = nil,
|
previousVersionKeyPath: @autoclosure @escaping () -> String? = nil,
|
||||||
coder fieldCoderType: Coder.Type,
|
coder fieldCoderType: Coder.Type = { fatalError("'coder' argument required (SR-13069 workaround)") }(),
|
||||||
customGetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>) -> V)? = nil,
|
customGetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>) -> V)? = nil,
|
||||||
customSetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>, _ newValue: V) -> Void)? = nil,
|
customSetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>, _ newValue: V) -> Void)? = nil,
|
||||||
affectedByKeyPaths: @autoclosure @escaping () -> Set<KeyPathString> = []
|
affectedByKeyPaths: @autoclosure @escaping () -> Set<KeyPathString> = []
|
||||||
@@ -150,10 +150,10 @@ extension FieldContainer {
|
|||||||
*/
|
*/
|
||||||
public init(
|
public init(
|
||||||
wrappedValue initial: @autoclosure @escaping () -> V,
|
wrappedValue initial: @autoclosure @escaping () -> V,
|
||||||
_ keyPath: KeyPathString,
|
_ keyPath: KeyPathString = { fatalError("'keyPath' argument required (SR-13069 workaround)") }(),
|
||||||
versionHashModifier: @autoclosure @escaping () -> String? = nil,
|
versionHashModifier: @autoclosure @escaping () -> String? = nil,
|
||||||
previousVersionKeyPath: @autoclosure @escaping () -> String? = nil,
|
previousVersionKeyPath: @autoclosure @escaping () -> String? = nil,
|
||||||
coder: (encode: (V) -> Data?, decode: (Data?) -> V),
|
coder: (encode: (V) -> Data?, decode: (Data?) -> V) = { fatalError("'coder' argument required (SR-13069 workaround)") }(),
|
||||||
customGetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>) -> V)? = nil,
|
customGetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>) -> V)? = nil,
|
||||||
customSetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>, _ newValue: V) -> Void)? = nil,
|
customSetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>, _ newValue: V) -> Void)? = nil,
|
||||||
affectedByKeyPaths: @autoclosure @escaping () -> Set<KeyPathString> = []
|
affectedByKeyPaths: @autoclosure @escaping () -> Set<KeyPathString> = []
|
||||||
@@ -478,10 +478,10 @@ extension FieldContainer.Coded where V: FieldOptionalType {
|
|||||||
*/
|
*/
|
||||||
public init<Coder: FieldCoderType>(
|
public init<Coder: FieldCoderType>(
|
||||||
wrappedValue initial: @autoclosure @escaping () -> V = nil,
|
wrappedValue initial: @autoclosure @escaping () -> V = nil,
|
||||||
_ keyPath: KeyPathString,
|
_ keyPath: KeyPathString = { fatalError("'keyPath' argument required (SR-13069 workaround)") }(),
|
||||||
versionHashModifier: @autoclosure @escaping () -> String? = nil,
|
versionHashModifier: @autoclosure @escaping () -> String? = nil,
|
||||||
previousVersionKeyPath: @autoclosure @escaping () -> String? = nil,
|
previousVersionKeyPath: @autoclosure @escaping () -> String? = nil,
|
||||||
coder: Coder.Type,
|
coder: Coder.Type = { fatalError("'coder' argument required (SR-13069 workaround)") }(),
|
||||||
customGetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>) -> V)? = nil,
|
customGetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>) -> V)? = nil,
|
||||||
customSetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>, _ newValue: V) -> Void)? = nil,
|
customSetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>, _ newValue: V) -> Void)? = nil,
|
||||||
affectedByKeyPaths: @autoclosure @escaping () -> Set<KeyPathString> = []
|
affectedByKeyPaths: @autoclosure @escaping () -> Set<KeyPathString> = []
|
||||||
@@ -552,10 +552,10 @@ extension FieldContainer.Coded where V: FieldOptionalType {
|
|||||||
*/
|
*/
|
||||||
public init(
|
public init(
|
||||||
wrappedValue initial: @autoclosure @escaping () -> V = nil,
|
wrappedValue initial: @autoclosure @escaping () -> V = nil,
|
||||||
_ keyPath: KeyPathString,
|
_ keyPath: KeyPathString = { fatalError("'keyPath' argument required (SR-13069 workaround)") }(),
|
||||||
versionHashModifier: @autoclosure @escaping () -> String? = nil,
|
versionHashModifier: @autoclosure @escaping () -> String? = nil,
|
||||||
previousVersionKeyPath: @autoclosure @escaping () -> String? = nil,
|
previousVersionKeyPath: @autoclosure @escaping () -> String? = nil,
|
||||||
coder: (encode: (V) -> Data?, decode: (Data?) -> V),
|
coder: (encode: (V) -> Data?, decode: (Data?) -> V) = { fatalError("'coder' argument required (SR-13069 workaround)") }(),
|
||||||
customGetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>) -> V)? = nil,
|
customGetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>) -> V)? = nil,
|
||||||
customSetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>, _ newValue: V) -> Void)? = nil,
|
customSetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>, _ newValue: V) -> Void)? = nil,
|
||||||
affectedByKeyPaths: @autoclosure @escaping () -> Set<KeyPathString> = []
|
affectedByKeyPaths: @autoclosure @escaping () -> Set<KeyPathString> = []
|
||||||
@@ -625,7 +625,7 @@ extension FieldContainer.Coded where V: DefaultNSSecureCodable {
|
|||||||
*/
|
*/
|
||||||
public init(
|
public init(
|
||||||
wrappedValue initial: @autoclosure @escaping () -> V,
|
wrappedValue initial: @autoclosure @escaping () -> V,
|
||||||
_ keyPath: KeyPathString,
|
_ keyPath: KeyPathString = { fatalError("'keyPath' argument required (SR-13069 workaround)") }(),
|
||||||
versionHashModifier: @autoclosure @escaping () -> String? = nil,
|
versionHashModifier: @autoclosure @escaping () -> String? = nil,
|
||||||
previousVersionKeyPath: @autoclosure @escaping () -> String? = nil,
|
previousVersionKeyPath: @autoclosure @escaping () -> String? = nil,
|
||||||
customGetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>) -> V)? = nil,
|
customGetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>) -> V)? = nil,
|
||||||
@@ -696,7 +696,7 @@ extension FieldContainer.Coded where V: FieldOptionalType, V.Wrapped: DefaultNSS
|
|||||||
*/
|
*/
|
||||||
public init(
|
public init(
|
||||||
wrappedValue initial: @autoclosure @escaping () -> V = nil,
|
wrappedValue initial: @autoclosure @escaping () -> V = nil,
|
||||||
_ keyPath: KeyPathString,
|
_ keyPath: KeyPathString = { fatalError("'keyPath' argument required (SR-13069 workaround)") }(),
|
||||||
versionHashModifier: @autoclosure @escaping () -> String? = nil,
|
versionHashModifier: @autoclosure @escaping () -> String? = nil,
|
||||||
previousVersionKeyPath: @autoclosure @escaping () -> String? = nil,
|
previousVersionKeyPath: @autoclosure @escaping () -> String? = nil,
|
||||||
customGetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>) -> V)? = nil,
|
customGetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>) -> V)? = nil,
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ extension FieldContainer {
|
|||||||
*/
|
*/
|
||||||
public init(
|
public init(
|
||||||
wrappedValue initial: @autoclosure @escaping () -> V,
|
wrappedValue initial: @autoclosure @escaping () -> V,
|
||||||
_ keyPath: KeyPathString,
|
_ keyPath: KeyPathString = { fatalError("'keyPath' argument required (SR-13069 workaround)") }(),
|
||||||
versionHashModifier: @autoclosure @escaping () -> String? = nil,
|
versionHashModifier: @autoclosure @escaping () -> String? = nil,
|
||||||
previousVersionKeyPath: @autoclosure @escaping () -> String? = nil,
|
previousVersionKeyPath: @autoclosure @escaping () -> String? = nil,
|
||||||
customGetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>) -> V)? = nil,
|
customGetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>) -> V)? = nil,
|
||||||
@@ -370,7 +370,7 @@ extension FieldContainer.Stored where V: FieldOptionalType {
|
|||||||
*/
|
*/
|
||||||
public init(
|
public init(
|
||||||
wrappedValue initial: @autoclosure @escaping () -> V = nil,
|
wrappedValue initial: @autoclosure @escaping () -> V = nil,
|
||||||
_ keyPath: KeyPathString,
|
_ keyPath: KeyPathString = { fatalError("'keyPath' argument required (SR-13069 workaround)") }(),
|
||||||
versionHashModifier: @autoclosure @escaping () -> String? = nil,
|
versionHashModifier: @autoclosure @escaping () -> String? = nil,
|
||||||
previousVersionKeyPath: @autoclosure @escaping () -> String? = nil,
|
previousVersionKeyPath: @autoclosure @escaping () -> String? = nil,
|
||||||
customGetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>) -> V)? = nil,
|
customGetter: ((_ object: ObjectProxy<O>, _ field: ObjectProxy<O>.FieldProxy<V>) -> V)? = nil,
|
||||||
|
|||||||
Reference in New Issue
Block a user