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
delegate = ADelegate() | |
sut = UnitBeingTested(delegate) | |
sut.aFunctionCall() | |
verify(delegate) | |
.callMadeTo(functionOnDelegate) | |
.withParameter(anything()) |
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
// | |
// Created by Chris Mash on 10/02/2022. | |
// | |
import UIKit | |
import ProvisioningProfile | |
import FirebaseDatabase | |
// NOTE: this gist uses some personal extensions I've written which aren't shared here but you should be able to swap out easily enough: | |
// Bundle.main.appVersion |
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 ContentView: View { | |
private var gameState = GameState() | |
@Namespace private var animation | |
var body: some View { | |
VStack { | |
// Some simple instructions | |
Text(""" | |
Tap a + button to add a card from the deck to the relevant hand. |
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 DeckView: View { | |
@ObservedObject var deck: Hand | |
let namespace: Namespace.ID | |
var body: some View { | |
ZStack { | |
// Just need to draw the last two so that the transition of card | |
// from the hand back to the deck results in the old top card being | |
// rendered as the new top card animates 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
// A view to represent the cards in a hand | |
struct HandView: View { | |
@ObservedObject var hand: Hand | |
let namespace: Namespace.ID | |
let onCardTap: (Card) -> Void | |
var body: some View { | |
HStack { | |
ForEach(hand.cards) { card 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
struct CardView_Previews: PreviewProvider { | |
// Create a wrapper view that will let us hold a @Namespace to pass to the view | |
struct Wrapper: View { | |
@Namespace var animation | |
var body: some View { | |
CardView(card: Card(number: 1), namespace: animation) | |
.padding() | |
.background(Color.gray) | |
} | |
} |
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
// A view to represent a single card | |
struct CardView: View { | |
let card: Card | |
let namespace: Namespace.ID | |
var body: some View { | |
ZStack { | |
RoundedRectangle(cornerRadius: 20, | |
style: .continuous) |
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
// A representation of the current state of the game, | |
// including which cards each player has and the deck | |
// of cards that can be picked up from | |
class GameState { | |
private(set) var deck = Hand() | |
private(set) var hands = [Hand]() | |
init() { | |
// Fill the deck with 20 cards, shuffled |
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
// A representation of a playing card | |
struct Card: Identifiable, Equatable { | |
let id = UUID() | |
let number: Int | |
} | |
// A representation of a player's hand of cards | |
class Hand: ObservableObject, Identifiable { | |
let id = UUID() | |
@Published var cards = [Card]() |
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
let address = "[email protected]" | |
let subject = "AwesomeApp Feedback" | |
// Example email body with useful info for bug reports | |
let body = "\n\nApp Version: \(appVersion)\nDevice: \(deviceType)\niOS: \(osVersion)" | |
// Build the URL from its components | |
var components = URLComponents() | |
components.scheme = "mailto" | |
components.path = address |