Difference between revisions of "Mobile App Development 2021W Lecture 16"

From Soma-notes
Jump to navigation Jump to search
Line 1: Line 1:
==Video==
Video from the lecture given on March 15, 2021 [https://homeostasis.scs.carleton.ca/~soma/mad-2021w/lectures/comp1601-2021w-lec16-20210315.m4v is now available].
==Code==
==Code==



Revision as of 15:02, 15 March 2021

Video

Video from the lecture given on March 15, 2021 is now available.

Code

TapDemo/Shared/ContentView.swift

//
//  ContentView.swift
//  Shared
//
//  Created by Anil Somayaji on 2021-03-15.
//

import SwiftUI

struct ContentView: View {
    @State var count = 0
    var body: some View {
        VStack{
            Button("Tap here!", action: onTapped)
                .font(/*@START_MENU_TOKEN@*/.title/*@END_MENU_TOKEN@*/)
            
            Text("You have tapped \(count) times.")
            .padding()
        }
    }
    func onTapped() {
        count = count + 1
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}