Skip to content

Instantly share code, notes, and snippets.

@lighttigerXIV
lighttigerXIV / MainActivity.kt
Last active December 1, 2024 16:45
Settings With Datastore
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
@Inject
lateinit var settingsRepository: SettingsRepository
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
@lighttigerXIV
lighttigerXIV / AndroidManifest.xml
Last active September 7, 2024 09:18
The basics for a launcher in compose
<!--To get the apps-->
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" />
<!--To expand the status bar on a swipe-->
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
<!--To uninstall apps-->
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
@lighttigerXIV
lighttigerXIV / SwipeAction.kt
Last active September 7, 2024 09:31
Swipe to action component
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SwipeToDelete(
onDelete: () -> Unit
) {
var value by remember { mutableFloatStateOf(0f) }
val source = remember { MutableInteractionSource() }
val scale = remember { 12f }
val height = remember { (4 * scale).dp }
var initialDragValue: Float? by remember { mutableStateOf(null) } //To prevent accidental deletes and make sure the user actually swipes