-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from jkuatdsc/bugfix/initial-values
[Bug fix] Non-editable fields
- Loading branch information
Showing
8 changed files
with
28 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,24 +32,13 @@ class MainActivity : ComponentActivity() { | |
@Composable | ||
fun Content() { | ||
val formState: FormState<BaseState<out Any>> = remember { viewModel.formState } | ||
val ageState: TextFieldState = formState.getState<TextFieldState>("age").also { | ||
it.change(23.toString()) | ||
} | ||
val emailState: TextFieldState = formState.getState<TextFieldState>("email").also { | ||
it.change("[email protected]") | ||
} | ||
val passwordState: TextFieldState = formState.getState<TextFieldState>("password").also { | ||
it.change("123456") | ||
} | ||
val genderState: ChoiceState = formState.getState<ChoiceState>("gender").also { | ||
it.change("Male") | ||
} | ||
val happinessState: TextFieldState = formState.getState<TextFieldState>("happiness").also { | ||
it.change(0.1.toString()) | ||
} | ||
val hobbiesState: SelectState = formState.getState<SelectState>("hobbies").also { | ||
it.select("Reading") | ||
} | ||
val ageState: TextFieldState = formState.getState("age") | ||
val genderState: ChoiceState = formState.getState("gender") | ||
val emailState: TextFieldState = formState.getState("email") | ||
val passwordState: TextFieldState = formState.getState("password") | ||
val happinessState: TextFieldState = formState.getState("happiness") | ||
val hobbiesState: SelectState = formState.getState<SelectState>("hobbies") | ||
|
||
val scrollState = rememberScrollState() | ||
|
||
Column( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,11 +13,13 @@ class MainViewModel : ViewModel() { | |
val formState = FormState( | ||
fields = listOf( | ||
ChoiceState( | ||
initial = "Male", | ||
name = "gender", | ||
validators = listOf(Validators.Required(message = "you need to specify your gender")) | ||
), | ||
TextFieldState( | ||
name = "email", | ||
initial = "[email protected]", | ||
transform = { it.trim().lowercase() }, | ||
validators = listOf(Validators.Email()), | ||
), | ||
|
@@ -27,6 +29,7 @@ class MainViewModel : ViewModel() { | |
), | ||
TextFieldState( | ||
name = "age", | ||
initial = "18", | ||
transform = { it.toInt() }, | ||
validators = listOf(Validators.MinValue(limit = 18, message = "too young")) | ||
), | ||
|
@@ -36,6 +39,7 @@ class MainViewModel : ViewModel() { | |
validators = listOf(Validators.Required(message = "how happy are you?")) | ||
), | ||
SelectState( | ||
initial = mutableListOf("Chess"), | ||
name = "hobbies", | ||
validators = listOf( | ||
Validators.Required(message = "pick at least one hobby") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Thu Feb 17 16:08:59 EAT 2022 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip | ||
distributionPath=wrapper/dists | ||
zipStorePath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME |