Skip to content

Instantly share code, notes, and snippets.

View delacrixmorgan's full-sized avatar
💭
🙉🙈🙊

Morgan Koh delacrixmorgan

💭
🙉🙈🙊
View GitHub Profile
@delacrixmorgan
delacrixmorgan / KMP Typography Style.md
Created August 24, 2024 14:17
KMP Typography Style
val displayFontFamily: FontFamily
    @Composable
    get() = FontFamily(
        Font(Res.font.league_spartan, weight = FontWeight.Normal)
    )

val bodyFontFamily: FontFamily
    @Composable get() = FontFamily(
        Font(Res.font.lato_black, weight = FontWeight.Black),
@delacrixmorgan
delacrixmorgan / Compose Animate Gradient Vertically.md
Created August 16, 2024 11:33
Compose Animate Gradient Vertically
val infiniteTransition = rememberInfiniteTransition(label = "background")
val targetOffset = with(LocalDensity.current) {
    1_000.dp.toPx()
}
val offset by infiniteTransition.animateFloat(
    initialValue = 0F,
    targetValue = targetOffset,
    animationSpec = infiniteRepeatable(
 tween(50_000, easing = LinearEasing),
@delacrixmorgan
delacrixmorgan / SwipeToDismissBox.md
Created August 6, 2024 19:14
KMP - SwipeToDismissBox
@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun EditableNameTimeView(
    viewModel: TodayViewModel,
    location: Location,
    onEdit: ((Location) -> Unit),
    onDelete: ((Location) -> Unit)
) {
    val dismissState = rememberSwipeToDismissBoxState(
@delacrixmorgan
delacrixmorgan / KMP - Open URL In Browser with Context.md
Last active August 5, 2024 19:51
KMP - Open URL In Browser with Context
actual fun openUrlInBrowser(url: String) {
    val intent = Intent(Intent.ACTION_VIEW).apply {
        addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
        data = Uri.parse(url)
    }

    AppContext.get().startActivity(intent)
}
@delacrixmorgan
delacrixmorgan / Compose - AnimatedVisibility Animation.md
Created July 31, 2024 14:01
Compose - AnimatedVisibility Animation
AnimatedVisibility(
    visible = collapsed,
    enter = fadeIn(animationSpec = tween(durationMillis = 500)),
    exit = fadeOut(animationSpec = tween(durationMillis = 300)),
)

AnimatedVisibility(
    visible = collapsed,
 enter = slideInVertically(initialOffsetY = { -it }),
@delacrixmorgan
delacrixmorgan / ArcShortcut.md
Last active October 4, 2023 06:58
Arc Shortcut

Move Address Bar between Sidebar and Webpage

CMD + Shift + D

Paste as New Tab

CMD + Option + V
@delacrixmorgan
delacrixmorgan / SecurityDtoToModelMapper.md
Last active June 7, 2023 13:18
SecurityDtoToModelMapper Question
class SecurityDtoToModelMapper @Inject constructor(
    private val securityDataProvider: SecurityDataProvider,
    private val securityAssetClassDtoToModelMapper: SecurityAssetClassDtoToModelMapper,
    private val securityDividendPolicyDtoToModelMapper: SecurityDividendPolicyDtoToModelMapper,
    private val securityEsgRatingDtoToModelMapper: SecurityEsgRatingDtoToModelMapper,
    private val securityTopHoldingDtoToModelMapper: SecurityTopHoldingDtoToModelMapper,
    private val securityPerformancePointDtoToModelMapper: SecurityPerformancePointDtoToModelMapper,
    private val securityTagsDtoToModelMapper: SecurityTagsDtoToModelMapper,
    private val currencyDtoToModelMapper: CurrencyDtoToModelMapper,
@delacrixmorgan
delacrixmorgan / DrawableMarginSpan.kt
Last active January 6, 2023 14:33
Android SpanUtils - LeadingMarginSpan with Images
internal class DrawableMarginSpan : LeadingMarginSpan {
private val bitmap: Bitmap
private val verticalAlignment: Int
private val padding: Int
private val totalHeight = 0
constructor(bitmap: Bitmap, pad: Int, verticalAlignment: Int) {
this.bitmap = bitmap
padding = pad
this.verticalAlignment = verticalAlignment
@delacrixmorgan
delacrixmorgan / SpanUtils.java
Created January 5, 2023 15:21
Android SpanUtils
package com.csjbot.mobileshop.util;
import android.annotation.SuppressLint;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BlurMaskFilter;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
@delacrixmorgan
delacrixmorgan / DrawOutlineLine.kt
Created December 30, 2022 10:26
Compose UI - Outline Button with Lines
val lineThickness = 4F
Modifier
.fillMaxWidth()
.border(
width = lineThickness.dp,
color = Color.Red,
shape = drawOutlineButtonLine(OutlineButtonLine.Top, lineThickness)
)
private fun drawOutlineButtonLine(outlineButtonLine: OutlineButtonLine, lineThickness: Float): Shape {