it builds
parent
8774723f43
commit
8c1a284151
|
@ -0,0 +1 @@
|
|||
{"xcodeproj": "/Users/saint/code/gloss/gloss.xcodeproj", "projectFile": "/Users/saint/code/gloss/gloss.xcodeproj", "scheme": "gloss", "projectCommand": "-project '/Users/saint/code/gloss/gloss.xcodeproj'"}
|
|
@ -96,8 +96,6 @@ struct Pane: View {
|
|||
|
||||
@Environment(\.appDatabase) private var appDatabase
|
||||
|
||||
// var handleVisibilityChanged: (String, VisibilityChange, VisibilityTracker<String>) -> Void
|
||||
|
||||
var body: some View {
|
||||
var adjustedHeight = height - paneConnector.vertSep
|
||||
ZStack {
|
||||
|
@ -232,12 +230,25 @@ struct Pane: View {
|
|||
return
|
||||
}
|
||||
|
||||
|
||||
|
||||
// currentId = tracker.sortedViewIDs[tracker.sortedViewIDs.count - 1]
|
||||
currentId = tracker.sortedViewIDs[0]
|
||||
currentOffset = tracker.visibleViews[currentId!]!
|
||||
|
||||
self.paneConnector.currentId = tracker.sortedViewIDs[0]
|
||||
self.paneConnector.currentOffset = tracker.visibleViews[currentId!]!
|
||||
|
||||
if self.paneConnector.currentId == self.paneConnector.scrollId
|
||||
&& abs(self.paneConnector.currentOffset - self.paneConnector.scrollOffset) < 10 {
|
||||
if self.paneConnector.hasMoved {
|
||||
self.paneConnector.hasMoved = false
|
||||
}
|
||||
} else {
|
||||
if !self.paneConnector.hasMoved {
|
||||
self.paneConnector.hasMoved = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,11 @@ struct NaviBar: View {
|
|||
@ObservedObject var paneConnector: PaneConnector
|
||||
|
||||
@Query(RibbonRequest(dir: .prev, groupId: 1)) private var backRibbon: [Ribbon]
|
||||
|
||||
// @Query(RibbonRequest(dir: .current, groupId: 1)) private var currentRibbon: [Ribbon]
|
||||
|
||||
@Query(RibbonRequest(dir: .next, groupId: 1)) private var nextRibbon: [Ribbon]
|
||||
|
||||
@Query(SelectedRibbonRequest()) private var selectedRibbon: [Ribbon]
|
||||
@Environment(\.appDatabase) private var appDatabase
|
||||
|
||||
|
@ -16,45 +20,75 @@ struct NaviBar: View {
|
|||
var body: some View {
|
||||
VStack {
|
||||
HStack {
|
||||
Print("meow navi reloaded back ribbon: \(backRibbon[0])")
|
||||
//Print("meow navi reloaded back ribbon: \(backRibbon[0])")
|
||||
|
||||
Print("rendering navi")
|
||||
Print("dog backRibbon: \(backRibbon)")
|
||||
BackArrow()
|
||||
.frame(width: CGFloat(30), height: CGFloat(30))
|
||||
.background(Color(red: 0.1, green: 0.1, blue: 0.1))
|
||||
.foregroundColor(Color(UIColor(red: 0.30, green: 0.30, blue: 0.30, alpha: 0.4)))
|
||||
// .foregroundColor(Color(UIColor(red: 0.30, green: 0.30, blue: 0.30, alpha: 0.4)))
|
||||
.if(paneConnector.hasMoved) { $0.foregroundColor(Color.black) }
|
||||
.if(!paneConnector.hasMoved) { $0.foregroundColor(Color(UIColor(red: 0.30, green: 0.30, blue: 0.30, alpha: 0.4))) }
|
||||
.onTapGesture {
|
||||
print("back backRibbon: \(backRibbon)")
|
||||
Task {
|
||||
print("back backRibbon: \(backRibbon)")
|
||||
if backRibbon.count == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
var br = backRibbon[0]
|
||||
//var sr = selectedRibbon[0]
|
||||
var sr = selectedRibbon[0]
|
||||
|
||||
do {
|
||||
if paneConnector.hasMoved {
|
||||
// if true {
|
||||
|
||||
var sr = try await appDatabase.getSelectedRibbon()
|
||||
print("meow first sr:\(sr)")
|
||||
print("meow first selectedRibbon:\(selectedRibbon[0])")
|
||||
try await updateRibbon(selectedRibbon: selectedRibbon[0],
|
||||
appDatabase: appDatabase,
|
||||
paneConnector: paneConnector)
|
||||
let updatedRibbon = try await createUndoState(selectedRibbon: sr,
|
||||
appDatabase: appDatabase,
|
||||
paneConnector: paneConnector)
|
||||
goToRibbon(selectedRibbon: sr,
|
||||
destRibbon: sr,
|
||||
appDatabase: appDatabase,
|
||||
paneConnector: paneConnector,
|
||||
loading: false,
|
||||
bump: true)
|
||||
} else {
|
||||
try await appDatabase.undoRibbon(&sr)
|
||||
|
||||
print("meow back from update in main")
|
||||
sr = try await appDatabase.getSelectedRibbon()
|
||||
print("meow second sr:\(sr)")
|
||||
print("meow backribbon br:\(br)")
|
||||
goToRibbon(selectedRibbon: sr,
|
||||
destRibbon: br,
|
||||
appDatabase: appDatabase,
|
||||
paneConnector: paneConnector,
|
||||
loading: false,
|
||||
bump: true)
|
||||
|
||||
_ = try await appDatabase.undoRibbon(&sr[0])
|
||||
goToRibbon(selectedRibbon: sr[0],
|
||||
destRibbon: br,
|
||||
appDatabase: appDatabase,
|
||||
paneConnector: paneConnector,
|
||||
loading: false,
|
||||
bump:false)
|
||||
}
|
||||
|
||||
// var sr = try await appDatabase.getSelectedRibbon()
|
||||
// print("meow first sr:\(sr)")
|
||||
// print("meow first selectedRibbon:\(selectedRibbon[0])")
|
||||
|
||||
// try await appDatabase.dbWriter.write { db in
|
||||
// var ribs = RibbonRequest().fetchValue(db)
|
||||
// }
|
||||
|
||||
// try await updateRibbon(selectedRibbon: selectedRibbon[0],
|
||||
// appDatabase: appDatabase,
|
||||
// paneConnector: paneConnector)
|
||||
|
||||
// print("meow back from update in main")
|
||||
// sr = try await appDatabase.getSelectedRibbon()
|
||||
// print("meow second sr:\(sr)")
|
||||
// print("meow backribbon br:\(br)")
|
||||
|
||||
// _ = try await appDatabase.undoRibbon(&sr[0])
|
||||
|
||||
// goToRibbon(selectedRibbon: sr[0],
|
||||
// destRibbon: br,
|
||||
// appDatabase: appDatabase,
|
||||
// paneConnector: paneConnector,
|
||||
// loading: false,
|
||||
// bump:false)
|
||||
|
||||
} catch {
|
||||
print("back 2 error")
|
||||
|
|
|
@ -7,6 +7,7 @@ struct RibbonRequest: Queryable {
|
|||
enum UndoDir {
|
||||
case prev
|
||||
case next
|
||||
case current
|
||||
}
|
||||
|
||||
/// The ordering used by the player request.
|
||||
|
@ -43,25 +44,32 @@ struct RibbonRequest: Queryable {
|
|||
|
||||
// this has to be a global variable
|
||||
let totalLevels = 3
|
||||
|
||||
do {
|
||||
print("back reload")
|
||||
if dir != nil && groupId != nil {
|
||||
|
||||
sql = """
|
||||
SELECT * FROM Ribbon \
|
||||
WHERE groupId = ?
|
||||
LIMIT 1
|
||||
"""
|
||||
ret = try Ribbon.fetchAll(db, sql: sql, arguments: [groupId])
|
||||
if ret.count == 0 {
|
||||
print("error no ribbons found")
|
||||
return []
|
||||
}
|
||||
|
||||
print("back all ribbon all: \(ret)")
|
||||
|
||||
let currentLevel = ret[0].currentLevel
|
||||
let minLevel = ret[0].minLevel
|
||||
let maxLevel = ret[0].maxLevel
|
||||
|
||||
if dir == .current {
|
||||
sql = """
|
||||
SELECT * FROM Ribbon \
|
||||
WHERE groupId = ?
|
||||
AND undoLevel = ?
|
||||
LIMIT 1
|
||||
"""
|
||||
ret = try Ribbon.fetchAll(db, sql: sql, arguments: [groupId, currentLevel])
|
||||
return ret
|
||||
}
|
||||
|
||||
var newCurrentLevel = (currentLevel - 1) %% totalLevels
|
||||
|
||||
// probably need more error checking to check
|
||||
|
@ -70,21 +78,21 @@ struct RibbonRequest: Queryable {
|
|||
// are probably a bunch of edge cases casue of the
|
||||
// mod stuff
|
||||
if dir == .prev {
|
||||
print("calling ribbon request prev")
|
||||
// no back undo steps left
|
||||
if currentLevel == minLevel {
|
||||
newCurrentLevel = currentLevel
|
||||
return []
|
||||
}
|
||||
} else if dir == .prev {
|
||||
} else if dir == .next {
|
||||
|
||||
// no forward redo steps left
|
||||
if currentLevel == maxLevel {
|
||||
newCurrentLevel = maxLevel
|
||||
return []
|
||||
} else {
|
||||
newCurrentLevel = (currentLevel + 1) %% totalLevels
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print("back newcurrentlevel \(newCurrentLevel)")
|
||||
sql = """
|
||||
SELECT * FROM Ribbon \
|
||||
WHERE groupId = ? AND
|
||||
|
@ -92,8 +100,7 @@ struct RibbonRequest: Queryable {
|
|||
LIMIT 1
|
||||
"""
|
||||
ret = try Ribbon.fetchAll(db, sql: sql, arguments: [groupId, newCurrentLevel])
|
||||
|
||||
print("back ribbon return: \(ret)")
|
||||
print("dog returning: \(ret)")
|
||||
return ret
|
||||
|
||||
} else {
|
||||
|
@ -105,8 +112,7 @@ struct RibbonRequest: Queryable {
|
|||
"""
|
||||
|
||||
var ret = try Ribbon.fetchAll(db, sql: sql, arguments: [groupId])
|
||||
print("xxxxx fetching ribbons")
|
||||
print(ret)
|
||||
print("all fetching ribbons: \(ret)")
|
||||
return ret
|
||||
} else {
|
||||
|
||||
|
|
|
@ -59,8 +59,7 @@ struct SelectedRibbonRequest: Queryable {
|
|||
ON SelectedRibbon.ribbonGroupId = Ribbon.groupId \
|
||||
WHERE SelectedRibbon.rowId = 1
|
||||
""")
|
||||
// [Player]
|
||||
print("Selected Ribbon query result: \(ret)")
|
||||
// print("Selected Ribbon query result: \(ret)")
|
||||
return ret
|
||||
}
|
||||
}
|
||||
|
|
14
Stats.swift
14
Stats.swift
|
@ -22,11 +22,13 @@ struct StatsPanel: View {
|
|||
HStack(spacing: 5) {
|
||||
VStack (spacing: 5) {
|
||||
|
||||
VStack {
|
||||
Text("back Ribbon")
|
||||
.foregroundColor(Color(UIColor(red: 0.76, green: 0.76, blue: 0.76, alpha: 1.00)))
|
||||
.font(Font.custom("AveriaSerifLibre-Regular", size: fontSize))
|
||||
RibbonDebug(ribbonDebug: RibbonDebugPrint(ribbon: backRibbon[0]))
|
||||
if backRibbon.count > 0 {
|
||||
VStack {
|
||||
Text("back Ribbon")
|
||||
.foregroundColor(Color(UIColor(red: 0.76, green: 0.76, blue: 0.76, alpha: 1.00)))
|
||||
.font(Font.custom("AveriaSerifLibre-Regular", size: fontSize))
|
||||
RibbonDebug(ribbonDebug: RibbonDebugPrint(ribbon: backRibbon[0]))
|
||||
}
|
||||
}
|
||||
|
||||
VStack {
|
||||
|
@ -90,7 +92,7 @@ func RibbonDebugPrint(ribbon: Ribbon) -> [String] {
|
|||
}
|
||||
|
||||
struct RibbonDebug: View {
|
||||
@State var ribbonDebug: [String]
|
||||
var ribbonDebug: [String]
|
||||
|
||||
var body: some View {
|
||||
|
||||
|
|
|
@ -1 +1,19 @@
|
|||
{"argv":["/Users/saint/.local/share/xbase/xbase-sourcekit-helper"],"bspVersion":"0.2","languages":["swift","objective-c","objective-cpp","c","cpp"],"name":"XBase","version":"0.3"}
|
||||
{
|
||||
"argv": [
|
||||
"/usr/local/bin/xcode-build-server"
|
||||
],
|
||||
"bspVersion": "2.0",
|
||||
"languages": [
|
||||
"c",
|
||||
"cpp",
|
||||
"objective-c",
|
||||
"objective-cpp",
|
||||
"swift"
|
||||
],
|
||||
"name": "xcode build server",
|
||||
"version": "0.2",
|
||||
"workspace": "/Users/saint/code/gloss/gloss.xcodeproj/project.xcworkspace",
|
||||
"build_root": "/Users/saint/Library/Developer/Xcode/DerivedData/gloss-ajphzxkxxghgqicpumudnmcgeuwg",
|
||||
"scheme": "gloss",
|
||||
"kind": "xcode"
|
||||
}
|
|
@ -456,7 +456,7 @@
|
|||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"gloss/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = V8B2B34W7R;
|
||||
DEVELOPMENT_TEAM = C8XWX9329P;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = gloss/Info.plist;
|
||||
|
@ -494,7 +494,7 @@
|
|||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"gloss/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = V8B2B34W7R;
|
||||
DEVELOPMENT_TEAM = C8XWX9329P;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = gloss/Info.plist;
|
||||
|
|
|
@ -5,10 +5,6 @@ import GRDB
|
|||
|
||||
let totalLevels = 3
|
||||
|
||||
/// AppDatabase lets the application access the database.
|
||||
///
|
||||
/// It applies the pratices recommended at
|
||||
/// <https://github.com/groue/GRDB.swift/blob/master/Documentation/GoodPracticesForDesigningRecordTypes.md>
|
||||
struct AppDatabase {
|
||||
/// Creates an `AppDatabase`, and make sure the database schema is ready.
|
||||
init(_ dbWriter: any DatabaseWriter) throws {
|
||||
|
@ -222,20 +218,21 @@ extension AppDatabase {
|
|||
}
|
||||
}
|
||||
|
||||
// this sets the current undoLevel to the previous value
|
||||
// if you can go back
|
||||
func undoRibbon(_ ribbon: inout Ribbon) async throws {
|
||||
let currentLevel = ribbon.currentLevel
|
||||
let minLevel = ribbon.minLevel
|
||||
|
||||
if currentLevel == minLevel {
|
||||
print("no where to undo")
|
||||
return
|
||||
}
|
||||
|
||||
let newCurrent = (ribbon.currentLevel - 1) %% totalLevels
|
||||
print("meow new current: \(newCurrent)")
|
||||
|
||||
do {
|
||||
try await dbWriter.write { [ribbon] db in
|
||||
print("back executing")
|
||||
try db.execute(sql: """
|
||||
UPDATE Ribbon \
|
||||
SET currentLevel = ? WHERE groupId = ?
|
||||
|
@ -246,23 +243,30 @@ extension AppDatabase {
|
|||
WHERE groupId = ?
|
||||
""", arguments: [ribbon.groupId])
|
||||
|
||||
print("back ret3: \(ret3)")
|
||||
}
|
||||
|
||||
} catch {
|
||||
print("back error")
|
||||
print("Error info: \(error)")
|
||||
print("Undo Ribbon Error info: \(error)")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// deletes all undo steps above the current undo level
|
||||
// and adds new undo level at the new current level,
|
||||
// adjusts the minLevel and maxLevel
|
||||
func bumpRibbon(_ ribbon: inout Ribbon) async throws -> [Ribbon] {
|
||||
var level = ribbon.currentLevel
|
||||
let maxLevel = ribbon.maxLevel
|
||||
|
||||
|
||||
// gets all the levels from the current to the max
|
||||
// so they can be deleted
|
||||
var delLevels2 = [Int]()
|
||||
while level != maxLevel {
|
||||
level = (level + 1) % totalLevels
|
||||
delLevels2.append(level)
|
||||
if level != maxLevel {
|
||||
repeat {
|
||||
level = (level + 1) %% totalLevels
|
||||
delLevels2.append(level)
|
||||
} while level != maxLevel
|
||||
}
|
||||
let delLevels = delLevels2
|
||||
|
||||
|
@ -279,7 +283,6 @@ extension AppDatabase {
|
|||
|
||||
do {
|
||||
try await dbWriter.write { [ribbon] db in
|
||||
print("meow enter bump 1")
|
||||
for l in delLevels {
|
||||
try db.execute(sql: """
|
||||
DELETE FROM Ribbon \
|
||||
|
@ -299,7 +302,6 @@ extension AppDatabase {
|
|||
SELECT * from Ribbon WHERE groupId = ? AND undoLevel = ?
|
||||
""", arguments: [ribbon.groupId, ribbon.undoLevel])
|
||||
|
||||
print("meow enter bump 3")
|
||||
if ret.count == 0 {
|
||||
// insert
|
||||
_ = try ribbon.inserted(db)
|
||||
|
@ -316,19 +318,8 @@ extension AppDatabase {
|
|||
|
||||
ret = try Ribbon.fetchAll(db, sql: """
|
||||
SELECT * from Ribbon WHERE groupId = ? AND undoLevel = ?
|
||||
""", arguments: [ribbon.groupId, ribbon.undoLevel])
|
||||
""", arguments: [ribbon.groupId, newCurrent])
|
||||
|
||||
|
||||
|
||||
let ret2 = try Ribbon.fetchAll(db, sql: """
|
||||
SELECT * from Ribbon WHERE groupId = 1 ORDER BY undoLevel ASC
|
||||
""")
|
||||
|
||||
for r2 in ret2 {
|
||||
print("meow ribbon dump: \(r2)")
|
||||
}
|
||||
|
||||
print("meow bumped ribbon: \(ret)")
|
||||
return ret
|
||||
}
|
||||
} catch {
|
||||
|
|
|
@ -39,16 +39,20 @@ public extension UserDefaults {
|
|||
}
|
||||
}
|
||||
|
||||
func updateRibbon(selectedRibbon: Ribbon,
|
||||
appDatabase : AppDatabase,
|
||||
paneConnector: PaneConnector) async throws -> [Ribbon]
|
||||
func createUndoState(selectedRibbon: Ribbon,
|
||||
appDatabase : AppDatabase,
|
||||
paneConnector : PaneConnector) async throws -> [Ribbon]
|
||||
|
||||
{
|
||||
let updateThreshold = 30
|
||||
print("meow updating ribbon")
|
||||
var updatedRibbon = selectedRibbon
|
||||
var scrollOffsetToSave = Int(floor(paneConnector.currentOffset))
|
||||
var scrollIdToSave = paneConnector.currentId
|
||||
print("meow scrolloffsets \(scrollIdToSave) \(scrollOffsetToSave)")
|
||||
|
||||
var offsetDiff = abs(scrollOffsetToSave - updatedRibbon.scrollOffset) > 30
|
||||
|
||||
var idDiff = Int(updatedRibbon.scrollId) != Int(scrollIdToSave)
|
||||
|
||||
if idDiff || offsetDiff {
|
||||
|
@ -81,7 +85,8 @@ func goToRibbon(selectedRibbon: Ribbon,
|
|||
print("go to ribbon")
|
||||
print("\(selectedRibbon.id) \(destRibbon.id!)")
|
||||
|
||||
if selectedRibbon.id != destRibbon.id! || loading {
|
||||
// if selectedRibbon.id != destRibbon.id! || loading {
|
||||
if true {
|
||||
print("switching ribbons")
|
||||
|
||||
paneConnector.showOverlay = true
|
||||
|
@ -183,19 +188,24 @@ struct RibbonCrown: View {
|
|||
}
|
||||
.onTapGesture {
|
||||
Task {
|
||||
|
||||
let sr = selectedRibbon[0]
|
||||
let updatedRibbon = try await updateRibbon(selectedRibbon: sr,
|
||||
appDatabase: appDatabase,
|
||||
paneConnector: paneConnector)
|
||||
let updatedRibbon = try await createUndoState(selectedRibbon: sr,
|
||||
appDatabase: appDatabase,
|
||||
paneConnector: paneConnector)
|
||||
|
||||
goToRibbon(selectedRibbon: sr,
|
||||
destRibbon: ribbon,
|
||||
appDatabase: appDatabase,
|
||||
paneConnector: paneConnector,
|
||||
loading: false,
|
||||
bump: true)
|
||||
}
|
||||
if sr.id == ribbon.id {
|
||||
paneConnector.scrollId = paneConnector.currentId
|
||||
paneConnector.scrollOffset = paneConnector.currentOffset
|
||||
paneConnector.hasMoved = false
|
||||
} else {
|
||||
goToRibbon(selectedRibbon: sr,
|
||||
destRibbon: ribbon,
|
||||
appDatabase: appDatabase,
|
||||
paneConnector: paneConnector,
|
||||
loading: false,
|
||||
bump: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(width: CGFloat(100 * 1.66 * scale + 10), height: CGFloat(100 * scale + 5))
|
||||
}
|
||||
|
@ -237,7 +247,10 @@ class PaneConnector: NSObject, ObservableObject {
|
|||
var visibilityTracker: VisibilityTracker<String>?
|
||||
@Published var scrollId = ""
|
||||
@Published var scrollOffset = CGFloat()
|
||||
// @Published var hasMoved = false
|
||||
@Published var hasMoved = false
|
||||
var setScrollOffset: CGFloat?
|
||||
|
||||
}
|
||||
|
||||
struct ContentView: View {
|
||||
|
|
Loading…
Reference in New Issue