Giter Site home page Giter Site logo

cs193p-memorize-app's Introduction

Memorize App

Thats a simple game of memorization. Created in IOS with Swift.

From Stanford CS193p (2023) course.

Course Progress

  • Class 1
  • Class 2
  • Class 3
  • Class 4
  • Class 5
  • Class 6
  • Class 7
  • Class 8
  • Class 9
  • Class 10
  • Class 11
  • Class 12
  • Class 13
  • Class 14
  • Class 15

Notes

States

  • To create a simple states:
    @State var cardCount: Int = 8

Functions

  • We can create a function that returns a View, like this:
    func makeCardCountAdjuster(
        by offset: Int,
        symbol: String,
        label: String,
        alignment: HorizontalAlignment = HorizontalAlignment.leading
    ) -> some View {
        Button(
            action: {
                cardCount += offset
            },
            label: {
                VStack (alignment: alignment) {
                    Image(systemName: symbol)
                    Text(label)
                }
            }
        )
        .disabled(cardCount + offset < 1 || cardCount + offset > emojis.count)
    }
  • Using the function to create a button component:
    var CardRemover: some View {
        makeCardCountAdjuster(
            by: -1,
            symbol: "minus.square",
            label: "remove card"
        )
    }
  • To use a component, we just need to add it in a View, Stack or Scrollview:
    var body: some View {
        VStack{
            ScrollView {
                Cards // A component responsible for list all cards
            }
            Spacer(minLength: 24)
            CardCountAdjusters // A wrapper component that contains the buttons
            
        }
        .padding()
    }

cs193p-memorize-app's People

Contributors

makusdouglas avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.