-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Bump Kotlin to 2.0.20, AGP to 8.5.0; Support selectedTextColor;…
… Support Adapter for SinglePickerDialog; Add more comment to functions.
- Loading branch information
Showing
36 changed files
with
956 additions
and
343 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ | |
local.properties | ||
|
||
/release | ||
/.kotlin |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
-keepclassmembers public class * extends androidx.lifecycle.ViewModel { | ||
public <init>(...); | ||
} | ||
-keepclassmembers public class * extends io.john6.base.compose.picker.dialog.multiple.IMultipleJPickerAdapter { | ||
-keepclassmembers public class * extends io.john6.base.compose.picker.dialog.IJPickerAdapter { | ||
public <init>(...); | ||
} |
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
61 changes: 61 additions & 0 deletions
61
JWheelPicker/src/main/kotlin/io/john6/base/compose/picker/Extension.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,61 @@ | ||
import androidx.compose.foundation.layout.WindowInsets | ||
import androidx.compose.foundation.layout.WindowInsetsSides | ||
import androidx.compose.foundation.layout.only | ||
import androidx.compose.foundation.layout.safeDrawing | ||
import androidx.compose.foundation.layout.windowInsetsPadding | ||
import androidx.compose.material.ElevationOverlay | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.material.contentColorFor | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.ReadOnlyComposable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.composed | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.compositeOver | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.dp | ||
import kotlin.math.ln | ||
/** | ||
* Add padding for Bottom section of our view | ||
*/ | ||
internal fun Modifier.bottomSafeDrawing(): Modifier = composed { | ||
this.windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom)) | ||
} | ||
|
||
/** | ||
* Some times We do not care the safe area at the horizontal edge, like in dialog | ||
*/ | ||
internal fun Modifier.onlyBottomSafeDrawing(): Modifier = composed { | ||
this.windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Bottom)) | ||
} | ||
|
||
@Composable | ||
fun jSurfaceColorAtElevation( | ||
color: Color, | ||
elevationOverlay: ElevationOverlay?, | ||
absoluteElevation: Dp | ||
): Color { | ||
return if (color == MaterialTheme.colors.surface && elevationOverlay != null) { | ||
elevationOverlay.apply(color, absoluteElevation) | ||
} else { | ||
color | ||
} | ||
} | ||
|
||
|
||
@ReadOnlyComposable | ||
@Composable | ||
fun calculateForegroundColor(backgroundColor: Color, elevation: Dp): Color { | ||
val alpha = ((4.5f * ln(elevation.value + 1)) + 2f) / 100f | ||
val baseForegroundColor = contentColorFor(backgroundColor) | ||
return baseForegroundColor.copy(alpha = alpha) | ||
} | ||
|
||
object JElevationOverlayInBothLightAndDarkMode : ElevationOverlay { | ||
@ReadOnlyComposable | ||
@Composable | ||
override fun apply(color: Color, elevation: Dp): Color { | ||
val foregroundColor = calculateForegroundColor(color, elevation) | ||
return foregroundColor.compositeOver(color) | ||
} | ||
} |
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
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.