Created
June 9, 2020 20:34
-
-
Save archieedwards/5932c7bd76dc6c1d7f377a52ade492aa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.simultaneousGesture(DragGesture().onChanged({value in | |
/// catch moving to category | |
if self.allowSubCategoryDragging { | |
let movingCategoryRight = self.page == 0 && self.nestedPages[self.page] == 2 && value.translation.width < 0 | |
let movingCategoryLeft = self.page == 1 && self.nestedPages[self.page] == 0 && value.translation.width > 0 | |
if movingCategoryRight || movingCategoryLeft{ | |
self.allowSubCategoryDragging = false | |
} | |
else{ | |
let westAsCanBe = self.nestedPages[self.page] == 0 && self.page == 0 && value.translation.width > 0 | |
let eastAsCanBe = self.nestedPages[self.page] == 2 && self.page == 1 && value.translation.width < 0 | |
if !westAsCanBe && !eastAsCanBe{ | |
/// we must be moving sub categorys move the offset for the indicator | |
self.indicatorOffsets[self.page] = -value.translation.width/10 | |
} | |
} | |
} | |
}).onEnded({ _ in | |
self.indicatorOffsets[self.page] = 0 | |
})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment