Splitties
A collection of hand-crafted extensions for your Kotlin projects.
Install / Use
/learn @LouisCAD/SplittiesREADME
Splitties
Splitties is a collection of small Kotlin multiplatform libraries (with Android as first target).
These libraries are intended to reduce the amount of code you have to write, freeing code reading and writing
time, so you can focus more on what you want to build for your users (even if you're the only one), or
have more time to have fun.
This project is named "Splitties" because it is split in small modules, distributed as independent libraries, so you can add only the ones you need to your project/module, helping reduce the size of the final binary that users devices will need to download and keep in the limited storage (BTW, everything is limited).
Some Android targeting modules have a content similar to what Anko offers. See a short comparison of Splitties with Anko here.
Each module has been designed to have a small footprint and be as efficient as possible.
A few examples
Splitties is all about simplifying your code. Here are a few examples:
Kotlin:
startActivity(Intent(this, DemoActivity::class.java))
Kotlin with Splitties Activities:
start<DemoActivity>()
Kotlin:
Snackbar.make(root, R.string.refresh_successful, Snackbar.LENGTH_SHORT)
.show()
Kotlin with Splitties Snackbar:
root.snack(R.string.refresh_successful)
Racing coroutines: (raceOf(…) comes from the Coroutines module)
suspend fun awaitUserChoice(ui: SomeUi, choices: List<Stuff>): Stuff? = raceOf({
ui.awaitSomeUserAction(choices)
}, {
ui.awaitDismissal()
null
}, {
ui.showSomethingInRealtimeUntilCancelled() // Returns Nothing, will run, but never "win".
})
Kotlin:
Snackbar.make(root, getString(R.string.deleted_x_items, deletedCount), Snackbar.LENGTH_LONG)
.setAction(android.R.string.cancel) {
deleteOperation.requestRollback()
}
.setActionTextColor(ContextCompat.getColor(this, R.color.fancy_color))
.show()
Kotlin with Splitties Snackbar:
root.longSnack(str(R.string.deleted_x_items, deletedCount)) {
action(android.R.string.cancel, textColor = color(R.color.fancy_color)) {
deleteOperation.requestRollback()
}
}
Overview
- System interaction (Android only)
- User input and user interface related splits
- Inter and cross app communication: Activities, Fragments, Intents, and Bundles
- Concurrency (Multiplatform)
- Data persistence (Multiplatform)
- Utilities (Multiplatform)
- Debugging (Android only)
- Legacy (Android only)
System interaction (Android only):
- App Context: Always have your application
Contextat hand withappCtx. - System Services: No more
context.getSystemService(NAME_OF_SERVICE) as NameOfManager.
User input and user interface related splits:
Small messages (Android only)
- Snackbar: Grab a snack without ceremony with
snack(…)andlongSnack(…). - Toast: Show a toast by just calling
toast(yourText), and dodge API 25BadTokenException.
Dialogs (Android only)
- Alert Dialog: Create simple alert dialogs with simple code.
- Alert Dialog AppCompat: AppCompat version of Alert Dialog.
- Alert Dialog AppCompat Coroutines:
showAndAwaitextension functions for AppCompat AlertDialog. - Alert Dialog Material: Material Components extension of Alert Dialog AppCompat.
System UI (Android only)
- Dangerous permissions: Request runtime permissions without polluting your codebase.
Extensions for Views (Android only)
- Views: Extensions function and properties on
Views. - Views AppCompat: AppCompat extension of Views. Includes helpers for
ImageViewtinting,ActionBarand tooltip. - Views CardView: CardView extension of Views. Provides a
contentPaddingproperty. - Views Material: Material Components extension of Views.
- Views Coroutines Material: Material Components + Kotlin coroutines.
- Views RecyclerView: RecyclerView extension of Views.
- Views Coroutines: Android Views + Kotlin coroutines.
Creating View based UIs with the power of Kotlin (Android only)
- Views DSL: Create UIs with readable Kotlin code (IDE preview supported).
- Views DSL AppCompat: AppCompat extension of Views DSL.
- Views DSL ConstraintLayout: ConstraintLayout extension of Views DSL.
- Views DSL CoordinatorLayout: CoordinatorLayout extension of Views DSL.
- Views DSL Material: Material Components extension of Views DSL.
- Views DSL RecyclerView: RecyclerView extension of Views DSL.
Various UI utilities (Android only)
- Resources: Extensions to get resources like strings, colors or drawables easily, with support for themed attributes.
- Dimensions: Android
dpextensions forViewandContext. Particularly handy when using Views DSL. - Selectable views
- Selectable Views: Selectable Views with
foregroundproperty before API 23. - Selectable Views AppCompat: Selectable Views for AppCompatTextView.
- Selectable Views ConstraintLayout: Selectable Views for ConstraintLayout.
- Selectable Views: Selectable Views with
- Typesafe RecyclerView: Typesafe
ViewHolderandItemViewHolderfor easy basic usage ofRecyclerView.
Material Design helpers (Android only)
- Material Colors: 2014 Material Design color palettes as color resources.
- Material Lists: List item Views implementing Material Design guidelines (perfect for usage in a
RecyclerView).
Inter and cross app communication: Activities, Fragments, Intents, and Bundles
- Activities: Start activities with minimal boilerplate.
- Intents: Transform
companion objects into powerful typesafe intent specs, and createPendingIntents the clean and easy way. - Fragments: Start activities from fragments and do transactions with minimal boilerplate.
- Fragment Args: Fragment arguments without ceremony thanks to delegated properties.
- Bundle:
BundleSpecto useBundlewith property syntax forIntentextras and more.
Concurrency (Multiplatform)
- Coroutines: General purpose extensions to kotlinx.coroutines.
- Lifecycle Coroutines (Android only): Coroutines integration with AndroidX
Lifecycle. - Main Thread: Properties and precondition checkers related to the main thread.
- Main Handler (Android only): Top-level
mainHandlerproperty to stop allocating multipleHandlers for mainLooper. - Checked Lazy (Android only):
mainThreadLazythat checks property access on
Data persistence (Multiplatform)
- Preferences: Property syntax for Android's
SharedPreferences/DataStoreand macOS/iOS/watchOSNSUserDefaults. - Arch Room: Room helpers to instantiate your DB and perform transactions in Kotlin.
Utilities (Multiplatform)
- Bit Flags:
hasFlag,withFlagandminusFlagextensions onLong,Int,Short,Byte, and their unsigned counterparts. - Collections:
forEachforLists withoutIteratorallocation.
Debugging (Android only)
- Stetho init: Have Stetho for your debug builds, without writing any code!
Legacy (Android only)
- Exceptions: `unexpectedValu
Related Skills
diffs
334.9kUse the diffs tool to produce real, shareable diffs (viewer URL, file artifact, or both) instead of manual edit summaries.
openpencil
1.6kThe world's first open-source AI-native vector design tool and the first to feature concurrent Agent Teams. Design-as-Code. Turn prompts into UI directly on the live canvas. A modern alternative to Pencil.
ui-ux-pro-max-skill
50.0kAn AI SKILL that provide design intelligence for building professional UI/UX multiple platforms
Figma-Context-MCP
13.9kMCP server to provide Figma layout information to AI coding agents like Cursor
