11// Definitions.
22import { ImageSource as ImageSourceDefinition , iosSymbolScaleType } from '.' ;
33import { ImageAsset } from '../image-asset' ;
4+ import type { ImageBase } from '../ui/image/image-common' ;
45import * as httpModule from '../http' ;
56import { Font } from '../ui/styling/font' ;
67import { Color } from '../color' ;
@@ -86,9 +87,9 @@ export class ImageSource implements ImageSourceDefinition {
8687 }
8788 }
8889
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 ) ;
9293 return image ? new ImageSource ( image ) : null ;
9394 } else {
9495 const image = UIImage . systemImageNamed ( name ) ;
@@ -97,12 +98,12 @@ export class ImageSource implements ImageSourceDefinition {
9798 }
9899 }
99100
100- static fromSystemImage ( name : string , scale ?: iosSymbolScaleType ) : Promise < ImageSource > {
101+ static fromSystemImage ( name : string , instance ?: ImageBase ) : Promise < ImageSource > {
101102 return new Promise < ImageSource > ( ( resolve , reject ) => {
102103 try {
103104 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 ) ;
106107 } else {
107108 image = UIImage . systemImageNamed ( name ) ;
108109 }
@@ -117,6 +118,12 @@ export class ImageSource implements ImageSourceDefinition {
117118 } ) ;
118119 }
119120
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+
120127 static fromResourceSync ( name : string ) : ImageSource {
121128 const nativeSource = ( < any > UIImage ) . tns_safeImageNamed ( name ) || ( < any > UIImage ) . tns_safeImageNamed ( `${ name } .jpg` ) ;
122129
0 commit comments