Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compose layout system doesn't handle additionalSafeAreaInsets correctly. #4944

Open
curliq opened this issue Jun 7, 2024 · 1 comment
Open
Assignees
Labels

Comments

@curliq
Copy link

curliq commented Jun 7, 2024

Describe the bug
When scrolling a LazyColumn inside a UIViewController, the scrolling is ignored by the SwiftUI components, for example scrolling the content will not trigger the TabView's bottombar transitions into showing the shadow and the blur, and with a navigation title it won't collapse and expand the top navigation bar/

Affected platforms

  • iOS

Versions

  • Libraries:
    • Compose Multiplatform version: 1.6.4
    • Navigation Multiplatform version (for related issues): n/a
  • Kotlin version: 1.9.22
  • OS version(s) iOS 17.0
  • OS architecture (x86 or arm64): xcode simulator
  • Device (model or simulator for iOS issues): iphone 15 pro max

To Reproduce
Steps to reproduce the behaviour:

  1. Run this code snippet:
    @Composable
    fun Screen() {
        LazyColumn(modifier = Modifier.fillMaxWidth()) {
         (0..200).forEach {
             item {
                 Text("test")
                 Spacer(modifier = Modifier.height(8.dp))
             }
         }
     }
    }
fun ScreenViewController() =
    ComposeUIViewController {
        Screen()
    }
@available(iOS 16.0, *)
@main
struct iOSApp: App {
    init() {
        IosModulesKt.startKoin()
    }
	var body: some Scene {
		WindowGroup {
			ContentView()
		}
	}
}

struct ContentView: View {
    var body: some View {
        TabView {
            Screen()
                .tabItem {
                    Label("Hello", systemImage: "gear")
                }
             // ... more tabs
        }
        .onAppear() {
            let standardAppearance = UITabBarAppearance()
            // this would be triggered if the content reaches the bottombar
            standardAppearance.configureWithTransparentBackground() 
            standardAppearance.backgroundColor = UIColor.systemGray6
            UITabBar.appearance().standardAppearance = standardAppearance
        }
    }
}

struct Screen: UIViewControllerRepresentable {
    func makeUIViewController(context: Context) -> UIViewController {
        return MainViewControllerKt.ScreenViewController()
    }

    func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
}


  1. Scroll down
  2. See error

Expected behavior
The content would be drawn behind the bottombar and the bottombar would become slightly transparent. This is just the standard tabview behaviour if you use a SwiftUI ScrollView or a List, instead of the compose UIViewController

Screenshots

Simulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-06-07.at.13.38.48.mp4

Example of an apple app with the tabview bottombar default behaviour:

Simulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-06-07.at.13.39.11.mp4

Additional context
I know the scrolling is handled by compose and is not an iOS native scroll but to be able to use compose in swiftUI it would be quite important to share scroll events

@curliq curliq added bug Something isn't working submitted labels Jun 7, 2024
@terrakok terrakok added enhancement New feature or request ios uikit interop and removed bug Something isn't working submitted labels Jun 7, 2024
@elijah-semyonov
Copy link
Contributor

elijah-semyonov commented Jun 7, 2024

Thought this issue is about scrolling, but it's about handling https://developer.apple.com/documentation/uikit/uiviewcontroller/2902284-additionalsafeareainsets coming from native UIViewControllers.

@elijah-semyonov elijah-semyonov changed the title Compose scrolling is ignored by SwiftUI scroll events Compose layout system doesn't handle additionalSafeAreaInsets correctly. Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants