1 - Install jitpack in your project in your (settings.gradle.kts)
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url = uri("https://jitpack.io") } //add me please
}
}
2 - Add jetpack-compose-brazilian-currency-visual-transformation dependency in your build.gradle.app (module app)
dependencies {
implementation("com.github.eliezerBrasilian:jetpack-compose-brazilian-currency-visual-transformation:v1.0.1") //add me
//...
}
video_recorder.mp4
You only need to pass the BrazilianCurrencyVisualTransformation on VisualTransformation as show below in this example
//...
import com.braziliancurrencyvisualtransformation.BrazilianCurrencyVisualTransformation
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MoedaBrasileiraTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
var valueInput by remember { mutableStateOf("") }
OutlinedTextField(
value = valueInput,
onValueChange = {
valueInput = it
},
visualTransformation = BrazilianCurrencyVisualTransformation(),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
)
}
}
}
}
}