teogor / ceres

🪐 Ceres is a comprehensive Android development framework designed to streamline your app development process. Powered by the latest technologies like Jetpack Compose, Hilt, Coroutines, and Flow, Ceres empowers developers to build modern and efficient Android applications.

Home Page:https://source.teogor.dev/ceres

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow Optional Status Bar Padding in FullScreenLayoutBase

zeoowl-dev opened this issue · comments

Is there an existing issue for this?

  • I have searched the existing issues

Is there a StackOverflow question about this issue?

  • I have searched StackOverflow

What happened?

Currently, the FullScreenLayoutBase function in the dev.teogor.ceres.screen.core.layout package adds status bar padding unconditionally. While this can be useful in some cases, it also prevents the layout from being truly full-screen when padding is not needed.

Proposed Solution:

We suggest making the status bar padding optional, allowing the user to decide whether they want to add padding to the status bar or not. This change will give users more flexibility in creating full-screen layouts.

Steps to Reproduce:

  1. Use the FullScreenLayoutBase function with hasStatusBar set to true.
  2. Observe that the status bar padding is added, which is not always desired.

Expected Behavior:

Users should be able to choose whether to add status bar padding in the FullScreenLayoutBase function.

Actual Behavior:

Status bar padding is added unconditionally, which may not be suitable for all use cases.

Relevant logcat output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Thank you for reporting this issue. In response to the concern you raised about the FullScreenLayoutBase function, I've made the necessary changes to allow for optional status bar padding.

With this update, users can now decide whether they want to add status bar padding or not by setting the hasStatusBar parameter when using the FullScreenLayoutBase function.

Here's an example of how to use it:

// Add status bar padding
FullScreenLayoutBase(
  screenName = "YourScreenName",
  backgroundColor = Color.White, // Background color
  hasStatusBar = true, // Add status bar padding
) {
  // Your content here
}

// Without status bar padding
FullScreenLayoutBase(
  screenName = "YourScreenName",
  backgroundColor = Color.White, // Background color
  hasStatusBar = false, // Do not add status bar padding
) {
  // Your content here
}

Thank you for reporting this issue. In response to the concern you raised about the FullScreenLayoutBase function, I've made the necessary changes to allow for optional status bar padding. Below is the updated code with JavaDoc comments included for clarity:

/**
 * A composable that provides a full-screen layout with optional status bar padding.
 *
 * @param screenName The name of the screen (for tracking purposes).
 * @param backgroundColor The background color of the layout.
 * @param hasStatusBar Flag to indicate whether to add status bar padding (default is `false`).
 * @param content The composable content to be displayed within the layout.
 */
@Composable
fun FullScreenLayoutBase(
  screenName: String? = null,
  backgroundColor: Color = MaterialTheme.colorScheme.background,
  hasStatusBar: Boolean = false,
  content: @Composable BoxScope.() -> Unit,
) {
  Box(
    modifier = Modifier
      .fillMaxSize()
      .background(color = backgroundColor)
      .apply {
        if (hasStatusBar) {
          statusBarsPadding()
        }
      },
    content = content,
  )

  screenName?.let {
    TrackScreenViewEvent(screenName = it)
  }
}

Thank you for reporting this issue. In response to the concern you raised about the FullScreenLayoutBase function, I've made the necessary changes to allow for optional status bar padding.

With this update, users can now decide whether they want to add status bar padding or not by setting the hasStatusBar parameter when using the FullScreenLayoutBase function.

Here's an example of how to use it:

// Add status bar padding
FullScreenLayoutBase(
  screenName = "YourScreenName",
  backgroundColor = Color.White, // Background color
  hasStatusBar = true, // Add status bar padding
) {
  // Your content here
}

// Without status bar padding
FullScreenLayoutBase(
  screenName = "YourScreenName",
  backgroundColor = Color.White, // Background color
  hasStatusBar = false, // Do not add status bar padding
) {
  // Your content here
}

I'm pleased to see the changes you've made to the FullScreenLayoutBase function, which now allows users to control the status bar padding with the hasStatusBar parameter. This enhancement will certainly improve the flexibility and usability of the function.