Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save archieedwards/32e2a1265a5507028119e21da5757ac2 to your computer and use it in GitHub Desktop.
Save archieedwards/32e2a1265a5507028119e21da5757ac2 to your computer and use it in GitHub Desktop.
code to enable swiping through categories
.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