Skip to content

Commit

Permalink
Fix button styling
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-z committed Nov 7, 2019
1 parent fc3993a commit d68e419
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
25 changes: 22 additions & 3 deletions free-sidecar/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@

import SwiftUI

struct ModelButtonStyle: ButtonStyle {
let isEnabled: Bool

init(isEnabled: Bool) {
self.isEnabled = isEnabled
}

func makeBody(configuration: Self.Configuration) -> some View {
let borderColor = self.isEnabled ? Color.green : Color.orange
let backgroundColor = configuration.isPressed ? Color.clear : borderColor

return configuration.label
.foregroundColor(configuration.isPressed ? Color.white : Color.black)
.background(backgroundColor)
.border(borderColor, width: 2)
.cornerRadius(4)
.padding(2)
}
}

struct ContentView: View {
@State var selectedURL: URL?
@State var models: [Model] = []
Expand Down Expand Up @@ -66,7 +86,6 @@ struct ContentView: View {
if result == .OK {
self.selectedURL = panel.url
self.models = dostuff2(sidecarCore: panel.url!);

}
}
}) {
Expand All @@ -87,9 +106,9 @@ struct ContentView: View {
self.models = dostuff2(sidecarCore: self.selectedURL!)
}) {
Text(model.enabled ? "\(model.str) enabled" : "Enable \(model.str)")
.foregroundColor(Color.black)
.padding()
}
.background(model.enabled ? Color.green : Color.orange)
.buttonStyle(ModelButtonStyle(isEnabled: model.enabled))
}.frame(minHeight: 300)
} else {
Text("Select a SidecarCore first")
Expand Down
4 changes: 2 additions & 2 deletions free-sidecar/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.1</string>
<string>1.2</string>
<key>CFBundleVersion</key>
<string>2</string>
<string>3</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
Expand Down

0 comments on commit d68e419

Please sign in to comment.