Skip to content

Commit 30ec42d

Browse files
committed
Merge branch 'master' of github.com:nativescript-community/ui-material-components
2 parents c16ce20 + 62074fc commit 30ec42d

File tree

23 files changed

+2068
-2254
lines changed

23 files changed

+2068
-2254
lines changed

.project

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
</natures>
2323
<filteredResources>
2424
<filter>
25-
<id>1604680591551</id>
25+
<id>1682616481632</id>
2626
<name></name>
2727
<type>30</type>
2828
<matcher>
2929
<id>org.eclipse.core.resources.regexFilterMatcher</id>
30-
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
30+
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
3131
</matcher>
3232
</filter>
3333
</filteredResources>

demo-ng

demo-react

demo-snippets/vue/TextView.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,19 @@
2727
</FormattedString>
2828
</MDTextView>
2929
<MDTextView id="textView2" editable="false" counterMaxLength="10" maxLength="10" hint="hint me" @textChange="onTextChange" @returnPress="onReturnPress" />
30-
<MDTextView id="textView3" placeholderColor="green" floatingColor="yellow" color="red" variant="outline" hint="text should be red" @textChange="onTextChange" v-model="value" @returnPress="onReturnPress" height="200" backgroundColor="blue"/>
30+
<MDTextView
31+
id="textView3"
32+
placeholderColor="green"
33+
floatingColor="yellow"
34+
color="red"
35+
variant="outline"
36+
hint="text should be red"
37+
helper="test"
38+
@textChange="onTextChange"
39+
v-model="value"
40+
@returnPress="onReturnPress"
41+
backgroundColor="blue"
42+
/>
3143
<MDTextView variant="filled" required="true" email="true" hint="fill this out..." @textChange="onTextChange" @returnPress="onReturnPress" />
3244
<MDTextView hint="fill this out..." />
3345
</StackLayout>
@@ -46,7 +58,7 @@ export default Vue.extend({
4658
4759
data() {
4860
return {
49-
title: title,
61+
title,
5062
value: 'test'
5163
};
5264
},

demo-vue

demo-vue3

packages/bottomsheet/tsconfig.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,11 @@
99
}
1010
},
1111
"include": ["../../src/bottomsheet/**/*.ts", "../../references.d.ts", "../../tools/references.d.ts", "../../src/references.d.ts"],
12-
"exclude": ["../../src/bottomsheet/angular/**"]
13-
}
12+
"exclude": ["../../src/bottomsheet/angular/**"],
13+
"references": [
14+
{
15+
//Need for tsc
16+
"path": "../../tsconfig.vue3.json"
17+
}
18+
]
19+
}

src/bottom-navigation/index.ios.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { TabStrip } from '@nativescript-community/ui-material-core-tabs/tab-stri
66
import { TabStripItem } from '@nativescript-community/ui-material-core-tabs/tab-strip-item';
77
// Types
88
// Requires
9-
import { CSSType, Color, CoreTypes, Device, Font, Frame, IOSHelper, ImageSource, Property, Utils, View, booleanConverter } from '@nativescript/core';
9+
import { CSSType, Color, CoreTypes, Device, Font, Frame, IOSHelper, ImageSource, ImageAsset, Property, Utils, View, booleanConverter } from '@nativescript/core';
1010
import { getTransformedText } from '@nativescript/core/ui/text-base';
1111
import { iOSNativeHelper } from '@nativescript/core/utils';
1212
export { TabContentItem, TabStrip, TabStripItem };
@@ -690,19 +690,28 @@ export class BottomNavigation extends TabNavigationBase {
690690
}
691691
const iconTag = [iconSource, font.fontStyle, font.fontWeight, font.fontSize, font.fontFamily, color].join(';');
692692

