Skip to content

Commit

Permalink
Merge pull request #397 from skydoves/kmp/placeholder
Browse files Browse the repository at this point in the history
Enhance the usage of ShimmerPlugin and implement various shimmer types
  • Loading branch information
skydoves authored Jan 6, 2024
2 parents 40c7695 + d717fb0 commit e63d616
Show file tree
Hide file tree
Showing 12 changed files with 517 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.material.primarySurface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand All @@ -37,6 +36,7 @@ import androidx.compose.ui.unit.sp
import com.github.skydoves.landscapistdemo.R
import com.github.skydoves.landscapistdemo.model.MockUtil
import com.github.skydoves.landscapistdemo.theme.DisneyComposeTheme
import com.github.skydoves.landscapistdemo.theme.background
import com.github.skydoves.landscapistdemo.theme.purple200
import dagger.hilt.android.AndroidEntryPoint

Expand All @@ -51,7 +51,11 @@ class MainActivity : ComponentActivity() {
setContent {
DisneyComposeTheme {
Scaffold(
backgroundColor = MaterialTheme.colors.primarySurface,
backgroundColor = if (isSystemInDarkTheme()) {
background
} else {
Color.White
},
topBar = { PosterAppBar() },
) {
val list = MockUtil.getMockPosters().toMutableList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.github.skydoves.landscapistdemo.ui
import androidx.compose.animation.Crossfade
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
Expand Down Expand Up @@ -54,6 +55,7 @@ import com.github.skydoves.landscapistdemo.R
import com.github.skydoves.landscapistdemo.model.MockUtil
import com.github.skydoves.landscapistdemo.model.Poster
import com.github.skydoves.landscapistdemo.theme.DisneyComposeTheme
import com.github.skydoves.landscapistdemo.theme.background
import com.skydoves.landscapist.ImageOptions
import com.skydoves.landscapist.animation.circular.CircularRevealPlugin
import com.skydoves.landscapist.animation.crossfade.CrossfadePlugin
Expand All @@ -62,6 +64,8 @@ import com.skydoves.landscapist.fresco.FrescoImage
import com.skydoves.landscapist.glide.GlideImage
import com.skydoves.landscapist.palette.PalettePlugin
import com.skydoves.landscapist.palette.rememberPaletteState
import com.skydoves.landscapist.placeholder.shimmer.Shimmer
import com.skydoves.landscapist.placeholder.shimmer.ShimmerPlugin

@Composable
fun DisneyPosters(
Expand Down Expand Up @@ -132,6 +136,16 @@ private fun SelectedPoster(
imageModel = { poster.image },
modifier = Modifier.aspectRatio(0.8f),
component = rememberImageComponent {
+ShimmerPlugin(
Shimmer.Resonate(
baseColor = if (isSystemInDarkTheme()) {
background
} else {
Color.White
},
highlightColor = Color.LightGray,
),
)
+CircularRevealPlugin()
+PalettePlugin { palette = it }
},
Expand Down
94 changes: 78 additions & 16 deletions landscapist-placeholder/api/android/landscapist-placeholder.api
Original file line number Diff line number Diff line change
Expand Up @@ -28,38 +28,100 @@ public final class com/skydoves/landscapist/placeholder/placeholder/PlaceholderP
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/placeholder/shimmer/FlashShimmerKt {
public static final fun Shimmer-0Cdfkco (Landroidx/compose/ui/Modifier;JJLandroidx/compose/ui/unit/Dp;FFFILandroidx/compose/runtime/Composer;II)V
}

public final class com/skydoves/landscapist/placeholder/shimmer/LocalShimmerKt {
public static final fun getLocalShimmerPlugin ()Landroidx/compose/runtime/ProvidableCompositionLocal;
}

public final class com/skydoves/landscapist/placeholder/shimmer/ShimmerKt {
public static final fun Shimmer-eopBjH0 (Landroidx/compose/ui/Modifier;JJLcom/skydoves/landscapist/placeholder/shimmer/ShimmerType;Landroidx/compose/runtime/Composer;II)V
public abstract class com/skydoves/landscapist/placeholder/shimmer/Shimmer {
public static final field $stable I
public synthetic fun <init> (JJILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun getShimmerBaseColor-0d7_KjU ()J
public final fun getShimmerDuration ()I
public final fun getShimmerHighlightColor-0d7_KjU ()J
}

public final class com/skydoves/landscapist/placeholder/shimmer/ShimmerPlugin : com/skydoves/landscapist/plugins/ImagePlugin$LoadingStatePlugin {
public final class com/skydoves/landscapist/placeholder/shimmer/Shimmer$Fade : com/skydoves/landscapist/placeholder/shimmer/Shimmer {
public static final field $stable I
public synthetic fun <init> (JJLcom/skydoves/landscapist/placeholder/shimmer/ShimmerType;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (JJLcom/skydoves/landscapist/placeholder/shimmer/ShimmerType;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (JJIILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (JJILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1-0d7_KjU ()J
public final fun component2-0d7_KjU ()J
public final fun component3 ()Lcom/skydoves/landscapist/placeholder/shimmer/ShimmerType;
public fun compose (Landroidx/compose/ui/Modifier;Lcom/skydoves/landscapist/ImageOptions;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;I)Lcom/skydoves/landscapist/plugins/ImagePlugin;
public final fun copy-jxsXWHM (JJLcom/skydoves/landscapist/placeholder/shimmer/ShimmerType;)Lcom/skydoves/landscapist/placeholder/shimmer/ShimmerPlugin;
public static synthetic fun copy-jxsXWHM$default (Lcom/skydoves/landscapist/placeholder/shimmer/ShimmerPlugin;JJLcom/skydoves/landscapist/placeholder/shimmer/ShimmerType;ILjava/lang/Object;)Lcom/skydoves/landscapist/placeholder/shimmer/ShimmerPlugin;
public final fun component3 ()I
public final fun copy-jxsXWHM (JJI)Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer$Fade;
public static synthetic fun copy-jxsXWHM$default (Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer$Fade;JJIILjava/lang/Object;)Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer$Fade;
public fun equals (Ljava/lang/Object;)Z
public final fun getBaseColor-0d7_KjU ()J
public final fun getDuration ()I
public final fun getHighlightColor-0d7_KjU ()J
public final fun getShimmerType ()Lcom/skydoves/landscapist/placeholder/shimmer/ShimmerType;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/placeholder/shimmer/ShimmerType : java/lang/Enum {
public static final field FADE Lcom/skydoves/landscapist/placeholder/shimmer/ShimmerType;
public static final field RESONATE Lcom/skydoves/landscapist/placeholder/shimmer/ShimmerType;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lcom/skydoves/landscapist/placeholder/shimmer/ShimmerType;
public static fun values ()[Lcom/skydoves/landscapist/placeholder/shimmer/ShimmerType;
public final class com/skydoves/landscapist/placeholder/shimmer/Shimmer$Flash : com/skydoves/landscapist/placeholder/shimmer/Shimmer {
public static final field $stable I
public synthetic fun <init> (JJLandroidx/compose/ui/unit/Dp;FFFIILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (JJLandroidx/compose/ui/unit/Dp;FFFILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1-0d7_KjU ()J
public final fun component2-0d7_KjU ()J
public final fun component3-lTKBWiU ()Landroidx/compose/ui/unit/Dp;
public final fun component4 ()F
public final fun component5 ()F
public final fun component6 ()F
public final fun component7 ()I
public final fun copy-EsoZhhI (JJLandroidx/compose/ui/unit/Dp;FFFI)Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer$Flash;
public static synthetic fun copy-EsoZhhI$default (Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer$Flash;JJLandroidx/compose/ui/unit/Dp;FFFIILjava/lang/Object;)Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer$Flash;
public fun equals (Ljava/lang/Object;)Z
public final fun getBaseColor-0d7_KjU ()J
public final fun getDropOff ()F
public final fun getDuration ()I
public final fun getHighlightColor-0d7_KjU ()J
public final fun getIntensity ()F
public final fun getTilt ()F
public final fun getWidth-lTKBWiU ()Landroidx/compose/ui/unit/Dp;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/placeholder/shimmer/Shimmer$Resonate : com/skydoves/landscapist/placeholder/shimmer/Shimmer {
public static final field $stable I
public synthetic fun <init> (JJIFILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (JJIFLkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1-0d7_KjU ()J
public final fun component2-0d7_KjU ()J
public final fun component3 ()I
public final fun component4 ()F
public final fun copy-RFnl5yQ (JJIF)Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer$Resonate;
public static synthetic fun copy-RFnl5yQ$default (Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer$Resonate;JJIFILjava/lang/Object;)Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer$Resonate;
public fun equals (Ljava/lang/Object;)Z
public final fun getBaseColor-0d7_KjU ()J
public final fun getDuration ()I
public final fun getHighlightColor-0d7_KjU ()J
public final fun getProgressForMaxAlpha ()F
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/placeholder/shimmer/ShimmerContainerKt {
public static final fun ShimmerContainer (Landroidx/compose/ui/Modifier;Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer;Landroidx/compose/runtime/Composer;I)V
}

public final class com/skydoves/landscapist/placeholder/shimmer/ShimmerPlugin : com/skydoves/landscapist/plugins/ImagePlugin$LoadingStatePlugin {
public static final field $stable I
public fun <init> ()V
public fun <init> (Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer;)V
public synthetic fun <init> (Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer;
public fun compose (Landroidx/compose/ui/Modifier;Lcom/skydoves/landscapist/ImageOptions;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;I)Lcom/skydoves/landscapist/plugins/ImagePlugin;
public final fun copy (Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer;)Lcom/skydoves/landscapist/placeholder/shimmer/ShimmerPlugin;
public static synthetic fun copy$default (Lcom/skydoves/landscapist/placeholder/shimmer/ShimmerPlugin;Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer;ILjava/lang/Object;)Lcom/skydoves/landscapist/placeholder/shimmer/ShimmerPlugin;
public fun equals (Ljava/lang/Object;)Z
public final fun getShimmer ()Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/placeholder/thumbnail/ThumbnailPlugin : com/skydoves/landscapist/plugins/ImagePlugin$LoadingStatePlugin {
Expand Down
94 changes: 78 additions & 16 deletions landscapist-placeholder/api/desktop/landscapist-placeholder.api
Original file line number Diff line number Diff line change
Expand Up @@ -28,38 +28,100 @@ public final class com/skydoves/landscapist/placeholder/placeholder/PlaceholderP
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/placeholder/shimmer/FlashShimmerKt {
public static final fun Shimmer-0Cdfkco (Landroidx/compose/ui/Modifier;JJLandroidx/compose/ui/unit/Dp;FFFILandroidx/compose/runtime/Composer;II)V
}

public final class com/skydoves/landscapist/placeholder/shimmer/LocalShimmerKt {
public static final fun getLocalShimmerPlugin ()Landroidx/compose/runtime/ProvidableCompositionLocal;
}

public final class com/skydoves/landscapist/placeholder/shimmer/ShimmerKt {
public static final fun Shimmer-eopBjH0 (Landroidx/compose/ui/Modifier;JJLcom/skydoves/landscapist/placeholder/shimmer/ShimmerType;Landroidx/compose/runtime/Composer;II)V
public abstract class com/skydoves/landscapist/placeholder/shimmer/Shimmer {
public static final field $stable I
public synthetic fun <init> (JJILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun getShimmerBaseColor-0d7_KjU ()J
public final fun getShimmerDuration ()I
public final fun getShimmerHighlightColor-0d7_KjU ()J
}

public final class com/skydoves/landscapist/placeholder/shimmer/ShimmerPlugin : com/skydoves/landscapist/plugins/ImagePlugin$LoadingStatePlugin {
public final class com/skydoves/landscapist/placeholder/shimmer/Shimmer$Fade : com/skydoves/landscapist/placeholder/shimmer/Shimmer {
public static final field $stable I
public synthetic fun <init> (JJLcom/skydoves/landscapist/placeholder/shimmer/ShimmerType;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (JJLcom/skydoves/landscapist/placeholder/shimmer/ShimmerType;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (JJIILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (JJILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1-0d7_KjU ()J
public final fun component2-0d7_KjU ()J
public final fun component3 ()Lcom/skydoves/landscapist/placeholder/shimmer/ShimmerType;
public fun compose (Landroidx/compose/ui/Modifier;Lcom/skydoves/landscapist/ImageOptions;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;I)Lcom/skydoves/landscapist/plugins/ImagePlugin;
public final fun copy-jxsXWHM (JJLcom/skydoves/landscapist/placeholder/shimmer/ShimmerType;)Lcom/skydoves/landscapist/placeholder/shimmer/ShimmerPlugin;
public static synthetic fun copy-jxsXWHM$default (Lcom/skydoves/landscapist/placeholder/shimmer/ShimmerPlugin;JJLcom/skydoves/landscapist/placeholder/shimmer/ShimmerType;ILjava/lang/Object;)Lcom/skydoves/landscapist/placeholder/shimmer/ShimmerPlugin;
public final fun component3 ()I
public final fun copy-jxsXWHM (JJI)Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer$Fade;
public static synthetic fun copy-jxsXWHM$default (Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer$Fade;JJIILjava/lang/Object;)Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer$Fade;
public fun equals (Ljava/lang/Object;)Z
public final fun getBaseColor-0d7_KjU ()J
public final fun getDuration ()I
public final fun getHighlightColor-0d7_KjU ()J
public final fun getShimmerType ()Lcom/skydoves/landscapist/placeholder/shimmer/ShimmerType;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/placeholder/shimmer/ShimmerType : java/lang/Enum {
public static final field FADE Lcom/skydoves/landscapist/placeholder/shimmer/ShimmerType;
public static final field RESONATE Lcom/skydoves/landscapist/placeholder/shimmer/ShimmerType;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lcom/skydoves/landscapist/placeholder/shimmer/ShimmerType;
public static fun values ()[Lcom/skydoves/landscapist/placeholder/shimmer/ShimmerType;
public final class com/skydoves/landscapist/placeholder/shimmer/Shimmer$Flash : com/skydoves/landscapist/placeholder/shimmer/Shimmer {
public static final field $stable I
public synthetic fun <init> (JJLandroidx/compose/ui/unit/Dp;FFFIILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (JJLandroidx/compose/ui/unit/Dp;FFFILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1-0d7_KjU ()J
public final fun component2-0d7_KjU ()J
public final fun component3-lTKBWiU ()Landroidx/compose/ui/unit/Dp;
public final fun component4 ()F
public final fun component5 ()F
public final fun component6 ()F
public final fun component7 ()I
public final fun copy-EsoZhhI (JJLandroidx/compose/ui/unit/Dp;FFFI)Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer$Flash;
public static synthetic fun copy-EsoZhhI$default (Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer$Flash;JJLandroidx/compose/ui/unit/Dp;FFFIILjava/lang/Object;)Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer$Flash;
public fun equals (Ljava/lang/Object;)Z
public final fun getBaseColor-0d7_KjU ()J
public final fun getDropOff ()F
public final fun getDuration ()I
public final fun getHighlightColor-0d7_KjU ()J
public final fun getIntensity ()F
public final fun getTilt ()F
public final fun getWidth-lTKBWiU ()Landroidx/compose/ui/unit/Dp;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/placeholder/shimmer/Shimmer$Resonate : com/skydoves/landscapist/placeholder/shimmer/Shimmer {
public static final field $stable I
public synthetic fun <init> (JJIFILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (JJIFLkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1-0d7_KjU ()J
public final fun component2-0d7_KjU ()J
public final fun component3 ()I
public final fun component4 ()F
public final fun copy-RFnl5yQ (JJIF)Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer$Resonate;
public static synthetic fun copy-RFnl5yQ$default (Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer$Resonate;JJIFILjava/lang/Object;)Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer$Resonate;
public fun equals (Ljava/lang/Object;)Z
public final fun getBaseColor-0d7_KjU ()J
public final fun getDuration ()I
public final fun getHighlightColor-0d7_KjU ()J
public final fun getProgressForMaxAlpha ()F
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/placeholder/shimmer/ShimmerContainerKt {
public static final fun ShimmerContainer (Landroidx/compose/ui/Modifier;Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer;Landroidx/compose/runtime/Composer;I)V
}

public final class com/skydoves/landscapist/placeholder/shimmer/ShimmerPlugin : com/skydoves/landscapist/plugins/ImagePlugin$LoadingStatePlugin {
public static final field $stable I
public fun <init> ()V
public fun <init> (Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer;)V
public synthetic fun <init> (Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer;
public fun compose (Landroidx/compose/ui/Modifier;Lcom/skydoves/landscapist/ImageOptions;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;I)Lcom/skydoves/landscapist/plugins/ImagePlugin;
public final fun copy (Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer;)Lcom/skydoves/landscapist/placeholder/shimmer/ShimmerPlugin;
public static synthetic fun copy$default (Lcom/skydoves/landscapist/placeholder/shimmer/ShimmerPlugin;Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer;ILjava/lang/Object;)Lcom/skydoves/landscapist/placeholder/shimmer/ShimmerPlugin;
public fun equals (Ljava/lang/Object;)Z
public final fun getShimmer ()Lcom/skydoves/landscapist/placeholder/shimmer/Shimmer;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/placeholder/thumbnail/ThumbnailPlugin : com/skydoves/landscapist/plugins/ImagePlugin$LoadingStatePlugin {
Expand Down
Loading

0 comments on commit e63d616

Please sign in to comment.