1 /* 2 * Copyright 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 @file:Suppress("DEPRECATION") 18 19 package androidx.compose.foundation 20 21 import androidx.compose.foundation.layout.PaddingValues 22 import androidx.compose.runtime.Stable 23 import androidx.compose.runtime.compositionLocalOf 24 import androidx.compose.ui.graphics.Color 25 26 /** 27 * Metadata for overscroll effects for android platform. 28 * 29 * @param glowColor color for the glow effect, if the platform effect is a glow effect, otherwise 30 * ignored. 31 * @param drawPadding the amount of padding to apply from scrollable container bounds to the effect 32 * before drawing it, if the platform effect is a glow effect, otherwise ignored. 33 */ 34 @Deprecated( 35 "Providing `OverscrollConfiguration` through `LocalOverscrollConfiguration` to disable / configure overscroll has been replaced with `LocalOverscrollFactory` and `rememberPlatformOverscrollFactory`. To disable overscroll, instead of `LocalOverscrollConfiguration provides null`, use `LocalOverscrollFactory provides null`. To change the glow color / padding, instead of `LocalOverscrollConfiguration provides OverscrollConfiguration(myColor, myPadding)`, use `LocalOverscrollFactory provides rememberPlatformOverscrollFactory(myColor, myPadding)`" 36 ) 37 @ExperimentalFoundationApi 38 @Stable 39 class OverscrollConfiguration( 40 val glowColor: Color = Color(0xff666666), // taken from EdgeEffect.java defaults 41 val drawPadding: PaddingValues = PaddingValues() 42 ) { equalsnull43 override fun equals(other: Any?): Boolean { 44 if (this === other) return true 45 if (javaClass != other?.javaClass) return false 46 47 other as OverscrollConfiguration 48 49 if (glowColor != other.glowColor) return false 50 if (drawPadding != other.drawPadding) return false 51 52 return true 53 } 54 hashCodenull55 override fun hashCode(): Int { 56 var result = glowColor.hashCode() 57 result = 31 * result + drawPadding.hashCode() 58 return result 59 } 60 toStringnull61 override fun toString(): String { 62 return "OverscrollConfiguration(glowColor=$glowColor, drawPadding=$drawPadding)" 63 } 64 } 65 66 /** 67 * Composition local to provide configuration for scrolling containers down the hierarchy. `null` 68 * means there will be no overscroll at all. 69 */ 70 @Deprecated( 71 "Providing `OverscrollConfiguration` through `LocalOverscrollConfiguration` to disable / configure overscroll has been replaced with `LocalOverscrollFactory` and `rememberPlatformOverscrollFactory`. To disable overscroll, instead of `LocalOverscrollConfiguration provides null`, use `LocalOverscrollFactory provides null`. To change the glow color / padding, instead of `LocalOverscrollConfiguration provides OverscrollConfiguration(myColor, myPadding)`, use `LocalOverscrollFactory provides rememberPlatformOverscrollFactory(myColor, myPadding)`", 72 replaceWith = 73 ReplaceWith("LocalOverscrollFactory", "androidx.compose.foundation.LocalOverscrollFactory") 74 ) 75 @Suppress("OPT_IN_MARKER_ON_WRONG_TARGET") 76 @ExperimentalFoundationApi 77 @get:ExperimentalFoundationApi 78 val LocalOverscrollConfiguration = <lambda>null79 compositionLocalOf<OverscrollConfiguration?> { OverscrollConfiguration() } 80