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 to ScrollView all props inherited from View #326

Merged
merged 2 commits into from
Feb 5, 2020
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
+ Use js.Object instead of js.Dynamics on attribute style [PR #322](https://github.com/shadaj/slinky/pull/322)
+ Add support for Scala.js 1.0.0-RC2 [PR #321](https://github.com/shadaj/slinky/pull/321)
+ Rewrite the class component logic to patch the component definition once to handle JS data instead of on every initialization [PR #321](https://github.com/shadaj/slinky/pull/321)
+ Add missing inherited props to native ScrollView component [PR #326](https://github.com/shadaj/slinky/pull/326)

## [v0.6.3](https://slinky.dev)
### Highlights :tada:
Expand Down
33 changes: 31 additions & 2 deletions native/src/main/scala/slinky/native/ScrollView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ trait ScrollViewInstance extends js.Object {
onScrollEndDrag: js.UndefOr[() => Unit] = js.undefined,
pagingEnabled: js.UndefOr[Boolean] = js.undefined,
refreshControl: js.UndefOr[ReactElement] = js.undefined,
removeClippedSubviews: js.UndefOr[Boolean] = js.undefined,
scrollEnabled: js.UndefOr[Boolean] = js.undefined,
showsHorizontalScrollIndicator: js.UndefOr[Boolean] = js.undefined,
showsVerticalScrollIndicator: js.UndefOr[Boolean] = js.undefined,
Expand Down Expand Up @@ -63,7 +62,37 @@ trait ScrollViewInstance extends js.Object {
scrollsToTop: js.UndefOr[Boolean] = js.undefined,
snapToAlignment: js.UndefOr[String] = js.undefined,
snapToInterval: js.UndefOr[Double] = js.undefined,
zoomScale: js.UndefOr[Double] = js.undefined
zoomScale: js.UndefOr[Double] = js.undefined,
// start of props inherited from View
onStartShouldSetResponder: js.UndefOr[NativeSyntheticEvent[NativeTouchEvent] => Unit] = js.undefined,
accessibilityLabel: js.UndefOr[ReactElement] = js.undefined,
hitSlop: js.UndefOr[BoundingBox] = js.undefined,
nativeID: js.UndefOr[String] = js.undefined,
onLayout: js.UndefOr[NativeSyntheticEvent[LayoutChangeEvent] => Unit] = js.undefined,
onMagicTap: js.UndefOr[() => Unit] = js.undefined,
onMoveShouldSetResponder: js.UndefOr[NativeSyntheticEvent[NativeTouchEvent] => Boolean] = js.undefined,
onMoveShouldSetResponderCapture: js.UndefOr[NativeSyntheticEvent[NativeTouchEvent] => Boolean] = js.undefined,
onResponderGrant: js.UndefOr[NativeSyntheticEvent[NativeTouchEvent] => Unit] = js.undefined,
onResponderMove: js.UndefOr[NativeSyntheticEvent[NativeTouchEvent] => Unit] = js.undefined,
onResponderReject: js.UndefOr[NativeSyntheticEvent[NativeTouchEvent] => Unit] = js.undefined,
onResponderRelease: js.UndefOr[NativeSyntheticEvent[NativeTouchEvent] => Unit] = js.undefined,
onResponderTerminate: js.UndefOr[NativeSyntheticEvent[NativeTouchEvent] => Unit] = js.undefined,
onResponderTerminationRequest: js.UndefOr[NativeSyntheticEvent[NativeTouchEvent] => Boolean] = js.undefined,
accessible: js.UndefOr[Boolean] = js.undefined,
onStartShouldSetResponderCapture: js.UndefOr[NativeSyntheticEvent[NativeTouchEvent] => Boolean] = js.undefined,
pointerEvents: js.UndefOr[String] = js.undefined,
removeClippedSubviews: js.UndefOr[Boolean] = js.undefined,
style: js.UndefOr[js.Object] = js.undefined,
testID: js.UndefOr[String] = js.undefined,
accessibilityComponentType: js.UndefOr[String] = js.undefined,
accessibilityLiveRegion: js.UndefOr[String] = js.undefined,
collapsable: js.UndefOr[Boolean] = js.undefined,
importantForAccessibility: js.UndefOr[String] = js.undefined,
needsOffscreenAlphaCompositing: js.UndefOr[Boolean] = js.undefined,
renderToHardwareTextureAndroid: js.UndefOr[Boolean] = js.undefined,
accessibilityTraits: js.UndefOr[String | Seq[String]] = js.undefined,
accessibilityViewIsModal: js.UndefOr[Boolean] = js.undefined,
shouldRasterizeIOS: js.UndefOr[Boolean] = js.undefined
)

@js.native
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import org.scalatest.funsuite.AnyFunSuite
import slinky.testrenderer.TestRenderer

import scala.scalajs.js
import scala.scalajs.js.Dynamic.literal

class NativeComponentRenderTest extends AnyFunSuite {
test("Can render a button component") {
Expand Down Expand Up @@ -49,6 +50,23 @@ class NativeComponentRenderTest extends AnyFunSuite {
)
}

val testStyle = literal(
fontSize = 20,
color = "black"
)

test("Can render a view component with style") {
assert(
!js.isUndefined(
TestRenderer
.create(
View(style = testStyle)()
)
.toJSON()
)
)
}

test("Can render an image component") {
assert(
!js.isUndefined(
Expand Down Expand Up @@ -111,6 +129,16 @@ class NativeComponentRenderTest extends AnyFunSuite {
)
}

test("Can render a ScrollView with style") {
assert(
!js.isUndefined(
TestRenderer.create(
ScrollView(style = testStyle)()
)
)
)
}

test("Can call scrollTo() on a scroll view instance") {
var scrolled = false
assert(
Expand Down