Originally, I've tried to configure the similar with the SwiftUI struct's styles for the passing values.
My codes are like below.
I defined the custom button styles in the separated target as framework. And I'd like to set the Button background color(or using Gradient), using the Builder pattern.
The structs & classes related to the Builder patterns are complied well.
But, the problem is occurred on the codes to use the Builder.
Specially when I use the different struct types as a property of the custom Button styles, it's occurred the compile error. Please refer the below codes.
// Custom View using the custom button style with the BuilderimportFoundationimportSwiftUIimportSwiftExtensionimportCustomStylespublicstructReceiptView: View {
publicvarbody: someView {
VStack(alignment: .center) {
Spacer().frame(minHeight: 10.0)
VStack(alignment: .center, spacing: 16.0) {
Image("clinicLogo")
Text("Clinic Name")
.font(.system(size: 40.0, weight: .medium))
}
Spacer().frame(maxHeight: 112.0)
Button(
action: {
debugPrint(#function)
},
label: {
VStack(alignment: .center, spacing: 0.0) {
Spacer().frame(height: 64.0)
Image("icon")
Spacer().frame(height: 16.0)
Text("Receipt")
Spacer().frame(height: 72.0)
}
})
.frame(width: 440.0, height: 440.0)
.buttonStyle(
RoundedButtonStyleBuilder()
.color(
LinearGradient(
colors: [.lightTheme, .defaultTheme],
startPoint: .top,
endPoint: .bottom
),
for: .normal
)
.color(Color.highlighted, for: .highlighted) // This case causes the compile error!!!!!// .color(// LinearGradient(// colors: [.defaultTheme],// startPoint: .top,// endPoint: .bottom// ),// for: .highlighted// ) // If the same type is passed, it's not occurred the compile error!!
.build()
)
Spacer().frame(height: 24.0)
}
.navigationBarTitleDisplayMode(.inline)
.navigationBarHidden(true)
}
}
So, I followed the compile error message and I reported the bug.
If I'm using the wrong way to use the Generics in Swift, plz, let me know & guide me.
The text was updated successfully, but these errors were encountered:
Attachment: Download
Environment
Xcode 13.2(included Swift 5.5)
OS: MacOS 12.1 Monterey(plz, refer the details in the 1st screen shot)
Testing Device on running the codes: iPad Air 9gen., iOS simulators
Additional Detail from JIRA
md5: 08d1c24459a3c9359296d685692609e4
Issue Description:
I've tried to use the Builder pattern in the swift, especially with the Generics.
But the swift complier said "Failed to produce diagnostic for expression; please submit a bug report (https://swift.org/contributing/#reporting-bugs)" and include the project".
Originally, I've tried to configure the similar with the SwiftUI struct's styles for the passing values.
My codes are like below.
I defined the custom button styles in the separated target as framework. And I'd like to set the Button background color(or using Gradient), using the Builder pattern.
The structs & classes related to the Builder patterns are complied well.
But, the problem is occurred on the codes to use the Builder.
Specially when I use the different struct types as a property of the custom Button styles, it's occurred the compile error. Please refer the below codes.
So, I followed the compile error message and I reported the bug.
If I'm using the wrong way to use the Generics in Swift, plz, let me know & guide me.
The text was updated successfully, but these errors were encountered: