Skip to content

jakepurple13/Jakepurple13Libraries

Repository files navigation

Jakepurple13Libraries

Compose Utilities I've found myself either reusing or just having fun with

Setup

 maven(url = "https://jitpack.io")
implementation("com.github.jakepurple13.Jakepurple13Libraries:patterninput:$purpleLibVersion")
implementation("com.github.jakepurple13.Jakepurple13Libraries:groupbutton:$purpleLibVersion")
implementation("com.github.jakepurple13.Jakepurple13Libraries:diamondloader:$purpleLibVersion")
implementation("com.github.jakepurple13.Jakepurple13Libraries:modifierutils:$purpleLibVersion")
implementation("com.github.jakepurple13.Jakepurple13Libraries:cards:$purpleLibVersion")
implementation("com.github.jakepurple13.Jakepurple13Libraries:navigationcomposeutils:$purpleLibVersion")

Or! Use BOM!

implementation(platform("com.github.jakepurple13.Jakepurple13Libraries:libraries-bom:$purpleLibVersion"))
implementation("com.github.jakepurple13.Jakepurple13Libraries:patterninput")
implementation("com.github.jakepurple13.Jakepurple13Libraries:groupbutton")
implementation("com.github.jakepurple13.Jakepurple13Libraries:diamondloader")
implementation("com.github.jakepurple13.Jakepurple13Libraries:modifierutils")
implementation("com.github.jakepurple13.Jakepurple13Libraries:cards")
implementation("com.github.jakepurple13.Jakepurple13Libraries:navigationcomposeutils")

Pattern Input

Documentation This is to mimic the Wordscapes input thingy.

var wordGuess by remember { mutableStateOf("") }
PatternInput(
    options = listOf("h", "e", "l", "l", "o", "!", "!"),
    modifier = Modifier.size(height = 250.dp, width = 250.dp), // a size is required
    optionToString = { it },
    colors = PatternInputDefaults.defaultColors(
        dotsColor = MaterialTheme.colorScheme.primary,
        linesColor = MaterialTheme.colorScheme.onSurface,
        letterColor = MaterialTheme.colorScheme.primary,
    ),
    sensitivity = 100f,
    dotsSize = 50.sp.value,
    linesStroke = 50f,
    circleStroke = Stroke(width = 4.dp.value),
    animationDuration = 200,
    animationDelay = 100,
    onStart = {
        wordGuess = ""
        wordGuess = it.id
    },
    onDotRemoved = { wordGuess = wordGuess.removeSuffix(it.id) },
    onDotConnected = { wordGuess = "$wordGuess${it.id}" },
    onResult = { /*Does a final thing*/ }
)

NavigationUtils

Documentation

This was something I found myself copying and pasting to many different projects.

So instead of needing to pass a navController around, this allows us to do:

val navController = LocalNavController.current

To set it up, you must have:

ProvideNavController { /*composable content here*/ }

If you don't want the default (which is just rememberNavController()) since maybe you need to add a navigator, you can pass that in!

ProvideNavController(rememberNavController()) { /*composable content here*/ }

GroupButton

Documentation

This is a segmented button

var item by remember { mutableStateOf(1) }

GroupButton(
    selected = item,
    options = (0..2).map {
        GroupButtonModel(
            item = it,
            iconContent = { Text(it.toString()) }
        )
    },
    onClick = { item = it }
)

Group button is generic so things can be typed!

ProjectInfo Plugin

Documentation

This is to view some information about the project like number of files of a type, line count, total lines, and showing the file with the most number of lines!

Gradle
plugin {
    id 'io.github.jakepurple13.ProjectInfo' version [version] apply false 
}
KTS
plugin {
    id("io.github.jakepurple13.ProjectInfo") version [version] apply false
}
Classpath
classpath("io.github.jakepurple13.ProjectInfo:projectinfoplugin:[version]")

Some modifiable things:

projectInfo {
    //add file types you want to exclude
    excludeFileTypes
    //to filter further:
    filter {
        //Then use normal excludes/includes here!
    }
    //To include some File Line Count Validation:
    fileLineCountValidation {
        //You can choose a custom color!
        //The color makes use of https://github.com/ajalt/mordant
        customColor(0f, 0.5f, 1f)
        color = TextColors.red
        //Add file types to check. So kt, kts, java, etc
        fileTypesToCheck.add("kt", "kts")
        //And finally, add a line count to flag the colors on.
        //This sample will flag kt and kts files that are above 100 lines of code
        lineCountToFlag = 100
        //In instances where you don't want this validation to run, you can set this variable to false
        runValidation = true
    }
    //Set a custom sortWith using Comparator!
    //This allows you to set a sort for both grouped and ungrouped files!
    sort {
        sortGroupedFiles = compareByDescending { p -> p.second.maxOf { it.size } }
        sortUngroupedFiles = compareBy<FileInfo> { it.extension }.thenByDescending { it.size }
    }
    //If you want to list all files:
    groupByFileType = false
    //If you do group by file type and you want to see the top x amount of files
    //Note, this MUST be above 0:
    showTopCount = 3
}

About

Compose Utilities I've found myself either reusing or just having fun with

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages