Compare commits
No commits in common. "0ac847c88cdfbb08dcfd1a51e50e18247ad7f1ea" and "8c1a28415148afb1eec6013b85ae6f40b1163047" have entirely different histories.
0ac847c88c
...
8c1a284151
|
@ -88,7 +88,7 @@ struct Pane: View {
|
||||||
@State var width: CGFloat
|
@State var width: CGFloat
|
||||||
@State var height: CGFloat
|
@State var height: CGFloat
|
||||||
|
|
||||||
var dragOffset = CGFloat()
|
@State var dragOffset = CGFloat()
|
||||||
|
|
||||||
@State var refresh: Bool = false
|
@State var refresh: Bool = false
|
||||||
|
|
||||||
|
@ -119,7 +119,8 @@ struct Pane: View {
|
||||||
destRibbon: selectedRibbon[0],
|
destRibbon: selectedRibbon[0],
|
||||||
appDatabase: appDatabase,
|
appDatabase: appDatabase,
|
||||||
paneConnector: paneConnector,
|
paneConnector: paneConnector,
|
||||||
loading: true)
|
loading: true,
|
||||||
|
bump: false)
|
||||||
}
|
}
|
||||||
.onChange(of: paneConnector.refresh) { _ in
|
.onChange(of: paneConnector.refresh) { _ in
|
||||||
print("inside change")
|
print("inside change")
|
||||||
|
@ -177,8 +178,8 @@ struct Pane: View {
|
||||||
// let reactive = self.paneConnector
|
// let reactive = self.paneConnector
|
||||||
// }
|
// }
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
|
||||||
if paneConnector.setScrollOffset != nil {
|
if paneConnector.setScrollOffset != nil {
|
||||||
|
DispatchQueue.main.async {
|
||||||
scrollView.contentOffset.y = scrollView.contentOffset.y + paneConnector.setScrollOffset!
|
scrollView.contentOffset.y = scrollView.contentOffset.y + paneConnector.setScrollOffset!
|
||||||
paneConnector.setScrollOffset = nil
|
paneConnector.setScrollOffset = nil
|
||||||
|
|
||||||
|
@ -235,10 +236,7 @@ struct Pane: View {
|
||||||
currentId = tracker.sortedViewIDs[0]
|
currentId = tracker.sortedViewIDs[0]
|
||||||
currentOffset = tracker.visibleViews[currentId!]!
|
currentOffset = tracker.visibleViews[currentId!]!
|
||||||
|
|
||||||
if self.paneConnector.currentId != tracker.sortedViewIDs[0] {
|
|
||||||
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
|
if self.paneConnector.currentId == self.paneConnector.scrollId
|
||||||
|
|
|
@ -8,6 +8,9 @@ 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]
|
||||||
|
@ -17,7 +20,7 @@ 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("rendering navi")
|
||||||
Print("dog backRibbon: \(backRibbon)")
|
Print("dog backRibbon: \(backRibbon)")
|
||||||
|
@ -29,12 +32,16 @@ struct NaviBar: View {
|
||||||
.if(!paneConnector.hasMoved) { $0.foregroundColor(Color(UIColor(red: 0.30, green: 0.30, blue: 0.30, alpha: 0.4))) }
|
.if(!paneConnector.hasMoved) { $0.foregroundColor(Color(UIColor(red: 0.30, green: 0.30, blue: 0.30, alpha: 0.4))) }
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
Task {
|
Task {
|
||||||
|
if backRibbon.count == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var br = backRibbon[0]
|
var br = backRibbon[0]
|
||||||
var sr = selectedRibbon[0]
|
var sr = selectedRibbon[0]
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if paneConnector.hasMoved {
|
if paneConnector.hasMoved {
|
||||||
print("has moved")
|
// if true {
|
||||||
|
|
||||||
let updatedRibbon = try await createUndoState(selectedRibbon: sr,
|
let updatedRibbon = try await createUndoState(selectedRibbon: sr,
|
||||||
appDatabase: appDatabase,
|
appDatabase: appDatabase,
|
||||||
|
@ -43,23 +50,49 @@ struct NaviBar: View {
|
||||||
destRibbon: sr,
|
destRibbon: sr,
|
||||||
appDatabase: appDatabase,
|
appDatabase: appDatabase,
|
||||||
paneConnector: paneConnector,
|
paneConnector: paneConnector,
|
||||||
loading: false)
|
loading: false,
|
||||||
|
bump: true)
|
||||||
} else {
|
} else {
|
||||||
if backRibbon.count == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
try await appDatabase.undoRibbon(&sr)
|
try await appDatabase.undoRibbon(&sr)
|
||||||
|
|
||||||
goToRibbon(selectedRibbon: sr,
|
goToRibbon(selectedRibbon: sr,
|
||||||
destRibbon: br,
|
destRibbon: br,
|
||||||
appDatabase: appDatabase,
|
appDatabase: appDatabase,
|
||||||
paneConnector: paneConnector,
|
paneConnector: paneConnector,
|
||||||
loading: false)
|
loading: 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 Arrow Error info: \(error)")
|
print("back 2 error")
|
||||||
|
print("Error info: \(error)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,23 +101,6 @@ struct NaviBar: View {
|
||||||
.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)))
|
||||||
.onTapGesture {
|
|
||||||
if nextRibbon.count == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
Task {
|
|
||||||
var sr = selectedRibbon[0]
|
|
||||||
var nr = nextRibbon[0]
|
|
||||||
try await appDatabase.redoRibbon(&sr)
|
|
||||||
|
|
||||||
goToRibbon(selectedRibbon: sr,
|
|
||||||
destRibbon: nr,
|
|
||||||
appDatabase: appDatabase,
|
|
||||||
paneConnector: paneConnector,
|
|
||||||
loading: false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.cornerRadius(5)
|
.cornerRadius(5)
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,31 +218,6 @@ extension AppDatabase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func redoRibbon(_ ribbon: inout Ribbon) async throws {
|
|
||||||
let currentLevel = ribbon.currentLevel
|
|
||||||
let minLevel = ribbon.maxLevel
|
|
||||||
|
|
||||||
if currentLevel == minLevel {
|
|
||||||
print("no where to redo")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
let newCurrent = (ribbon.currentLevel + 1) %% totalLevels
|
|
||||||
|
|
||||||
do {
|
|
||||||
try await dbWriter.write { [ribbon] db in
|
|
||||||
try db.execute(sql: """
|
|
||||||
UPDATE Ribbon \
|
|
||||||
SET currentLevel = ? WHERE groupId = ?
|
|
||||||
""", arguments: [newCurrent, ribbon.groupId])
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch {
|
|
||||||
print("Redo Ribbon Error info: \(error)")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// this sets the current undoLevel to the previous value
|
// this sets the current undoLevel to the previous value
|
||||||
// if you can go back
|
// if you can go back
|
||||||
func undoRibbon(_ ribbon: inout Ribbon) async throws {
|
func undoRibbon(_ ribbon: inout Ribbon) async throws {
|
||||||
|
@ -262,6 +237,12 @@ extension AppDatabase {
|
||||||
UPDATE Ribbon \
|
UPDATE Ribbon \
|
||||||
SET currentLevel = ? WHERE groupId = ?
|
SET currentLevel = ? WHERE groupId = ?
|
||||||
""", arguments: [newCurrent, ribbon.groupId])
|
""", arguments: [newCurrent, ribbon.groupId])
|
||||||
|
|
||||||
|
var ret3 = try Ribbon.fetchAll(db, sql: """
|
||||||
|
SELECT * from Ribbon \
|
||||||
|
WHERE groupId = ?
|
||||||
|
""", arguments: [ribbon.groupId])
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
@ -72,7 +72,8 @@ func goToRibbon(selectedRibbon: Ribbon,
|
||||||
destRibbon: Ribbon,
|
destRibbon: Ribbon,
|
||||||
appDatabase: AppDatabase,
|
appDatabase: AppDatabase,
|
||||||
paneConnector: PaneConnector,
|
paneConnector: PaneConnector,
|
||||||
loading: Bool)
|
loading: Bool,
|
||||||
|
bump: Bool)
|
||||||
{
|
{
|
||||||
print("meow goto ribbon - selected ribbon: \(selectedRibbon), dest ribbon: \(destRibbon) ")
|
print("meow goto ribbon - selected ribbon: \(selectedRibbon), dest ribbon: \(destRibbon) ")
|
||||||
|
|
||||||
|
@ -111,6 +112,26 @@ func goToRibbon(selectedRibbon: Ribbon,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// // this gets run regardless of if we switch ribbons or not
|
||||||
|
// // so if you click the same ribbon or a different ribbon
|
||||||
|
// if !loading || bump {
|
||||||
|
// print("not loading")
|
||||||
|
|
||||||
|
|
||||||
|
// print("saving ribbon")
|
||||||
|
// // updating the ribbon location
|
||||||
|
// updatedRibbon.scrollOffset = Int(floor(scrollOffsetToSave))
|
||||||
|
// updatedRibbon.scrollId = scrollIdToSave
|
||||||
|
// // updatedRibbon.undoLevel = updatedRibbon.undoLevel + 1
|
||||||
|
// // updatedRibbon.currentLevel = updatedRibbon.currentLevel + 1
|
||||||
|
|
||||||
|
// if bump {
|
||||||
|
// _ = try await appDatabase.bumpRibbon(&updatedRibbon)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// } else {
|
||||||
|
// print("loading")
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +202,8 @@ struct RibbonCrown: View {
|
||||||
destRibbon: ribbon,
|
destRibbon: ribbon,
|
||||||
appDatabase: appDatabase,
|
appDatabase: appDatabase,
|
||||||
paneConnector: paneConnector,
|
paneConnector: paneConnector,
|
||||||
loading: false)
|
loading: false,
|
||||||
|
bump: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -249,8 +271,6 @@ struct ContentView: View {
|
||||||
@State var draggedRibbon: Ribbon?
|
@State var draggedRibbon: Ribbon?
|
||||||
@State var isDragging = false
|
@State var isDragging = false
|
||||||
|
|
||||||
@State var dragOffset = CGFloat(0)
|
|
||||||
|
|
||||||
@Environment(\.appDatabase) private var appDatabase
|
@Environment(\.appDatabase) private var appDatabase
|
||||||
|
|
||||||
@Query(RibbonRequest()) private var ribbons: [Ribbon]
|
@Query(RibbonRequest()) private var ribbons: [Ribbon]
|
||||||
|
@ -311,15 +331,10 @@ struct ContentView: View {
|
||||||
|
|
||||||
VStack {
|
VStack {
|
||||||
// Top pane
|
// Top pane
|
||||||
|
|
||||||
// if viewState.width > -50 {
|
|
||||||
// dragOffset = viewState.width + pulledOut.width + 50
|
|
||||||
// }
|
|
||||||
Pane(paneConnector: paneConnector,
|
Pane(paneConnector: paneConnector,
|
||||||
selectedRibbon: selectedRibbon,
|
selectedRibbon: selectedRibbon,
|
||||||
width: geometry.size.width - 50,
|
width: geometry.size.width - 50,
|
||||||
height: geometry.size.height / 2,
|
height: geometry.size.height / 2)
|
||||||
dragOffset: dragOffset)
|
|
||||||
//////
|
//////
|
||||||
|
|
||||||
Text("separator").foregroundColor(Color(UIColor(red: 0.76, green: 0.76, blue: 0.76, alpha: 1.00)))
|
Text("separator").foregroundColor(Color(UIColor(red: 0.76, green: 0.76, blue: 0.76, alpha: 1.00)))
|
||||||
|
@ -376,9 +391,8 @@ struct ContentView: View {
|
||||||
.gesture(
|
.gesture(
|
||||||
DragGesture()
|
DragGesture()
|
||||||
.onChanged { gesture in
|
.onChanged { gesture in
|
||||||
let margin = CGFloat(50)
|
|
||||||
|
|
||||||
print("mao viewState :\(viewState.width)")
|
print(viewState.width)
|
||||||
print(pulledOut.width)
|
print(pulledOut.width)
|
||||||
// threshold of how much to swipe before the view drags
|
// threshold of how much to swipe before the view drags
|
||||||
if abs(gesture.translation.width) > 10 {
|
if abs(gesture.translation.width) > 10 {
|
||||||
|
@ -386,45 +400,21 @@ struct ContentView: View {
|
||||||
// if gesture.translation.width < -50, pulledOut.width == CGFloat(0) {
|
// if gesture.translation.width < -50, pulledOut.width == CGFloat(0) {
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
if viewState.width < -50 && pulledOut.width <= 0 {
|
|
||||||
dragOffset = margin + viewState.width + pulledOut.width
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if viewState.width > 0 && pulledOut.width != 0 {
|
|
||||||
dragOffset = margin + viewState.width + pulledOut.width
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.onEnded { _ in
|
.onEnded { _ in
|
||||||
let pulledOutRight = CGFloat(-300)
|
|
||||||
let pulledOutLeft = CGFloat(200)
|
|
||||||
let margin = CGFloat(50)
|
|
||||||
|
|
||||||
var setPulledOutWith = CGFloat(0)
|
var setPulledOutWith = CGFloat(0)
|
||||||
var setDragOffset = CGFloat(0)
|
|
||||||
if viewState.width < 0 && pulledOut.width > 0 {
|
if viewState.width < 0 && pulledOut.width > 0 {
|
||||||
setPulledOutWith = CGFloat(0)
|
setPulledOutWith = CGFloat(0)
|
||||||
} else if viewState.width > 0 && pulledOut.width < 0 {
|
} else if viewState.width > 0 && pulledOut.width < 0 {
|
||||||
setPulledOutWith = CGFloat(0)
|
setPulledOutWith = CGFloat(0)
|
||||||
} else if viewState.width < 0 && pulledOut.width == 0 {
|
} else if viewState.width < 0 && pulledOut.width == 0 {
|
||||||
setPulledOutWith = pulledOutRight
|
setPulledOutWith = CGFloat(-300)
|
||||||
setDragOffset = margin + setPulledOutWith
|
|
||||||
} else if abs(viewState.width + pulledOut.width) > 30 {
|
} else if abs(viewState.width + pulledOut.width) > 30 {
|
||||||
setPulledOutWith = pulledOutLeft
|
setPulledOutWith = CGFloat(200)
|
||||||
}
|
}
|
||||||
|
|
||||||
// if setPulledOutWith < 0 {
|
|
||||||
// setDragOffset = CGFloat(50) + setPulledOutWith
|
|
||||||
// } else if setPulledOutWith > 0 {
|
|
||||||
// setDragOffset = setPulledOutWith
|
|
||||||
// } else {
|
|
||||||
// setDragOffset = .zero
|
|
||||||
// }
|
|
||||||
|
|
||||||
print("mao setPulledOutWith \(setPulledOutWith)")
|
|
||||||
withAnimation(.spring(response: 0.2)) {
|
withAnimation(.spring(response: 0.2)) {
|
||||||
pulledOut.width = setPulledOutWith
|
pulledOut.width = setPulledOutWith
|
||||||
dragOffset = setDragOffset
|
|
||||||
viewState = .zero
|
viewState = .zero
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue