Skip to content

Commit f58e845

Browse files
Refactor: Apply padding on a per-screen basis
This change refactors the padding application from a global Scaffold modifier to a per-screen basis. - The global `padding(innerPadding)` is removed from the `Surface` in `MainActivity`. - `innerPadding` is now passed down to `AppNavigation` and then to individual screens (`MenuScreen`, `PhotoReasoningRoute`). - `MenuScreen` applies the full `innerPadding` to maintain its original layout. - `PhotoReasoningScreen` applies a custom padding, omitting the top padding to allow content to shift upwards.
1 parent 4889b08 commit f58e845

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

app/src/main/kotlin/com/google/ai/sample/MainActivity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import androidx.compose.foundation.layout.Spacer
4545
import androidx.compose.foundation.layout.fillMaxSize
4646
import androidx.compose.foundation.layout.fillMaxWidth
4747
import androidx.compose.foundation.layout.height
48+
import androidx.compose.foundation.layout.PaddingValues
4849
import androidx.compose.foundation.layout.padding
4950
import androidx.compose.material3.Button
5051
import androidx.compose.material3.Card

app/src/main/kotlin/com/google/ai/sample/MenuScreen.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,19 +358,19 @@ fun MenuScreen(
358358
@Composable
359359
fun MenuScreenPreview() {
360360
// Preview with trial not expired
361-
MenuScreen(isTrialExpired = false, isPurchased = false)
361+
MenuScreen(innerPadding = PaddingValues(), isTrialExpired = false, isPurchased = false)
362362
}
363363

364364
@Preview(showSystemUi = true)
365365
@Composable
366366
fun MenuScreenPurchasedPreview() {
367-
MenuScreen(isTrialExpired = false, isPurchased = true)
367+
MenuScreen(innerPadding = PaddingValues(), isTrialExpired = false, isPurchased = true)
368368
}
369369

370370
@Preview(showSystemUi = true)
371371
@Composable
372372
fun MenuScreenTrialExpiredPreview() {
373373
// Preview with trial expired
374-
MenuScreen(isTrialExpired = true, isPurchased = false)
374+
MenuScreen(innerPadding = PaddingValues(), isTrialExpired = true, isPurchased = false)
375375
}
376376

app/src/main/kotlin/com/google/ai/sample/feature/multimodal/PhotoReasoningScreen.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import androidx.activity.result.PickVisualMediaRequest
1212
import androidx.activity.result.contract.ActivityResultContracts
1313
import androidx.compose.foundation.layout.Box
1414
import androidx.compose.foundation.layout.Column
15+
import androidx.compose.foundation.layout.PaddingValues
1516
import androidx.compose.foundation.layout.Row
1617
import androidx.compose.foundation.layout.Spacer
1718
import androidx.compose.foundation.layout.fillMaxWidth
@@ -1075,6 +1076,7 @@ fun ErrorChatBubble(
10751076
fun PhotoReasoningScreenPreviewWithContent() {
10761077
MaterialTheme {
10771078
PhotoReasoningScreen(
1079+
innerPadding = PaddingValues(),
10781080
uiState = PhotoReasoningUiState.Success("This is a preview of the photo reasoning screen."),
10791081
commandExecutionStatus = "Command executed: Take screenshot",
10801082
detectedCommands = listOf(
@@ -1188,6 +1190,7 @@ val SystemMessageEntrySaver = Saver<SystemMessageEntry?, List<String?>>(
11881190
fun PhotoReasoningScreenPreviewEmpty() {
11891191
MaterialTheme {
11901192
PhotoReasoningScreen(
1193+
innerPadding = PaddingValues(),
11911194
isKeyboardOpen = false,
11921195
onStopClicked = {},
11931196
isInitialized = true

0 commit comments

Comments
 (0)