This file contains 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
@ExperimentalMaterialApi | |
@Composable | |
fun OverlayBottomSheetScaffold( | |
sheetContent: @Composable ColumnScope.() -> Unit, | |
scaffoldState: BottomSheetScaffoldState = rememberBottomSheetScaffoldState(), | |
sheetPeekHeight: Dp = 0.dp, | |
maxOverlayAlpha: Float = 0.7f, | |
overlayColor: Color = Color.Black, | |
cancelable: Boolean = true, | |
content: @Composable (PaddingValues) -> Unit, |
This file contains 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(ExperimentalPagerApi::class) | |
@Composable | |
fun Calendar( | |
startDate: LocalDate, | |
months: List<YearMonth>, | |
selectedDates: Set<LocalDate>, | |
focusedDate: LocalDate?, | |
isNewDateSelectionEnabled: Boolean, | |
onDateClick: (LocalDate) -> Unit, | |
horizontalPadding: Dp, |
This file contains 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
import androidx.compose.ui.Modifier | |
import androidx.compose.ui.composed | |
import androidx.compose.ui.draw.drawBehind | |
import androidx.compose.ui.graphics.Color | |
import androidx.compose.ui.graphics.Paint | |
import androidx.compose.ui.graphics.drawscope.drawIntoCanvas | |
import androidx.compose.ui.graphics.toArgb | |
import androidx.compose.ui.unit.Dp | |
import androidx.compose.ui.unit.dp |
This file contains 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 HomeList(taskViewModel: ListViewModel = viewModel()) { | |
val coroutineScope = rememberCoroutineScope() | |
val scaffoldState = rememberScaffoldState() | |
val onShowSnackbar: (Task) -> Unit = { task -> | |
coroutineScope.launch { | |
val snackbarResult = scaffoldState.snackbarHostState.showSnackbar( | |
message = "${task.title} completed", | |
actionLabel = "Undo" |
This file contains 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
import androidx.compose.foundation.Image | |
import androidx.compose.foundation.layout.Row | |
import androidx.compose.foundation.layout.padding | |
import androidx.compose.foundation.layout.preferredSize | |
import androidx.compose.material.MaterialTheme | |
import androidx.compose.material.Text | |
import androidx.compose.runtime.Composable | |
import androidx.compose.ui.Alignment | |
import androidx.compose.ui.Modifier | |
import androidx.compose.ui.graphics.ColorFilter |
This file contains 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
class FragmentViewBindingDelegate<T : ViewBinding>(private val factory: (View) -> T) : ReadOnlyProperty<Fragment, T> { | |
private var backingValue: T? = null | |
override operator fun getValue(thisRef: Fragment, property: KProperty<*>): T = when (val binding = backingValue) { | |
null -> { | |
thisRef.parentFragmentManager.registerFragmentLifecycleCallbacks(object : FragmentManager.FragmentLifecycleCallbacks() { | |
override fun onFragmentViewDestroyed(fm: FragmentManager, fragment: Fragment) { | |
if (fragment != thisRef) return | |
backingValue = null | |
fm.unregisterFragmentLifecycleCallbacks(this) |
This file contains 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
public static void notifyMediaStoreScanner(Context mContext, Uri cacheImageUri) throws IOException { | |
Uri newImageUri = createImageInMediaStore(mContext, cacheImageUri); | |
ContentResolver resolver = mContext | |
.getContentResolver(); | |
FileInputStream input ; | |
FileOutputStream outputStream ; | |
try (ParcelFileDescriptor pfd = resolver | |
.openFileDescriptor(newImageUri, "w", null)) { | |
// Write data into the pending image. |
This file contains 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
// https://github.com/Zhuinden/fragmentviewbindingdelegate-kt | |
import android.view.View | |
import androidx.fragment.app.Fragment | |
import androidx.lifecycle.DefaultLifecycleObserver | |
import androidx.lifecycle.Lifecycle | |
import androidx.lifecycle.LifecycleOwner | |
import androidx.lifecycle.Observer | |
import androidx.viewbinding.ViewBinding | |
import kotlin.properties.ReadOnlyProperty |
This file contains 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
/* | |
SampleAuthenticator (c) by Farhan Khan | |
SampleAuthenticator is licensed under a | |
Creative Commons Attribution 3.0 Unported License. | |
http://creativecommons.org/licenses/by/3.0/ | |
*/ | |
class SampleAuthenticator( |
NewerOlder