Created
November 8, 2019 16:39
-
-
Save haoyu-c/0945c98fb5ffc7f0b8f9575cfcf5158e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 父层级 | |
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