Last active
June 9, 2020 14:00
-
-
Save archieedwards/32e2a1265a5507028119e21da5757ac2 to your computer and use it in GitHub Desktop.
code to enable swiping through categories
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
.onPageChanged({ _ in | |
self.allowSubCategoryDragging = true | |
}) | |
.swipeInteractionArea(.allAvailable) | |
.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 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment