11/**
22 * @module @nativescript -community/ui-material-core/tab-navigation-base/tab-strip-item
3- */
4- import { AddChildFromBuilder , CSSType , Color , Image , Label , PropertyChangeData , PseudoClassHandler , View , ViewBase , Enums } from '@nativescript/core' ;
3+ */
4+ import { AddChildFromBuilder , CSSType , Color , Enums , Image , Label , PropertyChangeData , PseudoClassHandler , View , ViewBase } from '@nativescript/core' ;
55import { backgroundColorProperty , backgroundInternalProperty } from '@nativescript/core/ui/styling/style-properties' ;
66import { textTransformProperty } from '@nativescript/core/ui/text-base' ;
77import { TabStripItem as TabStripItemDefinition } from '.' ;
88import { TabNavigationBase } from '../tab-navigation-base' ;
99import { TabStrip } from '../tab-strip' ;
1010
11-
1211@CSSType ( 'MDTabStripItem' )
1312export class TabStripItem extends View implements TabStripItemDefinition , AddChildFromBuilder {
1413 public static tapEvent = 'tap' ;
@@ -102,73 +101,73 @@ export class TabStripItem extends View implements TabStripItemDefinition, AddChi
102101 super . onLoaded ( ) ;
103102
104103 this . _labelColorHandler =
105- this . _labelColorHandler ||
106- ( ( args : PropertyChangeData ) => {
107- const parent = this . parent as TabStrip ;
108- const tabStripParent = parent && parent . parent as TabNavigationBase ;
104+ this . _labelColorHandler ||
105+ ( ( args : PropertyChangeData ) => {
106+ const parent = this . parent as TabStrip ;
107+ const tabStripParent = parent && ( parent . parent as TabNavigationBase ) ;
109108
110- return tabStripParent && tabStripParent . setTabBarItemColor ( this , args . value ) ;
111- } ) ;
109+ return tabStripParent && tabStripParent . setTabBarItemColor ( this , args . value ) ;
110+ } ) ;
112111 this . label . style . on ( 'colorChange' , this . _labelColorHandler ) ;
113112
114113 this . _labelFontHandler =
115- this . _labelFontHandler ||
116- ( ( args : PropertyChangeData ) => {
117- const parent = this . parent as TabStrip ;
118- const tabStripParent = parent && parent . parent as TabNavigationBase ;
114+ this . _labelFontHandler ||
115+ ( ( args : PropertyChangeData ) => {
116+ const parent = this . parent as TabStrip ;
117+ const tabStripParent = parent && ( parent . parent as TabNavigationBase ) ;
119118
120- return tabStripParent && tabStripParent . setTabBarItemFontInternal ( this , args . value ) ;
121- } ) ;
119+ return tabStripParent && tabStripParent . setTabBarItemFontInternal ( this , args . value ) ;
120+ } ) ;
122121 this . label . style . on ( 'fontInternalChange' , this . _labelFontHandler ) ;
123122
124123 this . _labelTextTransformHandler =
125- this . _labelTextTransformHandler ||
126- ( ( args : PropertyChangeData ) => {
127- const parent = this . parent as TabStrip ;
128- const tabStripParent = parent && parent . parent as TabNavigationBase ;
124+ this . _labelTextTransformHandler ||
125+ ( ( args : PropertyChangeData ) => {
126+ const parent = this . parent as TabStrip ;
127+ const tabStripParent = parent && ( parent . parent as TabNavigationBase ) ;
129128
130- return tabStripParent && tabStripParent . setTabBarItemTextTransform ( this , args . value ) ;
131- } ) ;
129+ return tabStripParent && tabStripParent . setTabBarItemTextTransform ( this , args . value ) ;
130+ } ) ;
132131 this . label . style . on ( 'textTransformChange' , this . _labelTextTransformHandler ) ;
133132
134133 this . _labelTextHandler =
135- this . _labelTextHandler ||
136- ( ( args : PropertyChangeData ) => {
137- const parent = this . parent as TabStrip ;
138- const tabStripParent = parent && parent . parent as TabNavigationBase ;
134+ this . _labelTextHandler ||
135+ ( ( args : PropertyChangeData ) => {
136+ const parent = this . parent as TabStrip ;
137+ const tabStripParent = parent && ( parent . parent as TabNavigationBase ) ;
139138
140- return tabStripParent && tabStripParent . setTabBarItemTitle ( this , args . value ) ;
141- } ) ;
139+ return tabStripParent && tabStripParent . setTabBarItemTitle ( this , args . value ) ;
140+ } ) ;
142141 this . label . on ( 'textChange' , this . _labelTextHandler ) ;
143142
144143 this . _imageColorHandler =
145- this . _imageColorHandler ||
146- ( ( args : PropertyChangeData ) => {
147- const parent = this . parent as TabStrip ;
148- const tabStripParent = parent && parent . parent as TabNavigationBase ;
144+ this . _imageColorHandler ||
145+ ( ( args : PropertyChangeData ) => {
146+ const parent = this . parent as TabStrip ;
147+ const tabStripParent = parent && ( parent . parent as TabNavigationBase ) ;
149148
150- return tabStripParent && tabStripParent . setTabBarIconColor ( this , args . value ) ;
151- } ) ;
149+ return tabStripParent && tabStripParent . setTabBarIconColor ( this , args . value ) ;
150+ } ) ;
152151 this . image . style . on ( 'colorChange' , this . _imageColorHandler ) ;
153152
154153 this . _imageFontHandler =
155- this . _imageFontHandler ||
156- ( ( args : PropertyChangeData ) => {
157- const parent = this . parent as TabStrip ;
158- const tabStripParent = parent && parent . parent as TabNavigationBase ;
154+ this . _imageFontHandler ||
155+ ( ( args : PropertyChangeData ) => {
156+ const parent = this . parent as TabStrip ;
157+ const tabStripParent = parent && ( parent . parent as TabNavigationBase ) ;
159158
160- return tabStripParent && tabStripParent . setTabBarIconColor ( this , args . value ) ;
161- } ) ;
159+ return tabStripParent && tabStripParent . setTabBarIconColor ( this , args . value ) ;
160+ } ) ;
162161 this . image . style . on ( 'fontInternalChange' , this . _imageFontHandler ) ;
163162
164163 this . _imageSrcHandler =
165- this . _imageSrcHandler ||
166- ( ( args : PropertyChangeData ) => {
167- const parent = this . parent as TabStrip ;
168- const tabStripParent = parent && parent . parent as TabNavigationBase ;
164+ this . _imageSrcHandler ||
165+ ( ( args : PropertyChangeData ) => {
166+ const parent = this . parent as TabStrip ;
167+ const tabStripParent = parent && ( parent . parent as TabNavigationBase ) ;
169168
170- return tabStripParent && tabStripParent . setTabBarIconSource ( this , args . value ) ;
171- } ) ;
169+ return tabStripParent && tabStripParent . setTabBarIconSource ( this , args . value ) ;
170+ } ) ;
172171 this . image . on ( 'srcChange' , this . _imageSrcHandler ) ;
173172 }
174173
@@ -198,15 +197,15 @@ export class TabStripItem extends View implements TabStripItemDefinition, AddChi
198197 public _addChildFromBuilder ( name : string , value : any ) : void {
199198 if ( value instanceof Image ) {
200199 this . image = value ;
201- this . iconSource = ( value ) . src ;
202- this . iconClass = ( value ) . className ;
200+ this . iconSource = value . src ;
201+ this . iconClass = value . className ;
203202 this . _addView ( value ) ;
204203 // selectedIndexProperty.coerce(this);
205204 }
206205
207206 if ( value instanceof Label ) {
208207 this . label = value ;
209- this . title = ( value ) . text ;
208+ this . title = value . text ;
210209 this . _addView ( value ) ;
211210 // selectedIndexProperty.coerce(this);
212211 }
@@ -224,22 +223,22 @@ export class TabStripItem extends View implements TabStripItemDefinition, AddChi
224223 _updateTabStateChangeHandler ( subscribe : boolean ) {
225224 if ( subscribe ) {
226225 this . _highlightedHandler =
227- this . _highlightedHandler ||
228- ( ( ) => {
229- this . _goToVisualState ( 'highlighted' ) ;
230- } ) ;
226+ this . _highlightedHandler ||
227+ ( ( ) => {
228+ this . _goToVisualState ( 'highlighted' ) ;
229+ } ) ;
231230
232231 this . _normalHandler =
233- this . _normalHandler ||
234- ( ( ) => {
235- this . _goToVisualState ( 'normal' ) ;
236- } ) ;
232+ this . _normalHandler ||
233+ ( ( ) => {
234+ this . _goToVisualState ( 'normal' ) ;
235+ } ) ;
237236
238237 this . on ( TabStripItem . selectEvent , this . _highlightedHandler ) ;
239238 this . on ( TabStripItem . unselectEvent , this . _normalHandler ) ;
240239
241240 const parent = this . parent as TabStrip ;
242- const tabStripParent = parent && parent . parent as TabNavigationBase ;
241+ const tabStripParent = parent && ( parent . parent as TabNavigationBase ) ;
243242 if ( this . _index === tabStripParent . selectedIndex && ! ( global . isIOS && tabStripParent . cssType . toLowerCase ( ) === 'tabs' ) ) {
244243 // HACK: tabStripParent instanceof Tabs creates a circular dependency
245244 // HACK: tabStripParent.cssType === "Tabs" is a hacky workaround
@@ -253,26 +252,26 @@ export class TabStripItem extends View implements TabStripItemDefinition, AddChi
253252
254253 [ backgroundColorProperty . getDefault ] ( ) : Color {
255254 const parent = this . parent as TabStrip ;
256- const tabStripParent = parent && parent . parent as TabNavigationBase ;
255+ const tabStripParent = parent && ( parent . parent as TabNavigationBase ) ;
257256
258257 return tabStripParent && tabStripParent . getTabBarBackgroundColor ( ) ;
259258 }
260259 [ backgroundColorProperty . setNative ] ( value : Color ) {
261260 const parent = this . parent as TabStrip ;
262- const tabStripParent = parent && parent . parent as TabNavigationBase ;
261+ const tabStripParent = parent && ( parent . parent as TabNavigationBase ) ;
263262
264263 return tabStripParent && tabStripParent . setTabBarItemBackgroundColor ( this , value ) ;
265264 }
266265
267266 [ textTransformProperty . getDefault ] ( ) : Enums . TextTransformType {
268267 const parent = this . parent as TabStrip ;
269- const tabStripParent = parent && parent . parent as TabNavigationBase ;
268+ const tabStripParent = parent && ( parent . parent as TabNavigationBase ) ;
270269
271270 return tabStripParent && tabStripParent . getTabBarItemTextTransform ( this ) ;
272271 }
273272 [ textTransformProperty . setNative ] ( value : Enums . TextTransformType ) {
274273 const parent = this . parent as TabStrip ;
275- const tabStripParent = parent && parent . parent as TabNavigationBase ;
274+ const tabStripParent = parent && ( parent . parent as TabNavigationBase ) ;
276275
277276 return tabStripParent && tabStripParent . setTabBarItemTextTransform ( this , value ) ;
278277 }
0 commit comments