Skip to content

Instantly share code, notes, and snippets.

@haoyu-c
Created November 8, 2019 16:39
Show Gist options
  • Save haoyu-c/0945c98fb5ffc7f0b8f9575cfcf5158e to your computer and use it in GitHub Desktop.
Save haoyu-c/0945c98fb5ffc7f0b8f9575cfcf5158e to your computer and use it in GitHub Desktop.
// 父层级
struct ContentView : View {
@State private var brain: CalculatorBrain = .left("0")
var body: some View {
// ...
CalculatorButtonPad(brain: $brain)
.padding(.bottom)
}
}
// 子层级
struct CalculatorButtonPad: View {
@Binding var brain: CalculatorBrain
// ...
var body: some View {
VStack(spacing: 8) {
ForEach(pad, id: \.self) { row in
CalculatorButtonRow(row: row, brain: self.$brain)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment