All Projects → obrienser → memorize

obrienser / memorize

Licence: Unlicense license
Stanford University's course CS193p (Developing Applications for iOS using SwiftUI)

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to memorize

OMJoystick
This is the JoyStick UI library for SwiftUI.
Stars: ✭ 15 (-25%)
Mutual labels:  swiftui
RealmTaskTracker
SwiftUI version of the MongoDB Realm iOS tutorial
Stars: ✭ 24 (+20%)
Mutual labels:  swiftui
NumberTicker
Robinhood-like Rotating Number View | SwiftUI
Stars: ✭ 34 (+70%)
Mutual labels:  swiftui
IrregularGradient
Create animated irregular gradients in SwiftUI.
Stars: ✭ 127 (+535%)
Mutual labels:  swiftui
stinsen
Coordinators in SwiftUI. Simple, powerful and elegant.
Stars: ✭ 563 (+2715%)
Mutual labels:  swiftui
app
💥 a modern xkcd iOS client
Stars: ✭ 31 (+55%)
Mutual labels:  swiftui
BottomSheet
A sliding Sheet from the bottom of the Screen with 3 States build with SwiftUI.
Stars: ✭ 597 (+2885%)
Mutual labels:  swiftui
CombineUnsplash
A sample project exploring MVVM pattern with SwiftUI/Combine, using Unsplash API (via Picsum.photos API)
Stars: ✭ 25 (+25%)
Mutual labels:  swiftui
ECommerceAppSwiftUI
ECommerce App in SwiftUI
Stars: ✭ 37 (+85%)
Mutual labels:  swiftui
AppClipCodeGenerator
App Clip Code Generator macOS App built with SwiftUI
Stars: ✭ 75 (+275%)
Mutual labels:  swiftui
DarkModeSwitcher
Simple app for overriding light mode per app on macOS (demo for a blog post)
Stars: ✭ 37 (+85%)
Mutual labels:  swiftui
MVVM-in-SwiftUI
MVVM in SwiftUI (WWDC Player)
Stars: ✭ 60 (+200%)
Mutual labels:  swiftui
LongWeekend-iOS
🏖📱 LongWeekend is iOS Application that supports checking long weekends when taking a vacation in Japan
Stars: ✭ 19 (-5%)
Mutual labels:  swiftui
ios-sketch-elements
iOS SwiftUI starter kit based on Sketch Elements.
Stars: ✭ 34 (+70%)
Mutual labels:  swiftui
Builder
Demonstrates SwiftUI builder patterns for UIKit and networking.
Stars: ✭ 100 (+400%)
Mutual labels:  swiftui
BoxFeed
News App 📱 built to demonstrate the use of SwiftUI 3 features, Async/Await, CoreData and MVVM architecture pattern.
Stars: ✭ 112 (+460%)
Mutual labels:  swiftui
LineChartView
An interactive line chart written in SwiftUI with many customizations (colors, line size, dots, haptic feedbacks). Support value and time series.
Stars: ✭ 59 (+195%)
Mutual labels:  swiftui
RChat
No description or website provided.
Stars: ✭ 58 (+190%)
Mutual labels:  swiftui
NavigationRouter
A router implementation designed for complex modular apps, written in Swift
Stars: ✭ 89 (+345%)
Mutual labels:  swiftui
Micro
🏎Fast diffing and type safe SwiftUI style data source for UICollectionView
Stars: ✭ 77 (+285%)
Mutual labels:  swiftui

Memorize Game 🎮

Stanford University's course CS193p (Developing Applications for iOS using SwiftUI)

GitHub license GitHub stars GitHub forks visitors




About the game

You need to turn over the cards one by one to find the same cards. When you find two identical cards, you get one point and these cards will disappear. The game ends when you find all the pairs.

Technology

  • Swift
  • SwiftUI
  • MVVM

Screenshots

        

Sample code

MemoryGame.swift

    struct Card: Identifiable {
        var isFaceUp: Bool = false {
            didSet {
                if isFaceUp {
                    startUsingBonusTime()
                } else {
                    stopUsingBonusTime()
                }
            }
        }
        var isMatched: Bool = false {
            didSet {
                stopUsingBonusTime()
            }
        }
        var content: CardContent
        var id: Int
        
        // can be zero which means "no bonus available" for this card
        var bonusTimeLimit: TimeInterval = 10
        
        // how long this card has ever been face up
        private var faceUpTime: TimeInterval {
            if let lastFaceUpDate = self.lastFaceUpDate {
                return pastFaceUpTime + Date().timeIntervalSince(lastFaceUpDate)
            } else {
                return pastFaceUpTime
            }
        }
        // the last time this card was turned face up (and is still face up)
        var lastFaceUpDate: Date?
        // the accumulated  time yhis card has been face up in the past
        // (i.e. not including the current time it`s been face up if it is currently so)
        var pastFaceUpTime: TimeInterval = 0
        
        // how much time left before the bonus opportunity runs out
        var bonusTimeRemaining: TimeInterval {
            max(0, bonusTimeLimit - faceUpTime)
        }
        // percentage of the bonus time remaining
        var bonusRemaining: Double {
            (bonusTimeLimit > 0 && bonusTimeRemaining > 0) ? bonusTimeRemaining/bonusTimeLimit : 0
        }
        // whether the card was matched during the bonus time period
        var hasEarnedBonus: Bool {
            isMatched && bonusTimeRemaining > 0
        }
        // whether we are currently face up, unmatched and have not yet used up the bonus window
        var isConsumingBonusTime: Bool {
            isFaceUp && !isMatched && bonusTimeRemaining > 0
        }
        
        // called when the card transitions to face up state
        private mutating func startUsingBonusTime() {
            if isConsumingBonusTime, lastFaceUpDate == nil {
                lastFaceUpDate = Date()
            }
        }
        // called when the card goes back face down (or gets matched)
        private mutating func stopUsingBonusTime() {
            pastFaceUpTime = faceUpTime
            self.lastFaceUpDate = nil
        }
    }

About the course

Stanford's CS193p course, Developing Applications for iOS, explains the fundamentals of how to build applications for iPhone and iPad using SwiftUI.

Stanford University's course CS193p (Developing Applications for iOS using SwiftUI)

Lectures

  1. Course Logistics and Intro to SwiftUI
  2. MVVM and the Swift Type System
  3. Reactive UI Protocols Layout
  4. Grid enum Optionals
  5. ViewBuilder Shape ViewModifier
  6. Animation
  7. Multithreading EmojiArt
  8. Gestures JSON
  9. Data Flow
  10. Modal Presentation and Navigation
  11. Enroute Picker
  12. Core Data
  13. Persistence
  14. UIKit Integration

Requirements

  • iOS 14.2
  • Xcode 12.0
  • Swift 5.3

Install

Just open project and run 🚀


Buy Me A Coffee

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].