@nativescript-community/ui-material-core 6.2.20 → 6.2.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +2 -2
  3. package/platforms/android/include.gradle +3 -3
  4. package/platforms/android/ui_material_core.aar +0 -0
  5. package/platforms/android/java/com/nativescript/material/core/BottomNavigationBar.java +0 -311
  6. package/platforms/android/java/com/nativescript/material/core/TabItemSpec.java +0 -15
  7. package/platforms/android/java/com/nativescript/material/core/TabLayout.java +0 -441
  8. package/platforms/android/java/com/nativescript/material/core/TabStrip.java +0 -264
  9. package/platforms/android/java/com/nativescript/material/core/TabViewPager.java +0 -62
  10. package/platforms/android/java/com/nativescript/material/core/TabsBar.java +0 -442
  11. package/tab-navigation-base/react/index.d.ts +0 -60
  12. package/tab-navigation-base/react/index.js +0 -114
  13. package/tab-navigation-base/react/index.js.map +0 -1
  14. package/tab-navigation-base/tab-content-item/index.android.d.ts +0 -14
  15. package/tab-navigation-base/tab-content-item/index.android.js +0 -48
  16. package/tab-navigation-base/tab-content-item/index.android.js.map +0 -1
  17. package/tab-navigation-base/tab-content-item/index.d.ts +0 -11
  18. package/tab-navigation-base/tab-content-item/index.ios.d.ts +0 -7
  19. package/tab-navigation-base/tab-content-item/index.ios.js +0 -13
  20. package/tab-navigation-base/tab-content-item/index.ios.js.map +0 -1
  21. package/tab-navigation-base/tab-content-item/tab-content-item-common.d.ts +0 -7
  22. package/tab-navigation-base/tab-content-item/tab-content-item-common.js +0 -24
  23. package/tab-navigation-base/tab-content-item/tab-content-item-common.js.map +0 -1
  24. package/tab-navigation-base/tab-navigation/index-common.d.ts +0 -27
  25. package/tab-navigation-base/tab-navigation/index-common.js +0 -58
  26. package/tab-navigation-base/tab-navigation/index-common.js.map +0 -1
  27. package/tab-navigation-base/tab-navigation/index.android.d.ts +0 -80
  28. package/tab-navigation-base/tab-navigation/index.android.js +0 -860
  29. package/tab-navigation-base/tab-navigation/index.android.js.map +0 -1
  30. package/tab-navigation-base/tab-navigation/index.d.ts +0 -80
  31. package/tab-navigation-base/tab-navigation/index.ios.d.ts +0 -93
  32. package/tab-navigation-base/tab-navigation/index.ios.js +0 -819
  33. package/tab-navigation-base/tab-navigation/index.ios.js.map +0 -1
  34. package/tab-navigation-base/tab-navigation-base/index.d.ts +0 -68
  35. package/tab-navigation-base/tab-navigation-base/index.js +0 -247
  36. package/tab-navigation-base/tab-navigation-base/index.js.map +0 -1
  37. package/tab-navigation-base/tab-strip/index.d.ts +0 -24
  38. package/tab-navigation-base/tab-strip/index.js +0 -153
  39. package/tab-navigation-base/tab-strip/index.js.map +0 -1
  40. package/tab-navigation-base/tab-strip-item/index.d.ts +0 -34
  41. package/tab-navigation-base/tab-strip-item/index.js +0 -215
  42. package/tab-navigation-base/tab-strip-item/index.js.map +0 -1
