Skip to content

Commit

Permalink
Merge pull request #39 from mym0404/path-pattern-image
Browse files Browse the repository at this point in the history
`patternImage` prop of path overlay
  • Loading branch information
mym0404 authored May 8, 2024
2 parents 2fc7016 + cc9fbfd commit 263f58a
Show file tree
Hide file tree
Showing 40 changed files with 384 additions and 258 deletions.
55 changes: 53 additions & 2 deletions .husky/_/commit-msg
Original file line number Diff line number Diff line change
@@ -1,2 +1,53 @@
#!/usr/bin/env sh
. "${0%/*}/h"
#!/bin/sh

if [ "$LEFTHOOK_VERBOSE" = "1" -o "$LEFTHOOK_VERBOSE" = "true" ]; then
set -x
fi

if [ "$LEFTHOOK" = "0" ]; then
exit 0
fi

call_lefthook()
{
dir="$(git rev-parse --show-toplevel)"
osArch=$(uname | tr '[:upper:]' '[:lower:]')
cpuArch=$(uname -m | sed 's/aarch64/arm64/')

if test -n "$LEFTHOOK_BIN"
then
"$LEFTHOOK_BIN" "$@"
elif lefthook -h >/dev/null 2>&1
then
lefthook "$@"
elif test -f "$dir/node_modules/lefthook/bin/index.js"
then
"$dir/node_modules/lefthook/bin/index.js" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook_${osArch}_${cpuArch}/lefthook"
then
"$dir/node_modules/@evilmartians/lefthook/bin/lefthook_${osArch}_${cpuArch}/lefthook" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook_${osArch}_${cpuArch}/lefthook"
then
"$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook_${osArch}_${cpuArch}/lefthook" "$@"

elif bundle exec lefthook -h >/dev/null 2>&1
then
bundle exec lefthook "$@"
elif yarn lefthook -h >/dev/null 2>&1
then
yarn lefthook "$@"
elif pnpm lefthook -h >/dev/null 2>&1
then
pnpm lefthook "$@"
elif swift package plugin lefthook >/dev/null 2>&1
then
swift package --disable-sandbox plugin lefthook "$@"
elif command -v npx >/dev/null 2>&1
then
npx lefthook "$@"
else
echo "Can't find lefthook in PATH"
fi
}

call_lefthook run "commit-msg" "$@"
53 changes: 0 additions & 53 deletions .husky/_/lint

This file was deleted.

55 changes: 53 additions & 2 deletions .husky/_/pre-commit
Original file line number Diff line number Diff line change
@@ -1,2 +1,53 @@
#!/usr/bin/env sh
. "${0%/*}/h"
#!/bin/sh

if [ "$LEFTHOOK_VERBOSE" = "1" -o "$LEFTHOOK_VERBOSE" = "true" ]; then
set -x
fi

if [ "$LEFTHOOK" = "0" ]; then
exit 0
fi

call_lefthook()
{
dir="$(git rev-parse --show-toplevel)"
osArch=$(uname | tr '[:upper:]' '[:lower:]')
cpuArch=$(uname -m | sed 's/aarch64/arm64/')

if test -n "$LEFTHOOK_BIN"
then
"$LEFTHOOK_BIN" "$@"
elif lefthook -h >/dev/null 2>&1
then
lefthook "$@"
elif test -f "$dir/node_modules/lefthook/bin/index.js"
then
"$dir/node_modules/lefthook/bin/index.js" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook_${osArch}_${cpuArch}/lefthook"
then
"$dir/node_modules/@evilmartians/lefthook/bin/lefthook_${osArch}_${cpuArch}/lefthook" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook_${osArch}_${cpuArch}/lefthook"
then
"$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook_${osArch}_${cpuArch}/lefthook" "$@"

elif bundle exec lefthook -h >/dev/null 2>&1
then
bundle exec lefthook "$@"
elif yarn lefthook -h >/dev/null 2>&1
then
yarn lefthook "$@"
elif pnpm lefthook -h >/dev/null 2>&1
then
pnpm lefthook "$@"
elif swift package plugin lefthook >/dev/null 2>&1
then
swift package --disable-sandbox plugin lefthook "$@"
elif command -v npx >/dev/null 2>&1
then
npx lefthook "$@"
else
echo "Can't find lefthook in PATH"
fi
}

call_lefthook run "pre-commit" "$@"
2 changes: 0 additions & 2 deletions .husky/_/pre-push

This file was deleted.

55 changes: 53 additions & 2 deletions .husky/_/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -1,2 +1,53 @@
#!/usr/bin/env sh
. "${0%/*}/h"
#!/bin/sh

if [ "$LEFTHOOK_VERBOSE" = "1" -o "$LEFTHOOK_VERBOSE" = "true" ]; then
set -x
fi

if [ "$LEFTHOOK" = "0" ]; then
exit 0
fi

call_lefthook()
{
dir="$(git rev-parse --show-toplevel)"
osArch=$(uname | tr '[:upper:]' '[:lower:]')
cpuArch=$(uname -m | sed 's/aarch64/arm64/')

if test -n "$LEFTHOOK_BIN"
then
"$LEFTHOOK_BIN" "$@"
elif lefthook -h >/dev/null 2>&1
then
lefthook "$@"
elif test -f "$dir/node_modules/lefthook/bin/index.js"
then
"$dir/node_modules/lefthook/bin/index.js" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook_${osArch}_${cpuArch}/lefthook"
then
"$dir/node_modules/@evilmartians/lefthook/bin/lefthook_${osArch}_${cpuArch}/lefthook" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook_${osArch}_${cpuArch}/lefthook"
then
"$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook_${osArch}_${cpuArch}/lefthook" "$@"

elif bundle exec lefthook -h >/dev/null 2>&1
then
bundle exec lefthook "$@"
elif yarn lefthook -h >/dev/null 2>&1
then
yarn lefthook "$@"
elif pnpm lefthook -h >/dev/null 2>&1
then
pnpm lefthook "$@"
elif swift package plugin lefthook >/dev/null 2>&1
then
swift package --disable-sandbox plugin lefthook "$@"
elif command -v npx >/dev/null 2>&1
then
npx lefthook "$@"
else
echo "Can't find lefthook in PATH"
fi
}

call_lefthook run "prepare-commit-msg" "$@"
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -618,14 +618,6 @@ iOS에선 단순히 `UIView`를 `UIImage`로 캔버스에 그려 표시해줍니
| caption-fontFamily |||
| subcaption-fontFamily |||

### `NaverMapPathOverlay`

#### Props

| Prop | iOS | Android |
|------------------------|-----|---------|
| patternImage | 📦 | 📦 |

## Supporting Table - Architecture

| | iOS | Android |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,18 @@ package com.mjstudio.reactnativenavermap.overlay.ground

import android.annotation.SuppressLint
import android.graphics.Bitmap
import com.facebook.drawee.generic.GenericDraweeHierarchy
import com.facebook.drawee.view.DraweeHolder
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.uimanager.ThemedReactContext
import com.mjstudio.reactnativenavermap.event.NaverMapOverlayTapEvent
import com.mjstudio.reactnativenavermap.overlay.RNCNaverMapOverlay
import com.mjstudio.reactnativenavermap.util.ImageRequestCanceller
import com.mjstudio.reactnativenavermap.util.createDraweeHierarchy
import com.mjstudio.reactnativenavermap.util.RNCNaverMapImageRenderableOverlay
import com.mjstudio.reactnativenavermap.util.emitEvent
import com.mjstudio.reactnativenavermap.util.getOverlayImage
import com.naver.maps.map.NaverMap
import com.naver.maps.map.overlay.GroundOverlay
import com.naver.maps.map.overlay.OverlayImage
import com.naver.maps.map.util.MarkerIcons

