Last active
July 19, 2020 00:12
-
-
Save apatronl/34fd9b8a8a96d45e3e9af7502354f096 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
struct EmojibookListView: View { | |
let emojiData = EmojiProvider.all() | |
@State private var visibleEmojiDetails: EmojiDetails? | |
var body: some View { | |
NavigationView { | |
List { | |
ForEach(emojiData) { emojiDetails in | |
Button(action: { | |
visibleEmojiDetails = emojiDetails | |
}, label: { | |
EmojiItemView(emoji: emojiDetails.emoji, emojiName: emojiDetails.name) | |
}) | |
} | |
} | |
.foregroundColor(.black) | |
.listStyle(InsetGroupedListStyle()) | |
.navigationBarTitle("Emojibook") | |
} | |
.onOpenURL { url in | |
guard let emojiDetails = emojiData.first(where: { $0.url == url }) else { return } | |
visibleEmojiDetails = emojiDetails | |
} | |
.sheet(item: $visibleEmojiDetails, content: { emojiDetails in | |
EmojiDetailsView(emojiDetails: emojiDetails) | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment