Hello guys. I would like to style my composables i...
# compose
e
Hello guys. I would like to style my composables in Jetpack Compose using a similar mechanic to Swift UI’s styling like in this example.
Copy code
struct DefaultButton: View {
   
   var body: some View {
     Button("Button"){}
       .buttonStyle(ButtonDefaultStyle())
   }
}
My style is in an external class.
Copy code
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