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 EmojibookListView: View { | |
let emojiData = EmojiProvider.all() | |
@State private var visibleEmojiDetails: EmojiDetails? | |
var body: some View { | |
NavigationView { | |
List { | |
ForEach(emojiData) { emojiDetails in | |
Button(action: { |
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 | |
// Model | |
struct GuessingGame<GuessElement: Equatable> { | |
enum GameStatus { | |
case won | |
case lost | |
case playing | |
} |
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 | |
// ViewModel | |
class NumberGuessingGame { | |
private var model: GuessingGame<Int> | |
private var maxGuesses = 3 | |
init() { | |
model = GuessingGame(elementToGuess: NumberGuessingGame.generateGuess(), maxGuesses: maxGuesses) |
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 SwiftUI | |
struct NumberGuessingGameView: View { | |
private var gameViewModel: NumberGuessingGame | |
@State private var guessLabel = "Guess the number!" | |
@State private var guess = "" | |
@State private var showAlert = false |
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 Intents | |
class IntentHandler: INExtension { | |
override func handler(for intent: INIntent) -> Any { | |
// This is the default implementation. If you want different objects to handle different intents, | |
// you can override this and return the handler you want for that particular intent. | |
return self | |
} | |
} |
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 { | |
// ... | |
} | |
struct EmojiWidgetPlaceholderView: View { | |
var body: some View { | |
Color(UIColor.systemIndigo) | |
} | |
} |
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 SwiftUI | |
import WidgetKit | |
struct RandomEmojiWidgetProvider: TimelineProvider { | |
public func snapshot(with context: Context, completion: @escaping (RandomEmojiEntry) -> ()) { | |
let entry = RandomEmojiEntry(date: Date(), emojiDetails: EmojiProvider.random()) | |
completion(entry) | |
} |
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 SwiftUI | |
import WidgetKit | |
struct CustomEmojiWidgetProvider: IntentTimelineProvider { | |
func snapshot( | |
for configuration: SelectEmojiIntent, | |
with context: Context, | |
completion: @escaping (CustomEmojiEntry) -> () | |
) { |
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 SwiftUI | |
import WidgetKit | |
@main | |
struct EmojiWidgetBundle: WidgetBundle { | |
@WidgetBundleBuilder | |
var body: some Widget { | |
RandomEmojiWidget() | |
CustomEmojiWidget() |