Skip to content

Commit

Permalink
2.1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
T8RIN committed Aug 1, 2024
1 parent 17dd711 commit edf737f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ androidCompileSdk = "34"
jvmTarget = "17"
compose-compiler = "1.5.14"

libVersion = "2.1.5"
libVersion = "2.1.6"

composeColorfulSliders = "1.2.2"
paletteKtx = "1.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Environment;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.util.Base64;
Expand Down Expand Up @@ -98,10 +100,19 @@ public static Bitmap textAsBitmap(Context context, WatermarkText watermarkText)
if (boundWidth > mTextMaxWidth) {
boundWidth = mTextMaxWidth;
}
StaticLayout staticLayout = new StaticLayout(watermarkText.getText(),
0, watermarkText.getText().length(),
watermarkPaint, mTextMaxWidth, android.text.Layout.Alignment.ALIGN_NORMAL, 2.0f,
2.0f, false);
StaticLayout staticLayout;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
staticLayout = StaticLayout.Builder.obtain(watermarkText.getText(), 0, watermarkText.getText().length(), watermarkPaint, mTextMaxWidth)
.setAlignment(Layout.Alignment.ALIGN_NORMAL)
.setLineSpacing(2.0f, 2.0f)
.setIncludePad(false)
.build();
} else {
staticLayout = new StaticLayout(watermarkText.getText(),
0, watermarkText.getText().length(),
watermarkPaint, mTextMaxWidth, Layout.Alignment.ALIGN_NORMAL, 2.0f,
2.0f, false);
}

int lineCount = staticLayout.getLineCount();
int height = (int) (baseline + watermarkPaint.descent() + 3) * lineCount;
Expand Down
19 changes: 13 additions & 6 deletions libs/modalsheet/src/main/java/com/t8rin/modalsheet/ModalSheet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.contentColorFor
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
Expand Down Expand Up @@ -87,24 +89,29 @@ fun ModalSheet(
scrimColor: Color = BottomSheetDefaults.ScrimColor,
content: @Composable ColumnScope.() -> Unit,
) {
// Hold cancelable flag internally and set to true when modal sheet is dismissed via "visible" property in
// non-cancellable modal sheet. This ensures that "confirmValueChange" will return true when sheet is set to hidden
// state.
val internalCancelable = remember { mutableStateOf(cancelable) }
val sheetState = rememberModalBottomSheetState(
skipHalfExpanded = skipHalfExpanded,
animationSpec = animationSpec,
initialValue = ModalBottomSheetValue.Hidden,
animationSpec = animationSpec,
confirmValueChange = {
if (it == ModalBottomSheetValue.Hidden && !cancelable) {
// Intercept and disallow hide gesture / action
if (it == ModalBottomSheetValue.Hidden && !internalCancelable.value) {
return@rememberModalBottomSheetState false
}

true
}
},
)


LaunchedEffect(visible) {
LaunchedEffect(visible, cancelable) {
if (visible) {
internalCancelable.value = cancelable
sheetState.show()
} else {
internalCancelable.value = true
sheetState.hide()
}
}
Expand Down

0 comments on commit edf737f

Please sign in to comment.