Welcome back for the first features like the model year, acceleration, weight, horsepower, displacement,
cylinders.
We specified a text fields and allow the user to enter data inside the text fields.
Now we're going to make for the origin parameter.
For the origin feature, we're going to allow the user to select one of the buttons.
One of the origins European American Japanese.
So we're going to allow the user to select only one button from the group.
So for that create a new Kotlin file inside the screens package.
Name it as origin chip.
So we're going to create a chip composable function text a string selected boolean and on click lambda
expression okay.
Start with filter chip.
Set the selected to selected on click to unclick and the label a new text with with the parameter text
that it's best filter chip is a Material Design component in Jetpack Compose that allows users to select
multiple options from a set.
It's commonly used for filtering and categorizing.
Okay, so we're going to use it for selecting the origin of the car back to our car features form.
Under this text create a new row.
Set the modifier to modifier dot fill maximum width horizontal arrangement space evenly alt plus enter
to add this arrangement dot space evenly and here inside this row, start creating the first origin
chip.
Set the text for American selected.
Set the car origin to one F and on click on features changed car features dot copy.
We need to convert to this form, so please pay attention to me.
The first chip, the origin chip named as American set the selected The car features one equals to one
f.
Back to car features.
Here we need to set the origin 1 to 1 f.
But the problem here that our model needs only one origin.
We need to pass only one origin.
And the value for the origin one is one, American one, European two, and Japanese three.
To solve this problem, we need to set the other ones the other origins to zeros.
So here this is what we've did since it's American and it's uh it's number is one.
So here we set the origin one equals to one which is true.
The origin two is false and origin three is false or zero okay.
So this is how we specify the American origin.
The similar to what we've done here.
Let me copy this origin and paste it to here and change the American to European set.
The car features origin to to 1 F and the origin here set it to zero, the origin 2 to 1 and origin
three equals to zero.
Similar to this, we're going to copy the European and paste it here for the Japanese.
So we have American.
We have European.
And now Japanese set the origin to three equals to one.
And set the origin to to zero and make the origin three equals to one f okay.
So this is our origin chips.
Now let's call this function and run our application to see the results.
So car features four.
Copy this and let's go to Car Mileage Predictor inside the input form.
Let me call this composable.
And we need we need to pass the parameters the car features or features chains and validation errors.
In the next video we're going to create those variables and run our application.