-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'trunk' into feature/update-compile-sdk-33
- Loading branch information
Showing
33 changed files
with
356 additions
and
217 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
23 changes: 23 additions & 0 deletions
23
WordPress/src/main/java/org/wordpress/android/ui/compose/components/ContentAlphaProvider.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,23 @@ | ||
package org.wordpress.android.ui.compose.components | ||
|
||
import androidx.compose.material.ContentAlpha | ||
import androidx.compose.material.LocalContentAlpha | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.CompositionLocalProvider | ||
|
||
/** | ||
* Helper Composable to provide the [LocalContentAlpha] to the content. Prefer using the values below to match Material | ||
* guidelines regarding content emphasis: | ||
* - [ContentAlpha.high] | ||
* - [ContentAlpha.medium] | ||
* - [ContentAlpha.disabled] | ||
* | ||
* More info: https://developer.android.com/jetpack/compose/designsystems/material#emphasis | ||
*/ | ||
@Composable | ||
fun ContentAlphaProvider( | ||
alpha: Float, | ||
content: @Composable () -> Unit, | ||
) { | ||
CompositionLocalProvider(LocalContentAlpha provides alpha, content = content) | ||
} |
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
43 changes: 0 additions & 43 deletions
43
WordPress/src/main/java/org/wordpress/android/ui/compose/components/SecondaryButton.kt
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
WordPress/src/main/java/org/wordpress/android/ui/compose/components/buttons/ButtonSize.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,10 @@ | ||
package org.wordpress.android.ui.compose.components.buttons | ||
|
||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.dp | ||
|
||
enum class ButtonSize(val height: Dp) { | ||
NORMAL(height = Dp.Unspecified), | ||
// this height matches the jetpack_bottom_sheet_button_height | ||
LARGE(height = 52.dp) | ||
} |
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
83 changes: 83 additions & 0 deletions
83
...ress/src/main/java/org/wordpress/android/ui/compose/components/buttons/SecondaryButton.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,83 @@ | ||
package org.wordpress.android.ui.compose.components.buttons | ||
|
||
import android.content.res.Configuration | ||
import androidx.compose.foundation.layout.defaultMinSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material.Button | ||
import androidx.compose.material.ButtonDefaults | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.res.dimensionResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import org.wordpress.android.R | ||
import org.wordpress.android.ui.compose.theme.AppTheme | ||
|
||
@Composable | ||
fun SecondaryButton( | ||
text: String, | ||
onClick: () -> Unit, | ||
modifier: Modifier = Modifier, | ||
enabled: Boolean = true, | ||
useDefaultMargins: Boolean = true, | ||
buttonSize: ButtonSize = ButtonSize.NORMAL, | ||
) { | ||
var computedModifier: Modifier = modifier | ||
|
||
if (useDefaultMargins) { | ||
computedModifier = computedModifier | ||
.padding(bottom = 10.dp) | ||
.padding(horizontal = dimensionResource(R.dimen.jp_migration_buttons_padding_horizontal)) | ||
} | ||
|
||
computedModifier = computedModifier.defaultMinSize(minHeight = buttonSize.height) | ||
|
||
Button( | ||
onClick = onClick, | ||
enabled = enabled, | ||
elevation = ButtonDefaults.elevation( | ||
defaultElevation = 0.dp, | ||
pressedElevation = 0.dp, | ||
), | ||
colors = ButtonDefaults.buttonColors( | ||
backgroundColor = Color.Transparent, | ||
contentColor = MaterialTheme.colors.primary, | ||
disabledBackgroundColor = Color.Transparent, | ||
disabledContentColor = MaterialTheme.colors.primary, | ||
), | ||
modifier = computedModifier.fillMaxWidth() | ||
) { | ||
Text(text = text) | ||
} | ||
} | ||
|
||
@Preview | ||
@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) | ||
@Composable | ||
private fun SecondaryButtonPreview() { | ||
AppTheme { | ||
SecondaryButton(text = "Continue", onClick = {}) | ||
} | ||
} | ||
|
||
@Preview | ||
@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) | ||
@Composable | ||
private fun SecondaryButtonNoDefaultMarginsPreview() { | ||
AppTheme { | ||
SecondaryButton(text = "Continue", onClick = {}, useDefaultMargins = false) | ||
} | ||
} | ||
|
||
@Preview | ||
@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) | ||
@Composable | ||
private fun SecondaryButtonLargePreview() { | ||
AppTheme { | ||
SecondaryButton(text = "Continue", onClick = {}, buttonSize = ButtonSize.LARGE) | ||
} | ||
} |
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
Oops, something went wrong.