run lint-native:fix (#8836)
This commit is contained in:
@@ -43,7 +43,7 @@ class ViewController: UIViewController, WKScriptMessageHandler, WKNavigationDele
|
|||||||
let payload = try? JSONDecoder().decode(WebViewActionPayload.self, from: data) else {
|
let payload = try? JSONDecoder().decode(WebViewActionPayload.self, from: data) else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
switch payload.action {
|
switch payload.action {
|
||||||
case .present:
|
case .present:
|
||||||
self.presentAppStoreOverlay()
|
self.presentAppStoreOverlay()
|
||||||
@@ -65,18 +65,18 @@ class ViewController: UIViewController, WKScriptMessageHandler, WKNavigationDele
|
|||||||
guard let url = navigationAction.request.url else {
|
guard let url = navigationAction.request.url else {
|
||||||
return .allow
|
return .allow
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the previous one to compare later, but only set starterPackUrl when we find the right one
|
// Store the previous one to compare later, but only set starterPackUrl when we find the right one
|
||||||
prevUrl = url
|
prevUrl = url
|
||||||
// pathComponents starts with "/" as the first component, then each path name. so...
|
// pathComponents starts with "/" as the first component, then each path name. so...
|
||||||
// ["/", "start", "name", "rkey"]
|
// ["/", "start", "name", "rkey"]
|
||||||
if isStarterPackUrl(url){
|
if isStarterPackUrl(url) {
|
||||||
self.starterPackUrl = url
|
self.starterPackUrl = url
|
||||||
}
|
}
|
||||||
|
|
||||||
return .allow
|
return .allow
|
||||||
}
|
}
|
||||||
|
|
||||||
func isStarterPackUrl(_ url: URL) -> Bool {
|
func isStarterPackUrl(_ url: URL) -> Bool {
|
||||||
var host: String?
|
var host: String?
|
||||||
if #available(iOS 16.0, *) {
|
if #available(iOS 16.0, *) {
|
||||||
@@ -84,11 +84,11 @@ class ViewController: UIViewController, WKScriptMessageHandler, WKNavigationDele
|
|||||||
} else {
|
} else {
|
||||||
host = url.host
|
host = url.host
|
||||||
}
|
}
|
||||||
|
|
||||||
switch host {
|
switch host {
|
||||||
case "bsky.app":
|
case "bsky.app":
|
||||||
if url.pathComponents.count == 4,
|
if url.pathComponents.count == 4,
|
||||||
(url.pathComponents[1] == "start" || url.pathComponents[1] == "starter-pack") {
|
url.pathComponents[1] == "start" || url.pathComponents[1] == "starter-pack" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|||||||
+8
-8
@@ -19,7 +19,6 @@ import expo.modules.kotlin.AppContext
|
|||||||
import expo.modules.kotlin.viewevent.EventDispatcher
|
import expo.modules.kotlin.viewevent.EventDispatcher
|
||||||
import expo.modules.kotlin.views.ExpoView
|
import expo.modules.kotlin.views.ExpoView
|
||||||
|
|
||||||
|
|
||||||
class BottomSheetView(
|
class BottomSheetView(
|
||||||
context: Context,
|
context: Context,
|
||||||
appContext: AppContext,
|
appContext: AppContext,
|
||||||
@@ -31,12 +30,14 @@ class BottomSheetView(
|
|||||||
private lateinit var dialogRootViewGroup: DialogRootViewGroup
|
private lateinit var dialogRootViewGroup: DialogRootViewGroup
|
||||||
private var eventDispatcher: EventDispatcher? = null
|
private var eventDispatcher: EventDispatcher? = null
|
||||||
|
|
||||||
private val rawScreenHeight = context.resources.displayMetrics.heightPixels.toFloat()
|
private val rawScreenHeight =
|
||||||
|
context.resources.displayMetrics.heightPixels
|
||||||
|
.toFloat()
|
||||||
private val safeScreenHeight = (rawScreenHeight - getNavigationBarHeight()).toFloat()
|
private val safeScreenHeight = (rawScreenHeight - getNavigationBarHeight()).toFloat()
|
||||||
|
|
||||||
private fun getNavigationBarHeight(): Int {
|
private fun getNavigationBarHeight(): Int {
|
||||||
val resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android")
|
val resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android")
|
||||||
return if (resourceId > 0) resources.getDimensionPixelSize(resourceId) else 0
|
return if (resourceId > 0) resources.getDimensionPixelSize(resourceId) else 0
|
||||||
}
|
}
|
||||||
|
|
||||||
private val onAttemptDismiss by EventDispatcher()
|
private val onAttemptDismiss by EventDispatcher()
|
||||||
@@ -45,7 +46,7 @@ class BottomSheetView(
|
|||||||
|
|
||||||
// Props
|
// Props
|
||||||
var disableDrag = false
|
var disableDrag = false
|
||||||
set (value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
this.setDraggable(!value)
|
this.setDraggable(!value)
|
||||||
}
|
}
|
||||||
@@ -157,8 +158,8 @@ class BottomSheetView(
|
|||||||
|
|
||||||
// Presentation
|
// Presentation
|
||||||
|
|
||||||
private fun getHalfExpandedRatio(contentHeight: Float): Float {
|
private fun getHalfExpandedRatio(contentHeight: Float): Float =
|
||||||
return when {
|
when {
|
||||||
// Full height sheets
|
// Full height sheets
|
||||||
contentHeight >= safeScreenHeight -> 0.99f
|
contentHeight >= safeScreenHeight -> 0.99f
|
||||||
// Medium height sheets (>50% but <100%)
|
// Medium height sheets (>50% but <100%)
|
||||||
@@ -168,7 +169,6 @@ class BottomSheetView(
|
|||||||
else ->
|
else ->
|
||||||
this.clampRatio(this.getTargetHeight() / rawScreenHeight)
|
this.clampRatio(this.getTargetHeight() / rawScreenHeight)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun present() {
|
private fun present() {
|
||||||
if (this.isOpen || this.isOpening || this.isClosing) return
|
if (this.isOpen || this.isOpening || this.isClosing) return
|
||||||
|
|||||||
+4
-1
@@ -139,7 +139,10 @@ class DialogRootViewGroup(
|
|||||||
return super.onHoverEvent(event)
|
return super.onHoverEvent(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onChildStartedNativeGesture(childView: View?, ev: MotionEvent) {
|
override fun onChildStartedNativeGesture(
|
||||||
|
childView: View?,
|
||||||
|
ev: MotionEvent,
|
||||||
|
) {
|
||||||
eventDispatcher?.let { jSTouchDispatcher.onChildStartedNativeGesture(ev, it) }
|
eventDispatcher?.let { jSTouchDispatcher.onChildStartedNativeGesture(ev, it) }
|
||||||
jSPointerDispatcher?.onChildStartedNativeGesture(childView, ev, eventDispatcher)
|
jSPointerDispatcher?.onChildStartedNativeGesture(childView, ev, eventDispatcher)
|
||||||
}
|
}
|
||||||
|
|||||||
+60
-60
@@ -16,8 +16,8 @@ import expo.modules.kotlin.viewevent.EventDispatcher
|
|||||||
import expo.modules.kotlin.views.ExpoView
|
import expo.modules.kotlin.views.ExpoView
|
||||||
|
|
||||||
class GifView(
|
class GifView(
|
||||||
context: Context,
|
context: Context,
|
||||||
appContext: AppContext,
|
appContext: AppContext,
|
||||||
) : ExpoView(context, appContext) {
|
) : ExpoView(context, appContext) {
|
||||||
// Events
|
// Events
|
||||||
private val onPlayerStateChange by EventDispatcher()
|
private val onPlayerStateChange by EventDispatcher()
|
||||||
@@ -82,65 +82,65 @@ class GifView(
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.webpRequest =
|
this.webpRequest =
|
||||||
glide.load(source)
|
glide
|
||||||
.diskCacheStrategy(DiskCacheStrategy.DATA)
|
.load(source)
|
||||||
.skipMemoryCache(false)
|
.diskCacheStrategy(DiskCacheStrategy.DATA)
|
||||||
.listener(
|
.skipMemoryCache(false)
|
||||||
object : RequestListener<Drawable> {
|
.listener(
|
||||||
override fun onResourceReady(
|
object : RequestListener<Drawable> {
|
||||||
resource: Drawable,
|
override fun onResourceReady(
|
||||||
model: Any,
|
resource: Drawable,
|
||||||
target: Target<Drawable>?,
|
model: Any,
|
||||||
dataSource: DataSource,
|
target: Target<Drawable>?,
|
||||||
isFirstResource: Boolean
|
dataSource: DataSource,
|
||||||
): Boolean {
|
isFirstResource: Boolean,
|
||||||
placeholderRequest?.let { glide.clear(it) }
|
): Boolean {
|
||||||
return false
|
placeholderRequest?.let { glide.clear(it) }
|
||||||
}
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
override fun onLoadFailed(
|
override fun onLoadFailed(
|
||||||
e: GlideException?,
|
e: GlideException?,
|
||||||
model: Any?,
|
model: Any?,
|
||||||
target: Target<Drawable>,
|
target: Target<Drawable>,
|
||||||
isFirstResource: Boolean
|
isFirstResource: Boolean,
|
||||||
): Boolean = true
|
): Boolean = true
|
||||||
}
|
},
|
||||||
)
|
).into(this.imageView)
|
||||||
.into(this.imageView)
|
|
||||||
|
|
||||||
if (this.imageView.drawable == null || this.imageView.drawable !is Animatable) {
|
if (this.imageView.drawable == null || this.imageView.drawable !is Animatable) {
|
||||||
this.placeholderRequest =
|
this.placeholderRequest =
|
||||||
glide.load(placeholderSource)
|
glide
|
||||||
.diskCacheStrategy(DiskCacheStrategy.DATA)
|
.load(placeholderSource)
|
||||||
// Let's not bloat the memory cache with placeholders
|
.diskCacheStrategy(DiskCacheStrategy.DATA)
|
||||||
.skipMemoryCache(true)
|
// Let's not bloat the memory cache with placeholders
|
||||||
.listener(
|
.skipMemoryCache(true)
|
||||||
object : RequestListener<Drawable> {
|
.listener(
|
||||||
override fun onResourceReady(
|
object : RequestListener<Drawable> {
|
||||||
resource: Drawable,
|
override fun onResourceReady(
|
||||||
model: Any,
|
resource: Drawable,
|
||||||
target: Target<Drawable>?,
|
model: Any,
|
||||||
dataSource: DataSource,
|
target: Target<Drawable>?,
|
||||||
isFirstResource: Boolean
|
dataSource: DataSource,
|
||||||
): Boolean {
|
isFirstResource: Boolean,
|
||||||
// Incase this request finishes after the webp, let's just not set
|
): Boolean {
|
||||||
// the drawable. This shouldn't happen because the request should
|
// Incase this request finishes after the webp, let's just not set
|
||||||
// get cancelled
|
// the drawable. This shouldn't happen because the request should
|
||||||
if (imageView.drawable == null) {
|
// get cancelled
|
||||||
imageView.setImageDrawable(resource)
|
if (imageView.drawable == null) {
|
||||||
}
|
imageView.setImageDrawable(resource)
|
||||||
return true
|
}
|
||||||
}
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
override fun onLoadFailed(
|
override fun onLoadFailed(
|
||||||
e: GlideException?,
|
e: GlideException?,
|
||||||
model: Any?,
|
model: Any?,
|
||||||
target: Target<Drawable>,
|
target: Target<Drawable>,
|
||||||
isFirstResource: Boolean
|
isFirstResource: Boolean,
|
||||||
): Boolean = true
|
): Boolean = true
|
||||||
},
|
},
|
||||||
)
|
).submit()
|
||||||
.submit()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,10 +174,10 @@ class GifView(
|
|||||||
|
|
||||||
fun firePlayerStateChange() {
|
fun firePlayerStateChange() {
|
||||||
onPlayerStateChange(
|
onPlayerStateChange(
|
||||||
mapOf(
|
mapOf(
|
||||||
"isPlaying" to this.isPlaying,
|
"isPlaying" to this.isPlaying,
|
||||||
"isLoaded" to this.isLoaded,
|
"isLoaded" to this.isLoaded,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-5
@@ -5,11 +5,12 @@ import expo.modules.kotlin.modules.ModuleDefinition
|
|||||||
import java.net.URL
|
import java.net.URL
|
||||||
|
|
||||||
class EmojiPickerModule : Module() {
|
class EmojiPickerModule : Module() {
|
||||||
override fun definition() = ModuleDefinition {
|
override fun definition() =
|
||||||
Name("EmojiPicker")
|
ModuleDefinition {
|
||||||
|
Name("EmojiPicker")
|
||||||
|
|
||||||
View(EmojiPickerModuleView::class) {
|
View(EmojiPickerModuleView::class) {
|
||||||
Events("onEmojiSelected")
|
Events("onEmojiSelected")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+27
-25
@@ -8,33 +8,35 @@ import expo.modules.kotlin.AppContext
|
|||||||
import expo.modules.kotlin.viewevent.EventDispatcher
|
import expo.modules.kotlin.viewevent.EventDispatcher
|
||||||
import expo.modules.kotlin.views.ExpoView
|
import expo.modules.kotlin.views.ExpoView
|
||||||
|
|
||||||
|
|
||||||
@SuppressLint("ViewConstructor")
|
@SuppressLint("ViewConstructor")
|
||||||
class EmojiPickerModuleView(context: Context, appContext: AppContext) :
|
class EmojiPickerModuleView(
|
||||||
ExpoView(context, appContext) {
|
context: Context,
|
||||||
private var emojiView: EmojiPickerView = EmojiPickerView(context)
|
appContext: AppContext,
|
||||||
private val onEmojiSelected by EventDispatcher()
|
) : ExpoView(context, appContext) {
|
||||||
|
private var emojiView: EmojiPickerView = EmojiPickerView(context)
|
||||||
|
private val onEmojiSelected by EventDispatcher()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
setupView()
|
setupView()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupView() {
|
||||||
|
addView(
|
||||||
|
emojiView,
|
||||||
|
LayoutParams(
|
||||||
|
LayoutParams.MATCH_PARENT,
|
||||||
|
LayoutParams.MATCH_PARENT,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
emojiView.setOnEmojiPickedListener { emoji ->
|
||||||
|
onEmojiSelected(mapOf("emoji" to emoji.emoji))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setupView() {
|
override fun onConfigurationChanged(newConfig: Configuration?) {
|
||||||
addView(
|
super.onConfigurationChanged(newConfig)
|
||||||
emojiView, LayoutParams(
|
removeView(emojiView)
|
||||||
LayoutParams.MATCH_PARENT,
|
setupView()
|
||||||
LayoutParams.MATCH_PARENT
|
}
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
emojiView.setOnEmojiPickedListener { emoji ->
|
|
||||||
onEmojiSelected(mapOf("emoji" to emoji.emoji))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onConfigurationChanged(newConfig: Configuration?) {
|
|
||||||
super.onConfigurationChanged(newConfig)
|
|
||||||
removeView(emojiView)
|
|
||||||
setupView()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user