MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / createTabItemSpec

Function createTabItemSpec

packages/core/ui/tab-view/index.android.ts:291–325  ·  view source on GitHub ↗
(item: TabViewItem)

Source from the content-addressed store, hash-verified

289}
290
291function createTabItemSpec(item: TabViewItem): org.nativescript.widgets.TabItemSpec {
292 const result = new org.nativescript.widgets.TabItemSpec();
293 result.title = item.title;
294
295 if (item.iconSource) {
296 const addDrawable = (is: ImageSource) => {
297 if (is) {
298 // TODO: Make this native call that accepts string so that we don't load Bitmap in JS.
299 result.iconDrawable = new android.graphics.drawable.BitmapDrawable(appResources, is.android);
300 } else {
301 traceMissingIcon(item.iconSource);
302 }
303 };
304 if (item.iconSource.indexOf(RESOURCE_PREFIX) === 0) {
305 result.iconId = androidUtils.resources.getDrawableId(item.iconSource.slice(RESOURCE_PREFIX.length));
306 if (result.iconId === 0) {
307 traceMissingIcon(item.iconSource);
308 }
309 } else if (isFontIconURI(item.iconSource)) {
310 // Allow specifying a separate font family for the icon via style.iconFontFamily.
311 let iconFont: any = item.style.fontInternal;
312 const iconFontFamily = item.iconFontFamily || item.style.iconFontFamily;
313 if (iconFontFamily) {
314 const baseFont = item.style.fontInternal || Font.default;
315 iconFont = baseFont.withFontFamily(iconFontFamily);
316 }
317 const is = ImageSource.fromFontIconCodeSync(item.iconSource.slice(FONT_PREFIX.length), iconFont, item.style.color);
318 addDrawable(is);
319 } else {
320 addDrawable(ImageSource.fromFileOrResourceSync(item.iconSource));
321 }
322 }
323
324 return result;
325}
326
327let defaultAccentColor: number = undefined;
328function getDefaultAccentColor(context: android.content.Context): number {

Callers 2

_updateMethod · 0.85
setAdapterItemsMethod · 0.85

Calls 8

traceMissingIconFunction · 0.90
isFontIconURIFunction · 0.90
addDrawableFunction · 0.85
indexOfMethod · 0.80
sliceMethod · 0.45
withFontFamilyMethod · 0.45
fromFontIconCodeSyncMethod · 0.45

Tested by

no test coverage detected