TabView adds the status bar inset as top padding when it doesn't touch the top of the window (blank band below a view stacked above it)

Abierto
#604 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 5 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
52/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
swift
Área
frontend, mobile

Línea de trabajo

Start in Containers/TabView.swift near the reported tab entry content and Containers/Navigation.swift near topBarWindowInsets; trace how IgnoresSafeAreaLayout determines top-edge adjacency. Reproduce the issue with the supplied SwiftUI example on Android with edge-to-edge enabled, then verify both the blank band and navigation bar inset disappear when the TabView is below the banner.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Versions: Skip 1.9.20, skip-ui 1.66.3, skip-fuse-ui 1.19.4 (Skip Fuse), Android 16 (API 36) emulator, Pixel 9
system image; edge-to-edge (the default).

Minimal reproduction

import SwiftUI

struct ContentView: View {
    var body: some View {
        VStack(spacing: 0) {
            // Any view above the TabView, for example a banner.
            Text("Banner")
                .frame(maxWidth: .infinity, minHeight: 60)
                .background(Color.blue.ignoresSafeArea(edges: .top))
            TabView {
                Tab("One", systemImage: "house") {
                    NavigationStack {
                        Text("Content")
                            .navigationTitle("One")
                    }
                }
                Tab("Two", systemImage: "list.bullet") {
                    NavigationStack {
                        Text("Content")
                            .navigationTitle("Two")
                    }
                }
            }
        }
    }
}

Expected (what iOS does): the navigation bar starts directly under the banner. The banner already sits below the
status bar, so nothing below it should be inset for the status bar again.

Actual (Android): a blank band about the status bar's height appears between the banner and the navigation bar,
in the TabView's background color. The top app bar also includes the status bar inset in its own height, so the title
sits lower still.

Where it seems to come from (reading skip-ui 1.66.3):

  1. Containers/TabView.swift, in the tab entry content (around line 501):
    let topPadding = ignoresSafeAreaEdges.contains(.top) ? windowSafeDrawingInsets().asPaddingValues().calculateTopPadding() : 0.dp.
    ignoresSafeAreaEdges is [.bottom, .top] intersected with absoluteSystemBarEdges, so it contains .top
    whenever the window has a top system bar, whether or not this TabView is adjacent to the top edge.
    IgnoresSafeAreaLayout already tracks adjacency (the edges it passes to its content); using that here (only pad
    when the TabView actually expanded into the top inset) looks like the fix.
  2. Containers/Navigation.swift (around line 495): topBarWindowInsets is TopAppBarDefaults.windowInsets whenever
    absoluteSystemBarEdges contains .top, again regardless of whether the stack touches the top. The same adjacency
    check would avoid the second inset.

Workarounds tried: consuming WindowInsets.statusBars above the TabView removes the top bar's copy (Material 3
respects consumed insets), but not the TabView's fixed padding; safeAreaInset and safeAreaPadding are unavailable
in SkipUI, and EnvironmentValues._safeArea is internal, so app code can't mark the top edge as handled.

Lenguaje dominante
Swift
Estrellas
332
Forks
91
Merge medio
4 d 9 h
PR fusionados (30 d)
10

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de skiptools/skip-ui

Todos los issues de skiptools/skip-ui

Issues similares

Más issues de Swift

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.