Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -6576,6 +6576,11 @@ public abstract interface class com/facebook/react/views/modal/ReactModalHostVie
public abstract fun onRequestClose (Landroid/content/DialogInterface;)V
}

public final class com/facebook/react/views/progressbar/ProgressBarContainerView : android/widget/FrameLayout {
public static final field MAX_PROGRESS I
public fun <init> (Landroid/content/Context;)V
}

public final class com/facebook/react/views/progressbar/ProgressBarShadowNode : com/facebook/react/uimanager/LayoutShadowNode, com/facebook/yoga/YogaMeasureFunction {
public fun <init> ()V
public final fun getStyle ()Ljava/lang/String;
Expand All @@ -6590,20 +6595,17 @@ public class com/facebook/react/views/progressbar/ProgressBarShadowNode$$PropsSe
public fun setProperty (Lcom/facebook/react/views/progressbar/ProgressBarShadowNode;Ljava/lang/String;Ljava/lang/Object;)V
}

public class com/facebook/react/views/progressbar/ReactProgressBarViewManager : com/facebook/react/uimanager/BaseViewManager, com/facebook/react/viewmanagers/AndroidProgressBarManagerInterface {
public final class com/facebook/react/views/progressbar/ReactProgressBarViewManager : com/facebook/react/uimanager/BaseViewManager, com/facebook/react/viewmanagers/AndroidProgressBarManagerInterface {
public static final field Companion Lcom/facebook/react/views/progressbar/ReactProgressBarViewManager$Companion;
public static final field REACT_CLASS Ljava/lang/String;
public fun <init> ()V
public static fun createProgressBar (Landroid/content/Context;I)Landroid/widget/ProgressBar;
public synthetic fun createShadowNodeInstance ()Lcom/facebook/react/uimanager/ReactShadowNode;
public fun createShadowNodeInstance ()Lcom/facebook/react/views/progressbar/ProgressBarShadowNode;
protected synthetic fun createViewInstance (Lcom/facebook/react/uimanager/ThemedReactContext;)Landroid/view/View;
protected fun createViewInstance (Lcom/facebook/react/uimanager/ThemedReactContext;)Lcom/facebook/react/views/progressbar/ProgressBarContainerView;
protected fun getDelegate ()Lcom/facebook/react/uimanager/ViewManagerDelegate;
public synthetic fun createViewInstance (Lcom/facebook/react/uimanager/ThemedReactContext;)Landroid/view/View;
public fun getName ()Ljava/lang/String;
public fun getShadowNodeClass ()Ljava/lang/Class;
public fun measure (Landroid/content/Context;Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/ReadableMap;FLcom/facebook/yoga/YogaMeasureMode;FLcom/facebook/yoga/YogaMeasureMode;[F)J
protected synthetic fun onAfterUpdateTransaction (Landroid/view/View;)V
protected fun onAfterUpdateTransaction (Lcom/facebook/react/views/progressbar/ProgressBarContainerView;)V
public synthetic fun onAfterUpdateTransaction (Landroid/view/View;)V
public synthetic fun setAnimating (Landroid/view/View;Z)V
public fun setAnimating (Lcom/facebook/react/views/progressbar/ProgressBarContainerView;Z)V
public synthetic fun setColor (Landroid/view/View;Ljava/lang/Integer;)V
Expand All @@ -6629,6 +6631,10 @@ public class com/facebook/react/views/progressbar/ReactProgressBarViewManager$$P
public fun setProperty (Lcom/facebook/react/views/progressbar/ReactProgressBarViewManager;Lcom/facebook/react/views/progressbar/ProgressBarContainerView;Ljava/lang/String;Ljava/lang/Object;)V
}

public final class com/facebook/react/views/progressbar/ReactProgressBarViewManager$Companion {
public final fun createProgressBar (Landroid/content/Context;I)Landroid/widget/ProgressBar;
}

public abstract interface class com/facebook/react/views/scroll/FpsListener {
public abstract fun disable (Ljava/lang/String;)V
public abstract fun enable (Ljava/lang/String;)V
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.react.views.progressbar

import android.content.Context
import android.graphics.PorterDuff
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.ProgressBar
import com.facebook.react.bridge.JSApplicationIllegalArgumentException

/**
* Controls an enclosing [ProgressBar]. Exists so that the [ProgressBar] can be recreated if the
* style would change.
*/
public class ProgressBarContainerView(context: Context) : FrameLayout(context) {

internal var color: Int? = null
internal var indeterminate = true
internal var animating = true
internal var progress = 0.0

private var progressBar: ProgressBar? = null

internal fun apply() {
this.progressBar?.let { progressBar ->
progressBar.isIndeterminate = indeterminate
setColor(progressBar)
progressBar.progress = (progress * MAX_PROGRESS).toInt()
progressBar.visibility = if (animating) VISIBLE else INVISIBLE
} ?: throw JSApplicationIllegalArgumentException("setStyle() not called")
}

internal fun setStyle(styleName: String?) {
val style = ReactProgressBarViewManager.getStyleFromString(styleName)
progressBar =
ReactProgressBarViewManager.createProgressBar(context, style).apply { max = MAX_PROGRESS }
removeAllViews()
addView(
progressBar,
ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))
}

private fun setColor(progressBar: ProgressBar) {
val drawable =
if (progressBar.isIndeterminate) {
progressBar.indeterminateDrawable
} else {
progressBar.progressDrawable
}

if (drawable == null) {
return
}

@Suppress("DEPRECATION")
color?.let { drawable.setColorFilter(it, PorterDuff.Mode.SRC_IN) }
?: drawable.clearColorFilter()
}

private companion object {
const val MAX_PROGRESS = 1000
}
}
Loading