Skip to content

Instantly share code, notes, and snippets.

@Dimillian
Created May 6, 2020 12:33
Show Gist options
  • Save Dimillian/a57c162eba82ce2d266d3347d8e3e2df to your computer and use it in GitHub Desktop.
Save Dimillian/a57c162eba82ce2d266d3347d8e3e2df to your computer and use it in GitHub Desktop.
private var sortSheet: ActionSheet {
var buttons: [ActionSheet.Button] = []
for sort in ItemsViewModel.Sort.allCases {
buttons.append(.default(Text(sort.rawValue.localizedCapitalized),
action: {
self.viewModel.sort = sort
}))
}
if viewModel.sort != nil {
buttons.append(.default(Text("Clear Selection"), action: {
self.viewModel.sort = nil
}))
}
buttons.append(.cancel())
let title = Text("Sort items")
if let currentSort = viewModel.sort {
return ActionSheet(title: title,
message: Text("Current Sort: \(currentSort.rawValue.localizedCapitalized)"),
buttons: buttons)
}
return ActionSheet(title: title, buttons: buttons)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment