Skip to content

Commit

Permalink
Merge pull request #4 from mj-studio-library/animation-props
Browse files Browse the repository at this point in the history
animationDuration, animationEasing Prop
  • Loading branch information
mym0404 authored Apr 15, 2024
2 parents f91f3a1 + 9912261 commit d7dcf16
Show file tree
Hide file tree
Showing 16 changed files with 295 additions and 128 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

리액트 네이티브 [Naver Map](https://www.ncloud.com/product/applicationService/maps) 컴포넌트입니다.

<img src="https://raw.githubusercontent.com/mym0404/image-archive/master/202404101826965.webp" width="500" alt="preview">
<img src="https://raw.githubusercontent.com/mym0404/image-archive/master/202404152351235.webp" width="500" alt="preview">

## 왜 이 라이브러리를 써야하나요?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ class RNCNaverMapViewManager : RNCNaverMapViewManagerSpec<RNCNaverMapViewWrapper
}

private var initialMapOptions: NaverMapOptions? = null
private var animationDuration = 0
private var animationEasing = CameraAnimationUtil.numberToCameraAnimationEasing(0)
private var isFirstCameraMoving = true


override fun createViewInstance(
Expand Down Expand Up @@ -197,12 +200,21 @@ class RNCNaverMapViewManager : RNCNaverMapViewManagerSpec<RNCNaverMapViewWrapper
val tilt = value.getDoubleOrNull("tilt") ?: it.cameraPosition.tilt
val bearing = value.getDoubleOrNull("bearing") ?: it.cameraPosition.bearing

it.cameraPosition = CameraPosition(
latlng,
zoom,
tilt,
bearing,
it.moveCamera(
CameraUpdate.toCameraPosition(
CameraPosition(
latlng,
zoom,
tilt,
bearing,
)
).apply {
if (animationDuration > 0 && !isFirstCameraMoving) {
animate(animationEasing, animationDuration.toLong())
}
}
)
isFirstCameraMoving = false
}
}

Expand All @@ -222,11 +234,26 @@ class RNCNaverMapViewManager : RNCNaverMapViewManagerSpec<RNCNaverMapViewWrapper
@ReactProp(name = "region")
override fun setRegion(view: RNCNaverMapViewWrapper?, value: ReadableMap?) = view.withMap {
value.getLatLngBoundsOrNull()?.run {
val update = CameraUpdate.fitBounds(this)
val update = CameraUpdate.fitBounds(this).apply {
if (animationDuration > 0 && !isFirstCameraMoving) {
animate(animationEasing, animationDuration.toLong())
}
}
it.moveCamera(update)
isFirstCameraMoving = false
}
}

@ReactProp(name = "animationDuration")
override fun setAnimationDuration(view: RNCNaverMapViewWrapper?, value: Int) {
animationDuration = value
}

@ReactProp(name = "animationEasing")
override fun setAnimationEasing(view: RNCNaverMapViewWrapper?, value: Int) {
animationEasing = CameraAnimationUtil.numberToCameraAnimationEasing(value)
}

@ReactProp(name = "isIndoorEnabled")
override fun setIsIndoorEnabled(view: RNCNaverMapViewWrapper?, value: Boolean) = view.withMap {
it.isIndoorEnabled = value
Expand Down
2 changes: 2 additions & 0 deletions android/src/oldarch/RNCNaverMapViewManagerSpec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ internal interface RNCNaverMapViewManagerInterface<T : ViewGroup?> {
fun setCamera(view: T, value: ReadableMap?)
fun setInitialRegion(view: T, value: ReadableMap?)
fun setRegion(view: T, value: ReadableMap?)
fun setAnimationDuration(view: T, value: Int)
fun setAnimationEasing(view: T, value: Int)
fun setIsIndoorEnabled(view: T, value: Boolean)
fun setIsNightModeEnabled(view: T, value: Boolean)
fun setIsLiteModeEnabled(view: T, value: Boolean)
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
# your application. You should enable this flag either if you want
# to write custom TurboModules/Fabric components OR use libraries that
# are providing them.
newArchEnabled=true
newArchEnabled=false
# Use this property to enable or disable the Hermes JS engine.
# If set to false, you will be using JSC instead.
hermesEnabled=true
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PODS:
- hermes-engine/Pre-built (= 0.73.6)
- hermes-engine/Pre-built (0.73.6)
- libevent (2.1.12)
- mj-studio-react-native-naver-map (1.0.9):
- mj-studio-react-native-naver-map (1.0.11):
- glog
- hermes-engine
- NMapsMap (= 3.18.0)
Expand Down Expand Up @@ -1344,7 +1344,7 @@ SPEC CHECKSUMS:
glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2
hermes-engine: 9cecf9953a681df7556b8cc9c74905de8f3293c0
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
mj-studio-react-native-naver-map: 65c969c70ed752049a053d1ed6714c3ad3b09441
mj-studio-react-native-naver-map: 8ee73123ae3ae9cf4f9c0191fdd726876ea561fe
NMapsGeometry: 53c573ead66466681cf123f99f698dc8071a4b83
NMapsMap: 36dc18a1f5f315121b33fccd2398c7a702bf0fc8
RCT-Folly: 7169b2b1c44399c76a47b5deaaba715eeeb476c0
Expand Down
Loading

0 comments on commit d7dcf16

Please sign in to comment.