Skip to content

Commit

Permalink
(All) Supply horizontal padding values to custom header composable
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkeppeler committed Jan 30, 2024
1 parent 9713118 commit ba2f654
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.maxkeppeker.sheets.core.models.base

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.runtime.Composable

/**
Expand All @@ -24,8 +25,8 @@ abstract class Header {

/**
* Standard implementation of a header.
* @param icon The icon that is displayed above the title..
* @param title The text that will be set as title.
* @param title The title of the header.
* @param icon The icon of the header.
*/
data class Default(
val title: String,
Expand All @@ -34,8 +35,9 @@ abstract class Header {

/**
* Custom implementation of a header.
* @param header The custom header implementation with the horizontal padding values of the default header.
*/
data class Custom(
val header: @Composable () -> Unit
val header: @Composable (paddingValues: PaddingValues) -> Unit
) : Header()
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
*/
package com.maxkeppeker.sheets.core.views

import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
Expand All @@ -41,7 +45,7 @@ fun HeaderComponent(
contentHorizontalPadding: PaddingValues,
) {
when (header) {
is Header.Custom -> header.header.invoke()
is Header.Custom -> header.header.invoke(contentHorizontalPadding)
is Header.Default -> DefaultHeaderComponent(header, contentHorizontalPadding)
}
}
Expand Down

0 comments on commit ba2f654

Please sign in to comment.