@@ -1,62 +0,0 @@
1
- package com.nativescript.material.core;
2
-
3
- import android.content.Context;
4
- import androidx.viewpager.widget.ViewPager;
5
- import android.util.AttributeSet;
6
- import android.view.MotionEvent;
7
- import android.view.KeyEvent;
8
-
9
- // See this thread for more information https://stackoverflow.com/questions/9650265
10
- public class TabViewPager extends ViewPager {
11
- private boolean swipePageEnabled = true;
12
- private boolean animationEnabled = true;
13
-
14
- public TabViewPager(Context context) {
15
- super(context);
16
- }
17
-
18
- public TabViewPager(Context context, AttributeSet attrs) {
19
- super(context, attrs);
20
- }
21
-
22
- public void setSwipePageEnabled(boolean enabled) {
23
- this.swipePageEnabled = enabled;
24
- }
25
-
26
- public void setAnimationEnabled(boolean enabled) {
27
- this.animationEnabled = enabled;
28
- }
29
-
30
- @Override
31
- public boolean onInterceptTouchEvent(MotionEvent event) {
32
- if (this.swipePageEnabled) {
33
- return super.onInterceptTouchEvent(event);
34
- }
35
-
36
- return false;
37
- }
38
-
39
- @Override
40
- public boolean onTouchEvent(MotionEvent event) {
41
- if (this.swipePageEnabled) {
42
- return super.onTouchEvent(event);
43
- }
44
-
45
- return false;
46
- }
47
-
48
- @Override
49
- public boolean executeKeyEvent(KeyEvent event) {
50
- if (this.swipePageEnabled) {
51
- return super.executeKeyEvent(event);
52
- }
53
-
54
- return false;
55
- }
56
-
57
- @Override
58
- public void setCurrentItem(int item) {
59
- boolean smoothScroll = this.animationEnabled;
60
- super.setCurrentItem(item, smoothScroll);
61
- }
62
- }
@@ -1,442 +0,0 @@
1
- /*
2
- * Copyright 2014 Google Inc. All rights reserved.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
- package com.nativescript.material.core;
18
-
19
- import android.content.Context;
20
- import android.graphics.Typeface;
21
- import androidx.viewpager.widget.PagerAdapter;
22
- import androidx.viewpager.widget.ViewPager;
23
- import android.text.TextUtils;
24
- import android.util.AttributeSet;
25
- import android.util.SparseArray;
26
- import android.util.TypedValue;
27
- import android.view.Gravity;
28
- import android.view.View;
29
- import android.view.ViewGroup;
30
- import android.widget.HorizontalScrollView;
31
- import android.widget.ImageView;
32
- import android.widget.ImageView.ScaleType;
33
- import android.widget.LinearLayout;
34
- import android.widget.TextView;
35
-
36
- /**
37
- * To be used with ViewPager to provide a tab indicator component which give
38
- * constant feedback as to the user's scroll progress.
39
- * <p>
40
- * To use the component, simply add it to your view hierarchy. Then in your
41
- * {@link android.app.Activity} or {@link android.support.v4.app.Fragment} call
42
- * {@link #setViewPager(ViewPager)} providing it the ViewPager this layout is
43
- * being used for.
44
- * <p>
45
- * The colors can be customized in two ways. The first and simplest is to
46
- * provide an array of colors via {@link #setSelectedIndicatorColors(int...)}.
47
- * The alternative is via the {@link TabColorizer} interface which provides you
48
- * complete control over which color is used for any individual position.
49
- * <p>
50
- */
51
- public class TabsBar extends HorizontalScrollView {
52
- /**
53
- * Allows complete control over the colors drawn in the tab layout. Set with
54
- * {@link #setCustomTabColorizer(TabColorizer)}.
55
- */
56
- public interface TabColorizer {
57
-
58
- /**
59
- * @return return the color of the indicator used when {@code position}
60
- * is selected.
61
- */
62
- int getIndicatorColor(int position);
63
-
64
- }
65
-
66
- private static final int TITLE_OFFSET_DIPS = 24;
67
- private static final int TAB_VIEW_PADDING_DIPS = 16;
68
- private static final int TAB_VIEW_TEXT_SIZE_SP = 12;
69
- private static final int TEXT_MAX_WIDTH = 180;
70
- private static final int SMALL_MIN_HEIGHT = 48;
71
- private static final int LARGE_MIN_HEIGHT = 72;
72
-
73
- private int mTitleOffset;
74
-
75
- private boolean mDistributeEvenly = true;
76
-
77
- private TabItemSpec[] mTabItems;
78
- private ViewPager mViewPager;
79
- private SparseArray<String> mContentDescriptions = new SparseArray<String>();
80
- private ViewPager.OnPageChangeListener mViewPagerPageChangeListener;
81
-
82
- private final TabStrip mTabStrip;
83
-
84
- public TabsBar(Context context) {
85
- this(context, null);
86
- }
87
-
88
- public TabsBar(Context context, AttributeSet attrs) {
89
- this(context, attrs, 0);
90
- }
91
-
92
- public TabsBar(Context context, AttributeSet attrs, int defStyle) {
93
- super(context, attrs, defStyle);
94
- // Disable the Scroll Bar
95
- setHorizontalScrollBarEnabled(false);
96
- // Make sure that the Tab Strips fills this View
97
- setFillViewport(true);
98
-
99
- mTitleOffset = (int) (TITLE_OFFSET_DIPS * getResources().getDisplayMetrics().density);
100
-
101
- mTabStrip = new TabStrip(context);
102
- addView(mTabStrip, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
103
- }
104
-
105
- /**
106
- * Set the custom {@link TabColorizer} to be used.
107
- *
108
- * If you only require simple customisation then you can use
109
- * {@link #setSelectedIndicatorColors(int...)} to achieve similar effects.
110
- */
111
- public void setCustomTabColorizer(TabColorizer tabColorizer) {
112
- //mTabStrip.setCustomTabColorizer(tabColorizer);
113
- }
114
-
115
- public void setDistributeEvenly(boolean distributeEvenly) {
116
- mDistributeEvenly = distributeEvenly;
117
- }
118
-
119
- /**
120
- * Sets the colors to be used for indicating the selected tab. These colors
121
- * are treated as a circular array. Providing one color will mean that all
122
- * tabs are indicated with the same color.
123
- */
124
- public void setSelectedIndicatorColors(int... colors) {
125
- mTabStrip.setSelectedIndicatorColors(colors);
126
- this.mSelectedIndicatorColors = colors;
127
- }
128
-
129
- private int[] mSelectedIndicatorColors;
130
- public int[] getSelectedIndicatorColors() {
131
- return this.mSelectedIndicatorColors;
132
- }
133
-
134
- public void setTabTextColor(int color){
135
- mTabStrip.setTabTextColor(color);
136
- }
137
-
138
- public int getTabTextColor(){
139
- return mTabStrip.getTabTextColor();
140
- }
141
-
142
- public void setSelectedTabTextColor(int color){
143
- mTabStrip.setSelectedTabTextColor(color);
144
- }
145
-
146
- public int getSelectedTabTextColor(){
147
- return mTabStrip.getSelectedTabTextColor();
148
- }
149
-
150
- public void setTabTextFontSize(float fontSize){
151
- mTabStrip.setTabTextFontSize(fontSize);
152
- }
153
-
154
- public float getTabTextFontSize(){
155
- return mTabStrip.getTabTextFontSize();
156
- }
157
-
158
- /**
159
- * Set the {@link ViewPager.OnPageChangeListener}. When using
160
- * {@link TabsBar} you are required to set any
161
- * {@link ViewPager.OnPageChangeListener} through this method. This is so
162
- * that the layout can update it's scroll position correctly.
163
- *
164
- * @see ViewPager#setOnPageChangeListener(ViewPager.OnPageChangeListener)
165
- */
166
- public void setOnPageChangeListener(ViewPager.OnPageChangeListener listener) {
167
- mViewPagerPageChangeListener = listener;
168
- }
169
-
170
- /**
171
- * Sets the associated view pager. Note that the assumption here is that the
172
- * pager content (number of tabs and tab titles) does not change after this
173
- * call has been made.
174
- */
175
- public void setViewPager(ViewPager viewPager) {
176
- this.setItems(null, viewPager);
177
- }
178
-
179
- public void setItems(TabItemSpec[] items, ViewPager viewPager) {
180
- mTabStrip.removeAllViews();
181
-
182
- mViewPager = viewPager;
183
- mTabItems = items;
184
- if (viewPager != null) {
185
- viewPager.addOnPageChangeListener(new InternalViewPagerListener());
186
- populateTabStrip();
187
- }
188
- }
189
-
190
- /**
191
- * Updates the UI of an item at specified index
192
- */
193
- public void updateItemAt(int position, TabItemSpec tabItem) {
194
- LinearLayout ll = (LinearLayout)mTabStrip.getChildAt(position);
195
- ImageView imgView = (ImageView)ll.getChildAt(0);
196
- TextView textView = (TextView)ll.getChildAt(1);
197
- this.setupItem(ll, textView, imgView, tabItem);
198
- }
199
-
200
- /**
201
- * Gets the TextView for tab item at index
202
- */
203
- public TextView getTextViewForItemAt(int index){
204
- LinearLayout ll = this.getViewForItemAt(index);
205
- return (ll != null) ? (TextView)ll.getChildAt(1) : null;
206
- }
207
-
208
- /**
209
- * Gets the LinearLayout container for tab item at index
210
- */
211
- public LinearLayout getViewForItemAt(int index){
212
- LinearLayout result = null;
213
-
214
- if(this.mTabStrip.getChildCount() > index){
215
- result = (LinearLayout)this.mTabStrip.getChildAt(index);
216
- }
217
-
218
- return result;
219
- }
220
-
221
- /**
222
- * Gets the number of realized tabs.
223
- */
224
- public int getItemCount(){
225
- return this.mTabStrip.getChildCount();
226
- }
227
-
228
- /**
229
- * Create a default view to be used for tabs.
230
- */
231
- protected View createDefaultTabView(Context context, TabItemSpec tabItem) {
232
- float density = getResources().getDisplayMetrics().density;
233
- int padding = (int) (TAB_VIEW_PADDING_DIPS * density);
234
-
235
- LinearLayout ll = new LinearLayout(context);
236
- ll.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
237
- ll.setGravity(Gravity.CENTER);
238
- ll.setOrientation(LinearLayout.VERTICAL);
239
- TypedValue outValue = new TypedValue();
240
- getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
241
- ll.setBackgroundResource(outValue.resourceId);
242
-
243
- ImageView imgView = new ImageView(context);
244
- imgView.setScaleType(ScaleType.FIT_CENTER);
245
- LinearLayout.LayoutParams imgLP = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
246
- imgLP.gravity = Gravity.CENTER;
247
- imgView.setLayoutParams(imgLP);
248
-
249
- TextView textView = new TextView(context);
250
- textView.setGravity(Gravity.CENTER);
251
- textView.setMaxWidth((int) (TEXT_MAX_WIDTH * density));
252
- textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
253
- textView.setEllipsize(TextUtils.TruncateAt.END);
254
- textView.setMaxLines(2);
255
- textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
256
- textView.setPadding(padding, 0, padding, 0);
257
-
258
- this.setupItem(ll, textView, imgView, tabItem);
259
-
260
- ll.addView(imgView);
261
- ll.addView(textView);
262
- return ll;
263
- }
264
-
265
- private void setupItem(LinearLayout ll, TextView textView,ImageView imgView, TabItemSpec tabItem){
266
- float density = getResources().getDisplayMetrics().density;
267
-
268
- if (tabItem.iconId != 0) {
269
- imgView.setImageResource(tabItem.iconId);
270
- imgView.setVisibility(VISIBLE);
271
- } else if (tabItem.iconDrawable != null) {
272
- imgView.setImageDrawable(tabItem.iconDrawable);
273
- imgView.setVisibility(VISIBLE);
274
- } else {
275
- imgView.setVisibility(GONE);
276
- }
277
-
278
- if (tabItem.title != null && !tabItem.title.isEmpty()) {
279
- textView.setText(tabItem.title);
280
- textView.setVisibility(VISIBLE);
281
-
282
- if (tabItem.typeFace != null) {
283
- textView.setTypeface(tabItem.typeFace);
284
- }
285
-
286
- if (tabItem.fontSize != 0) {
287
- textView.setTextSize(tabItem.fontSize);
288
- }
289
-
290
- if (tabItem.color != 0) {
291
- textView.setTextColor(tabItem.color);
292
- mTabStrip.setShouldUpdateTabsTextColor(false);
293
- }
294
- } else {
295
- textView.setVisibility(GONE);
296
- }
297
-
298
- if (tabItem.backgroundColor != 0) {
299
- ll.setBackgroundColor(tabItem.backgroundColor);
300
- }
301
-
302
- if (imgView.getVisibility() == VISIBLE && textView.getVisibility() == VISIBLE) {
303
- ll.setMinimumHeight((int) (LARGE_MIN_HEIGHT * density));
304
- } else {
305
- ll.setMinimumHeight((int) (SMALL_MIN_HEIGHT * density));
306
- }
307
-
308
- if (mDistributeEvenly) {
309
- LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ll.getLayoutParams();
310
- lp.width = 0;
311
- lp.weight = 1;
312
- }
313
- }
314
-
315
- public boolean onTap(int position) {
316
- // to be overridden in JS
317
- return true;
318
- }
319
-
320
- private void populateTabStrip() {
321
- final PagerAdapter adapter = mViewPager.getAdapter();
322
- final OnClickListener tabClickListener = new TabClickListener();
323
-
324
- for (int i = 0; i < adapter.getCount(); i++) {
325
- View tabView = null;
326
-
327
- TabItemSpec tabItem;
328
- if (this.mTabItems != null && this.mTabItems.length > i) {
329
- tabItem = this.mTabItems[i];
330
- } else {
331
- tabItem = new TabItemSpec();
332
- tabItem.title = adapter.getPageTitle(i).toString();
333
- }
334
-
335
- tabView = createDefaultTabView(getContext(), tabItem);
336
-
337
- tabView.setOnClickListener(tabClickListener);
338
- String desc = mContentDescriptions.get(i, null);
339
- if (desc != null) {
340
- tabView.setContentDescription(desc);
341
- }
342
-
343
- mTabStrip.addView(tabView);
344
- if (i == mViewPager.getCurrentItem()) {
345
- tabView.setSelected(true);
346
- }
347
- }
348
- }
349
-
350
- public void setContentDescription(int i, String desc) {
351
- mContentDescriptions.put(i, desc);
352
- }
353
-
354
- @Override
355
- protected void onAttachedToWindow() {
356
- super.onAttachedToWindow();
357
-
358
- if (mViewPager != null) {
359
- scrollToTab(mViewPager.getCurrentItem(), 0);
360
- }
361
- }
362
-
363
- private void scrollToTab(int tabIndex, int positionOffset) {
364
- final int tabStripChildCount = mTabStrip.getChildCount();
365
- if (tabStripChildCount == 0 || tabIndex < 0 || tabIndex >= tabStripChildCount) {
366
- return;
367
- }
368
-
369
- View selectedChild = mTabStrip.getChildAt(tabIndex);
370
- if (selectedChild != null) {
371
- int targetScrollX = selectedChild.getLeft() + positionOffset;
372
-
373
- if (tabIndex > 0 || positionOffset > 0) {
374
- // If we're not at the first child and are mid-scroll, make sure
375
- // we obey the offset
376
- targetScrollX -= mTitleOffset;
377
- }
378
-
379
- scrollTo(targetScrollX, 0);
380
- }
381
- }
382
-
383
- private class InternalViewPagerListener implements ViewPager.OnPageChangeListener {
384
- private int mScrollState;
385
-
386
- @Override
387
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
388
- int tabStripChildCount = mTabStrip.getChildCount();
389
- if ((tabStripChildCount == 0) || (position < 0) || (position >= tabStripChildCount)) {
390
- return;
391
- }
392
-
393
- mTabStrip.onTabsViewPagerPageChanged(position, positionOffset);
394
-
395
- View selectedTitle = mTabStrip.getChildAt(position);
396
- int extraOffset = (selectedTitle != null) ? (int) (positionOffset * selectedTitle.getWidth()) : 0;
397
- scrollToTab(position, extraOffset);
398
-
399
- if (mViewPagerPageChangeListener != null) {
400
- mViewPagerPageChangeListener.onPageScrolled(position, positionOffset, positionOffsetPixels);
401
- }
402
- }
403
-
404
- @Override
405
- public void onPageScrollStateChanged(int state) {
406
- mScrollState = state;
407
-
408
- if (mViewPagerPageChangeListener != null) {
409
- mViewPagerPageChangeListener.onPageScrollStateChanged(state);
410
- }
411
- }
412
-
413
- @Override
414
- public void onPageSelected(int position) {
415
- if (mScrollState == ViewPager.SCROLL_STATE_IDLE) {
416
- mTabStrip.onTabsViewPagerPageChanged(position, 0f);
417
- scrollToTab(position, 0);
418
- }
419
- for (int i = 0; i < mTabStrip.getChildCount(); i++) {
420
- mTabStrip.getChildAt(i).setSelected(position == i);
421
- }
422
- if (mViewPagerPageChangeListener != null) {
423
- mViewPagerPageChangeListener.onPageSelected(position);
424
- }
425
- }
426
-
427
- }
428
-
429
- private class TabClickListener implements OnClickListener {
430
- @Override
431
- public void onClick(View v) {
432
- for (int i = 0; i < mTabStrip.getChildCount(); i++) {
433
- if (v == mTabStrip.getChildAt(i)) {
434
- if (onTap(i)) {
435
- mViewPager.setCurrentItem(i);
436
- }
437
- return;
438
- }
439
- }
440
- }
441
- }
442
- }
@@ -1,60 +0,0 @@
1
- import { ContentViewAttributes, NativeScriptProps, ViewAttributes } from 'react-nativescript';
2
- import { Color, EventData, Image, Label, PropertyChangeData } from '@nativescript/core';
3
- import { SelectedIndexChangedEventData } from '../tab-navigation-base';
4
- import { TabContentItem } from '../tab-content-item';
5
- import { TabStrip } from '../tab-strip';
6
- import { TabStripItem } from '../tab-strip-item';
7
- export declare type TabNavigationBaseAttributes = ViewAttributes & {
8
- android?: any;
9
- ios?: any;
10
- items?: string | TabContentItem[];
11
- onItemsChange?: (args: PropertyChangeData) => void;
12
- onSelectedIndexChange?: (args: PropertyChangeData) => void;
13
- onSelectedIndexChanged?: (args: SelectedIndexChangedEventData) => void;
14
- onTabStripChange?: (args: PropertyChangeData) => void;
15
- selectedIndex?: string | number;
16
- tabStrip?: string | TabStrip;
17
- };
18
- export declare type TabContentItemAttributes = ContentViewAttributes & {
19
- canBeLoaded?: false | true;
20
- };
21
- export declare type TabStripAttributes = ViewAttributes & {
22
- highlightColor?: string | Color;
23
- iosIconRenderingMode?: 'automatic' | 'alwaysOriginal' | 'alwaysTemplate';
24
- isIconSizeFixed?: string | false | true;
25
- items?: string | TabStripItem[];
26
- onHighlightColorChange?: (args: PropertyChangeData) => void;
27
- onIosIconRenderingModeChange?: (args: PropertyChangeData) => void;
28
- onIsIconSizeFixedChange?: (args: PropertyChangeData) => void;
29
- onItemTap?: (args: EventData) => void;
30
- onItemsChange?: (args: PropertyChangeData) => void;
31
- onSelectedItemColorChange?: (args: PropertyChangeData) => void;
32
- onUnSelectedItemColorChange?: (args: PropertyChangeData) => void;
33
- selectedItemColor?: string | Color;
34
- unSelectedItemColor?: string | Color;
35
- };
36
- export declare type TabStripItemAttributes = ViewAttributes & {
37
- iconClass?: string;
38
- iconSource?: string;
39
- image?: Image;
40
- label?: Label;
41
- onTap?: (args: EventData) => void;
42
- title?: string;
43
- };
44
- declare global {
45
- module JSX {
46
- interface IntrinsicElements {
47
- tabStrip: NativeScriptProps<TabStripAttributes, TabStrip>;
48
- tabStripItem: NativeScriptProps<TabStripItemAttributes, TabStripItem>;
49
- tabContentItem: NativeScriptProps<TabContentItemAttributes, TabContentItem>;
50
- }
51
- interface ElementChildrenAttribute {
52
- children: {};
53
- }
54
- }
55
- }
56
- interface RegisterTabsOptions {
57
- enableDebugLogging?: boolean;
58
- }
59
- export declare function registerTabNavigationBase(opts?: RegisterTabsOptions): void;
60
- export {};
@@ -1,114 +0,0 @@
1
- import { NSVElement, registerElement } from 'react-nativescript';
2
- import { Color, Image, Label } from '@nativescript/core';
3
- import { warn } from 'react-nativescript/dist/shared/Logger';
4
- import { TabContentItem } from '../tab-content-item';
5
- import { TabStrip } from '../tab-strip';
6
- import { TabStripItem } from '../tab-strip-item';
7
- let installed = false;
8
- export function registerTabNavigationBase(opts = {}) {
9
- const { enableDebugLogging = false } = opts;
10
- if (installed) {
11
- return;
12
- }
13
- registerElement('tabStrip', () => TabStrip, {
14
- nodeOps: {
15
- insert(child, parent, atIndex) {
16
- const tabStrip = parent.nativeView;
17
- if (child.nodeRole === 'items') {
18
- if (child.nativeView instanceof TabStripItem === false) {
19
- if (enableDebugLogging) {
20
- warn(`Unable to add child "${child.nativeView.constructor.name}" to the items of <tabStrip> as it is not an instance of TabStripItem.`);
21
- }
22
- return;
23
- }
24
- const items = tabStrip.items || [];
25
- if (typeof atIndex === 'undefined' || atIndex === items.length) {
26
- tabStrip._addChildFromBuilder('items', child.nativeView);
27
- }
28
- else {
29
- const itemsClone = items.slice();
30
- itemsClone.splice(atIndex, 0, child.nativeView);
31
- tabStrip.items = itemsClone;
32
- }
33
- }
34
- else if (child.nodeRole === 'item') {
35
- if (enableDebugLogging) {
36
- warn(`Unable to add child "${child.nativeView.constructor.name}" to <tabStrip> as it had the nodeRole "item"; please correct it to "items".`);
37
- }
38
- }
39
- else {
40
- if (enableDebugLogging) {
41
- warn(`Unable to add child "${child.nativeView.constructor.name}" to <tabStrip> as it does not have a nodeRole specified; ` +
42
- 'please set a nodeRole of "tabStrip", or "items".');
43
- }
44
- }
45
- },
46
- remove(child, parent) {
47
- const tabStrip = parent.nativeView;
48
- if (child.nodeRole === 'items') {
49
- tabStrip.items = (tabStrip.items || []).filter((i) => i !== child.nativeView);
50
- }
51
- else if (child.nodeRole === 'item') {
52
- if (enableDebugLogging) {
53
- warn(`Unable to remove child "${child.nativeView.constructor.name}" from <tabStrip> as it had the nodeRole "item"; please correct it to "items".`);
54
- }
55
- }
56
- else {
57
- if (enableDebugLogging) {
58
- warn(`Unable to remove child "${child.nativeView.constructor.name}" from <tabStrip> as it does not have a nodeRole specified; ` +
59
- 'please set a nodeRole of "tabStrip", or "items"');
60
- }
61
- }
62
- }
63
- }
64
- });
65
- registerElement('tabStripItem', () => TabStripItem, {
66
- nodeOps: {
67
- insert(child, parent, atIndex) {
68
- const tabStripItem = parent.nativeView;
69
- if (child.nodeRole === 'label') {
70
- if (child.nativeView instanceof Label === false) {
71
- if (enableDebugLogging) {
72
- warn(`Unable to add child "${child.nativeView.constructor.name}" to the items of <tabStripItem> as it is not an instance of Label.`);
73
- }
74
- return;
75
- }
76
- tabStripItem.label = child.nativeView;
77
- }
78
- else if (child.nodeRole === 'image') {
79
- if (child.nativeView instanceof Image === false) {
80
- if (enableDebugLogging) {
81
- warn(`Unable to add child "${child.nativeView.constructor.name}" to the items of <tabStripItem> as it is not an instance of Image.`);
82
- }
83
- return;
84
- }
85
- tabStripItem.image = child.nativeView;
86
- }
87
- else {
88
- if (enableDebugLogging) {
89
- warn(`Unable to add child "${child.nativeView.constructor.name}" to <tabStripItem> as it does not have a nodeRole specified; ` +
90
- 'please set a nodeRole of "label", or "image".');
91
- }
92
- }
93
- },
94
- remove(child, parent) {
95
- const tabStripItem = parent.nativeView;
96
- if (child.nodeRole === 'label') {
97
- tabStripItem.label = null;
98
- }
99
- else if (child.nodeRole === 'image') {
100
- tabStripItem.image = null;
101
- }
102
- else {
103
- if (enableDebugLogging) {
104
- warn(`Unable to remove child "${child.nativeView.constructor.name}" from <tabStripItem> as it does not have a nodeRole specified; ` +
105
- 'please set a nodeRole of "label", or "image"');
106
- }
107
- }
108
- }
109
- }
110
- });
111
- registerElement('tabContentItem', () => TabContentItem, { viewFlags: 2 });
112
- installed = true;
113
- }
114
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["tab-navigation-base/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,UAAU,EAAmD,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACzI,OAAO,EAAE,KAAK,EAAa,KAAK,EAAE,KAAK,EAAsB,MAAM,oBAAoB,CAAC;AACxF,OAAO,EAAE,IAAI,EAAE,MAAM,uCAAuC,CAAC;AAE7D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA4DjD,IAAI,SAAS,GAAY,KAAK,CAAC;AAM/B,MAAM,UAAU,yBAAyB,CAAC,OAA4B,EAAE;IACpE,MAAM,EAAE,kBAAkB,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC;IAE5C,IAAI,SAAS,EAAE;QACX,OAAO;KACV;IAED,eAAe,CACX,UAAU,EAEV,GAAG,EAAE,CAAC,QAAQ,EACd;QACI,OAAO,EAAE;YACL,MAAM,CAAC,KAAiB,EAAE,MAA4B,EAAE,OAAgB;gBACpE,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC;gBAEnC,IAAI,KAAK,CAAC,QAAQ,KAAK,OAAO,EAAE;oBAC5B,IAAI,KAAK,CAAC,UAA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