Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ package com.example.android.architecture.blueprints.todoapp.addedittask

import androidx.annotation.StringRes
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.ime
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
Expand Down Expand Up @@ -67,7 +70,9 @@ fun AddEditTaskScreen(
snackbarHostState: SnackbarHostState = remember { SnackbarHostState() }
) {
Scaffold(
modifier = modifier.fillMaxSize(),
modifier = modifier
.fillMaxSize()
.windowInsetsPadding(WindowInsets.ime),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better readability and conciseness, you can use the imePadding() modifier, which is a shorthand for windowInsetsPadding(WindowInsets.ime).

Using it will simplify the code here and also reduce the number of imports needed. You'll need to replace import androidx.compose.foundation.layout.WindowInsets, import androidx.compose.foundation.layout.ime, and import androidx.compose.foundation.layout.windowInsetsPadding with a single import androidx.compose.foundation.layout.imePadding.

Suggested change
modifier = modifier
.fillMaxSize()
.windowInsetsPadding(WindowInsets.ime),
modifier = modifier
.fillMaxSize()
.imePadding(),

snackbarHost = { SnackbarHost(snackbarHostState) },
topBar = { AddEditTaskTopAppBar(topBarTitle, onBack) },
floatingActionButton = {
Expand Down