@SuppressLint("ViewConstructor")
class RNCNaverMapGround(private val reactContext: ThemedReactContext) :
RNCNaverMapOverlay<GroundOverlay>(reactContext) {
private val imageHolder: DraweeHolder<GenericDraweeHierarchy>? by lazy {
DraweeHolder.create(createDraweeHierarchy(resources), reactContext)?.apply {
onAttach()
}
}
private var lastImage: ReadableMap? = null
private var imageRequestCanceller: ImageRequestCanceller? = null
RNCNaverMapImageRenderableOverlay<GroundOverlay>(reactContext) {
private var isImageSet = false

override val overlay: GroundOverlay by lazy {
Expand Down Expand Up @@ -58,23 +45,15 @@ class RNCNaverMapGround(private val reactContext: ThemedReactContext) :
override fun onDropViewInstance() {
overlay.map = null
overlay.onClickListener = null
imageHolder?.onDetach()
imageRequestCanceller?.invoke()
super.onDropViewInstance()
}

fun setImage(image: ReadableMap?) {
lastImage = image
overlay.alpha = 0f
imageRequestCanceller?.invoke()
imageRequestCanceller =
getOverlayImage(imageHolder!!, context, image?.toHashMap()) {
setOverlayImage(it)
isImageSet = true
overlay.alpha = 1f
}
override fun setOverlayAlpha(alpha: Float) {
overlay.alpha = alpha
}

private fun setOverlayImage(image: OverlayImage?) {
override fun setOverlayImage(image: OverlayImage?) {
isImageSet = true
overlay.image =
image ?: OverlayImage.fromBitmap(Bitmap.createBitmap(0, 0, Bitmap.Config.ARGB_8888))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,21 @@ import android.view.View
import androidx.core.view.children
import com.airbnb.android.react.maps.TrackableView
import com.airbnb.android.react.maps.ViewChangesTracker
import com.facebook.drawee.generic.GenericDraweeHierarchy
import com.facebook.drawee.view.DraweeHolder
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.uimanager.ThemedReactContext
import com.mjstudio.reactnativenavermap.event.NaverMapOverlayTapEvent
import com.mjstudio.reactnativenavermap.overlay.RNCNaverMapOverlay
import com.mjstudio.reactnativenavermap.util.ImageRequestCanceller
import com.mjstudio.reactnativenavermap.util.createDraweeHierarchy
import com.mjstudio.reactnativenavermap.util.RNCNaverMapImageRenderableOverlay
import com.mjstudio.reactnativenavermap.util.emitEvent
import com.mjstudio.reactnativenavermap.util.getOverlayImage
import com.naver.maps.map.NaverMap
import com.naver.maps.map.overlay.Marker
import com.naver.maps.map.overlay.OverlayImage
import kotlin.math.max

@SuppressLint("ViewConstructor")
class RNCNaverMapMarker(val reactContext: ThemedReactContext) :
RNCNaverMapOverlay<Marker>(reactContext), TrackableView {
private val imageHolder: DraweeHolder<GenericDraweeHierarchy>? by lazy {
DraweeHolder.create(createDraweeHierarchy(resources), reactContext)?.apply {
onAttach()
}
}
RNCNaverMapImageRenderableOverlay<Marker>(reactContext), TrackableView {
private var customView: View? = null
private var customViewBitmap: Bitmap? = null
private var lastImage: ReadableMap? = null
private var imageRequestCanceller: ImageRequestCanceller? = null

private var isImageSetFromSubview = false

override val overlay: Marker by lazy {
Expand Down Expand Up @@ -62,8 +50,7 @@ class RNCNaverMapMarker(val reactContext: ThemedReactContext) :
override fun onDropViewInstance() {
overlay.map = null
overlay.onClickListener = null
imageHolder?.onDetach()
imageRequestCanceller?.invoke()
super.onDropViewInstance()
}

fun setCustomView(
Expand Down Expand Up @@ -91,7 +78,7 @@ class RNCNaverMapMarker(val reactContext: ThemedReactContext) :
ViewChangesTracker.getInstance().removeMarker(this)
if (customViewBitmap != null && !customViewBitmap!!.isRecycled) customViewBitmap!!.recycle()
isImageSetFromSubview = false
setImage(lastImage)
setImageWithLastImage()
super.removeView(children.elementAt(index))
}

Expand Down Expand Up @@ -125,6 +112,10 @@ class RNCNaverMapMarker(val reactContext: ThemedReactContext) :
}
}

override fun skipTryRender(): Boolean {
return isImageSetFromSubview
}

override fun updateCustomForTracking(): Boolean {
return true
}
Expand All @@ -136,19 +127,11 @@ class RNCNaverMapMarker(val reactContext: ThemedReactContext) :
updateCustomView()
}

fun setImage(image: ReadableMap?) {
lastImage = image
if (isImageSetFromSubview) return
overlay.alpha = 0f
imageRequestCanceller?.invoke()
imageRequestCanceller =
getOverlayImage(imageHolder!!, context, image?.toHashMap()) {
setOverlayImage(it)
overlay.alpha = 1f
}
override fun setOverlayAlpha(alpha: Float) {
overlay.alpha = alpha
}

private fun setOverlayImage(image: OverlayImage?) {
override fun setOverlayImage(image: OverlayImage?) {
overlay.icon =
image ?: OverlayImage.fromBitmap(Bitmap.createBitmap(0, 0, Bitmap.Config.ARGB_8888))
}
Expand Down
Loading

0 comments on commit 263f58a

Please sign in to comment.