Created
May 6, 2020 12:33
-
-
Save Dimillian/a57c162eba82ce2d266d3347d8e3e2df 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
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