-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add
TopAppBar
components and update button interactions
- Introduced `LargeTopAppBarWithScaffold` and `TopAppBarScaffold` for creating top app bars with scaffold layouts. - Added a `nestedScroll` modifier to the scaffolds to enable scrolling behavior. - Updated `AnimatedButtonDirection`, `FloatingActionButton`, and `SmallFloatingActionButton` to play a click sound effect when pressed. - Bumping the library version to 0.0.64.
- Loading branch information
Mihai-Cristian Condrea
committed
Feb 19, 2025
1 parent
b8a4de5
commit 8603cf9
Showing
5 changed files
with
87 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...lkit/src/main/java/com/d4rk/android/libs/apptoolkit/ui/components/navigation/TopAppBar.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.d4rk.android.libs.apptoolkit.ui.components.navigation | ||
|
||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.RowScope | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.automirrored.filled.ArrowBack | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.LargeTopAppBar | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TopAppBarDefaults | ||
import androidx.compose.material3.TopAppBarScrollBehavior | ||
import androidx.compose.material3.rememberTopAppBarState | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.input.nestedscroll.nestedScroll | ||
import androidx.compose.ui.res.stringResource | ||
import com.d4rk.android.libs.apptoolkit.ui.components.buttons.AnimatedButtonDirection | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun LargeTopAppBarWithScaffold(title: String, onBackClicked: () -> Unit, actions: @Composable (RowScope.() -> Unit) = {}, floatingActionButton: @Composable (() -> Unit)? = null, content: @Composable (PaddingValues) -> Unit) { | ||
val scrollBehaviorState: TopAppBarScrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior(state = rememberTopAppBarState()) | ||
|
||
Scaffold( | ||
modifier = Modifier.nestedScroll(connection = scrollBehaviorState.nestedScrollConnection) , | ||
topBar = { | ||
LargeTopAppBar( | ||
title = { Text(text = title) }, | ||
navigationIcon = { | ||
AnimatedButtonDirection( | ||
icon = Icons.AutoMirrored.Filled.ArrowBack, | ||
contentDescription = stringResource(id = com.d4rk.android.libs.apptoolkit.R.string.go_back), | ||
onClick = { onBackClicked() } | ||
) | ||
}, | ||
actions = actions, | ||
scrollBehavior = scrollBehaviorState | ||
) | ||
} , | ||
floatingActionButton = floatingActionButton ?: {} , | ||
) { paddingValues -> | ||
content(paddingValues) | ||
} | ||
} | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun TopAppBarScaffold(title : String , content : @Composable (PaddingValues) -> Unit) { | ||
val scrollBehaviorState : TopAppBarScrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior(state = rememberTopAppBarState()) | ||
|
||
Scaffold(modifier = Modifier.nestedScroll(connection = scrollBehaviorState.nestedScrollConnection) , topBar = { | ||
LargeTopAppBar(title = { Text(text = title) } , scrollBehavior = scrollBehaviorState) | ||
}) { paddingValues -> | ||
content(paddingValues) | ||
} | ||
} |