LAB 3 — State, Input & Interactive UIs ======================================= Mobile Application Development | SUZA | Semester II 2025/2026 OBJECTIVES ---------- - Use mutableStateOf + remember / rememberSaveable - Handle TextField input with number keyboards - Hoist state from child to parent - Build Switch, Checkbox, and Slider controls EXERCISES --------- 1. Counter App - Display a number that starts at 0 - Two buttons: "+" increments, "-" decrements (not below 0) - A "Reset" button sets it back to 0 - Use rememberSaveable so rotation preserves the value 2. Tip Calculator Inputs: - Bill amount (numeric TextField) - Tip percentage (numeric TextField, default 15) - Switch: "Round up tip" Output: - Calculated tip (2 decimal places) - Total to pay Use state hoisting so the TipCalculator composable is reusable. 3. Name Badge Generator - TextField for first name - TextField for last name - Slider (0..72sp) for font size - ColorPicker row (4 circles: red, blue, green, black) — selecting sets badge colour Show live preview card under the inputs. 4. Simple Login Form - Email TextField with email keyboard type - Password TextField (visualTransformation = PasswordVisualTransformation()) - "Show password" Checkbox toggles the visual transformation - Login button: disabled until email contains "@" and password length >= 6 - On click: show a Toast or update a "status" Text. 5. Todo Mini-App (in-memory) - TextField + "Add" button appends to a mutableStateListOf - Each item shown in a Column with a "✕" delete button - Empty state text shown if the list is empty - Use state hoisting: TodoList(items, onAdd, onRemove) DISCUSSION QUESTIONS (write 2-3 sentences each in a NOTES.md) ------------------------------------------------------------ a. What is the difference between remember and rememberSaveable? Give a concrete example of when each one matters. b. Why is state hoisting valuable? Name a concrete benefit it brought to your Todo mini-app design. c. Why do Composables need to be "idempotent" (produce the same UI for the same inputs)? What breaks if they aren't? DELIVERABLES ------------ - Project "StateLab" with all 5 exercises as separate Composables - NOTES.md with answers to discussion questions - A short screen-recording (< 60 sec) of each app in action - Push to GitHub: "mad-lab03"