skiptools / skip-ui

SwiftUI for Android
https://skip.tools
GNU Lesser General Public License v3.0
129 stars 14 forks source link

How to customize Textfeild ? #24

Closed X901 closed 10 months ago

X901 commented 11 months ago

Hi, I tried to customize Textfield

TextField("", text: .constant("Text"))
                        .textFieldStyle(.plain)
                        .padding(5.0)
                        .background(RoundedRectangle(cornerRadius: 5.0)
                            .fill(Color.white))
                        .padding(.horizontal, 10)
                        .overlay(
                            RoundedRectangle(cornerRadius: 5.0)
                                .stroke(.gray, lineWidth: 1.0)
                                .padding(.horizontal, 10.0)
                           )
                       But I got alot of errors

horizontal:

Skip is unable to determine the owning type for member 'horizontal'. Add the owning type (e.g. MyType.horizontal)

textFieldStyle :

This API is not yet available in Skip. Consider filing an issue against the owning library at https://github.com/skiptools, or see the library README for information on adding support

overlay:

Skip is unable to match this API call to determine whether it results in a View. Consider adding additional type information

aabewhite commented 11 months ago

Sorry for the trouble.

Skip does not yet support .textFieldStyle on Android. And that is likely contributing to the other errors, because chaining calls from an unsupported API will confuse the transpiler.

The documentation covers options when you encounter an unsupported API, but the easiest is typically to just accept the Android defaults and only customize on iOS:

 TextField("", text: .constant("Text"))
                       #if !SKIP
                        .textFieldStyle(.plain)
                        .padding(5.0)
                        .background(RoundedRectangle(cornerRadius: 5.0)
                            .fill(Color.white))
                        .padding(.horizontal, 10)
                        .overlay(
                            RoundedRectangle(cornerRadius: 5.0)
                                .stroke(.gray, lineWidth: 1.0)
                                .padding(.horizontal, 10.0)
                           )
                       #endif
aabewhite commented 10 months ago

Added support for TextStyle.plain in SkipUI 0.4.2