Skip to content

Instantly share code, notes, and snippets.

View bmc08gt's full-sized avatar
:shipit:
Building Flipcash and Sharpen (McGraw Hill)

Brandon McAnsh bmc08gt

:shipit:
Building Flipcash and Sharpen (McGraw Hill)
View GitHub Profile
@bmc08gt
bmc08gt / SegmentedControl.android.kt
Last active March 18, 2024 09:27
Compose Multiplatform Segmented Control
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.MaterialTheme
@bmc08gt
bmc08gt / GoogleMap.issue.kt
Last active November 20, 2023 09:25
Compose Map Markers Not Clearing Fix
@Composable
actual fun MapView(
modifier: Modifier,
contentPadding: PaddingValues,
userLocation: LatLong?,
resultLocations: List<Stay.Minimal>,
useTotalPrice: Boolean,
onMarkerSelectionChange: (String?) -> Unit,
onMapMoved: () -> Unit,
) {
@bmc08gt
bmc08gt / Currency.kt
Last active October 24, 2025 22:19
All Global currencies in a nice easy use to enum
@Suppress("EnumEntryName")
@Serializable
enum class Currency(
val code: String,
val symbol: String,
) {
Australian_dollar("AUD", "$"),
Brazilian_real("BRL", "R$"),
Bulgarian_lev("BGN", "лв."),
Canadian_dollar("CAD", "$"),
@bmc08gt
bmc08gt / Tips.kt
Last active August 25, 2023 13:10
TipKit
@Singleton
class AnchorTip @Inject constructor(
eventEngine: EventEngine,
tipEngine: TipsEngine
) : Tip(eventEngine, tipEngine) {
init {
flowPosition = 0
flowId = "onboarding-flow"
}
@bmc08gt
bmc08gt / compose.kt
Created December 6, 2021 22:16
compose.kt
ext {
compose_version = '1.0.5'
accompanist_version = "0.20.2"
}
android {
buildFeatures {
compose true
}
composeOptions {
@bmc08gt
bmc08gt / WorkEnqueuer.kt
Created October 21, 2021 18:59
WorkManager state observation
interface WorkListener {
fun onConditionNotMet()
fun onStart()
fun onSuccess(data: Data)
fun onError(data: Data)
}
class WorkEnqueuer(val context: Context) {
private var listener: WorkListener? = null
@bmc08gt
bmc08gt / insets.kt
Created September 14, 2021 02:55
WindowInsets IME extensions
val View.windowInsetsCompat: WindowInsetsCompat?
get() {
val rootInsets = rootWindowInsets ?: return null
return WindowInsetsCompat.toWindowInsetsCompat(rootInsets)
}
val View.isKeyboardVisible: Boolean
get() = windowInsetsCompat?.isVisible(WindowInsetsCompat.Type.ime()) ?: false
fun View.hideKeyboard() {
@bmc08gt
bmc08gt / AutoSizeText.kt
Last active April 7, 2025 10:20
Autosizing Text in Jetpack Compose
import androidx.compose.material.LocalTextStyle
import androidx.compose.material.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawWithContent
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
@bmc08gt
bmc08gt / grid.kt
Last active January 6, 2022 05:33
Jetpack Compose Composable wrapping an Android SwipeRefresh & RecyclerView using Composable ViewHolders
@OptIn(ExperimentalFoundationApi::class)
@Composable
internal fun AndroidIgGrid(
viewState: InstagramGridViewState,
isRefreshing: Boolean,
items: PagingData<GridMediaItem>,
selectedItems: List<GridMediaItem>,
onRefresh: () -> Unit,
onItemSelected: (GridMediaItem) -> Unit,
onItemUnSelected: (GridMediaItem) -> Unit,
@bmc08gt
bmc08gt / app_build.gradle
Last active July 4, 2022 11:46
Gradle task that downloads a signing config from a remote server
def execDownloadSigningInfo(ProductFlavor flavor) {
task z {
download {
src "$url"
dest {
return rootProject.file("../file")
}
onlyIfNewer true
}