LAB 7 — Animation, Theming & Testing ====================================== Mobile Application Development | SUZA | Semester II 2025/2026 OBJECTIVES ---------- - Animate state changes with animate*AsState and AnimatedVisibility - Theme the app with Material 3 (light/dark + dynamic color on Android 12+) - Write Compose UI tests - Exercise accessibility (contentDescription, TalkBack) EXERCISES --------- 1. Expanding Profile Card - A Card that toggles between collapsed (height 100.dp) and expanded (height 260.dp) - Tap anywhere on the card to toggle - Animate the height with animateDpAsState - Animate the chevron icon rotation 0 → 180 degrees - Use AnimatedVisibility to show/hide the "bio" section 2. Crossfade Tabs - Three tabs (TabRow): "Home", "Stats", "About" - Use Crossfade(targetState = selectedTab) to transition between them - Each tab shows a different Composable 3. Light/Dark Theme Toggle - Add a Switch in the TopAppBar action area - Switching updates the whole app's theme immediately - Persist the choice using DataStore (so it survives restarts) - Verify readability in both modes 4. Dynamic Color (Android 12+) - In your AppTheme, use dynamicLightColorScheme / dynamicDarkColorScheme when Build.VERSION.SDK_INT >= S - Change the system wallpaper and observe the theme adapting TESTING ------- 5. Unit Test — Tip Calculator Create src/test/java/.../TipCalculatorTest.kt @Test fun calculatesTipCorrectly() { assertEquals(15.0, calculateTip(100.0, 15.0), 0.001) } Add 3 more cases, including edge (0.0 bill, 100% tip). 6. Compose UI Test — Counter In src/androidTest add: @get:Rule val rule = createComposeRule() @Test fun counter_incrementsOnClick() { ... } Verify: - Initial text "Count: 0" - After clicking "+", text is "Count: 1" 7. Accessibility Audit - Turn on TalkBack on a device - Navigate your Student Registry app (from Lab 5) with TalkBack - Identify: * Any images/icons missing contentDescription * Any tap targets < 48dp * Any colour contrast issues - Fix them and document before/after in NOTES.md DELIVERABLES ------------ - Project "AnimationLab" on GitHub as "mad-lab07" - Screen recording of expanding card & crossfade tabs - Screenshot of light/dark theme - Test report (JUnit console output or HTML report) - NOTES.md with accessibility audit findings & fixes