Skip to content

Instantly share code, notes, and snippets.

@mhijack
Created June 13, 2021 21:19
Show Gist options
  • Save mhijack/6aede154bba3c2e672a29b386ceb7178 to your computer and use it in GitHub Desktop.
Save mhijack/6aede154bba3c2e672a29b386ceb7178 to your computer and use it in GitHub Desktop.
struct MarshallSpeaker: View {
var maximumVolume: Int = 100
@State var volume: Int = 50
var body: some View {
// UI code
}
public func updateVolume(volume: Int) {
self.volume = volume < maximumVolume ? volume : maximumVolume
}
}
let MarshallSpeakerBefore = MarshallSpeaker(volume: 50)
MarshallSpeakerBefore.updateVolume(volume: 80)
// Above statement generates a view with the new value
let MarshallSpeakerAfter = MarshallSpeaker(volume: 80)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment