CS 3180 Mobile Application Development

Week 6 Monday: Lists, App Bars, and Dialogs

CS 3180 Mobile Application Development

Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

Today’s Topics

  1. Quiz 2 (Weeks 4–5)
  2. LazyColumn essentials and performance
  3. App bars and dialogs
Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

Part 1: Quiz 2

Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

Quiz 2 Logistics

  • 10–12 minutes
  • Closed notes
  • Compose + state fundamentals
  • ViewModel lifecycle basics
Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

Part 2: Lists with LazyColumn

Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

Why LazyColumn?

Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

Why LazyColumn? (continued)

  • Renders only visible rows
Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

Why LazyColumn? (continued)

  • Renders only visible rows
  • Recycles item content efficiently
Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

Why LazyColumn? (continued)

  • Renders only visible rows
  • Recycles item content efficiently
  • Smooth scrolling with large datasets
Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

Why LazyColumn? (continued)

  • Renders only visible rows
  • Recycles item content efficiently
  • Smooth scrolling with large datasets
  • Built-in item keys and animations
Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

Core LazyColumn Pattern

val holes = (1..18).toList()

LazyColumn(
    contentPadding = PaddingValues(16.dp),
    verticalArrangement = Arrangement.spacedBy(8.dp)
) {
    items(holes, key = { it }) { hole ->
        Text("Hole $hole")
    }
}
Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

List Item as a Composable

@Composable
fun HoleRow(holeNumber: Int, par: Int, score: Int?) {
    Row(
        modifier = Modifier
            .fillMaxWidth()
            .padding(12.dp),
        horizontalArrangement = Arrangement.SpaceBetween
    ) {
        Text("Hole $holeNumber")
        Text("Par $par")
        Text(score?.toString() ?: "—")
    }
}
Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

Common LazyColumn Mistakes

Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

Common LazyColumn Mistakes (continued)

  • No stable keys when list order changes
Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

Common LazyColumn Mistakes (continued)

  • No stable keys when list order changes
  • Putting heavy work in row composables
Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

Common LazyColumn Mistakes (continued)

  • No stable keys when list order changes
  • Putting heavy work in row composables
  • Nesting a LazyColumn inside a Column with scroll
Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

Common LazyColumn Mistakes (continued)

  • No stable keys when list order changes
  • Putting heavy work in row composables
  • Nesting a LazyColumn inside a Column with scroll
  • Forgetting item padding/spacing
Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

Part 3: App Bars and Dialogs

Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

Top App Bar Basics

TopAppBar(
    title = { Text("Hope Foundation Scores") },
    navigationIcon = {
        IconButton(onClick = onBack) {
            Icon(Icons.Default.ArrowBack, contentDescription = "Back")
        }
    },
    actions = {
        IconButton(onClick = onShare) {
            Icon(Icons.Default.Share, contentDescription = "Share")
        }
    }
)
Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

App Bar Patterns

Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

App Bar Patterns (continued)

  • TopAppBar for standard screens
Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

App Bar Patterns (continued)

  • TopAppBar for standard screens
  • CenterAlignedTopAppBar for brand emphasis
Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

App Bar Patterns (continued)

  • TopAppBar for standard screens
  • CenterAlignedTopAppBar for brand emphasis
  • SmallTopAppBar vs LargeTopAppBar for scroll behavior
Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

App Bar Patterns (continued)

  • TopAppBar for standard screens
  • CenterAlignedTopAppBar for brand emphasis
  • SmallTopAppBar vs LargeTopAppBar for scroll behavior
  • Add actions only when they are frequent and safe
Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

Dialog Basics

if (showConfirm) {
    AlertDialog(
        onDismissRequest = { showConfirm = false },
        title = { Text("Reset Scores?") },
        text = { Text("This will clear all 18 holes.") },
        confirmButton = {
            TextButton(onClick = onReset) { Text("Reset") }
        },
        dismissButton = {
            TextButton(onClick = { showConfirm = false }) { Text("Cancel") }
        }
    )
}
Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

Dialog Design Guidelines

Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

Dialog Design Guidelines (continued)

  • Use for destructive actions (reset, delete)
Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

Dialog Design Guidelines (continued)

  • Use for destructive actions (reset, delete)
  • Keep text short and specific
Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

Dialog Design Guidelines (continued)

  • Use for destructive actions (reset, delete)
  • Keep text short and specific
  • Provide clear action labels
Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

Dialog Design Guidelines (continued)

  • Use for destructive actions (reset, delete)
  • Keep text short and specific
  • Provide clear action labels
  • Allow cancel/dismiss without penalty
Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

Wrap-Up and Next Steps

Week 6 Monday: Lists, App Bars, and Dialogs
CS 3180 Mobile Application Development

Checkpoint for Today

  • LazyColumn essentials + keys
  • Top app bar structure
  • AlertDialog patterns
  • Wednesday: build a contacts list demo
Week 6 Monday: Lists, App Bars, and Dialogs

SPEAKER NOTES: Welcome to Week 6! Today we focus on three everyday UI needs for our Hope Foundation golf app: lists, app bars, and dialogs. Hook: "Your app is useless if the user can’t scroll through 18 holes, access actions, or confirm changes." We’ll solve all three.

SPEAKER NOTES: We start with Quiz 2, then move into the core Compose tools for lists. We’ll close with app bars and dialogs, which we’ll build out further on Wednesday.

SPEAKER NOTES: Quiz 2 covers Weeks 4–5: Compose basics, state, and ViewModels. Keep this short and focused.

SPEAKER NOTES: Confirm timing and expectations. Remind students that the quiz mirrors common mistakes from recent labs.

SPEAKER NOTES: Lists are how users navigate data. For Hope Foundation, think: scorecards, team rosters, and hole summaries.

SPEAKER NOTES: We use LazyColumn because it only composes what’s on screen. It’s memory-efficient and fast.

SPEAKER NOTES: This prevents building all 18 holes at once when only 6 fit on screen.

SPEAKER NOTES: The list manages composition and reuse, similar to RecyclerView but with simpler APIs.

SPEAKER NOTES: Scrolling stays smooth even with hundreds of items. This matters for lists like golfer histories.

SPEAKER NOTES: Keys are critical to avoid item state bugs when lists change.

SPEAKER NOTES: Point out three essentials: content padding, spacing, and stable keys. Keys preserve item identity.

SPEAKER NOTES: Keep list rows small and reusable. When UI grows, splitting components keeps code readable.

SPEAKER NOTES: Let’s highlight pitfalls that cause stuttering or incorrect list behavior.

SPEAKER NOTES: Without keys, Compose might reuse state incorrectly. This can show the wrong score in the wrong row.

SPEAKER NOTES: Don’t parse JSON or run complex calculations inside a row. Precompute outside.

SPEAKER NOTES: Avoid nested scrolls. Use a single LazyColumn and include headers/footers.

SPEAKER NOTES: Spacing is usability, not decoration. Make rows tap-friendly.

SPEAKER NOTES: App bars provide navigation and actions. Dialogs handle confirmations and data entry.

SPEAKER NOTES: Explain the three slots: title, navigation icon, actions. Actions are right-side icons.

SPEAKER NOTES: Use the right app bar type depending on context.

SPEAKER NOTES: Default choice for most screens.

SPEAKER NOTES: Center aligned is useful for branding or a prominent title.

SPEAKER NOTES: Large app bars can collapse on scroll. We’ll demo this later in the term.

SPEAKER NOTES: Actions should be common tasks, not destructive ones.

SPEAKER NOTES: Dialogs should always have clear confirm/dismiss options. Note `onDismissRequest` for taps outside.

SPEAKER NOTES: Dialogs should be rare and purposeful. They interrupt the flow.

SPEAKER NOTES: Confirmations prevent accidental loss.

SPEAKER NOTES: “Reset scores” is better than “Are you sure?”

SPEAKER NOTES: Use verbs like “Delete,” “Reset,” “Save.” Avoid vague labels.

SPEAKER NOTES: Users should always be able to back out safely.

SPEAKER NOTES: Summarize what we covered and connect to Wednesday’s demo.

SPEAKER NOTES: Preview Wednesday: we’ll build a list with app bar actions and dialogs from scratch.