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
|
@Environment(\.appDatabase) private var appDatabase
|
||||||
|
|
||||||
// var handleVisibilityChanged: (String, VisibilityChange, VisibilityTracker<String>) -> Void
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
var adjustedHeight = height - paneConnector.vertSep
|
var adjustedHeight = height - paneConnector.vertSep
|
||||||
ZStack {
|
ZStack {
|
||||||
|
@ -232,12 +230,25 @@ struct Pane: View {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// currentId = tracker.sortedViewIDs[tracker.sortedViewIDs.count - 1]
|
// currentId = tracker.sortedViewIDs[tracker.sortedViewIDs.count - 1]
|
||||||
currentId = tracker.sortedViewIDs[0]
|
currentId = tracker.sortedViewIDs[0]
|
||||||
currentOffset = tracker.visibleViews[currentId!]!
|
currentOffset = tracker.visibleViews[currentId!]!
|
||||||
|
|
||||||
self.paneConnector.currentId = tracker.sortedViewIDs[0]
|
self.paneConnector.currentId = tracker.sortedViewIDs[0]
|
||||||
self.paneConnector.currentOffset = tracker.visibleViews[currentId!]!
|
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
|
@ObservedObject var paneConnector: PaneConnector
|
||||||
|
|
||||||
@Query(RibbonRequest(dir: .prev, groupId: 1)) private var backRibbon: [Ribbon]
|
@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(RibbonRequest(dir: .next, groupId: 1)) private var nextRibbon: [Ribbon]
|
||||||
|
|
||||||
@Query(SelectedRibbonRequest()) private var selectedRibbon: [Ribbon]
|
@Query(SelectedRibbonRequest()) private var selectedRibbon: [Ribbon]
|
||||||
@Environment(\.appDatabase) private var appDatabase
|
@Environment(\.appDatabase) private var appDatabase
|
||||||
|
|
||||||
|
@ -16,45 +20,75 @@ struct NaviBar: View {
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
HStack {
|
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()
|
BackArrow()
|
||||||
.frame(width: CGFloat(30), height: CGFloat(30))
|
.frame(width: CGFloat(30), height: CGFloat(30))
|
||||||
.background(Color(red: 0.1, green: 0.1, blue: 0.1))
|
.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 {
|
.onTapGesture {
|
||||||
print("back backRibbon: \(backRibbon)")
|
|
||||||
Task {
|
Task {
|
||||||
print("back backRibbon: \(backRibbon)")
|
|
||||||
if backRibbon.count == 0 {
|
if backRibbon.count == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var br = backRibbon[0]
|
var br = backRibbon[0]
|
||||||
//var sr = selectedRibbon[0]
|
var sr = selectedRibbon[0]
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
if paneConnector.hasMoved {
|
||||||
|
// if true {
|
||||||
|
|
||||||
var sr = try await appDatabase.getSelectedRibbon()
|
let updatedRibbon = try await createUndoState(selectedRibbon: sr,
|
||||||
print("meow first sr:\(sr)")
|
|
||||||
print("meow first selectedRibbon:\(selectedRibbon[0])")
|
|
||||||
try await updateRibbon(selectedRibbon: selectedRibbon[0],
|
|
||||||
appDatabase: appDatabase,
|
appDatabase: appDatabase,
|
||||||
paneConnector: paneConnector)
|
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")
|
goToRibbon(selectedRibbon: sr,
|
||||||
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,
|
destRibbon: br,
|
||||||
appDatabase: appDatabase,
|
appDatabase: appDatabase,
|
||||||
paneConnector: paneConnector,
|
paneConnector: paneConnector,
|
||||||
loading: false,
|
loading: false,
|
||||||
bump:false)
|
bump: true)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 {
|
} catch {
|
||||||
print("back 2 error")
|
print("back 2 error")
|
||||||
|
|
|
@ -7,6 +7,7 @@ struct RibbonRequest: Queryable {
|
||||||
enum UndoDir {
|
enum UndoDir {
|
||||||
case prev
|
case prev
|
||||||
case next
|
case next
|
||||||
|
case current
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The ordering used by the player request.
|
/// The ordering used by the player request.
|
||||||
|
@ -43,25 +44,32 @@ struct RibbonRequest: Queryable {
|
||||||
|
|
||||||
// this has to be a global variable
|
// this has to be a global variable
|
||||||
let totalLevels = 3
|
let totalLevels = 3
|
||||||
|
|
||||||
do {
|
do {
|
||||||
print("back reload")
|
|
||||||
if dir != nil && groupId != nil {
|
if dir != nil && groupId != nil {
|
||||||
|
|
||||||
sql = """
|
sql = """
|
||||||
SELECT * FROM Ribbon \
|
SELECT * FROM Ribbon \
|
||||||
WHERE groupId = ?
|
WHERE groupId = ?
|
||||||
|
LIMIT 1
|
||||||
"""
|
"""
|
||||||
ret = try Ribbon.fetchAll(db, sql: sql, arguments: [groupId])
|
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 currentLevel = ret[0].currentLevel
|
||||||
let minLevel = ret[0].minLevel
|
let minLevel = ret[0].minLevel
|
||||||
let maxLevel = ret[0].maxLevel
|
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
|
var newCurrentLevel = (currentLevel - 1) %% totalLevels
|
||||||
|
|
||||||
// probably need more error checking to check
|
// probably need more error checking to check
|
||||||
|
@ -70,21 +78,21 @@ struct RibbonRequest: Queryable {
|
||||||
// are probably a bunch of edge cases casue of the
|
// are probably a bunch of edge cases casue of the
|
||||||
// mod stuff
|
// mod stuff
|
||||||
if dir == .prev {
|
if dir == .prev {
|
||||||
|
print("calling ribbon request prev")
|
||||||
// no back undo steps left
|
// no back undo steps left
|
||||||
if currentLevel == minLevel {
|
if currentLevel == minLevel {
|
||||||
newCurrentLevel = currentLevel
|
return []
|
||||||
}
|
}
|
||||||
} else if dir == .prev {
|
} else if dir == .next {
|
||||||
|
|
||||||
// no forward redo steps left
|
// no forward redo steps left
|
||||||
if currentLevel == maxLevel {
|
if currentLevel == maxLevel {
|
||||||
newCurrentLevel = maxLevel
|
return []
|
||||||
} else {
|
} else {
|
||||||
newCurrentLevel = (currentLevel + 1) %% totalLevels
|
newCurrentLevel = (currentLevel + 1) %% totalLevels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
print("back newcurrentlevel \(newCurrentLevel)")
|
|
||||||
sql = """
|
sql = """
|
||||||
SELECT * FROM Ribbon \
|
SELECT * FROM Ribbon \
|
||||||
WHERE groupId = ? AND
|
WHERE groupId = ? AND
|
||||||
|
@ -92,8 +100,7 @@ struct RibbonRequest: Queryable {
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
"""
|
"""
|
||||||
ret = try Ribbon.fetchAll(db, sql: sql, arguments: [groupId, newCurrentLevel])
|
ret = try Ribbon.fetchAll(db, sql: sql, arguments: [groupId, newCurrentLevel])
|
||||||
|
print("dog returning: \(ret)")
|
||||||
print("back ribbon return: \(ret)")
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -105,8 +112,7 @@ struct RibbonRequest: Queryable {
|
||||||
"""
|
"""
|
||||||
|
|
||||||
var ret = try Ribbon.fetchAll(db, sql: sql, arguments: [groupId])
|
var ret = try Ribbon.fetchAll(db, sql: sql, arguments: [groupId])
|
||||||
print("xxxxx fetching ribbons")
|
print("all fetching ribbons: \(ret)")
|
||||||
print(ret)
|
|
||||||
return ret
|
return ret
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
|
@ -59,8 +59,7 @@ struct SelectedRibbonRequest: Queryable {
|
||||||
ON SelectedRibbon.ribbonGroupId = Ribbon.groupId \
|
ON SelectedRibbon.ribbonGroupId = Ribbon.groupId \
|
||||||
WHERE SelectedRibbon.rowId = 1
|
WHERE SelectedRibbon.rowId = 1
|
||||||
""")
|
""")
|
||||||
// [Player]
|
// print("Selected Ribbon query result: \(ret)")
|
||||||
print("Selected Ribbon query result: \(ret)")
|
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,12 +22,14 @@ struct StatsPanel: View {
|
||||||
HStack(spacing: 5) {
|
HStack(spacing: 5) {
|
||||||
VStack (spacing: 5) {
|
VStack (spacing: 5) {
|
||||||
|
|
||||||
|
if backRibbon.count > 0 {
|
||||||
VStack {
|
VStack {
|
||||||
Text("back Ribbon")
|
Text("back Ribbon")
|
||||||
.foregroundColor(Color(UIColor(red: 0.76, green: 0.76, blue: 0.76, alpha: 1.00)))
|
.foregroundColor(Color(UIColor(red: 0.76, green: 0.76, blue: 0.76, alpha: 1.00)))
|
||||||
.font(Font.custom("AveriaSerifLibre-Regular", size: fontSize))
|
.font(Font.custom("AveriaSerifLibre-Regular", size: fontSize))
|
||||||
RibbonDebug(ribbonDebug: RibbonDebugPrint(ribbon: backRibbon[0]))
|
RibbonDebug(ribbonDebug: RibbonDebugPrint(ribbon: backRibbon[0]))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
VStack {
|
VStack {
|
||||||
Text("next Ribbon")
|
Text("next Ribbon")
|
||||||
|
@ -90,7 +92,7 @@ func RibbonDebugPrint(ribbon: Ribbon) -> [String] {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RibbonDebug: View {
|
struct RibbonDebug: View {
|
||||||
@State var ribbonDebug: [String]
|
var ribbonDebug: [String]
|
||||||
|
|
||||||
var body: some View {
|
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;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEVELOPMENT_ASSET_PATHS = "\"gloss/Preview Content\"";
|
DEVELOPMENT_ASSET_PATHS = "\"gloss/Preview Content\"";
|
||||||
DEVELOPMENT_TEAM = V8B2B34W7R;
|
DEVELOPMENT_TEAM = C8XWX9329P;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
INFOPLIST_FILE = gloss/Info.plist;
|
INFOPLIST_FILE = gloss/Info.plist;
|
||||||
|
@ -494,7 +494,7 @@
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEVELOPMENT_ASSET_PATHS = "\"gloss/Preview Content\"";
|
DEVELOPMENT_ASSET_PATHS = "\"gloss/Preview Content\"";
|
||||||
DEVELOPMENT_TEAM = V8B2B34W7R;
|
DEVELOPMENT_TEAM = C8XWX9329P;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
INFOPLIST_FILE = gloss/Info.plist;
|
INFOPLIST_FILE = gloss/Info.plist;
|
||||||
|
|
|
@ -5,10 +5,6 @@ import GRDB
|
||||||
|
|
||||||
let totalLevels = 3
|
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 {
|
struct AppDatabase {
|
||||||
/// Creates an `AppDatabase`, and make sure the database schema is ready.
|
/// Creates an `AppDatabase`, and make sure the database schema is ready.
|
||||||
init(_ dbWriter: any DatabaseWriter) throws {
|
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 {
|
func undoRibbon(_ ribbon: inout Ribbon) async throws {
|
||||||
let currentLevel = ribbon.currentLevel
|
let currentLevel = ribbon.currentLevel
|
||||||
let minLevel = ribbon.minLevel
|
let minLevel = ribbon.minLevel
|
||||||
|
|
||||||
if currentLevel == minLevel {
|
if currentLevel == minLevel {
|
||||||
print("no where to undo")
|
print("no where to undo")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let newCurrent = (ribbon.currentLevel - 1) %% totalLevels
|
let newCurrent = (ribbon.currentLevel - 1) %% totalLevels
|
||||||
print("meow new current: \(newCurrent)")
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
try await dbWriter.write { [ribbon] db in
|
try await dbWriter.write { [ribbon] db in
|
||||||
print("back executing")
|
|
||||||
try db.execute(sql: """
|
try db.execute(sql: """
|
||||||
UPDATE Ribbon \
|
UPDATE Ribbon \
|
||||||
SET currentLevel = ? WHERE groupId = ?
|
SET currentLevel = ? WHERE groupId = ?
|
||||||
|
@ -246,23 +243,30 @@ extension AppDatabase {
|
||||||
WHERE groupId = ?
|
WHERE groupId = ?
|
||||||
""", arguments: [ribbon.groupId])
|
""", arguments: [ribbon.groupId])
|
||||||
|
|
||||||
print("back ret3: \(ret3)")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch {
|
} catch {
|
||||||
print("back error")
|
print("Undo Ribbon Error info: \(error)")
|
||||||
print("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] {
|
func bumpRibbon(_ ribbon: inout Ribbon) async throws -> [Ribbon] {
|
||||||
var level = ribbon.currentLevel
|
var level = ribbon.currentLevel
|
||||||
let maxLevel = ribbon.maxLevel
|
let maxLevel = ribbon.maxLevel
|
||||||
|
|
||||||
|
|
||||||
|
// gets all the levels from the current to the max
|
||||||
|
// so they can be deleted
|
||||||
var delLevels2 = [Int]()
|
var delLevels2 = [Int]()
|
||||||
while level != maxLevel {
|
if level != maxLevel {
|
||||||
level = (level + 1) % totalLevels
|
repeat {
|
||||||
|
level = (level + 1) %% totalLevels
|
||||||
delLevels2.append(level)
|
delLevels2.append(level)
|
||||||
|
} while level != maxLevel
|
||||||
}
|
}
|
||||||
let delLevels = delLevels2
|
let delLevels = delLevels2
|
||||||
|
|
||||||
|
@ -279,7 +283,6 @@ extension AppDatabase {
|
||||||
|
|
||||||
do {
|
do {
|
||||||
try await dbWriter.write { [ribbon] db in
|
try await dbWriter.write { [ribbon] db in
|
||||||
print("meow enter bump 1")
|
|
||||||
for l in delLevels {
|
for l in delLevels {
|
||||||
try db.execute(sql: """
|
try db.execute(sql: """
|
||||||
DELETE FROM Ribbon \
|
DELETE FROM Ribbon \
|
||||||
|
@ -299,7 +302,6 @@ extension AppDatabase {
|
||||||
SELECT * from Ribbon WHERE groupId = ? AND undoLevel = ?
|
SELECT * from Ribbon WHERE groupId = ? AND undoLevel = ?
|
||||||
""", arguments: [ribbon.groupId, ribbon.undoLevel])
|
""", arguments: [ribbon.groupId, ribbon.undoLevel])
|
||||||
|
|
||||||
print("meow enter bump 3")
|
|
||||||
if ret.count == 0 {
|
if ret.count == 0 {
|
||||||
// insert
|
// insert
|
||||||
_ = try ribbon.inserted(db)
|
_ = try ribbon.inserted(db)
|
||||||
|
@ -316,19 +318,8 @@ extension AppDatabase {
|
||||||
|
|
||||||
ret = try Ribbon.fetchAll(db, sql: """
|
ret = try Ribbon.fetchAll(db, sql: """
|
||||||
SELECT * from Ribbon WHERE groupId = ? AND undoLevel = ?
|
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
|
return ret
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
@ -39,16 +39,20 @@ public extension UserDefaults {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateRibbon(selectedRibbon: Ribbon,
|
func createUndoState(selectedRibbon: Ribbon,
|
||||||
appDatabase : AppDatabase,
|
appDatabase : AppDatabase,
|
||||||
paneConnector : PaneConnector) async throws -> [Ribbon]
|
paneConnector : PaneConnector) async throws -> [Ribbon]
|
||||||
|
|
||||||
{
|
{
|
||||||
|
let updateThreshold = 30
|
||||||
print("meow updating ribbon")
|
print("meow updating ribbon")
|
||||||
var updatedRibbon = selectedRibbon
|
var updatedRibbon = selectedRibbon
|
||||||
var scrollOffsetToSave = Int(floor(paneConnector.currentOffset))
|
var scrollOffsetToSave = Int(floor(paneConnector.currentOffset))
|
||||||
var scrollIdToSave = paneConnector.currentId
|
var scrollIdToSave = paneConnector.currentId
|
||||||
print("meow scrolloffsets \(scrollIdToSave) \(scrollOffsetToSave)")
|
print("meow scrolloffsets \(scrollIdToSave) \(scrollOffsetToSave)")
|
||||||
|
|
||||||
var offsetDiff = abs(scrollOffsetToSave - updatedRibbon.scrollOffset) > 30
|
var offsetDiff = abs(scrollOffsetToSave - updatedRibbon.scrollOffset) > 30
|
||||||
|
|
||||||
var idDiff = Int(updatedRibbon.scrollId) != Int(scrollIdToSave)
|
var idDiff = Int(updatedRibbon.scrollId) != Int(scrollIdToSave)
|
||||||
|
|
||||||
if idDiff || offsetDiff {
|
if idDiff || offsetDiff {
|
||||||
|
@ -81,7 +85,8 @@ func goToRibbon(selectedRibbon: Ribbon,
|
||||||
print("go to ribbon")
|
print("go to ribbon")
|
||||||
print("\(selectedRibbon.id) \(destRibbon.id!)")
|
print("\(selectedRibbon.id) \(destRibbon.id!)")
|
||||||
|
|
||||||
if selectedRibbon.id != destRibbon.id! || loading {
|
// if selectedRibbon.id != destRibbon.id! || loading {
|
||||||
|
if true {
|
||||||
print("switching ribbons")
|
print("switching ribbons")
|
||||||
|
|
||||||
paneConnector.showOverlay = true
|
paneConnector.showOverlay = true
|
||||||
|
@ -183,12 +188,16 @@ struct RibbonCrown: View {
|
||||||
}
|
}
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
Task {
|
Task {
|
||||||
|
|
||||||
let sr = selectedRibbon[0]
|
let sr = selectedRibbon[0]
|
||||||
let updatedRibbon = try await updateRibbon(selectedRibbon: sr,
|
let updatedRibbon = try await createUndoState(selectedRibbon: sr,
|
||||||
appDatabase: appDatabase,
|
appDatabase: appDatabase,
|
||||||
paneConnector: paneConnector)
|
paneConnector: paneConnector)
|
||||||
|
|
||||||
|
if sr.id == ribbon.id {
|
||||||
|
paneConnector.scrollId = paneConnector.currentId
|
||||||
|
paneConnector.scrollOffset = paneConnector.currentOffset
|
||||||
|
paneConnector.hasMoved = false
|
||||||
|
} else {
|
||||||
goToRibbon(selectedRibbon: sr,
|
goToRibbon(selectedRibbon: sr,
|
||||||
destRibbon: ribbon,
|
destRibbon: ribbon,
|
||||||
appDatabase: appDatabase,
|
appDatabase: appDatabase,
|
||||||
|
@ -197,6 +206,7 @@ struct RibbonCrown: View {
|
||||||
bump: true)
|
bump: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
.frame(width: CGFloat(100 * 1.66 * scale + 10), height: CGFloat(100 * scale + 5))
|
.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>?
|
var visibilityTracker: VisibilityTracker<String>?
|
||||||
@Published var scrollId = ""
|
@Published var scrollId = ""
|
||||||
@Published var scrollOffset = CGFloat()
|
@Published var scrollOffset = CGFloat()
|
||||||
|
// @Published var hasMoved = false
|
||||||
|
@Published var hasMoved = false
|
||||||
var setScrollOffset: CGFloat?
|
var setScrollOffset: CGFloat?
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
|
|
Loading…
Reference in New Issue