Quick start
Two steps: provide a skin and theme once at the top of the app, then use components anywhere below it.
1. Add the provider
The provider goes above your navigation, so dialogs, menus and sheets inherit the skin and theme too.
- Kotlin
- Dart
import androidx.compose.runtime.Composable
import com.srctool.camouflage.core.provider.CamouflageProvider
import com.srctool.camouflage.skin.material.MaterialSkin
import com.srctool.camouflage.skin.material.materialTheme
@Composable
fun App() {
CamouflageProvider(skin = MaterialSkin, theme = materialTheme()) {
SignUpScreen()
}
}
2. Build a screen
- Kotlin
- Dart
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import com.srctool.camouflage.core.button.CamoButton
import com.srctool.camouflage.core.checkbox.CamoCheckbox
import com.srctool.camouflage.core.provider.Camouflage
import com.srctool.camouflage.core.surface.CamoSurface
import com.srctool.camouflage.core.text.CamoText
import com.srctool.camouflage.core.textfield.CamoTextField
@Composable
fun SignUpScreen() {
var email by remember { mutableStateOf("") }
var terms by remember { mutableStateOf(false) }
val spacing = Camouflage.spacing
CamoSurface(Modifier.fillMaxWidth()) {
Column(
Modifier.padding(spacing.l),
verticalArrangement = Arrangement.spacedBy(spacing.m),
) {
CamoText("Create your account")
CamoTextField(value = email, onValueChange = { email = it }, label = "Email")
CamoCheckbox(checked = terms, onCheckedChange = { terms = it }, label = "I agree to the terms")
CamoButton(
text = "Sign up",
onClick = { /* submit */ },
enabled = terms && email.isNotEmpty(),
modifier = Modifier.fillMaxWidth(),
)
}
}
}
Notice what is not here: no colors, no fonts, no shapes. The spacing comes from the theme (spacing.l), everything else from the skin.
3. Change the look
Swap the two arguments of the provider. Nothing else changes.
- Kotlin
- Dart
CamouflageProvider(skin = CupertinoSkin, theme = cupertinoTheme()) { SignUpScreen() }
CamouflageProvider(skin = CarbonSkin, theme = carbonTheme()) { SignUpScreen() }
Next: make the theme your own.