This file contains hidden or 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
package com.monzo.compose | |
import android.app.Dialog | |
import android.content.Context | |
import android.graphics.Color | |
import android.os.Build | |
import android.os.Bundle | |
import android.view.View | |
import android.view.ViewGroup | |
import android.view.Window |
This file contains hidden or 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
@Composable | |
@OptIn(ExperimentalSubcomposeLayoutApi::class) | |
fun ListSection( | |
modifier: Modifier = Modifier, | |
header: String? = null, | |
footer: String? = null, | |
showDividers: Boolean = true, | |
dividerInset: Dp = 16.dp, | |
content: @Composable () -> Unit, | |
) { |
This file contains hidden or 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
/** | |
* Sets a background drawable on this view that will draw a slice of [ancestor]'s background that sits underneath | |
* this view. This is useful when [ancestor] has a gradient background and you want another child to seamlessly | |
* continue that gradient while also having an opaque background to allow for elevation. | |
*/ | |
fun View.setBackgroundFromAncestor(ancestor: ViewGroup) { | |
check(ancestor.isAncestorOf(this)) | |
if (ancestor.background == null) return | |
background = CopyBackgroundDrawable(this, ancestor) | |
} |
This file contains hidden or 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
package com.monzo.design.nosymbol | |
import android.content.Context | |
import android.util.AttributeSet | |
import android.view.HapticFeedbackConstants.VIRTUAL_KEY | |
import android.view.MotionEvent | |
import android.view.View | |
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT | |
import android.view.accessibility.AccessibilityEvent | |
import androidx.recyclerview.widget.LinearSnapHelper |
This file contains hidden or 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
internal class RaindropView(context: Context) : View(context) { | |
private val backgroundPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { | |
style = Paint.Style.FILL | |
color = Color.WHITE | |
} | |
private val gradientPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { | |
style = Paint.Style.FILL | |
color = Color.WHITE | |
} |
This file contains hidden or 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
fun IntArray.radixSort(): IntArray { | |
var result = this | |
val max = getMax() | |
var place = 1 | |
while (max / place > 0) { | |
result = result.countingSort(place) | |
place *= 10 | |
} |
This file contains hidden or 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
fun Node.format(): String { | |
return formatInternal().lines.joinToString(separator = "\n") | |
} | |
fun max(a: Int, b: Int, c: Int): Int { | |
return Math.max(Math.max(a, b), c) | |
} | |
fun String.center(width: Int, fillChar: Char = ' ') : String { | |
var s = this |
This file contains hidden or 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
package nz.bradcampbell.app.presentation; | |
import android.content.Context; | |
import android.support.v4.view.LayoutInflaterFactory; | |
import android.util.AttributeSet; | |
import android.view.View; | |
import java.lang.reflect.Constructor; | |
import java.lang.reflect.InvocationTargetException; | |
import java.util.HashMap; |