@@ -807,6 +807,117 @@ export class View extends ViewCommon {
807
807
this . nativeViewProtected . setAlpha ( float ( value ) ) ;
808
808
}
809
809
810
+ [ accessibilityRoleProperty . setNative ] ( value : AccessibilityRole ) : void {
811
+ this . accessibilityRole = value as AccessibilityRole ;
812
+ updateAccessibilityProperties ( this ) ;
813
+
814
+ if ( SDK_VERSION >= 28 ) {
815
+ this . nativeViewProtected ?. setAccessibilityHeading ( value === AccessibilityRole . Header ) ;
816
+ }
817
+ }
818
+
819
+ [ accessibilityLiveRegionProperty . setNative ] ( value : AccessibilityLiveRegion ) : void {
820
+ switch ( value as AccessibilityLiveRegion ) {
821
+ case AccessibilityLiveRegion . Assertive : {
822
+ this . nativeViewProtected . setAccessibilityLiveRegion ( android . view . View . ACCESSIBILITY_LIVE_REGION_ASSERTIVE ) ;
823
+ break ;
824
+ }
825
+ case AccessibilityLiveRegion . Polite : {
826
+ this . nativeViewProtected . setAccessibilityLiveRegion ( android . view . View . ACCESSIBILITY_LIVE_REGION_POLITE ) ;
827
+ break ;
828
+ }
829
+ default : {
830
+ this . nativeViewProtected . setAccessibilityLiveRegion ( android . view . View . ACCESSIBILITY_LIVE_REGION_NONE ) ;
831
+ break ;
832
+ }
833
+ }
834
+ }
835
+
836
+ [ accessibilityStateProperty . setNative ] ( value : AccessibilityState ) : void {
837
+ this . accessibilityState = value as AccessibilityState ;
838
+ updateAccessibilityProperties ( this ) ;
839
+ }
840
+
841
+ [ horizontalAlignmentProperty . getDefault ] ( ) : CoreTypes . HorizontalAlignmentType {
842
+ return < CoreTypes . HorizontalAlignmentType > org . nativescript . widgets . ViewHelper . getHorizontalAlignment ( this . nativeViewProtected ) ;
843
+ }
844
+ [ horizontalAlignmentProperty . setNative ] ( value : CoreTypes . HorizontalAlignmentType ) {
845
+ const nativeView = this . nativeViewProtected ;
846
+ const lp : any = nativeView . getLayoutParams ( ) || new org . nativescript . widgets . CommonLayoutParams ( ) ;
847
+ const gravity = lp . gravity ;
848
+ const weight = lp . weight ;
849
+ // Set only if params gravity exists.
850
+ if ( gravity !== undefined ) {
851
+ switch ( value ) {
852
+ case 'left' :
853
+ lp . gravity = GRAVITY_LEFT | ( gravity & VERTICAL_GRAVITY_MASK ) ;
854
+ if ( weight < 0 ) {
855
+ lp . weight = - 2 ;
856
+ }
857
+ break ;
858
+ case 'center' :
859
+ lp . gravity = GRAVITY_CENTER_HORIZONTAL | ( gravity & VERTICAL_GRAVITY_MASK ) ;
860
+ if ( weight < 0 ) {
861
+ lp . weight = - 2 ;
862
+ }
863
+ break ;
864
+ case 'right' :
865
+ lp . gravity = GRAVITY_RIGHT | ( gravity & VERTICAL_GRAVITY_MASK ) ;
866
+ if ( weight < 0 ) {
867
+ lp . weight = - 2 ;
868
+ }
869
+ break ;
870
+ case 'stretch' :
871
+ lp . gravity = GRAVITY_FILL_HORIZONTAL | ( gravity & VERTICAL_GRAVITY_MASK ) ;
872
+ if ( weight < 0 ) {
873
+ lp . weight = - 1 ;
874
+ }
875
+ break ;
876
+ }
877
+ nativeView . setLayoutParams ( lp ) ;
878
+ }
879
+ }
880
+
881
+ [ verticalAlignmentProperty . getDefault ] ( ) : CoreTypes . VerticalAlignmentType {
882
+ return < CoreTypes . VerticalAlignmentType > org . nativescript . widgets . ViewHelper . getVerticalAlignment ( this . nativeViewProtected ) ;
883
+ }
884
+ [ verticalAlignmentProperty . setNative ] ( value : CoreTypes . VerticalAlignmentType ) {
885
+ const nativeView = this . nativeViewProtected ;
886
+ const lp : any = nativeView . getLayoutParams ( ) || new org . nativescript . widgets . CommonLayoutParams ( ) ;
887
+ const gravity = lp . gravity ;
888
+ const height = lp . height ;
889
+ // Set only if params gravity exists.
890
+ if ( gravity !== undefined ) {
891
+ switch ( value ) {
892
+ case 'top' :
893
+ lp . gravity = GRAVITY_TOP | ( gravity & HORIZONTAL_GRAVITY_MASK ) ;
894
+ if ( height < 0 ) {
895
+ lp . height = - 2 ;
896
+ }
897
+ break ;
898
+ case 'middle' :
899
+ lp . gravity = GRAVITY_CENTER_VERTICAL | ( gravity & HORIZONTAL_GRAVITY_MASK ) ;
900
+ if ( height < 0 ) {
901
+ lp . height = - 2 ;
902
+ }
903
+ break ;
904
+ case 'bottom' :
905
+ lp . gravity = GRAVITY_BOTTOM | ( gravity & HORIZONTAL_GRAVITY_MASK ) ;
906
+ if ( height < 0 ) {
907
+ lp . height = - 2 ;
908
+ }
909
+ break ;
910
+ case 'stretch' :
911
+ lp . gravity = GRAVITY_FILL_VERTICAL | ( gravity & HORIZONTAL_GRAVITY_MASK ) ;
912
+ if ( height < 0 ) {
913
+ lp . height = - 1 ;
914
+ }
915
+ break ;
916
+ }
917
+ nativeView . setLayoutParams ( lp ) ;
918
+ }
919
+ }
920
+
810
921
[ testIDProperty . setNative ] ( value : string ) {
811
922
this . setAccessibilityIdentifier ( this . nativeViewProtected , value ) ;
812
923
}
@@ -833,27 +944,17 @@ export class View extends ViewCommon {
833
944
this . setAccessibilityIdentifier ( this . nativeViewProtected , value ) ;
834
945
}
835
946
836
- // @ts -expect-error
837
- [ accessibilityRoleProperty . setNative ] ( value : AccessibilityRole ) : void {
838
- this . accessibilityRole = value ;
839
- updateAccessibilityProperties ( this ) ;
840
-
841
- if ( SDK_VERSION >= 28 ) {
842
- this . nativeViewProtected ?. setAccessibilityHeading ( value === AccessibilityRole . Header ) ;
843
- }
844
- }
845
-
846
- [ accessibilityValueProperty . setNative ] ( ) : void {
947
+ [ accessibilityValueProperty . setNative ] ( value : string ) : void {
847
948
this . _androidContentDescriptionUpdated = true ;
848
949
updateContentDescription ( this ) ;
849
950
}
850
951
851
- [ accessibilityLabelProperty . setNative ] ( ) : void {
952
+ [ accessibilityLabelProperty . setNative ] ( value : string ) : void {
852
953
this . _androidContentDescriptionUpdated = true ;
853
954
updateContentDescription ( this ) ;
854
955
}
855
956
856
- [ accessibilityHintProperty . setNative ] ( ) : void {
957
+ [ accessibilityHintProperty . setNative ] ( value : string ) : void {
857
958
this . _androidContentDescriptionUpdated = true ;
858
959
updateContentDescription ( this ) ;
859
960
}
@@ -866,31 +967,7 @@ export class View extends ViewCommon {
866
967
}
867
968
}
868
969
869
- // @ts -expect-error
870
- [ accessibilityLiveRegionProperty . setNative ] ( value : AccessibilityLiveRegion ) : void {
871
- switch ( value ) {
872
- case AccessibilityLiveRegion . Assertive : {
873
- this . nativeViewProtected . setAccessibilityLiveRegion ( android . view . View . ACCESSIBILITY_LIVE_REGION_ASSERTIVE ) ;
874
- break ;
875
- }
876
- case AccessibilityLiveRegion . Polite : {
877
- this . nativeViewProtected . setAccessibilityLiveRegion ( android . view . View . ACCESSIBILITY_LIVE_REGION_POLITE ) ;
878
- break ;
879
- }
880
- default : {
881
- this . nativeViewProtected . setAccessibilityLiveRegion ( android . view . View . ACCESSIBILITY_LIVE_REGION_NONE ) ;
882
- break ;
883
- }
884
- }
885
- }
886
-
887
- // @ts -expect-error
888
- [ accessibilityStateProperty . setNative ] ( value : AccessibilityState ) : void {
889
- this . accessibilityState = value ;
890
- updateAccessibilityProperties ( this ) ;
891
- }
892
-
893
- [ accessibilityMediaSessionProperty . setNative ] ( ) : void {
970
+ [ accessibilityMediaSessionProperty . setNative ] ( value : string ) : void {
894
971
updateAccessibilityProperties ( this ) ;
895
972
}
896
973
@@ -974,88 +1051,6 @@ export class View extends ViewCommon {
974
1051
nativeView . setStateListAnimator ( stateListAnimator ) ;
975
1052
}
976
1053
977
- [ horizontalAlignmentProperty . getDefault ] ( ) : CoreTypes . HorizontalAlignmentType {
978
- return < CoreTypes . HorizontalAlignmentType > org . nativescript . widgets . ViewHelper . getHorizontalAlignment ( this . nativeViewProtected ) ;
979
- }
980
- // @ts -expect-error
981
- [ horizontalAlignmentProperty . setNative ] ( value : CoreTypes . HorizontalAlignmentType ) {
982
- const nativeView = this . nativeViewProtected ;
983
- const lp : any = nativeView . getLayoutParams ( ) || new org . nativescript . widgets . CommonLayoutParams ( ) ;
984
- const gravity = lp . gravity ;
985
- const weight = lp . weight ;
986
- // Set only if params gravity exists.
987
- if ( gravity !== undefined ) {
988
- switch ( value ) {
989
- case 'left' :
990
- lp . gravity = GRAVITY_LEFT | ( gravity & VERTICAL_GRAVITY_MASK ) ;
991
- if ( weight < 0 ) {
992
- lp . weight = - 2 ;
993
- }
994
- break ;
995
- case 'center' :
996
- lp . gravity = GRAVITY_CENTER_HORIZONTAL | ( gravity & VERTICAL_GRAVITY_MASK ) ;
997
- if ( weight < 0 ) {
998
- lp . weight = - 2 ;
999
- }
1000
- break ;
1001
- case 'right' :
1002
- lp . gravity = GRAVITY_RIGHT | ( gravity & VERTICAL_GRAVITY_MASK ) ;
1003
- if ( weight < 0 ) {
1004
- lp . weight = - 2 ;
1005
- }
1006
- break ;
1007
- case 'stretch' :
1008
- lp . gravity = GRAVITY_FILL_HORIZONTAL | ( gravity & VERTICAL_GRAVITY_MASK ) ;
1009
- if ( weight < 0 ) {
1010
- lp . weight = - 1 ;
1011
- }
1012
- break ;
1013
- }
1014
- nativeView . setLayoutParams ( lp ) ;
1015
- }
1016
- }
1017
-
1018
- [ verticalAlignmentProperty . getDefault ] ( ) : CoreTypes . VerticalAlignmentType {
1019
- return < CoreTypes . VerticalAlignmentType > org . nativescript . widgets . ViewHelper . getVerticalAlignment ( this . nativeViewProtected ) ;
1020
- }
1021
- // @ts -expect-error
1022
- [ verticalAlignmentProperty . setNative ] ( value : CoreTypes . VerticalAlignmentType ) {
1023
- const nativeView = this . nativeViewProtected ;
1024
- const lp : any = nativeView . getLayoutParams ( ) || new org . nativescript . widgets . CommonLayoutParams ( ) ;
1025
- const gravity = lp . gravity ;
1026
- const height = lp . height ;
1027
- // Set only if params gravity exists.
1028
- if ( gravity !== undefined ) {
1029
- switch ( value ) {
1030
- case 'top' :
1031
- lp . gravity = GRAVITY_TOP | ( gravity & HORIZONTAL_GRAVITY_MASK ) ;
1032
- if ( height < 0 ) {
1033
- lp . height = - 2 ;
1034
- }
1035
- break ;
1036
- case 'middle' :
1037
- lp . gravity = GRAVITY_CENTER_VERTICAL | ( gravity & HORIZONTAL_GRAVITY_MASK ) ;
1038
- if ( height < 0 ) {
1039
- lp . height = - 2 ;
1040
- }
1041
- break ;
1042
- case 'bottom' :
1043
- lp . gravity = GRAVITY_BOTTOM | ( gravity & HORIZONTAL_GRAVITY_MASK ) ;
1044
- if ( height < 0 ) {
1045
- lp . height = - 2 ;
1046
- }
1047
- break ;
1048
- case 'stretch' :
1049
- lp . gravity = GRAVITY_FILL_VERTICAL | ( gravity & HORIZONTAL_GRAVITY_MASK ) ;
1050
- if ( height < 0 ) {
1051
- lp . height = - 1 ;
1052
- }
1053
- break ;
1054
- }
1055
- nativeView . setLayoutParams ( lp ) ;
1056
- }
1057
- }
1058
-
1059
1054
[ rotateProperty . setNative ] ( value : number ) {
1060
1055
org . nativescript . widgets . ViewHelper . setRotate ( this . nativeViewProtected , float ( value ) ) ;
1061
1056
}
0 commit comments