Skip to content

Instantly share code, notes, and snippets.

@SlappyAUS
Created November 24, 2020 01:59
Show Gist options
  • Select an option

  • Save SlappyAUS/d98d099a5bb082939516ba278d711b1e to your computer and use it in GitHub Desktop.

Select an option

Save SlappyAUS/d98d099a5bb082939516ba278d711b1e to your computer and use it in GitHub Desktop.
Watchkit Button Style #swiftui #watchos
struct ContentView: View {
@State private var EnrouteText = "Enroute"
var body: some View {
List {
Button(action: {
self.EnrouteText = getCurrentTime()
}) {
Text(EnrouteText)
}
.buttonStyle(BtnStyle(bgColor: .red, fgColor: .white))
.listRowInsets(EdgeInsets.init(top: 0, leading: 0, bottom: 0, trailing: 0))
.listRowPlatterColor(.clear)
// The rest of the buttons.
}
}
}
// Button Styles
struct BtnStyle: ButtonStyle {
var bgColor: Color
var fgColor: Color
func makeBody(configuration: Self.Configuration) -> some View {
configuration.label
.frame(minWidth: 0, maxWidth: .infinity)
.padding()
.foregroundColor(fgColor)
.background(bgColor)
.cornerRadius(32)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment