Last active
          August 4, 2021 18:26 
        
      - 
      
- 
        Save steipete/8bfa13ce80a105e19ea1996705b39f24 to your computer and use it in GitHub Desktop. 
    (me learning SwiftUI layout) https://twitter.com/steipete/status/1363151782428479490?s=21
  
        
  
    
      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
    
  
  
    
  | //: A Cocoa based Playground to present user interface | |
| import SwiftUI | |
| import PlaygroundSupport | |
| struct ContentView: View { | |
| var body: some View { | |
| HStack { | |
| VStack { | |
| HStack { | |
| Spacer() | |
| Text("Highlight :") | |
| .background(Color.green) | |
| } | |
| Spacer() | |
| } | |
| .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity) | |
| .background(Color.yellow) | |
| VStack { | |
| HStack { | |
| VStack(alignment: .leading) { | |
| Text("Checkbox 111") | |
| Text("Checkbox 2") | |
| } | |
| .background(Color.blue) | |
| Spacer() | |
| } | |
| Spacer() | |
| } | |
| .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity) | |
| .background(Color.red) | |
| } | |
| .frame(width: 400, height: 200) | |
| } | |
| } | |
| PlaygroundPage.current.setLiveView(ContentView()) | 
        
      
            kean
  
      
      
      commented 
        Feb 20, 2021 
      
    
  
Adjusted for "stack three of these instead of putting them in a large frame; background color is not really needed" goal
struct ContentView: View {
    var body: some View {
        VStack {
            SettingsPanel()
            SettingsPanel()
        }
//        .frame(width: 400, height: 200)
    }
}
struct SettingsPanel: View {
    var body: some View {
        HStack(alignment: .firstTextBaseline) {
            Text("Highlight :")
                .background(Color.green)
                .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, alignment: .topTrailing)
            VStack(alignment: .leading) {
                Text("Checkbox 111")
                Text("Checkbox 2")
            }
            .background(Color.blue)
            .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, alignment: .topLeading)
        }
    }
}
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment