mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-04-19 15:31:21 +02:00
WIP: migrations demo
This commit is contained in:
@@ -78,18 +78,6 @@ extension Menu {
|
||||
)
|
||||
}
|
||||
Section(header: Text("Classic (NSManagedObject subclasses)")) {
|
||||
Menu.ItemView(
|
||||
title: "Placemarks",
|
||||
subtitle: "Making changes using transactions in Swift",
|
||||
destination: { EmptyView() }
|
||||
)
|
||||
.disabled(true)
|
||||
Menu.ItemView(
|
||||
title: "Time Zones",
|
||||
subtitle: "Fetching objects and Querying raw values",
|
||||
destination: { EmptyView() }
|
||||
)
|
||||
.disabled(true)
|
||||
Menu.ItemView(
|
||||
title: "Colors",
|
||||
subtitle: "Observing list changes and single-object changes using ListMonitor",
|
||||
@@ -104,16 +92,19 @@ extension Menu {
|
||||
subtitle: "Switching between multiple persistent stores",
|
||||
destination: { EmptyView() }
|
||||
)
|
||||
.disabled(true)
|
||||
Menu.ItemView(
|
||||
title: "Evolution",
|
||||
subtitle: "Migrating and reverse-migrating stores",
|
||||
destination: { EmptyView() }
|
||||
)
|
||||
.disabled(true)
|
||||
Menu.ItemView(
|
||||
title: "Logger",
|
||||
subtitle: "Implementing a custom logger",
|
||||
destination: { EmptyView() }
|
||||
)
|
||||
.disabled(true)
|
||||
}
|
||||
}
|
||||
.listStyle(GroupedListStyle())
|
||||
|
||||
10
Demo/⭐️Sources/⭐️Demos/⭐️Advanced/Advanced.swift
Normal file
10
Demo/⭐️Sources/⭐️Demos/⭐️Advanced/Advanced.swift
Normal file
@@ -0,0 +1,10 @@
|
||||
//
|
||||
// Demo
|
||||
// Copyright © 2020 John Rommel Estropia, Inc. All rights reserved.
|
||||
|
||||
// MARK: - Advanced
|
||||
|
||||
/**
|
||||
Sample application of complex use cases
|
||||
*/
|
||||
enum Advanced {}
|
||||
@@ -0,0 +1,5 @@
|
||||
//
|
||||
// Demo
|
||||
// Copyright © 2020 John Rommel Estropia, Inc. All rights reserved.
|
||||
|
||||
import Foundation
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// Demo
|
||||
// Copyright © 2020 John Rommel Estropia, Inc. All rights reserved.
|
||||
|
||||
import UIKit
|
||||
import CoreStore
|
||||
|
||||
// MARK: - Advanced.EvolutionDemo
|
||||
|
||||
extension Advanced.EvolutionDemo {
|
||||
|
||||
// MARK: - Advanced.EvolutionDemo.CreatureV1
|
||||
|
||||
final class CreatureV1: CoreStoreObject {
|
||||
|
||||
// MARK: Internal
|
||||
|
||||
@Field.Stored("dnaCode")
|
||||
var dnaCode: Int64 = 0
|
||||
|
||||
@Field.Stored("hasHead")
|
||||
var hasHead: Bool = false
|
||||
|
||||
@Field.Stored("hasTail")
|
||||
var hasTail: Bool = false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
//
|
||||
// Advanced.Evolution.CreatureV2.swift
|
||||
// Demo
|
||||
//
|
||||
// Created by John Rommel Estropia on 2020/09/06.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@@ -0,0 +1,8 @@
|
||||
//
|
||||
// Advanced.Evolution.CreatureV3.swift
|
||||
// Demo
|
||||
//
|
||||
// Created by John Rommel Estropia on 2020/09/06.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@@ -0,0 +1,8 @@
|
||||
//
|
||||
// Advanced.Evolution.CreatureV4.swift
|
||||
// Demo
|
||||
//
|
||||
// Created by John Rommel Estropia on 2020/09/06.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@@ -0,0 +1,5 @@
|
||||
//
|
||||
// Demo
|
||||
// Copyright © 2020 John Rommel Estropia, Inc. All rights reserved.
|
||||
|
||||
import Foundation
|
||||
@@ -0,0 +1,5 @@
|
||||
//
|
||||
// Demo
|
||||
// Copyright © 2020 John Rommel Estropia, Inc. All rights reserved.
|
||||
|
||||
import Foundation
|
||||
@@ -0,0 +1,5 @@
|
||||
//
|
||||
// Demo
|
||||
// Copyright © 2020 John Rommel Estropia, Inc. All rights reserved.
|
||||
|
||||
import Foundation
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// Demo
|
||||
// Copyright © 2020 John Rommel Estropia, Inc. All rights reserved.
|
||||
|
||||
// MARK: - Advanced
|
||||
|
||||
extension Advanced {
|
||||
|
||||
// MARK: - Advanced.EvolutionDemo
|
||||
|
||||
/**
|
||||
Sample execution of progressive migrations. This demo also supports backwards migration.
|
||||
*/
|
||||
enum EvolutionDemo: CaseIterable {
|
||||
|
||||
// MARK: Internal
|
||||
|
||||
case ageOfInvertebrates
|
||||
case ageOfFishes
|
||||
case ageOfReptiles
|
||||
case ageOfMammals
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ extension Classic.ColorsDemo {
|
||||
switch self {
|
||||
|
||||
case .all: return .init()
|
||||
case .light: return (\.brightness >= 0.9)
|
||||
case .light: return (\.brightness >= 0.6)
|
||||
case .dark: return (\.brightness <= 0.4)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +96,6 @@ final class Classic_ColorsDemo_Palette: NSManagedObject {
|
||||
|
||||
private static func randomBrightness() -> Float {
|
||||
|
||||
return Float.random(in: 0.0 ... 1.0)
|
||||
return Float.random(in: 0.1 ... 0.9)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ extension Modern.ColorsDemo {
|
||||
switch self {
|
||||
|
||||
case .all: return .init()
|
||||
case .light: return (\.$brightness >= 0.9)
|
||||
case .light: return (\.$brightness >= 0.6)
|
||||
case .dark: return (\.$brightness <= 0.4)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ extension Modern.ColorsDemo {
|
||||
|
||||
private static func randomBrightness() -> Float {
|
||||
|
||||
return Float.random(in: 0.0 ... 1.0)
|
||||
return Float.random(in: 0.1 ... 0.9)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user