File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed
Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -10,11 +10,16 @@ export function navigatingTo(args: EventData) {
1010
1111export class DemoModel extends Observable {
1212 addingPhoto = false ;
13+ tintTestSrc = 'res://icon' ;
1314 symbolWiggleEffect = ImageSymbolEffects . Wiggle ;
1415 symbolBounceEffect = ImageSymbolEffects . Bounce ;
1516 symbolBreathEffect = ImageSymbolEffects . Breathe ;
1617 symbolRotateEffect = ImageSymbolEffects . Rotate ;
1718
19+ toggleTintTestSrc ( ) {
20+ this . set ( 'tintTestSrc' , this . tintTestSrc === 'res://icon' ? 'res://add_to_fav' : 'res://icon' ) ;
21+ }
22+
1823 pickImage ( ) {
1924 const context = create ( {
2025 mode : 'single' ,
Original file line number Diff line number Diff line change 66
77 <StackLayout class =" p-20" >
88
9+ <Label text =" tintColor + dynamic src" class =" h2" />
10+ <Label text =" Tap the image to swap src between icon and add_to_fav. The red tint should persist after each swap." textWrap =" true" />
11+ <GridLayout columns =" auto, *, auto" rows =" auto" class =" m-t-10 m-b-10" >
12+ <Image col =" 0" src =" {{ tintTestSrc }}" tintColor =" #E53935" width =" 80" height =" 80" tap =" {{ toggleTintTestSrc }}" stretch =" aspectFit" />
13+ <StackLayout col =" 1" verticalAlignment =" center" class =" m-l-10" >
14+ <Label text =" {{ 'src: ' + tintTestSrc }}" textWrap =" true" />
15+ <Label text =" tintColor: #E53935" />
16+ <Label text =" (tap image to toggle)" class =" footnote" />
17+ </StackLayout >
18+ </GridLayout >
19+
20+ <ContentView height =" 1" width =" 100%" backgroundColor =" #efefef" margin =" 10" />
21+
922 <Label text =" Test Memory leaks with image picking and saving to device. Best to profile from platform IDE like Xcode." textWrap =" true" />
1023
1124 <Button text =" Pick and Save Image" tap =" {{ pickImage }}" />
Original file line number Diff line number Diff line change @@ -37,6 +37,9 @@ function initializeImageLoadedListener() {
3737 const owner = this . owner ;
3838 if ( owner ) {
3939 owner . isLoading = false ;
40+ if ( success ) {
41+ owner . _reapplyTintColor ( ) ;
42+ }
4043 }
4144 }
4245 }
@@ -78,6 +81,13 @@ export class Image extends ImageBase {
7881 this . nativeViewProtected . setImageMatrix ( new android . graphics . Matrix ( ) ) ;
7982 }
8083
84+ public _reapplyTintColor ( ) : void {
85+ const tintColor = this . style ?. tintColor ;
86+ if ( tintColor && this . nativeViewProtected ) {
87+ this . nativeViewProtected . setColorFilter ( tintColor . android ) ;
88+ }
89+ }
90+
8191 public _createImageSourceFromSrc ( value : string | ImageSource | ImageAsset ) {
8292 const imageView = this . nativeViewProtected ;
8393 if ( ! imageView ) {
@@ -181,6 +191,7 @@ export class Image extends ImageBase {
181191 nativeView . setRotationAngle ( 0 ) ;
182192 nativeView . setImageBitmap ( null ) ;
183193 }
194+ this . _reapplyTintColor ( ) ;
184195 }
185196
186197 [ srcProperty . getDefault ] ( ) : any {
You can’t perform that action at this time.
0 commit comments