Commit a889b6e0 authored by Ruben Daniels's avatar Ruben Daniels
Browse files

Rename CascadingView to CascadableView

parent 0ec7848b
Showing with 55 additions and 55 deletions
+55 -55
......@@ -95,7 +95,7 @@
5DB66FB52431DD41007736D6 /* contextTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DB66FB42431DD41007736D6 /* contextTest.swift */; };
5DB66FB72431DEB0007736D6 /* realmTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DB66FB62431DEB0007736D6 /* realmTest.swift */; };
5DB8EBFF24598E1E0028FD2E /* ViewsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DB8EBFE24598E1E0028FD2E /* ViewsTest.swift */; };
5DB8EC0424598FA30028FD2E /* CascadingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DB8EC0324598FA30028FD2E /* CascadingView.swift */; };
5DB8EC0424598FA30028FD2E /* CascadableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DB8EC0324598FA30028FD2E /* CascadableView.swift */; };
5DB8EC0B24599A080028FD2E /* ComputedViewTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DB8EC0A24599A080028FD2E /* ComputedViewTest.swift */; };
5DB8EC0D24599A280028FD2E /* DynamicViewTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DB8EC0C24599A280028FD2E /* DynamicViewTest.swift */; };
5DC1692724093C3900367905 /* sessions_manually_single.json in Resources */ = {isa = PBXBuildFile; fileRef = 5DC1692624093C3900367905 /* sessions_manually_single.json */; };
......@@ -375,7 +375,7 @@
5DB66FB42431DD41007736D6 /* contextTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = contextTest.swift; sourceTree = "<group>"; };
5DB66FB62431DEB0007736D6 /* realmTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = realmTest.swift; sourceTree = "<group>"; };
5DB8EBFE24598E1E0028FD2E /* ViewsTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewsTest.swift; sourceTree = "<group>"; };
5DB8EC0324598FA30028FD2E /* CascadingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CascadingView.swift; sourceTree = "<group>"; wrapsLines = 0; };
5DB8EC0324598FA30028FD2E /* CascadableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CascadableView.swift; sourceTree = "<group>"; wrapsLines = 0; };
5DB8EC0A24599A080028FD2E /* ComputedViewTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComputedViewTest.swift; sourceTree = "<group>"; };
5DB8EC0C24599A280028FD2E /* DynamicViewTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DynamicViewTest.swift; sourceTree = "<group>"; };
5DC1692524093BD300367905 /* sessions_manually_expanded.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = sessions_manually_expanded.json; sourceTree = "<group>"; };
......@@ -889,7 +889,7 @@
5DFB0CBE24179FA6002FBDE7 /* Sessions.swift */,
86C6D895246EC33A001B87D0 /* Session.swift */,
5D38DE18240577BA00FF9B70 /* Views.swift */,
5DB8EC0324598FA30028FD2E /* CascadingView.swift */,
5DB8EC0324598FA30028FD2E /* CascadableView.swift */,
86911E8124C543C3009AC8B1 /* CascadableDict.swift */,
86911E8324C543CD009AC8B1 /* CascadableContextPane.swift */,
86DDB360247AAD030051A92F /* Cascadable.swift */,
......@@ -1662,7 +1662,7 @@
5D3D961F24164B240004040E /* CodeExtended.swift in Sources */,
B88AAB3224A1AEBB0007C9EB /* LineChartView.swift in Sources */,
5DD28B772417BAF900CE9F6A /* ThumbnailRendererView.swift in Sources */,
5DB8EC0424598FA30028FD2E /* CascadingView.swift in Sources */,
5DB8EC0424598FA30028FD2E /* CascadableView.swift in Sources */,
5D3D9621241675100004040E /* util.swift in Sources */,
B88AAB2D24A1AEBB0007C9EB /* ChartModel.swift in Sources */,
B89A268324A70358009119E4 /* MapView.swift in Sources */,
......
......@@ -34,7 +34,7 @@ public class MemriContext: ObservableObject, Subscriptable {
sessions.currentSession
}
public var currentView: CascadingView? {
public var currentView: CascadableView? {
sessions.currentSession?.currentView
}
......@@ -88,8 +88,8 @@ public class MemriContext: ObservableObject, Subscriptable {
private var uiUpdateSubject = PassthroughSubject<Void, Never>()
private var uiUpdateCancellable: AnyCancellable?
private var cascadingViewUpdateSubject = PassthroughSubject<Void, Never>()
private var cascadingViewUpdateCancellable: AnyCancellable?
private var cascadableViewUpdateSubject = PassthroughSubject<Void, Never>()
private var cascadableViewUpdateCancellable: AnyCancellable?
func scheduleUIUpdate(immediate: Bool = false, _ check: ((_ context: MemriContext) -> Bool)? = nil) { // Update UI
if immediate {
......@@ -110,18 +110,18 @@ public class MemriContext: ObservableObject, Subscriptable {
uiUpdateSubject.send()
}
func scheduleCascadingViewUpdate(immediate: Bool = false) {
func scheduleCascadableViewUpdate(immediate: Bool = false) {
if immediate {
// Do this straight away, usually for the sake of correct animation
do { try self.currentSession?.setCurrentView() }
catch {
// TODO: User error handling
// TODO: Error Handling
debugHistory.error("Could not update CascadingView: \(error)")
debugHistory.error("Could not update CascadableView: \(error)")
}
return
} else {
cascadingViewUpdateSubject.send()
cascadableViewUpdateSubject.send()
}
}
......@@ -235,7 +235,7 @@ public class MemriContext: ObservableObject, Subscriptable {
}
// Setup update publishers
self.cascadingViewUpdateCancellable = cascadingViewUpdateSubject
self.cascadableViewUpdateCancellable = cascadableViewUpdateSubject
.throttle(for: .milliseconds(500), scheduler: RunLoop.main, latest: true)
.receive(on: DispatchQueue.main)
.sink { [weak self] in
......
......@@ -3,9 +3,9 @@
"name": "filter-starred",
"fromTemplate": "{view}",
"datasource": {
"query": "{cascadingView.datasource.query} AND starred = true"
"query": "{cascadableView.datasource.query} AND starred = true"
},
"title": "Starred {cascadingView.title}"
"title": "Starred {cascadableView.title}"
},
{
......
......@@ -3,9 +3,9 @@
"name": "filter-starred",
"fromTemplate": "{view}",
"datasource": {
"query": "{cascadingView.datasource.query} AND starred = true"
"query": "{cascadableView.datasource.query} AND starred = true"
},
"title": "Starred {cascadingView.title}"
"title": "Starred {cascadableView.title}"
},
{
......
......@@ -441,7 +441,7 @@ class ActionBack: Action, ActionExec {
print("Warn: Can't go back. Already at earliest view in session")
} else {
session.currentViewIndex -= 1
context.scheduleCascadingViewUpdate()
context.scheduleCascadableViewUpdate()
}
} else {
// TODO: Error Handling?
......@@ -528,7 +528,7 @@ class ActionOpenView: Action, ActionExec {
}
func exec(_ arguments: [String: Any?]) throws {
// let selection = context.cascadingView.userState.get("selection") as? [Item]
// let selection = context.cascadableView.userState.get("selection") as? [Item]
let item = arguments["item"] as? Item
let viewArguments = arguments["viewArguments"] as? ViewArguments
......@@ -644,7 +644,7 @@ class ActionStar: Action, ActionExec {
// TODO: selection handling for binding
func exec(_: [String: Any?]) throws {
// if let item = arguments["item"] as? Item {
// var selection:[Item] = context.cascadingView.userState.get("selection") ?? []
// var selection:[Item] = context.cascadableView.userState.get("selection") ?? []
// let toValue = !item.starred
//
// if !selection.contains(item) {
......@@ -794,7 +794,7 @@ class ActionForward: Action, ActionExec {
print("Warn: Can't go forward. Already at last view in session")
} else {
session.currentViewIndex += 1
context.scheduleCascadingViewUpdate()
context.scheduleCascadableViewUpdate()
}
} else {
// TODO: Error handling?
......@@ -818,7 +818,7 @@ class ActionForwardToFront: Action, ActionExec {
func exec(_: [String: Any?]) throws {
if let session = context.currentSession {
session.currentViewIndex = session.views.count - 1
context.scheduleCascadingViewUpdate()
context.scheduleCascadableViewUpdate()
} else {
// TODO: Error handling
}
......@@ -992,10 +992,10 @@ class ActionDelete: Action, ActionExec {
selection.count > 0
{
context.cache.delete(selection)
context.scheduleCascadingViewUpdate(immediate: true)
context.scheduleCascadableViewUpdate(immediate: true)
} else if let dataItem = arguments["item"] as? Item {
context.cache.delete(dataItem)
context.scheduleCascadingViewUpdate(immediate: true)
context.scheduleCascadableViewUpdate(immediate: true)
} else {
// TODO: Erorr handling
}
......
......@@ -8,7 +8,7 @@ import Foundation
import SwiftUI
import RealmSwift
public class CascadingView: Cascadable, ObservableObject, Subscriptable {
public class CascadableView: Cascadable, ObservableObject, Subscriptable {
var context: MemriContext?
var session: Session? = nil
......@@ -324,7 +324,7 @@ public class CascadingView: Cascadable, ObservableObject, Subscriptable {
super.init(head, [])
}
/// This init should only be called to create an empty CascadingView when needed inside a SwiftUI View
/// This init should only be called to create an empty CascadableView when needed inside a SwiftUI View
required init(
_ head: CVUParsedDefinition? = nil,
_ tail: [CVUParsedDefinition]? = nil,
......@@ -480,7 +480,7 @@ public class CascadingView: Cascadable, ObservableObject, Subscriptable {
else {
throw "Exception: could not parse view: \(viewName)"
}
} else if let view = result as? CascadingView {
} else if let view = result as? CascadableView {
let parsed = CVUParsedViewDefinition(parsed: view.head.parsed)
try include(parsed, domain)
} else {
......
......@@ -87,7 +87,7 @@ class FilterPanelRendererButton: Action, ActionExec {
func exec(_: [String: Any?]) {
context.currentView?.activeRenderer = rendererName
context.scheduleUIUpdate { _ in true } // scheduleCascadingViewUpdate() // TODO why are userState not kept?
context.scheduleUIUpdate { _ in true } // scheduleCascadableViewUpdate() // TODO why are userState not kept?
}
}
......
......@@ -67,7 +67,7 @@ class InfoState: Hashable {
var displayMessage: String = ""
var messageCount: Int = 1
var type: InfoType = .info
// var cascadingView: ComputedView
// var cascadableView: ComputedView
init(displayMessage m: String) {
displayMessage = m
......@@ -109,42 +109,42 @@ class DebugHistory: ObservableObject {
return "[\(dateFormatter.string(from: d))]"
}
func info(_ message: String /* , _ cascadingView:ComputedView */ ) {
func info(_ message: String /* , _ cascadableView:ComputedView */ ) {
// if same view
if log.last?.displayMessage == message {
log[log.count - 1].messageCount += 1
} else {
log.append(InfoState(
displayMessage: message
// cascadingView: cascadingView
// cascadableView: cascadableView
))
}
print("\(time()) INFO: \(message.replace("\n", "\n "))")
}
func warn(_ message: String /* , _ cascadingView:ComputedView */ ) {
func warn(_ message: String /* , _ cascadableView:ComputedView */ ) {
// if same view
if log.last?.displayMessage == message {
log[log.count - 1].messageCount += 1
} else {
log.append(WarnState(
displayMessage: message
// cascadingView: cascadingView
// cascadableView: cascadableView
))
}
print("\(time()) WARNING: \(message.replace("\n", "\n "))")
}
func error(_ message: String /* , _ cascadingView:ComputedView */ ) {
func error(_ message: String /* , _ cascadableView:ComputedView */ ) {
// if same view
if log.last?.displayMessage == message {
log[log.count - 1].messageCount += 1
} else {
log.append(ErrorState(
displayMessage: message
// cascadingView: cascadingView
// cascadableView: cascadableView
))
}
......
......@@ -161,13 +161,13 @@ public class Views {
// // Determine whether the current view needs reloading
// for def in defs {
// var selectors = [String]()
// if let stack = context?.cascadingView?.cascadeStack {
// if let stack = context?.cascadableView?.cascadeStack {
// for parsed in stack { selectors.append(parsed.selectors) }
// ...
// }
// }
self.context?.scheduleCascadingViewUpdate()
self.context?.scheduleCascadableViewUpdate()
}
func getGlobalReference(_ name: String, viewArguments: ViewArguments?) throws -> Any? {
......@@ -504,7 +504,7 @@ public class Views {
return view
}
// TODO: Refactor: Consider caching cascadingView based on the type of the item
// TODO: Refactor: Consider caching cascadableView based on the type of the item
public func renderItemCell(with item: Item?,
search rendererNames: [String] = [],
inView viewOverride: String? = nil,
......
......@@ -16,7 +16,7 @@ struct Browser: View {
}
var body: some View {
let currentView = self.context.currentView ?? CascadingView()
let currentView = self.context.currentView ?? CascadableView()
return ZStack {
if self.context.currentView == nil {
......
......@@ -46,12 +46,12 @@ struct FilterPanel: View {
private func toggleAscending() {
let ds = self.context.currentView?.datasource
ds?.sortAscending = !(ds?.sortAscending ?? true)
context.scheduleCascadingViewUpdate()
context.scheduleCascadableViewUpdate()
}
private func changeOrderProperty(_ fieldName: String) {
self.context.currentView?.datasource.sortProperty = fieldName
context.scheduleCascadingViewUpdate()
context.scheduleCascadableViewUpdate()
}
private func rendererCategories() -> [(String, FilterPanelRendererButton)] {
......@@ -84,7 +84,7 @@ struct FilterPanel: View {
var body: some View {
let context = self.context
let cascadingView = self.context.currentView
let cascadableView = self.context.currentView
return
HStack(alignment: .top, spacing: 0) {
......@@ -116,7 +116,7 @@ struct FilterPanel: View {
ASSection(id: 0, data: renderersAvailable(), dataID: \.0) { (item: (key: String, renderer: FilterPanelRendererButton), _) in
Button(action: { context.executeAction(item.renderer) }) {
Group {
if cascadingView?.activeRenderer == item.renderer.rendererName {
if cascadableView?.activeRenderer == item.renderer.rendererName {
Text(LocalizedStringKey(item.renderer.getString("title")))
.foregroundColor(Color(hex: "#6aa84f"))
.fontWeight(.semibold)
......@@ -142,7 +142,7 @@ struct FilterPanel: View {
.padding(.horizontal)
.padding(.vertical, 6)
}) {
cascadingView?.datasource.sortProperty.map { currentSortProperty in
cascadableView?.datasource.sortProperty.map { currentSortProperty in
Button(action: { self.toggleAscending() }) {
HStack {
Text(currentSortProperty)
......@@ -150,7 +150,7 @@ struct FilterPanel: View {
.font(.system(size: 16, weight: .semibold, design: .default))
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
Spacer()
Image(systemName: cascadingView?.datasource.sortAscending == false
Image(systemName: cascadableView?.datasource.sortAscending == false
? "arrow.down"
: "arrow.up")
.resizable()
......@@ -160,8 +160,8 @@ struct FilterPanel: View {
}
}
}
cascadingView?.sortFields.filter {
cascadingView?.datasource.sortProperty != $0
cascadableView?.sortFields.filter {
cascadableView?.datasource.sortProperty != $0
}.map { fieldName in
Button(action: { self.changeOrderProperty(fieldName) }) {
Text(fieldName)
......
......@@ -40,7 +40,7 @@ public struct SubView: View {
}
catch {
// TODO: Refactor error handling
throw "Cannot update CascadingView \(self): \(error)"
throw "Cannot update CascadableView \(self): \(error)"
}
} catch {
// TODO: Refactor: error handling
......@@ -65,7 +65,7 @@ public struct SubView: View {
try proxyMain?.currentSession?.setCurrentView(state, args)
} catch {
// TODO: Refactor error handling
debugHistory.error("Error: cannot init subview, failed to update CascadingView: \(error)")
debugHistory.error("Error: cannot init subview, failed to update CascadableView: \(error)")
}
}
......
......@@ -65,7 +65,7 @@ public final class Session : Equatable, Subscriptable {
}
/// TBD
var views = [CascadingView]()
var views = [CascadableView]()
/// TBD
var sessions: Sessions?
var context: MemriContext?
......@@ -88,7 +88,7 @@ public final class Session : Equatable, Subscriptable {
currentViewIndex > 0
}
public var currentView: CascadingView? {
public var currentView: CascadableView? {
views[safe: currentViewIndex]
}
......@@ -118,7 +118,7 @@ public final class Session : Equatable, Subscriptable {
storedViewStates.count > 0
{
for viewState in storedViewStates {
views.append(try CascadingView(viewState, self))
views.append(try CascadableView(viewState, self))
}
}
// Or if the views are encoded in the definition
......@@ -130,7 +130,7 @@ public final class Session : Equatable, Subscriptable {
for parsed in parsedViews {
let viewState = try CVUStateDefinition.fromCVUParsedDefinition(parsed)
_ = try state.link(viewState, type: "view", sequence: .last)
views.append(try CascadingView(viewState, self))
views.append(try CascadableView(viewState, self))
}
}
......@@ -251,7 +251,7 @@ public final class Session : Equatable, Subscriptable {
}
// Add session to list
views.append(try CascadingView(storedView, self))
views.append(try CascadableView(storedView, self))
nextIndex = views.count - 1
}
......
......@@ -42,7 +42,7 @@ public final class Sessions : ObservableObject, Equatable {
sessions[safe: currentSessionIndex]
}
var currentView: CascadingView? {
var currentView: CascadableView? {
currentSession?.currentView
}
......
......@@ -22,7 +22,7 @@ class contextTest: XCTestCase {
let root = try RootContext(name: "", key: "")
try root.boot()
XCTAssertEqual(root.cascadingView?.sessionView.viewDefinition!.selector, "[view]")
XCTAssertEqual(root.cascadableView?.sessionView.viewDefinition!.selector, "[view]")
}
func testSubContext() throws {
......@@ -30,7 +30,7 @@ class contextTest: XCTestCase {
try root.boot()
let sub = try root.createSubContext(Session())
XCTAssertEqual(sub.cascadingView?.sessionView.viewDefinition, nil)
XCTAssertEqual(sub.cascadableView?.sessionView.viewDefinition, nil)
}
func testDynamicProperties() throws {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment