Skip to content

Commit becddaa

Browse files
committed
fix(ui): stop the status banner doubling screens' own status-bar padding
Several screens apply their own statusBarsPadding()/Scaffold inset (ThreadsOverviewActivity, DiagnosisActivity, LogsActivity, ConversationCreationActivity, ContactsScreen, LocationPickerScreen) assuming they sit at the true top of the window. Once StatusBannerRow is visible it already claims that inset for itself, so those screens' own padding added a second, redundant gap on top of it (e.g. an oversized app bar in "new conversation"). setContentWithStatusBanner now marks the status-bar inset consumed for content() whenever the banner is showing, so screens' existing statusBarsPadding() calls add nothing extra in that case. Fixed once centrally since some of the affected composables (ContactsScreen, LocationPickerScreen) have no access to the banner state to guard against it themselves. Assisted-by: Claude Code:claude-sonnet-5 Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
1 parent 340e63d commit becddaa

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

app/src/main/java/com/nextcloud/talk/activities/BaseActivity.kt

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,15 @@ import android.widget.Toast
2727
import androidx.activity.compose.setContent
2828
import androidx.appcompat.app.AlertDialog
2929
import androidx.appcompat.app.AppCompatActivity
30+
import androidx.compose.foundation.layout.Box
3031
import androidx.compose.foundation.layout.Column
32+
import androidx.compose.foundation.layout.WindowInsets
33+
import androidx.compose.foundation.layout.consumeWindowInsets
34+
import androidx.compose.foundation.layout.fillMaxSize
35+
import androidx.compose.foundation.layout.statusBars
3136
import androidx.compose.runtime.Composable
3237
import androidx.compose.runtime.getValue
38+
import androidx.compose.ui.Modifier
3339
import androidx.core.content.res.ResourcesCompat
3440
import androidx.core.view.ViewCompat
3541
import androidx.core.view.WindowInsetsCompat
@@ -128,9 +134,26 @@ open class BaseActivity : AppCompatActivity() {
128134
setContent {
129135
val isOnline by networkMonitor.isOnline.collectAsStateWithLifecycle()
130136
val isMaintenanceMode by maintenanceModeFlow.collectAsStateWithLifecycle()
131-
Column {
137+
val showBanner = !isOnline || isMaintenanceMode
138+
Column(modifier = Modifier.fillMaxSize()) {
132139
StatusBannerRow(isOffline = !isOnline, isMaintenanceMode = isMaintenanceMode)
133-
content()
140+
// content() itself emits bare sibling composables (e.g. ColoredStatusBar() next to
141+
// the screen), which rely on being at the composition root to overlay rather than
142+
// stack. Confining them to a single weighted Box here preserves that overlay
143+
// behavior while still reserving exactly the space below the banner for them.
144+
//
145+
// Several screens also apply their own statusBarsPadding()/Scaffold insets that
146+
// assume they sit at the true top of the window. Once the banner is visible it has
147+
// already claimed that inset (StatusBannerRow pads itself for it), so mark it
148+
// consumed here — any statusBarsPadding() further down then adds nothing extra,
149+
// avoiding a doubled gap under the banner.
150+
Box(
151+
modifier = Modifier
152+
.weight(1f)
153+
.let { if (showBanner) it.consumeWindowInsets(WindowInsets.statusBars) else it }
154+
) {
155+
content()
156+
}
134157
}
135158
}
136159
}

0 commit comments

Comments
 (0)