1
1
// Definitions.
2
2
import { ImageSource as ImageSourceDefinition , iosSymbolScaleType } from '.' ;
3
3
import { ImageAsset } from '../image-asset' ;
4
+ import type { ImageBase } from '../ui/image/image-common' ;
4
5
import * as httpModule from '../http' ;
5
6
import { Font } from '../ui/styling/font' ;
6
7
import { Color } from '../color' ;
@@ -86,9 +87,9 @@ export class ImageSource implements ImageSourceDefinition {
86
87
}
87
88
}
88
89
89
- static fromSystemImageSync ( name : string , scale ?: iosSymbolScaleType ) : ImageSource {
90
- if ( scale ) {
91
- const image = UIImage . systemImageNamedWithConfiguration ( name , UIImageSymbolConfiguration . configurationWithScale ( ImageSource . iosSystemScaleFor ( scale ) ) ) ;
90
+ static fromSystemImageSync ( name : string , instance ?: ImageBase ) : ImageSource {
91
+ if ( instance ?. iosSymbolScale ) {
92
+ const image = ImageSource . systemImageWithConfig ( name , instance ) ;
92
93
return image ? new ImageSource ( image ) : null ;
93
94
} else {
94
95
const image = UIImage . systemImageNamed ( name ) ;
@@ -97,12 +98,12 @@ export class ImageSource implements ImageSourceDefinition {
97
98
}
98
99
}
99
100
100
- static fromSystemImage ( name : string , scale ?: iosSymbolScaleType ) : Promise < ImageSource > {
101
+ static fromSystemImage ( name : string , instance ?: ImageBase ) : Promise < ImageSource > {
101
102
return new Promise < ImageSource > ( ( resolve , reject ) => {
102
103
try {
103
104
let image : UIImage ;
104
- if ( scale ) {
105
- image = UIImage . systemImageNamedWithConfiguration ( name , UIImageSymbolConfiguration . configurationWithScale ( ImageSource . iosSystemScaleFor ( scale ) ) ) ;
105
+ if ( instance ?. iosSymbolScale ) {
106
+ image = ImageSource . systemImageWithConfig ( name , instance ) ;
106
107
} else {
107
108
image = UIImage . systemImageNamed ( name ) ;
108
109
}
@@ -117,6 +118,12 @@ export class ImageSource implements ImageSourceDefinition {
117
118
} ) ;
118
119
}
119
120
121
+ static systemImageWithConfig ( name : string , instance ?: ImageBase ) {
122
+ const fontSize = instance . style . fontSize ;
123
+ const fontWeight = instance . style . fontWeight ;
124
+ return UIImage . systemImageNamedWithConfiguration ( name , fontSize ? UIImageSymbolConfiguration . configurationWithPointSizeWeightScale ( fontSize , fontWeight === 'bold' ? UIImageSymbolWeight . Bold : UIImageSymbolWeight . Regular , ImageSource . iosSystemScaleFor ( instance . iosSymbolScale ) ) : UIImageSymbolConfiguration . configurationWithScale ( ImageSource . iosSystemScaleFor ( instance . iosSymbolScale ) ) ) ;
125
+ }
126
+
120
127
static fromResourceSync ( name : string ) : ImageSource {
121
128
const nativeSource = ( < any > UIImage ) . tns_safeImageNamed ( name ) || ( < any > UIImage ) . tns_safeImageNamed ( `${ name } .jpg` ) ;
122
129
0 commit comments