@@ -11,8 +11,9 @@ import { fromObject } from "tns-core-modules/data/observable";
11
11
import { addWeakEventListener , removeWeakEventListener } from "tns-core-modules/ui/core/weak-event-listener" ;
12
12
import { ObservableArray , ChangedData } from "tns-core-modules/data/observable-array/observable-array" ;
13
13
import { GridLayout } from 'tns-core-modules/ui/layouts/grid-layout/grid-layout' ;
14
- import { ActionItem } from 'tns-core-modules/ui/action-bar/action-bar' ;
14
+ import { ActionItem , NavigationButton } from 'tns-core-modules/ui/action-bar/action-bar' ;
15
15
import { Frame } from 'tns-core-modules/ui/frame/frame' ;
16
+ import { isAndroid } from 'tns-core-modules/platform' ;
16
17
17
18
export interface ItemsSource {
18
19
length : number ;
@@ -47,7 +48,7 @@ export class PickerField extends TextField implements TemplatedItemsView {
47
48
public selectedIndex : number ;
48
49
public iOSCloseButtonPosition : "left" | "right" ;
49
50
public iOSCloseButtonIcon : number ;
50
- public androidCloseButtonPosition : "actionBar" | "actionBarIfRoom" | "popup" ;
51
+ public androidCloseButtonPosition : "navigationButton" | " actionBar" | "actionBarIfRoom" | "popup" ;
51
52
public androidCloseButtonIcon : string ;
52
53
private _modalListView : ListView ;
53
54
private _modalRoot : Frame ;
@@ -96,31 +97,34 @@ export class PickerField extends TextField implements TemplatedItemsView {
96
97
97
98
this . applyCssScope ( this . _page . actionBar ) ;
98
99
99
- let actionItem = new ActionItem ( ) ;
100
- actionItem . text = "Close" ;
101
- actionItem . on ( Button . tapEvent , ( args : ItemEventData ) => {
102
- this . closeCallback ( undefined , undefined ) ;
103
- } ) ;
100
+ const isNavigationButton = isAndroid && this . androidCloseButtonPosition === "navigationButton" ;
101
+ const closeButton = isNavigationButton ? new NavigationButton ( ) : new ActionItem ( ) ;
104
102
105
- this . applyCssScope ( < any > actionItem ) ;
103
+ closeButton . text = "Close" ;
104
+ closeButton . on ( Button . tapEvent , ( ) => {
105
+ this . closeCallback ( ) ;
106
+ } ) ;
107
+ this . applyCssScope ( < any > closeButton ) ;
106
108
107
- if ( actionItem . ios ) {
108
- actionItem . ios . position = this . iOSCloseButtonPosition ;
109
- actionItem . ios . systemIcon = this . iOSCloseButtonIcon ;
109
+ if ( closeButton . ios ) {
110
+ closeButton . ios . position = this . iOSCloseButtonPosition ;
111
+ closeButton . ios . systemIcon = this . iOSCloseButtonIcon ;
110
112
}
111
-
112
- if ( actionItem . android ) {
113
- actionItem . android . systemIcon = this . androidCloseButtonIcon ;
114
- actionItem . android . position = this . androidCloseButtonPosition ;
113
+ if ( closeButton . android ) {
114
+ closeButton . android . systemIcon = this . androidCloseButtonIcon ;
115
+ closeButton . android . position = < any > this . androidCloseButtonPosition ;
115
116
}
116
117
117
- this . _page . actionBar . actionItems . addItem ( actionItem ) ;
118
+ if ( isNavigationButton ) {
119
+ this . _page . actionBar . navigationButton = closeButton ;
120
+ } else {
121
+ this . _page . actionBar . actionItems . addItem ( closeButton ) ;
122
+ }
118
123
119
124
this . _modalRoot . on ( Page . shownModallyEvent , this . shownModallyHandler . bind ( this ) ) ;
120
125
121
126
this . _modalListView . on ( ListView . itemLoadingEvent , this . listViewItemLoadingHandler . bind ( this ) ) ;
122
127
this . _modalListView . on ( ListView . itemTapEvent , this . listViewItemTapHandler . bind ( this ) ) ;
123
- this . applyCssScope ( this . _modalListView ) ;
124
128
this . _modalListView . items = this . items ;
125
129
126
130
this . applyCssScope ( this . _modalGridLayout ) ;
0 commit comments