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 SimpleEntry: TimelineEntry { | |
public let date: Date | |
public let emojiDetails: EmojiDetails | |
} | |
// ... |
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
import Foundation | |
public struct EmojiProvider { | |
/// Creates a list of emoji details that includes an emoji along with its name and description. | |
/// - Returns: The list of `EmojiDetail`s | |
/// - Note: Emoji descriptions obtained from [Empojipedia](https://emojipedia.org/). | |
static func all() -> [EmojiDetails] { | |
// ... | |
} |
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 Emojibook_WidgetEntryView: View { | |
var entry: Provider.Entry | |
var body: some View { | |
EmojiWidgetView(emojiDetails: entry.emojiDetails) | |
} | |
} |
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
@main | |
struct Emojibook_Widget: Widget { | |
private let kind: String = "Emojibook_Widget" | |
public var body: some WidgetConfiguration { | |
StaticConfiguration( | |
kind: kind, | |
provider: Provider(), | |
placeholder: PlaceholderView() | |
) { entry in |
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
// ... | |
@main | |
struct Emojibook_Widget: Widget { | |
private let kind: String = "Emojibook_Widget" | |
public var body: some WidgetConfiguration { | |
StaticConfiguration( | |
kind: kind, | |
provider: Provider(), |
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 MediumEmojiWidgetView: View { | |
let emojiDetails: EmojiDetails | |
var body: some View { | |
ZStack { | |
Color(UIColor.systemIndigo) | |
HStack { |
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 MediumEmojiWidgetView: View { | |
// ... | |
} | |
struct LargeEmojiWidgetView: View { | |
let emojiDetails: EmojiDetails |
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 SmallEmojiWidgetView: View { | |
let emojiDetails: EmojiDetails | |
var body: some View { | |
ZStack { | |
Color(UIColor.systemIndigo) | |
VStack { |
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 EmojiWidgetView: View { | |
@Environment(\.widgetFamily) var family: WidgetFamily | |
let emojiDetails: EmojiDetails | |
@ViewBuilder | |
var body: some View { | |
switch family { | |
case .systemSmall: | |
SmallEmojiWidgetView(emojiDetails: emojiDetails) |
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
public struct EmojiDetails { | |
public let emoji: String | |
public let name: String | |
public let description: String | |
public let url: URL? | |
init(emoji: String, name: String, description: String) { | |
self.emoji = emoji | |
self.name = name | |
self.description = description |