Skip to content

Commit

Permalink
docs: add TopBar documentation (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
andresmr authored Oct 16, 2024
1 parent 021760f commit a6e2209
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector

/**
* A composable function that renders a top app bar. Depending on the [type], it can display either a
* default aligned top app bar or a center-aligned top app bar.
*
* @param modifier The [Modifier] to be applied to the TopBar.
* @param type The type of the TopBar, either [TopBarType.DEFAULT] for a default aligned top app bar or [TopBarType.CENTERED] for a center-aligned top app bar.
* @param navigationIcon A composable function that represents the navigation icon displayed in the TopBar, typically a back arrow or a menu icon.
* @param actions A composable function that represents the actions (e.g., icons, menus) displayed on the right side of the TopBar.
* @param title A composable function that represents the title content of the TopBar.
* @param colors A [TopAppBarColors] that defines the color scheme for the TopBar. Default is [TopAppBarDefaults.topAppBarColors].
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun TopBar(
Expand Down Expand Up @@ -47,6 +58,14 @@ fun TopBar(
}
}

/**
* A composable function that renders an action icon within the TopBar.
*
* @param icon The [ImageVector] representing the icon to be displayed.
* @param tint The tint color for the icon. Default is [Color.Unspecified].
* @param contentDescription A description of the icon for accessibility purposes.
* @param onClick The callback to be invoked when the icon is clicked.
*/
@Composable
fun TopBarActionIcon(
icon: ImageVector,
Expand All @@ -66,6 +85,12 @@ fun TopBarActionIcon(
)
}

/**
* A composable function that renders an icon button which toggles a dropdown menu.
*
* @param iconTint The tint color for the dropdown icon. Default is [Color.Unspecified].
* @param dropDownMenu A composable function that renders the dropdown menu, receiving the current state (shown or hidden) and a callback to dismiss the menu.
*/
@Composable
fun TopBarDropdownMenuIcon(
iconTint: Color = Color.Unspecified,
Expand All @@ -86,6 +111,12 @@ fun TopBarDropdownMenuIcon(
dropDownMenu(showMenu) { showMenu = false }
}

/**
* Enum class representing the type of the TopBar.
*
* @property DEFAULT The default TopBar alignment with the title left-aligned.
* @property CENTERED A center-aligned TopBar with the title centered.
*/
enum class TopBarType {
DEFAULT,
CENTERED,
Expand Down

0 comments on commit a6e2209

Please sign in to comment.