693-
let isFontIcon = false;
693+
const isFontIcon = false;
694694
let image: UIImage = this.mIconsCache[iconTag];
695695
if (!image) {
696-
let is;
697-
if (Utils.isFontIconURI(iconSource)) {
698-
isFontIcon = true;
699-
const fontIconCode = iconSource.split('//')[1];
700-
is = ImageSource.fromFontIconCodeSync(fontIconCode, font, color);
696+
let is: ImageSource | ImageAsset;
697+
if (typeof iconSource === 'string') {
698+
if (Utils.isFontIconURI(iconSource)) {
699+
const fontIconCode = iconSource.split('//')[1];
700+
const target = tabStripItem.image ? tabStripItem.image : tabStripItem;
701+
const font = target.style.fontInternal;
702+
if (!color) {
703+
color = target.style.color;
704+
}
705+
is = ImageSource.fromFontIconCodeSync(fontIconCode, font, color);
706+
} else {
707+
is = ImageSource.fromFileOrResourceSync(iconSource);
708+
}
701709
} else {
702-
is = ImageSource.fromFileOrResourceSync(iconSource);
710+
is = iconSource;
703711
}
704712

705-
if (is && is.ios) {
713+
image = is?.ios;
714+
if (image) {
706715
image = is.ios;
707716

708717
if (this.tabStrip && this.tabStrip.isIconSizeFixed) {

src/bottomsheet/vue3/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { App, createApp } from 'nativescript-vue3';
1+
import { App, createApp } from 'nativescript-vue';
22
import { Frame, View, ViewBase } from '@nativescript/core';
33
import { BottomSheetOptions } from '../bottomsheet';
44
import { ComponentCustomProperties } from '@vue/runtime-core';
55

66
declare module '@vue/runtime-core' {
77
interface ComponentCustomProperties {
8-
$showBottomSheet: (component: any, options: VueBottomSheetOptions) => Promise<any>;
8+
$showBottomSheet(component: any, options: VueBottomSheetOptions): Promise<any>;
99
$closeBottomSheet(...args);
1010
}
1111
}

src/core-tabs/tab-navigation/index.android.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Application, Color, CoreTypes, Font, ImageSource, Utils, getTransformedText } from '@nativescript/core';
1+
import { Application, Color, CoreTypes, Font, ImageAsset, ImageSource, Utils, getTransformedText } from '@nativescript/core';
22
import { TabContentItem } from '../tab-content-item';
33
import { getIconSpecSize, itemsProperty, selectedIndexProperty, tabStripProperty } from '../tab-navigation-base';
44
import { TabStrip } from '../tab-strip';
@@ -459,25 +459,29 @@ export abstract class TabNavigation<T extends android.view.ViewGroup = any> exte
459459
}
460460

461461
private getOriginalIcon(tabStripItem: TabStripItem, color?: Color): android.graphics.Bitmap {
462-
const iconSource = tabStripItem.image && tabStripItem.image.src;
462+
const iconSource = tabStripItem.image?.src;
463463
if (!iconSource) {
464464
return null;
465465
}
466466

467-
let is: ImageSource;
468-
if (Utils.isFontIconURI(iconSource)) {
469-
const fontIconCode = iconSource.split('//')[1];
470-
const target = tabStripItem.image ? tabStripItem.image : tabStripItem;
471-
const font = target.style.fontInternal;
472-
if (!color) {
473-
color = target.style.color;
467+
let is: ImageSource | ImageAsset;
468+
if (typeof iconSource === 'string') {
469+
if (Utils.isFontIconURI(iconSource)) {
470+
const fontIconCode = iconSource.split('//')[1];
471+
const target = tabStripItem.image ? tabStripItem.image : tabStripItem;
472+
const font = target.style.fontInternal;
473+
if (!color) {
474+
color = target.style.color;
475+
}
476+
is = ImageSource.fromFontIconCodeSync(fontIconCode, font, color);
477+
} else {
478+
is = ImageSource.fromFileOrResourceSync(iconSource);
474479
}
475-
is = ImageSource.fromFontIconCodeSync(fontIconCode, font, color);
476480
} else {
477-
is = ImageSource.fromFileOrResourceSync(iconSource);
481+
is = iconSource;
478482
}
479483

480-
return is && is.android;
484+
return is?.android;
481485
}
482486

483487
private getDrawableInfo(image: android.graphics.Bitmap): IconInfo {

src/core-tabs/tab-navigation/index.ios.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @module @nativescript-community/ui-material-core-tabs/tab-navigation
33
*/
4-
import { Color, CoreTypes, Device, Font, Frame, IOSHelper, ImageSource, Property, Utils, View, ViewBase, booleanConverter, getTransformedText } from '@nativescript/core';
4+
import { Color, CoreTypes, Device, Font, Frame, IOSHelper, ImageAsset, ImageSource, Property, Utils, View, ViewBase, booleanConverter, getTransformedText } from '@nativescript/core';
55
import { TabContentItem } from '../tab-content-item';
66
import { getIconSpecSize, itemsProperty, selectedIndexProperty, tabStripProperty } from '../tab-navigation-base';
77
import { TabStrip } from '../tab-strip';
@@ -253,6 +253,7 @@ export abstract class TabNavigation<
253253
public nativeViewProtected: UIView;
254254
public selectedIndex: number;
255255
public mCanSelectItem: boolean;
256+
//@ts-ignore
256257
public isLoaded: boolean;
257258
public viewController: T;
258259
public items: TabContentItem[];
@@ -630,21 +631,28 @@ export abstract class TabNavigation<
630631
}
631632
const iconTag = [iconSource, font.fontStyle, font.fontWeight, font.fontSize, font.fontFamily, color].join(';');
632633

633-
let isFontIcon = false;
634+
const isFontIcon = false;
634635
let image: UIImage = this.mIconsCache[iconTag];
635636
if (!image) {
636-
let is: ImageSource;
637-
if (Utils.isFontIconURI(iconSource)) {
638-
isFontIcon = true;
639-
const fontIconCode = iconSource.split('//')[1];
640-
is = ImageSource.fromFontIconCodeSync(fontIconCode, font, color);
637+
let is: ImageSource | ImageAsset;
638+
if (typeof iconSource === 'string') {
639+
if (Utils.isFontIconURI(iconSource)) {
640+
const fontIconCode = iconSource.split('//')[1];
641+
const target = tabStripItem.image ? tabStripItem.image : tabStripItem;
642+
const font = target.style.fontInternal;
643+
if (!color) {
644+
color = target.style.color;
645+
}
646+
is = ImageSource.fromFontIconCodeSync(fontIconCode, font, color);
647+
} else {
648+
is = ImageSource.fromFileOrResourceSync(iconSource);
649+
}
641650
} else {
642-
is = ImageSource.fromFileOrResourceSync(iconSource);
651+
is = iconSource;
643652
}
644653

645-
if (is && is.ios) {
646-
image = is.ios;
647-
654+
image = is?.ios;
655+
if (image) {
648656
if (this.tabStrip && this.tabStrip.isIconSizeFixed) {
649657
image = this.getFixedSizeIcon(image);
650658
}

src/core-tabs/tab-strip-item/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @module @nativescript-community/ui-material-core-tabs/tab-strip-item
33
*/
4-
import { AddChildFromBuilder, CSSType, Color, CoreTypes, Image, Label, PropertyChangeData, PseudoClassHandler, View, ViewBase } from '@nativescript/core';
4+
import { AddChildFromBuilder, CSSType, Color, CoreTypes, Image, ImageAsset, ImageSource, Label, PropertyChangeData, PseudoClassHandler, View, ViewBase } from '@nativescript/core';
55
import { backgroundColorProperty, backgroundInternalProperty } from '@nativescript/core/ui/styling/style-properties';
66
import { textTransformProperty } from '@nativescript/core/ui/text-base';
77
import { TabStripItem as TabStripItemDefinition } from '.';
@@ -19,7 +19,7 @@ export class TabStripItem extends View implements TabStripItemDefinition, AddChi
1919
private mIndex: number;
2020

2121
private mTitle: string;
22-
private mIconSource: string;
22+
private mIconSource: string | ImageSource | ImageAsset;
2323
private mIconClass: string;
2424

2525
private mHighlightedHandler: () => void;
@@ -73,15 +73,15 @@ export class TabStripItem extends View implements TabStripItemDefinition, AddChi
7373
}
7474
}
7575

76-
get iconSource() {
76+
get iconSource(): string | ImageSource | ImageAsset {
7777
if (this.isLoaded) {
7878
return this.image.src;
7979
}
8080

8181
return this.mIconSource;
8282
}
8383

84-
set iconSource(value: string) {
84+
set iconSource(value: string | ImageSource | ImageAsset) {
8585
this.mIconSource = value;
8686

8787
if (this.isLoaded) {

src/speeddial/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { Animation, AnimationDefinition, CSSType, Color, CoreTypes, EventData, FlexboxLayout, GridLayout, ImageSource, isUserInteractionEnabledProperty } from '@nativescript/core';
77
import { Button } from '@nativescript-community/ui-material-button';
88
import { LinearGradient } from '@nativescript/core/ui/styling/linear-gradient';
9-
import { NotifyData } from '@nativescript/core/data/observable';
9+
import { Optional } from '@nativescript/core/utils/typescript-utils';
1010

1111
export class SpeedDialItemBase extends GridLayout {}
1212

@@ -139,7 +139,7 @@ export class SpeedDialItem extends SpeedDialItemBase {
139139
}
140140

141141
notifyChildEvent(child, superNotifyMethod) {
142-
return <T extends NotifyData>(data: T) => {
142+
return <T extends Optional<EventData, 'object'>>(data: T) => {
143143
(data as any).speeddialItem = this;
144144
if (data.eventName === 'tap') {
145145
if (this.isMain) {

src/tabs/index.android.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ export class Tabs extends TabNavigation<TabsBar> {
8787
protected override setTabBarItems(tabItems: com.nativescript.material.core.TabItemSpec[]) {
8888
this.mTabsBar.setItems(tabItems);
8989
// The setTimeout below is necessary to ensure the scrollToTab is executed only after
90-
// all tabs are recreated. The tabs' recreation is triggered by the setItems call above.
90+
// all tabs are recreated. The tabs' recreation is triggered by the setItems call above.
9191
//
92-
// The setTimeout is necessary to fix an Android issue:
92+
// The setTimeout is necessary to fix an Android issue:
9393
// Android Issue: Active Tab item not displaying after nav back
9494
// Reproduce steps:
9595
// 1. On app with multiple (overflown) tab items, Switch to the last tab item

src/tabs/index.ios.ts

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,35 @@ class MDCTabBarViewDelegateImpl extends NSObject implements MDCTabBarViewDelegat
2323
}
2424

2525
public tabBarViewShouldSelectItem(tabBar: MDCTabBarView, item: UITabBarItem): boolean {
26-
const owner = this._owner.get();
27-
const shouldSelectItem = owner.mCanSelectItem;
28-
const selectedIndex = owner.tabBarItems.indexOf(item);
26+
const owner = this._owner?.get();
27+
if (owner) {
28+
const shouldSelectItem = owner.mCanSelectItem;
29+
const selectedIndex = owner.tabBarItems.indexOf(item);
2930

30-
if (owner.selectedIndex !== selectedIndex) {
31-
owner.beginTabTransition();
32-
}
31+
if (owner.selectedIndex !== selectedIndex) {
32+
owner.beginTabTransition();
33+
}
3334

34-
const tabStrip = owner.tabStrip;
35-
const tabStripItems = tabStrip && tabStrip.items;
35+
const tabStrip = owner.tabStrip;
36+
const tabStripItems = tabStrip && tabStrip.items;
3637

37-
if (tabStripItems && tabStripItems[selectedIndex]) {
38-
tabStripItems[selectedIndex]._emit(TabStripItem.tapEvent);
39-
tabStrip.notify({ eventName: TabStrip.itemTapEvent, object: tabStrip, index: selectedIndex });
40-
}
38+
if (tabStripItems && tabStripItems[selectedIndex]) {
39+
tabStripItems[selectedIndex]._emit(TabStripItem.tapEvent);
40+
tabStrip.notify({ eventName: TabStrip.itemTapEvent, object: tabStrip, index: selectedIndex });
41+
}
4142

42-
return shouldSelectItem;
43+
return shouldSelectItem;
44+
}
45+
return false;
4346
}
4447

4548
public tabBarViewDidSelectItem(tabBar: MDCTabBarView, selectedItem: UITabBarItem): void {
46-
const owner = this._owner.get();
47-
const tabBarItems = owner.tabBarItems;
48-
const selectedIndex = tabBarItems.indexOf(selectedItem);
49-
owner.selectedIndex = selectedIndex;
49+
const owner = this._owner?.get();
50+
if (owner) {
51+
const tabBarItems = owner.tabBarItems;
52+
const selectedIndex = tabBarItems.indexOf(selectedItem);
53+
owner.selectedIndex = selectedIndex;
54+
}
5055
}
5156
}
5257

File renamed without changes.

src/textfield/textfield.ios.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ declare module '@nativescript/core/ui/text-field' {
123123
export class TextField extends TextFieldBase {
124124
nativeViewProtected: MDCBaseTextField;
125125
nativeTextViewProtected: MDCBaseTextField;
126+
//@ts-ignore
126127
public readonly style: Style & { variant: 'outline' | 'underline' | 'filled' };
127128
public nsdigits?: NSCharacterSet;
128129
firstEdit: boolean;

src/textview/textview.ios.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ export class TextView extends TextViewBase {
154154
nativeViewProtected: MDCMultilineTextField;
155155
private _controller: MDCTextInputControllerBase;
156156
public _isEditing: boolean;
157+
//@ts-ignore
157158
public readonly style: Style & { variant: 'outline' | 'underline' | 'filled' };
158159

159160
public clearFocus() {

tools

Submodule tools updated 1 file

tsconfig.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,11 @@
3838
"@nativescript-community/ui-material-speeddial": ["src/speeddial/index"],
3939
"@nativescript-community/ui-material-speeddial/*": ["src/speeddial/*"],
4040
}
41-
}
41+
},
42+
"references": [
43+
{
44+
//Need for IDE
45+
"path": "./tsconfig.vue3.json"
46+
}
47+
]
4248
}

0 commit comments

Comments
 (0)