@nativue/core 0.4.5 → 0.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativue/core",
3
- "version": "0.4.5",
3
+ "version": "0.5.0",
4
4
  "description": "Vue rendering real native views on iOS and Android",
5
5
  "keywords": [
6
6
  "vue",
package/src/components.ts CHANGED
@@ -230,6 +230,33 @@ function averageOf(values: Iterable<number>): number | undefined {
230
230
  return count === 0 ? undefined : sum / count
231
231
  }
232
232
 
233
+ const FILL_STYLE: Style = { position: 'absolute', top: 0, right: 0, bottom: 0, left: 0 }
234
+
235
+ // An <Image> behind its children: it fills the box, which `style` sizes. Takes the Image's props; other
236
+ // attributes (role, aria-*, @layout...) go to the box.
237
+ export const ImageBackground = defineComponent({
238
+ name: 'ImageBackground',
239
+ props: {
240
+ source: { type: [String, Object] as PropType<string | { uri: string }>, required: true },
241
+ resizeMode: String as PropType<'cover' | 'contain' | 'stretch' | 'center'>,
242
+ cache: String as PropType<'disk' | 'memory' | 'none'>,
243
+ alt: String,
244
+ style: Object as PropType<Style>,
245
+ },
246
+ slots: Object as SlotsType<{ default?: {} }>,
247
+
248
+ setup(props, { slots }) {
249
+ return () => {
250
+ const { style, ...imageProps } = props
251
+
252
+ return h('View', { style }, [
253
+ h('Image', { ...imageProps, style: FILL_STYLE }),
254
+ slots.default?.({}),
255
+ ])
256
+ }
257
+ },
258
+ })
259
+
233
260
  const SWIPE_ACTIONS_STYLE: Style = { position: 'absolute', top: 0, bottom: 0, flexDirection: 'row' }
234
261
  const SWIPE_LEFT_ACTIONS_STYLE: Style = { ...SWIPE_ACTIONS_STYLE, left: 0 }
235
262
  const SWIPE_RIGHT_ACTIONS_STYLE: Style = { ...SWIPE_ACTIONS_STYLE, right: 0 }
@@ -2,7 +2,7 @@
2
2
  // Events are listed as on* props: @press is onPress, @change-text is onChangeText.
3
3
  import type { DefineComponent } from '@vue/runtime-core'
4
4
  import type { AnimatedEvent } from './animated'
5
- import type { FlatList, Pressable, Swipeable } from './components'
5
+ import type { FlatList, ImageBackground, Pressable, Swipeable } from './components'
6
6
  import type { LayoutEvent, PanEvent, PinchEvent, RotateEvent, ScrollEvent, Style } from './types'
7
7
 
8
8
  type NativeComponent<Props = {}> = DefineComponent<
@@ -108,5 +108,6 @@ declare module '@vue/runtime-core' {
108
108
  Pressable: typeof Pressable
109
109
  FlatList: typeof FlatList
110
110
  Swipeable: typeof Swipeable
111
+ ImageBackground: typeof ImageBackground
111
112
  }
112
113
  }
package/src/renderer.ts CHANGED
@@ -21,7 +21,7 @@ import {
21
21
  import { animatedEventMapping, animatedStyleBinding, isAnimatedEvent } from './animated'
22
22
  import { Appearance } from './appearance'
23
23
  import { COLOR_PROPERTIES, processColor } from './colors'
24
- import { FlatList, Pressable, Swipeable } from './components'
24
+ import { FlatList, ImageBackground, Pressable, Swipeable } from './components'
25
25
  import type { LayoutAnimationConfig, Style } from './types'
26
26
  export * from '@vue/runtime-core'
27
27
  export { AccessibilityInfo } from './accessibility'
@@ -511,6 +511,7 @@ export function createApp(rootComponent: Component) {
511
511
  app.component('Pressable', Pressable)
512
512
  app.component('FlatList', FlatList)
513
513
  app.component('Swipeable', Swipeable)
514
+ app.component('ImageBackground', ImageBackground)
514
515
 
515
516
  return Object.assign(app, { mount: () => mountOnContainer(rootNode) })
516
517
  }