@nativue/core 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -109,7 +109,11 @@ Import the runtime from `vue`: `ref`, `computed`, `StyleSheet`, `Animated`, `Lay
109
109
  - Tab and header icons (`tabBarIcon`, a header item's `icon`): an `@nativue/icons` component,
110
110
  `svgIcon(viewBox, elements)` from `@nativue/svg`, an image `{ uri }`, or an SF Symbol name (iOS).
111
111
  - Official packages: `@nativue/svg`, `@nativue/icons` (icon components), `@nativue/tailwind`, `@nativue/haptics`,
112
- `@nativue/clipboard` (copy text), `@nativue/notifications` (local notifications), `@nativue/sqlite`.
112
+ `@nativue/clipboard` (copy text), `@nativue/notifications` (local notifications), `@nativue/sqlite`,
113
+ `@nativue/image-picker` (`ImagePicker.pick({ limit, mediaTypes })`,
114
+ `openCamera({ mediaTypes, videoMaxDuration, videoQuality })`; call `getPendingResult()` on start, for
115
+ what was picked or taken while Android closed the app),
116
+ `@nativue/secure-store` (secrets: `SecureStore.setItem(key, value)`, `getItem`, `deleteItem`).
113
117
  A package with native code needs the app
114
118
  rebuilt with `npm run ios` or `npm run android`, not just a reload.
115
119
  - Notifications: `Notifications.schedule({ title, body, data }, { seconds } | { date } | { hour, minute } | null)`
@@ -5,7 +5,9 @@ import android.content.Context
5
5
  import android.graphics.Bitmap
6
6
  import android.graphics.BitmapFactory
7
7
  import android.graphics.Canvas
8
+ import android.graphics.Matrix
8
9
  import android.graphics.Rect
10
+ import android.media.ExifInterface
9
11
  import android.os.Build
10
12
  import android.os.Handler
11
13
  import android.os.Looper
@@ -629,7 +631,7 @@ class RemoteImageView(context: Context) : ImageView(context) {
629
631
  val cachedBytes = if (readsDisk) diskCache.read(source) else null
630
632
  val downloadedBytes = if (cachedBytes == null) runCatching { download(source) }.getOrNull() else null
631
633
  val bytes = cachedBytes ?: downloadedBytes
632
- val bitmap = bytes?.let { BitmapFactory.decodeByteArray(it, 0, it.size) }
634
+ val bitmap = bytes?.let(::decodeUpright)
633
635
  if (bitmap == null) {
634
636
  mainThread.post(onFailed)
635
637
  return@execute
@@ -642,6 +644,29 @@ class RemoteImageView(context: Context) : ImageView(context) {
642
644
  }
643
645
  }
644
646
 
647
+ /** Turned as its EXIF orientation says, as cameras save photos sideways and leave the turn to the viewer. */
648
+ private fun decodeUpright(bytes: ByteArray): Bitmap? {
649
+ val bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.size) ?: return null
650
+ val orientation = runCatching {
651
+ ExifInterface(bytes.inputStream()).getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL)
652
+ }.getOrDefault(ExifInterface.ORIENTATION_NORMAL)
653
+ val turn = Matrix().apply {
654
+ when (orientation) {
655
+ ExifInterface.ORIENTATION_FLIP_HORIZONTAL -> postScale(-1f, 1f)
656
+ ExifInterface.ORIENTATION_ROTATE_180 -> postRotate(180f)
657
+ ExifInterface.ORIENTATION_FLIP_VERTICAL -> postScale(1f, -1f)
658
+ ExifInterface.ORIENTATION_TRANSPOSE -> postRotate(90f).also { postScale(-1f, 1f) }
659
+ ExifInterface.ORIENTATION_ROTATE_90 -> postRotate(90f)
660
+ ExifInterface.ORIENTATION_TRANSVERSE -> postRotate(270f).also { postScale(-1f, 1f) }
661
+ ExifInterface.ORIENTATION_ROTATE_270 -> postRotate(270f)
662
+ }
663
+ }
664
+
665
+ if (turn.isIdentity) return bitmap
666
+
667
+ return Bitmap.createBitmap(bitmap, 0, 0, bitmap.width, bitmap.height, turn, true)
668
+ }
669
+
645
670
  private fun store(bitmap: Bitmap, downloadedBytes: ByteArray?, source: String, diskCache: ImageDiskCache, cachePolicy: String) {
646
671
  if (cachePolicy == "none") return
647
672
 
package/ios/Plugins.swift CHANGED
@@ -50,6 +50,15 @@ public final class PluginRegistry {
50
50
  viewMakers[type] = makeView
51
51
  }
52
52
 
53
+ /// The view controller on top, the app's or what it presents, to present a system screen from (a photo
54
+ /// picker, the camera). nil before the app shows its window.
55
+ @MainActor public var topViewController: UIViewController? {
56
+ let windows = UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }.flatMap(\.windows)
57
+ guard let root = (windows.first { $0.isKeyWindow } ?? windows.first)?.rootViewController else { return nil }
58
+
59
+ return sequence(first: root, next: \.presentedViewController).reduce(root) { _, presented in presented }
60
+ }
61
+
53
62
  /// Draws the tab bar and header icons whose `drawnIcon.drawer` is `drawer` (see router.ts's DrawnIcon).
54
63
  /// The image is tinted, like an SF Symbol: only its shape counts.
55
64
  public func addIconDrawer(_ drawer: String, _ draw: @escaping DrawIcon) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativue/core",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "Vue rendering real native views on iOS and Android",
5
5
  "keywords": [
6
6
  "vue",