Skip to content

Commit 99f63bc

Browse files
committed
Merge branch 'EddyVerbruggen-implement-actionbar'
2 parents 5a0635a + d4e2c50 commit 99f63bc

File tree

9 files changed

+330
-62
lines changed

9 files changed

+330
-62
lines changed

dist/index.js

Lines changed: 151 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

platform/nativescript/element-registry.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ registerElement("ListPicker", () => require("ui/list-picker").ListPicker, {
8585
event: 'selectedIndexChange'
8686
}
8787
});
88+
registerElement("NativeActionBar", () => require("ui/action-bar").ActionBar);
89+
registerElement("NativeActionItem", () => require("ui/action-bar").ActionItem);
8890
registerElement("NativeListView", () => require("ui/list-view").ListView);
91+
registerElement("NativeNavigationButton", () => require("ui/action-bar").NavigationButton);
8992
registerElement("Page", () => require("ui/page").Page, {
9093
skipAddToDom: true
9194
});
Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,46 @@
1+
import { warn } from 'core/util/debug'
2+
13
export default {
24
name: 'action-bar',
35

4-
template: `<native-action-bar></native-action-bar>`,
5-
6-
props: {},
6+
template: `<native-action-bar ref="actionBar"><slot></slot></native-action-bar>`,
77

8-
created() {
8+
props: {
9+
title: {
10+
type: String,
11+
required: false
12+
}
913
},
1014

1115
mounted() {
16+
this.$nextTick(() => {
17+
if (this.$root.$el.tagName !== 'page') {
18+
warn('Make sure you are placing the <ActionBar> component as a direct child of a <Page> element.')
19+
return
20+
}
21+
22+
const page = this.$root.$el.nativeView
23+
24+
page.actionBar = this.$refs.actionBar.nativeView
25+
page.actionBarHidden = false
26+
if (this.title) {
27+
this.$refs.actionBar.setAttribute('title', this.title)
28+
}
29+
})
30+
},
31+
32+
watch: {
33+
title(newVal) {
34+
this.$refs.actionBar.setAttribute('title', newVal)
35+
}
1236
},
1337

14-
methods: {}
38+
methods: {
39+
registerActionItem(actionItem) {
40+
this.$refs.actionBar.nativeView.actionItems.addItem(actionItem)
41+
},
42+
registerNavigationButton(navigationButton) {
43+
this.$refs.actionBar.nativeView.navigationButton = navigationButton
44+
}
45+
}
1546
}

0 commit comments

Comments
 (0)