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 | |
| fun Modifier.shimmerable( | |
| enabled: Boolean, | |
| color: Color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f), | |
| shape: Shape = RoundedCornerShape(8.dp), | |
| ): Modifier { | |
| if (!enabled) return this | |
| return this | |
| .shimmer() // 3rd party library call |
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.escodro.task.presentation.detail.main | |
| //... | |
| import dev.icerock.moko.mvvm.viewmodel.ViewModel | |
| internal class TaskViewModel : ViewModel() { | |
| fun loadTaskInfo() { | |
| // Everything an Android ViewModel has | |
| viewModelScope.launch { doSuspendStuff() } |
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
| //... | |
| androidDependencies { | |
| // Module responsible to download from Google Play | |
| implementation(projects.libraries.splitInstall) | |
| } | |
| iosDependencies { | |
| // Dynamic Module always available | |
| implementation(projects.features.tracker) | |
| } |
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
| override fun scheduleTaskNotification(task: Task, timeInMillis: Long) { | |
| val content = UNMutableNotificationContent() | |
| content.setBody(task.title) | |
| content.setCategoryIdentifier(CATEGORY_IDENTIFIER_TASK) | |
| content.setUserInfo(mapOf(USER_INFO_TASK_ID to task.id)) | |
| val nsDate = NSDate.dateWithTimeIntervalSince1970(timeInMillis / 1000.0) | |
| val dateComponents = NSCalendar.currentCalendar.components( | |
| NSCalendarUnitYear or NSCalendarUnitMonth or NSCalendarUnitDay | |
| or NSCalendarUnitHour or NSCalendarUnitMinute, |
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
| // Android | |
| val string = MR.strings.category_default_personal.desc().toString(context) | |
| // iOS | |
| val string = MR.strings.category_default_personal.desc().localized() |
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
| @OptIn(ExperimentalForeignApi::class) | |
| fun getDataStore(): DataStore<Preferences> = getDataStore( | |
| producePath = { | |
| val documentDirectory: NSURL? = NSFileManager.defaultManager.URLForDirectory( | |
| directory = NSDocumentDirectory, | |
| inDomain = NSUserDomainMask, | |
| appropriateForURL = null, | |
| create = false, | |
| error = null, | |
| ) |
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 getDataStore(): DataStore<Preferences> = getDataStore( | |
| producePath = { context.filesDir.resolve("datastore/$dataStoreFileName").absolutePath }, | |
| ) |
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
| private lateinit var dataStore: DataStore<Preferences> | |
| private val lock = SynchronizedObject() | |
| fun getDataStore(producePath: () -> String): DataStore<Preferences> = | |
| synchronized(lock) { | |
| if (::dataStore.isInitialized) { | |
| dataStore | |
| } else { | |
| PreferenceDataStoreFactory.createWithPath( |
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
| override fun shouldPrepopulateDatabase(databaseName: String): Boolean = | |
| !databaseExists(databaseName) | |
| private fun databaseExists(databaseName: String): Boolean { | |
| val fileManager = NSFileManager.defaultManager | |
| val documentDirectory = NSFileManager.defaultManager.URLsForDirectory( | |
| NSLibraryDirectory, | |
| NSUserDomainMask, | |
| ).last() as NSURL | |
| val file = documentDirectory |