Equilat
05/10/2021, 11:33 AMstruct DefaultButton: View {
var body: some View {
Button("Button"){}
.buttonStyle(ButtonDefaultStyle())
}
}
My style is in an external class.
struct ButtonDefaultStyle: ButtonStyle {
func makeBody(configuration: Configuration) -> some View {
configuration.label
.frame(width: 100, height: 40)
.foregroundColor(Color( colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)))
.background(configuration.isPressed ? Color( colorLiteral(red: 0.1254901961, green: 0.4666666667, blue: 0.4235294118, alpha: 1)) : Color( colorLiteral(red: 0.1411764706, green: 0.6784313725, blue: 0.5529411765, alpha: 1)))
.clipShape(RoundedRectangle(cornerRadius: 50))
.font(Font.custom("EuclidSquare-Medium", size: 16))
}
}
The best would be to be able to override a style by another style or by an attribute (Button().{}.style1(...).style2(...).color(...)...
Is there a way to do something similar in Compose ?
If not, did I misunderstood Compose philosophy or is it just something currently lacking ?
Thread in Slack Conversation