mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore: fix eslint issues (#9017)
This commit is contained in:
@@ -9,7 +9,7 @@ export class SegmentedBarItem extends SegmentedBarItemBase {
|
||||
public _update() {
|
||||
const parent = <SegmentedBar>this.parent;
|
||||
if (parent) {
|
||||
let tabIndex = parent.items.indexOf(this);
|
||||
const tabIndex = parent.items.indexOf(this);
|
||||
let title = this.title;
|
||||
title = title === null || title === undefined ? '' : title;
|
||||
parent.ios.setTitleForSegmentAtIndex(title, tabIndex);
|
||||
@@ -74,7 +74,7 @@ export class SegmentedBar extends SegmentedBarBase {
|
||||
}
|
||||
[selectedBackgroundColorProperty.setNative](value: UIColor | Color) {
|
||||
const currentOsVersion = iOSNativeHelper.MajorVersion;
|
||||
let color = value instanceof Color ? value.ios : value;
|
||||
const color = value instanceof Color ? value.ios : value;
|
||||
if (currentOsVersion < 13) {
|
||||
this.ios.tintColor = color;
|
||||
} else {
|
||||
@@ -86,10 +86,10 @@ export class SegmentedBar extends SegmentedBarBase {
|
||||
return null;
|
||||
}
|
||||
[colorProperty.setNative](value: Color | UIColor) {
|
||||
let color = value instanceof Color ? value.ios : value;
|
||||
let bar = this.ios;
|
||||
let currentAttrs = bar.titleTextAttributesForState(UIControlState.Normal);
|
||||
let attrs = currentAttrs ? currentAttrs.mutableCopy() : NSMutableDictionary.new();
|
||||
const color = value instanceof Color ? value.ios : value;
|
||||
const bar = this.ios;
|
||||
const currentAttrs = bar.titleTextAttributesForState(UIControlState.Normal);
|
||||
const attrs = currentAttrs ? currentAttrs.mutableCopy() : NSMutableDictionary.new();
|
||||
attrs.setValueForKey(color, NSForegroundColorAttributeName);
|
||||
bar.setTitleTextAttributesForState(attrs, UIControlState.Normal);
|
||||
}
|
||||
@@ -98,10 +98,10 @@ export class SegmentedBar extends SegmentedBarBase {
|
||||
return null;
|
||||
}
|
||||
[fontInternalProperty.setNative](value: Font) {
|
||||
let font: UIFont = value ? value.getUIFont(UIFont.systemFontOfSize(UIFont.labelFontSize)) : null;
|
||||
let bar = this.ios;
|
||||
let currentAttrs = bar.titleTextAttributesForState(UIControlState.Normal);
|
||||
let attrs = currentAttrs ? currentAttrs.mutableCopy() : NSMutableDictionary.new();
|
||||
const font: UIFont = value ? value.getUIFont(UIFont.systemFontOfSize(UIFont.labelFontSize)) : null;
|
||||
const bar = this.ios;
|
||||
const currentAttrs = bar.titleTextAttributesForState(UIControlState.Normal);
|
||||
const attrs = currentAttrs ? currentAttrs.mutableCopy() : NSMutableDictionary.new();
|
||||
attrs.setValueForKey(font, NSFontAttributeName);
|
||||
bar.setTitleTextAttributesForState(attrs, UIControlState.Normal);
|
||||
}
|
||||
@@ -112,14 +112,14 @@ class SelectionHandlerImpl extends NSObject {
|
||||
private _owner: WeakRef<SegmentedBar>;
|
||||
|
||||
public static initWithOwner(owner: WeakRef<SegmentedBar>): SelectionHandlerImpl {
|
||||
let handler = <SelectionHandlerImpl>SelectionHandlerImpl.new();
|
||||
const handler = <SelectionHandlerImpl>SelectionHandlerImpl.new();
|
||||
handler._owner = owner;
|
||||
|
||||
return handler;
|
||||
}
|
||||
|
||||
public selected(sender: UISegmentedControl) {
|
||||
let owner = this._owner.get();
|
||||
const owner = this._owner.get();
|
||||
if (owner) {
|
||||
owner.selectedIndex = sender.selectedSegmentIndex;
|
||||
}
|
||||
|
||||
@@ -8,13 +8,13 @@ import { EventData } from '../../data/observable';
|
||||
|
||||
@CSSType('SegmentedBarItem')
|
||||
export abstract class SegmentedBarItemBase extends ViewBase implements SegmentedBarItemDefinition {
|
||||
private _title: string = '';
|
||||
private _title = '';
|
||||
|
||||
get title(): string {
|
||||
return this._title;
|
||||
}
|
||||
set title(value: string) {
|
||||
let strValue = value !== null && value !== undefined ? value.toString() : '';
|
||||
const strValue = value !== null && value !== undefined ? value.toString() : '';
|
||||
if (this._title !== strValue) {
|
||||
this._title = strValue;
|
||||
this._update();
|
||||
@@ -110,9 +110,9 @@ export const selectedIndexProperty = new CoercibleProperty<SegmentedBarBase, num
|
||||
});
|
||||
},
|
||||
coerceValue: (target, value) => {
|
||||
let items = target.items;
|
||||
const items = target.items;
|
||||
if (items) {
|
||||
let max = items.length - 1;
|
||||
const max = items.length - 1;
|
||||
if (value < 0) {
|
||||
value = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user