Giter Club home page Giter Club logo

form-conductor's Introduction

Hi ๐Ÿ‘‹, I'm Naing Aung Luu @Harry

An aspiring android developer/tech lead from Myanmar ๐Ÿ‡ฒ๐Ÿ‡ฒ.

naingaungluu

harryluu_96

  • ๐Ÿ”ญ Iโ€™m currently working on Form Conductor

  • ๐ŸŒฑ Iโ€™m currently learning Systems Designs, DSA, and Dev-ops

  • ๐Ÿค Iโ€™m looking for help with Form Conductor

  • ๐Ÿ“ I regularly write articles on blog.naingaungluu.me

  • ๐Ÿ’ฌ Ask me about android, kotlin, and cloud

  • ๐Ÿ“ซ How to reach me [email protected]

Blogs posts

Connect with me:

harryluu_96 naing-aung-luu-6113b7192 @naingaungluu harryluu

Languages and Tools:

android arduino bash blender circleci docker figma firebase git graphql java javascript jekyll kotlin linux mysql nodejs postman vuejs vuepress

Support:

naingaungluu



ย naingaungluu

naingaungluu

form-conductor's People

Contributors

naingaungluu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

form-conductor's Issues

Button not enabled during UI Test

I'm a beginner in android compose. I don't know what went wrong in my code. The button won't enabled during UI test but working during manual testing.

rule.onNode(signInButton).assertIsNotEnabled()

rule.onNode(emailField).assertIsNotFocused()
rule.onNode(emailField).performClick()
rule.onNode(emailField).performTextInput("[email protected]")
rule.onNode(emailField).performImeAction()

rule.onNode(signInButton).assertIsNotEnabled()

rule.onNode(passwordField).assertIsFocused()
rule.onNode(passwordField).performTextInput("password")
rule.onNode(passwordField).performImeAction()

rule.onNode(signInButton).assertIsEnabled() // Failed to assert because the button is disabled

Please advise. Thank you

Edit: I think i know the problem. Compose isn't recompose yet during check assertIsEnabled. But still didn't understand how to fix it

Support Validation Priorities

We'll need to support priority values in form field annotations to specify the order in which they are validated

IDEA

@Form
data class FormData(
    @Priority(2)
    val emailAddress: String,
    
    @Priority(1)
    val name: String,

    @Priority(3)
    val countryCode: String,

    @Priority(4)
   val mobileNumber: String 
)

Incompatible with kotlinx-serialization

import com.boe.itc.b4client.utlis.Required
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import me.naingaungluu.formconductor.annotations.Form

@Form
@Serializable
data class User(
    @SerialName("userId")
    @Required("User ID is required")
    val userName: String = "",
    @SerialName("password")
    @Required("Password is required")
    val password: String = ""
)

Use kotlinx-serialization will report errors

java.lang.IllegalArgumentException: Form data class 'User' needs to have a default constructor parameters.
                 Following parameters need to have a default value in the constructor:
                 [seen1, userName, password, serializationConstructorMarker]

The default state of the form is incorrect

Form

@Form
@JsonClass(generateAdapter = true)
data class User(
    @Json(name = "userId")
    @MinLength(1)
    val userName: String = "",
    @Json(name = "password")
    @MinLength(1)
    val password: String = ""
)

Compose

Column {
        form(User::class) {
            field(User::userName) {
                TextField(
                    value = state.value?.value.orEmpty(),
                    onValueChange = this::setField
                )
            }
            field(User::password) {
                TextField(
                    value = state.value?.value.orEmpty(),
                    onValueChange = this::setField
                )
            }
            val formResult = this.formState.value
            Button(
                enabled = formResult is FormResult.Success,
                onClick = {
                    
                }
            ) {
                Text(text = "Login")
            }
        }
    }

When I type nothing, the default button state is available

err message

if we have not one validator and for every validator toast different message ,how can i achieve this

Can we use it in custom input?

I have my custom text field input, like below:
`form(RegisterRequestDto::class) {
Column(
modifier = Modifier
.fillMaxWidth()
.constrainAs(contentColumn) {
top.linkTo(parent.top)
bottom.linkTo(button.top, margin = (200).dp)
start.linkTo(parent.start)
end.linkTo(parent.end)
}
) {
field(fieldClass = RegisterRequestDto::name) {
InputTextField(
labelValue = stringResource(id = R.string.text_name),
onTextChanged = {
registerViewModel.onTriggerEvent(RegisterEvent.NameChanged(it))
}
)
}
LargeSpacer()
field(fieldClass = RegisterRequestDto::email) {
InputTextField(
labelValue = stringResource(id = R.string.text_email),
onTextChanged = {
registerViewModel.onTriggerEvent(RegisterEvent.EmailChanged(it))
}
)
}
LargeSpacer()
field(fieldClass = RegisterRequestDto::password) {
PasswordTextField(
labelValue = stringResource(id = R.string.text_password),
onTextChanged = {
registerViewModel.onTriggerEvent(RegisterEvent.PasswordChanged(it))
}
)
}
LargeSpacer()
field(fieldClass = RegisterRequestDto::confirmPassword) {
PasswordTextField(
labelValue = stringResource(id = R.string.text_confirm_password),
onTextChanged = {
registerViewModel.onTriggerEvent(
RegisterEvent.ConfirmPasswordChanged(
it
)
)
}
)
}
}

            ButtonView(
                value = stringResource(id = R.string.text_register),
                onButtonClicked = {
                    registerViewModel.onTriggerEvent(RegisterEvent.DoRegister)
                    navigator.openLogin()
                },
                isEnabled = this.formState.value is FormResult.Success,
                modifier = Modifier
                    .constrainAs(button) {
                        bottom.linkTo(parent.bottom)
                        start.linkTo(parent.start)
                        end.linkTo(parent.end)
                    }
            )
        }
    }`

Is i'm doing it correctly? Because the validation is not working

Dynamic Evaluation of Mandatory/Optional flag

We'll need to support evaluation of whether a field should be Mandatory or Optional at runtime based on the current form state.

IDEA

  • Develop a new type of annotation class or ValidationRule with access to current form state at the time of validation.
  • Then develop a new type of field annotation with reference to Rule implementation

Feature requested by Issue #34

How to get form data for onClick handler?

I was wondering how to get the data out of the form and into somewhere an onClick handler can access it? I am getting the usual error @Composable invocations can only happen from the context of an @Composable function.

I assume calling a onClick handler with the form data is a popular option so it may be good to add to the sample.

This may be really obvious, I am new to Jetpack compose ๐Ÿ™ƒ

java.lang.NullPointerException during submit formData

Let's say you have this simple form

@Form
data class SignUpForm(
    @Optional
    @MaxLength(150)
    val address: String? = null
)

In the UI using effect you update the form by submitting it

form(SignUpForm::class) {
    // formData is SignUpForm == true
    // formData = SignUpForm()
    LaunchedEffect(formData) { submit(formData) }
}

This causing an error like this

FATAL EXCEPTION: main
Process: com.bangkit.coffee, PID: 26216
java.lang.NullPointerException: null cannot be cast to non-null type kotlin.Any
    at me.naingaungluu.formconductor.FormImpl.submit(FormImpl.kt:183)
    at me.naingaungluu.formconductor.composeui.scope.FormScopeImpl.submit(FormScopeImpl.kt:29)
    ...

But if you change the default into empty string instead null, the problem is gone

val address: String? = ""

The problem exists if you update the form via submit()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.