Created
December 30, 2020 02:22
-
-
Save jodyabney/1ed66626df4b2ee33ae263f559dc24c2 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
| // | |
| // PhotoCategoryPicker.swift | |
| // MediumArticleFlickrApp | |
| // | |
| // Created by Jody Abney on 12/19/20. | |
| // | |
| import SwiftUI | |
| struct PhotoCategoryPicker: View { | |
| @ObservedObject var viewModel: ViewModel | |
| var body: some View { | |
| Picker(selection: $viewModel.selectedCategory, | |
| label: Text("Photo Category Picker")) { | |
| Text("Interesting").tag(PhotoCategory.interestingness) | |
| // only show Recent photos option if enabled | |
| // via Settings screen | |
| if viewModel.includeRecentPhotos { | |
| Text("Recent").tag(PhotoCategory.recent) | |
| } | |
| Text("Near By").tag(PhotoCategory.nearBy) | |
| } | |
| .pickerStyle(SegmentedPickerStyle()) | |
| } | |
| } | |
| struct PhotoCategoryPicker_Previews: PreviewProvider { | |
| static var previews: some View { | |
| Group { | |
| PhotoCategoryPicker(viewModel: ViewModel()) | |
| .previewLayout(.sizeThatFits) | |
| PhotoCategoryPicker(viewModel: PreviewViewModel()) | |
| .previewLayout(.sizeThatFits) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment