mirror of
https://github.com/bitwarden/android.git
synced 2026-05-03 21:58:40 -05:00
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
2.0 KiB
2.0 KiB
Compose UI Patterns Quick Reference
Quick reference for Bitwarden Android Compose UI patterns during code reviews. For comprehensive details, read docs/ARCHITECTURE.md and docs/STYLE_AND_BEST_PRACTICES.md.
Component Reuse
✅ GOOD - Uses existing components:
BitwardenButton(
text = "Submit",
onClick = onSubmit
)
BitwardenTextField(
value = text,
onValueChange = onTextChange,
label = "Email"
)
❌ BAD - Duplicates existing components:
// ❌ Recreating BitwardenButton
Button(
onClick = onSubmit,
colors = ButtonDefaults.buttonColors(
containerColor = BitwardenTheme.colorScheme.primary
)
) {
Text("Submit")
}
Key Rules:
- Check
:uimodule for existing components before creating custom ones - Use BitwardenButton, BitwardenTextField, etc. for consistency
- Place new reusable components in
:uimodule
Theme Usage
✅ GOOD - Uses theme:
Text(
text = "Title",
style = BitwardenTheme.typography.titleLarge,
color = BitwardenTheme.colorScheme.primary
)
Spacer(modifier = Modifier.height(16.dp)) // Standard spacing
❌ BAD - Hardcoded values:
Text(
text = "Title",
style = TextStyle(fontSize = 24.sp, fontWeight = FontWeight.Bold), // Use theme
color = Color(0xFF0066FF) // Use theme color
)
Spacer(modifier = Modifier.height(17.dp)) // Non-standard spacing
Key Rules:
- Use
BitwardenTheme.colorSchemefor colors - Use
BitwardenTheme.typographyfor text styles - Use standard spacing (4.dp, 8.dp, 16.dp, 24.dp)
Quick Checklist
UI Patterns
- Using existing Bitwarden components from
:uimodule? - Using BitwardenTheme for colors and typography?
- Using standard spacing values (4, 8, 16, 24 dp)?
- No hardcoded colors or text styles?
- UI is stateless (observes state, doesn't modify)?
For comprehensive details, always refer to:
docs/ARCHITECTURE.md- Full architecture patternsdocs/STYLE_AND_BEST_PRACTICES.md- Complete style guide