3
3
QPixmap ,
4
4
AspectRatioMode ,
5
5
NodeWidget ,
6
- QSize
6
+ QSize ,
7
+ TransformationMode
7
8
} from "@nodegui/nodegui" ;
8
9
import { TextProps , setTextProps } from "../Text/RNText" ;
9
10
import { RNWidget } from "../config" ;
@@ -13,6 +14,7 @@ import phin from "phin";
13
14
export interface ImageProps extends TextProps {
14
15
src ?: string ;
15
16
aspectRatioMode ?: AspectRatioMode ;
17
+ transformationMode ?: TransformationMode ;
16
18
buffer ?: Buffer ;
17
19
}
18
20
@@ -37,6 +39,9 @@ const setImageProps = (
37
39
} ,
38
40
set aspectRatioMode ( mode : AspectRatioMode ) {
39
41
widget . setAspectRatioMode ( mode ) ;
42
+ } ,
43
+ set transformationMode ( mode : TransformationMode ) {
44
+ widget . setTransformationMode ( mode ) ;
40
45
}
41
46
} ;
42
47
Object . assign ( setter , newProps ) ;
@@ -65,6 +70,7 @@ export class RNImage extends QLabel implements RNWidget {
65
70
static tagName = "image" ;
66
71
originalPixmap ?: QPixmap ;
67
72
aspectRatioMode ?: AspectRatioMode ;
73
+ transformationMode ?: TransformationMode ;
68
74
setPixmap = ( pixmap : QPixmap ) => {
69
75
// react:✓
70
76
super . setPixmap ( pixmap ) ;
@@ -73,14 +79,21 @@ export class RNImage extends QLabel implements RNWidget {
73
79
setAspectRatioMode ( mode : AspectRatioMode ) {
74
80
// react:✓ TODO://getter
75
81
this . aspectRatioMode = mode ;
82
+ this . scalePixmap ( this . size ( ) ) ;
83
+ }
84
+ setTransformationMode ( mode : TransformationMode ) {
85
+ // react:✓ TODO://getter
86
+ this . transformationMode = mode ;
87
+ this . scalePixmap ( this . size ( ) ) ;
76
88
}
77
89
scalePixmap ( size : QSize ) {
78
90
if ( this . originalPixmap ) {
79
91
return super . setPixmap (
80
92
this . originalPixmap . scaled (
81
93
size . width ( ) ,
82
94
size . height ( ) ,
83
- this . aspectRatioMode
95
+ this . aspectRatioMode ,
96
+ this . transformationMode
84
97
)
85
98
) ;
86
99
}
0 commit comments