-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathOutlineProvider.kt
More file actions
33 lines (29 loc) · 912 Bytes
/
OutlineProvider.kt
File metadata and controls
33 lines (29 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.reactnativenavigation.utils
import android.graphics.Outline
import android.os.Build
import android.view.View
import android.view.ViewOutlineProvider
import androidx.annotation.RequiresApi
import com.reactnativenavigation.views.element.animators.ViewOutline
import kotlin.math.roundToInt
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
class OutlineProvider(
private val view: View,
private var outline: ViewOutline
) : ViewOutlineProvider() {
val radius: Float
get() = outline.radius
override fun getOutline(view: View, outline: Outline) {
outline.setRoundRect(
0,
0,
this.outline.width.roundToInt(),
this.outline.height.roundToInt(),
this.outline.radius
)
}
fun update(outline: ViewOutline) {
this.outline = outline
view.invalidateOutline()
}
}