Sfoglia il codice sorgente

Add showAsAction prop (#5034)

David undefined 5 anni fa
parent
commit
cb763b450f
1 ha cambiato i file con 20 aggiunte e 2 eliminazioni
  1. 20
    2
      docs/docs/topBar-buttons.md

+ 20
- 2
docs/docs/topBar-buttons.md Vedi File

@@ -10,12 +10,15 @@ The following options can be used to customise buttons.
10 10
     name: 'example.CustomButtonComponent'
11 11
   },
12 12
   text: 'Button one',
13
-  systemItem: 'done', // iOS only. Sets a system bar button item as the icon. Matches UIBarButtonSystemItem naming. See below for details.
14 13
   enabled: true,
15 14
   disableIconTint: false,
16 15
   color: 'red',
17 16
   disabledColor: 'black',
18
-  testID: 'buttonOneTestID'
17
+  testID: 'buttonOneTestID',
18
+  // Android only
19
+  showAsAction: 'ifRoom', // See below for details.
20
+  // iOS only
21
+  systemItem: 'done', // Sets a system bar button item as the icon. Matches UIBarButtonSystemItem naming. See below for details.
19 22
 }
20 23
 ```
21 24
 
@@ -48,6 +51,19 @@ On iOS, UIKit supplies some common bar button glyphs for developers to use. The
48 51
 
49 52
 More information about these glyphs can be found in [Apple's Human Interface Guidelines](https://developer.apple.com/ios/human-interface-guidelines/icons-and-images/system-icons/).
50 53
 
54
+
55
+## Android showAsAction
56
+
57
+It is keyword witch configure when and how this item should appear as an action item in the app bar. 
58
+A menu item can appear as an action item only when the activity includes an app bar.
59
+
60
+* `always`
61
+* `ifRoom`
62
+* `never`
63
+* `withText`
64
+
65
+[More info about `showAsAction` values](https://developer.android.com/guide/topics/resources/menu-resource)
66
+
51 67
 # Declaring Buttons statically
52 68
 
53 69
 Buttons can be defined in a screen's options:
@@ -129,6 +145,7 @@ class MyScreen extends Component {
129 145
 As buttons are part of a screen's options, they can be modified like any other styling option using the `mergeOptions` command.
130 146
 
131 147
 ## Setting buttons
148
+
132 149
 The following command will set the screen's right buttons. If the screen already has Right Buttons declared - they will be overridden.
133 150
 
134 151
 ```js
@@ -145,6 +162,7 @@ Navigation.mergeOptions(this.props.componentId, {
145 162
 ```
146 163
 
147 164
 ## Removing buttons
165
+
148 166
 Buttons can be removed by setting zero buttons, as shown in the snippet below.
149 167
 
150 168
 ```js