Skip to content

Commit fac3b7f

Browse files
committed
chore: cleanup
1 parent 1808f28 commit fac3b7f

File tree

2 files changed

+9
-26
lines changed

2 files changed

+9
-26
lines changed

apps/toolbox/src/_app-platform.ios.css

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@
9393
}
9494

9595
.ns-ios-26 .action-bar {
96-
/* Note: nativescript-theme-core auto adds background-color to actionbar */
97-
/* doing so will cause iOS 26+ to not render titles when large title is enabled */
96+
/**
97+
* Note: nativescript-theme-core auto adds background-color to actionbar
98+
* doing so will cause iOS 26+ to not render titles when large title is enabled
99+
* We can now scope specific styling behavior for platform sdk versions
100+
*/
98101
background-color: transparent;
99102
}

packages/core/ui/switch/index.ios.ts

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import { SwitchBase, checkedProperty, offBackgroundColorProperty } from './switch-common';
22
import { colorProperty, backgroundColorProperty, backgroundInternalProperty } from '../styling/style-properties';
33
import { Color } from '../../color';
4-
import { iOSNativeHelper, layout } from '../../utils';
4+
import { SDK_VERSION } from '../../utils/constants';
55

66
export * from './switch-common';
77

8-
const majorVersion = iOSNativeHelper.MajorVersion;
9-
108
@NativeClass
119
class SwitchChangeHandlerImpl extends NSObject {
1210
private _owner: WeakRef<Switch>;
@@ -30,7 +28,6 @@ class SwitchChangeHandlerImpl extends NSObject {
3028
};
3129
}
3230

33-
const zeroSize = { width: 0, height: 0 };
3431
export class Switch extends SwitchBase {
3532
nativeViewProtected: UISwitch;
3633
private _handler: NSObject;
@@ -48,11 +45,6 @@ export class Switch extends SwitchBase {
4845
const nativeView = this.nativeViewProtected;
4946
this._handler = SwitchChangeHandlerImpl.initWithOwner(new WeakRef(this));
5047
nativeView.addTargetActionForControlEvents(this._handler, 'valueChanged', UIControlEvents.ValueChanged);
51-
52-
// Set proper dimensions based on actual native size (important for iOS 26+ switches)
53-
const nativeSize = nativeView.sizeThatFits(zeroSize);
54-
this.width = nativeSize.width;
55-
this.height = nativeSize.height;
5648
}
5749

5850
public disposeNativeView() {
@@ -78,7 +70,7 @@ export class Switch extends SwitchBase {
7870
// only add :checked pseudo handling on supported iOS versions
7971
// ios <13 works but causes glitchy animations when toggling
8072
// so we decided to keep the old behavior on older versions.
81-
if (majorVersion >= 13) {
73+
if (SDK_VERSION >= 13) {
8274
super._onCheckedPropertyChanged(newValue);
8375

8476
if (this.offBackgroundColor) {
@@ -96,18 +88,6 @@ export class Switch extends SwitchBase {
9688
return this.nativeViewProtected;
9789
}
9890

99-
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
100-
// Get actual native size - iOS 26+ switches have different dimensions than the legacy 51x31
101-
const nativeSize = this.nativeViewProtected.sizeThatFits(zeroSize);
102-
this.width = nativeSize.width;
103-
this.height = nativeSize.height;
104-
105-
// Use actual native dimensions instead of hardcoded fallback values
106-
const widthAndState = Switch.resolveSizeAndState(layout.toDevicePixels(nativeSize.width), layout.toDevicePixels(nativeSize.width), layout.EXACTLY, 0);
107-
const heightAndState = Switch.resolveSizeAndState(layout.toDevicePixels(nativeSize.height), layout.toDevicePixels(nativeSize.height), layout.EXACTLY, 0);
108-
this.setMeasuredDimension(widthAndState, heightAndState);
109-
}
110-
11191
[checkedProperty.getDefault](): boolean {
11292
return false;
11393
}
@@ -134,7 +114,7 @@ export class Switch extends SwitchBase {
134114
return this.nativeViewProtected.onTintColor;
135115
}
136116
[backgroundColorProperty.setNative](value: UIColor | Color) {
137-
if (majorVersion >= 13) {
117+
if (SDK_VERSION >= 13) {
138118
if (!this.offBackgroundColor || this.checked) {
139119
this.setNativeBackgroundColor(value);
140120
}
@@ -155,7 +135,7 @@ export class Switch extends SwitchBase {
155135
return this.nativeViewProtected.backgroundColor;
156136
}
157137
[offBackgroundColorProperty.setNative](value: Color | UIColor) {
158-
if (majorVersion >= 13) {
138+
if (SDK_VERSION >= 13) {
159139
if (!this.checked) {
160140
this.setNativeBackgroundColor(value);
161141
}

0 commit comments

Comments
 (0)