Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add react-native-animate (#8) #11

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mvillafuertem
Copy link
Collaborator

I had some problems with my fork and I had to delete it, to recover the changes I had to merge into a scalablytyped branch. I'm sorry :(

@mvillafuertem mvillafuertem marked this pull request as draft March 29, 2021 20:10
@oyvindberg
Copy link
Contributor

Don't worry at all

Thanks for keeping it up here. I'll have a look as soon as easter permits :)

@oyvindberg
Copy link
Contributor

You can type the animated components like this:

diff --git a/react-native-animations/src/main/scala/demo/AnimatedIconApp.scala b/react-native-animations/src/main/scala/demo/AnimatedIconApp.scala
index 8b569ea..84b930e 100644
--- a/react-native-animations/src/main/scala/demo/AnimatedIconApp.scala
+++ b/react-native-animations/src/main/scala/demo/AnimatedIconApp.scala
@@ -8,7 +8,7 @@ import japgolly.scalajs.react.{CallbackTo, Children, CtorType, JsComponent, Scal
 import typings.react.mod.useState
 import typings.reactNative.components.{TouchableWithoutFeedback, View}
 import typings.reactNative.mod.Animated.{InterpolationConfigType, SpringAnimationConfig, TimingAnimationConfig}
-import typings.reactNative.mod.{Animated, FlexAlignType, ViewStyle}
+import typings.reactNative.mod.{Animated, FlexAlignType, OpaqueColorValue, ViewProps, ViewStyle}
 import typings.reactNative.reactNativeStrings
 
 import scala.scalajs.js
@@ -97,25 +97,19 @@ object AnimatedIconApp {
     )(
       TouchableWithoutFeedback().onPress((_) => CallbackTo[Unit](startAnimation()))(
         AnimatedView.component(
-          js.Dynamic
-            .literal(
-              style = js.Array(
-                js.Dynamic.literal(
-                  display = reactNativeStrings.flex,
-                  flexDirection = reactNativeStrings.column,
-                  justifyContent = reactNativeStrings.`space-between`,
-                  alignItems = reactNativeStrings.center,
-                  width = 100,
-                  height = 100,
-                  paddingVertical = 20,
-                  borderRadius = 50,
-                  backgroundColor = jsAnimation
-                    .interpolate(InterpolationConfigType(js.Array(0, 1), js.Array("green", "red")))
-                    .asInstanceOf[js.Dynamic]
-                )
-              )
-            )
-            .asInstanceOf[AnimatedViewProps]
+          ViewProps()
+            .setStyle(
+              ViewStyle()
+                .setDisplay(reactNativeStrings.flex)
+                .setFlexDirection(reactNativeStrings.column)
+                .setJustifyContent(reactNativeStrings.`space-between`)
+                .setAlignItems(FlexAlignType.center)
+                .setWidth(100)
+                .setHeight(100)
+                .setPaddingVertical(20)
+                .setBorderRadius(50)
+                .setBackgroundColor(jsAnimation.interpolate(InterpolationConfigType(js.Array(0, 1), js.Array("green", "red"))).asInstanceOf[OpaqueColorValue])
+          ),
         )(
           AnimatedView.component(
             js.Dynamic
diff --git a/react-native-animations/src/main/scala/demo/facade/AnimatedView.scala b/react-native-animations/src/main/scala/demo/facade/AnimatedView.scala
index 30c7b9c..de5f3e7 100644
--- a/react-native-animations/src/main/scala/demo/facade/AnimatedView.scala
+++ b/react-native-animations/src/main/scala/demo/facade/AnimatedView.scala
@@ -1,8 +1,8 @@
 package demo.facade
 
-import japgolly.scalajs.react.{Children, CtorType, JsComponent}
 import japgolly.scalajs.react.component.Js
-import typings.reactNative.components.SharedBuilder_ViewProps39190290
+import japgolly.scalajs.react.{Children, CtorType, JsComponent}
+import typings.reactNative.mod.ViewProps
 
 import scala.scalajs.js
 import scala.scalajs.js.annotation.JSImport
@@ -13,11 +13,8 @@ object AnimatedView {
   @js.native
   object RawComponent extends js.Object
 
-  @js.native
-  trait AnimatedViewProps extends js.Object {}
-
-  val component: Js.Component[AnimatedViewProps, Null, CtorType.PropsAndChildren] =
-    JsComponent[AnimatedViewProps, Children.Varargs, Null](RawComponent)
+  val component: Js.Component[ViewProps, Null, CtorType.PropsAndChildren] =
+    JsComponent[ViewProps, Children.Varargs, Null](RawComponent)
 
 
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants