@capgo/capacitor-navigation-bar 8.0.24 → 8.1.3
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.
- package/README.md +4 -4
- package/android/src/main/java/ee/forgr/capacitor_navigation_bar/CapgoNavigationBarPlugin.java +14 -2
- package/dist/docs.json +3 -3
- package/dist/esm/definitions.d.ts +9 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +1 -0
- package/dist/esm/web.js.map +1 -1
- package/ios/Sources/CapgoNavigationBarPlugin/CapgoNavigationBarPlugin.swift +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -55,14 +55,14 @@ Capacitor Navigation Bar Plugin for customizing the Android navigation bar.
|
|
|
55
55
|
### setNavigationBarColor(...)
|
|
56
56
|
|
|
57
57
|
```typescript
|
|
58
|
-
setNavigationBarColor(options: { color: NavigationBarColor | string; darkButtons?: boolean; }) => Promise<void>
|
|
58
|
+
setNavigationBarColor(options: { color: NavigationBarColor | string; darkButtons?: boolean; dividerColor?: NavigationBarColor | string; }) => Promise<void>
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
Set the navigation bar color and button theme.
|
|
62
62
|
|
|
63
|
-
| Param | Type
|
|
64
|
-
| ------------- |
|
|
65
|
-
| **`options`** | <code>{ color: string; darkButtons?: boolean; }</code> | - Configuration for navigation bar appearance |
|
|
63
|
+
| Param | Type | Description |
|
|
64
|
+
| ------------- | ----------------------------------------------------------------------------- | --------------------------------------------- |
|
|
65
|
+
| **`options`** | <code>{ color: string; darkButtons?: boolean; dividerColor?: string; }</code> | - Configuration for navigation bar appearance |
|
|
66
66
|
|
|
67
67
|
**Since:** 1.0.0
|
|
68
68
|
|
package/android/src/main/java/ee/forgr/capacitor_navigation_bar/CapgoNavigationBarPlugin.java
CHANGED
|
@@ -15,12 +15,13 @@ import java.util.Locale;
|
|
|
15
15
|
@CapacitorPlugin(name = "NavigationBar")
|
|
16
16
|
public class CapgoNavigationBarPlugin extends Plugin {
|
|
17
17
|
|
|
18
|
-
private final String pluginVersion = "8.
|
|
18
|
+
private final String pluginVersion = "8.1.3";
|
|
19
19
|
|
|
20
20
|
@PluginMethod
|
|
21
21
|
public void setNavigationBarColor(PluginCall call) {
|
|
22
22
|
final String color = call.getString("color");
|
|
23
23
|
final boolean darkButtons = Boolean.TRUE.equals(call.getBoolean("darkButtons", true));
|
|
24
|
+
final String dividerColor = call.getString("dividerColor");
|
|
24
25
|
|
|
25
26
|
if (color == null) {
|
|
26
27
|
call.reject("Color must be provided");
|
|
@@ -29,11 +30,19 @@ public class CapgoNavigationBarPlugin extends Plugin {
|
|
|
29
30
|
|
|
30
31
|
getBridge().executeOnMainThread(() -> {
|
|
31
32
|
try {
|
|
33
|
+
final Integer parsedDividerColor =
|
|
34
|
+
Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && dividerColor != null
|
|
35
|
+
? ("transparent".equalsIgnoreCase(dividerColor) ? Color.TRANSPARENT : WebColor.parseColor(dividerColor))
|
|
36
|
+
: null;
|
|
37
|
+
|
|
32
38
|
if ("transparent".equalsIgnoreCase(color)) {
|
|
33
39
|
int flags = getActivity().getWindow().getDecorView().getSystemUiVisibility();
|
|
34
40
|
flags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
|
|
35
41
|
getActivity().getWindow().getDecorView().setSystemUiVisibility(flags);
|
|
36
42
|
getActivity().getWindow().setNavigationBarColor(Color.TRANSPARENT);
|
|
43
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && parsedDividerColor != null) {
|
|
44
|
+
getActivity().getWindow().setNavigationBarDividerColor(parsedDividerColor);
|
|
45
|
+
}
|
|
37
46
|
} else {
|
|
38
47
|
final int parsedColor = WebColor.parseColor(color);
|
|
39
48
|
View decor = getActivity().getWindow().getDecorView();
|
|
@@ -41,6 +50,9 @@ public class CapgoNavigationBarPlugin extends Plugin {
|
|
|
41
50
|
flags &= ~View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION & ~View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
|
|
42
51
|
decor.setSystemUiVisibility(flags);
|
|
43
52
|
getActivity().getWindow().setNavigationBarColor(parsedColor);
|
|
53
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && parsedDividerColor != null) {
|
|
54
|
+
getActivity().getWindow().setNavigationBarDividerColor(parsedDividerColor);
|
|
55
|
+
}
|
|
44
56
|
}
|
|
45
57
|
|
|
46
58
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
@@ -66,7 +78,7 @@ public class CapgoNavigationBarPlugin extends Plugin {
|
|
|
66
78
|
}
|
|
67
79
|
call.resolve();
|
|
68
80
|
} catch (IllegalArgumentException ex) {
|
|
69
|
-
call.reject("Invalid color provided.
|
|
81
|
+
call.reject("Invalid color provided. color and dividerColor must be hex colors (#RRGGBB) or color can be 'transparent'");
|
|
70
82
|
}
|
|
71
83
|
});
|
|
72
84
|
}
|
package/dist/docs.json
CHANGED
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
"methods": [
|
|
13
13
|
{
|
|
14
14
|
"name": "setNavigationBarColor",
|
|
15
|
-
"signature": "(options: { color: NavigationBarColor | string; darkButtons?: boolean; }) => Promise<void>",
|
|
15
|
+
"signature": "(options: { color: NavigationBarColor | string; darkButtons?: boolean; dividerColor?: NavigationBarColor | string; }) => Promise<void>",
|
|
16
16
|
"parameters": [
|
|
17
17
|
{
|
|
18
18
|
"name": "options",
|
|
19
19
|
"docs": "- Configuration for navigation bar appearance",
|
|
20
|
-
"type": "{ color: string; darkButtons?: boolean | undefined; }"
|
|
20
|
+
"type": "{ color: string; darkButtons?: boolean | undefined; dividerColor?: string | undefined; }"
|
|
21
21
|
}
|
|
22
22
|
],
|
|
23
23
|
"returns": "Promise<void>",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
"name": "example",
|
|
43
|
-
"text": "```typescript\n// Set to white with dark buttons\nawait NavigationBar.setNavigationBarColor({\n color: NavigationBarColor.WHITE,\n darkButtons: true\n});\n\n// Set to custom color\nawait NavigationBar.setNavigationBarColor({\n color: '#FF5733',\n darkButtons: false\n});\n```"
|
|
43
|
+
"text": "```typescript\n// Set to white with dark buttons\nawait NavigationBar.setNavigationBarColor({\n color: NavigationBarColor.WHITE,\n darkButtons: true\n});\n\n// Set to custom color\nawait NavigationBar.setNavigationBarColor({\n color: '#FF5733',\n darkButtons: false\n});\n\n// Set a custom divider color on Android 9+\nawait NavigationBar.setNavigationBarColor({\n color: NavigationBarColor.WHITE,\n darkButtons: true,\n dividerColor: '#D9D9D9'\n});\n```"
|
|
44
44
|
}
|
|
45
45
|
],
|
|
46
46
|
"docs": "Set the navigation bar color and button theme.",
|
|
@@ -37,6 +37,13 @@ export interface NavigationBarPlugin {
|
|
|
37
37
|
* color: '#FF5733',
|
|
38
38
|
* darkButtons: false
|
|
39
39
|
* });
|
|
40
|
+
*
|
|
41
|
+
* // Set a custom divider color on Android 9+
|
|
42
|
+
* await NavigationBar.setNavigationBarColor({
|
|
43
|
+
* color: NavigationBarColor.WHITE,
|
|
44
|
+
* darkButtons: true,
|
|
45
|
+
* dividerColor: '#D9D9D9'
|
|
46
|
+
* });
|
|
40
47
|
* ```
|
|
41
48
|
*/
|
|
42
49
|
setNavigationBarColor(options: {
|
|
@@ -44,6 +51,8 @@ export interface NavigationBarPlugin {
|
|
|
44
51
|
color: NavigationBarColor | string;
|
|
45
52
|
/** Whether to use dark buttons. Defaults to true if not specified */
|
|
46
53
|
darkButtons?: boolean;
|
|
54
|
+
/** Divider color for Android 9+ (API 28+). Accepts predefined colors or any valid hex color code */
|
|
55
|
+
dividerColor?: NavigationBarColor | string;
|
|
47
56
|
}): Promise<void>;
|
|
48
57
|
/**
|
|
49
58
|
* Get the current navigation bar color and button theme.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAN,IAAY,kBAOX;AAPD,WAAY,kBAAkB;IAC5B,kBAAkB;IAClB,uCAAiB,CAAA;IACjB,kBAAkB;IAClB,uCAAiB,CAAA;IACjB,wBAAwB;IACxB,iDAA2B,CAAA;AAC7B,CAAC,EAPW,kBAAkB,KAAlB,kBAAkB,QAO7B","sourcesContent":["/**\n * Predefined navigation bar colors.\n *\n * @since 1.0.0\n */\nexport enum NavigationBarColor {\n /** White color */\n WHITE = '#FFFFFF',\n /** Black color */\n BLACK = '#000000',\n /** Transparent color */\n TRANSPARENT = 'transparent',\n}\n\n/**\n * Capacitor Navigation Bar Plugin for customizing the Android navigation bar.\n *\n * @since 1.0.0\n */\nexport interface NavigationBarPlugin {\n /**\n * Set the navigation bar color and button theme.\n *\n * @param options - Configuration for navigation bar appearance\n * @returns Promise that resolves when the color is set\n * @throws Error if setting the color fails\n * @since 1.0.0\n * @example\n * ```typescript\n * // Set to white with dark buttons\n * await NavigationBar.setNavigationBarColor({\n * color: NavigationBarColor.WHITE,\n * darkButtons: true\n * });\n *\n * // Set to custom color\n * await NavigationBar.setNavigationBarColor({\n * color: '#FF5733',\n * darkButtons: false\n * });\n * ```\n */\n setNavigationBarColor(options: {\n /** Predefined colors or any valid hex color code */\n color: NavigationBarColor | string;\n /** Whether to use dark buttons. Defaults to true if not specified */\n darkButtons?: boolean;\n }): Promise<void>;\n\n /**\n * Get the current navigation bar color and button theme.\n *\n * @returns Promise that resolves with the current navigation bar configuration\n * @throws Error if getting the color fails\n * @since 1.0.0\n * @example\n * ```typescript\n * const { color, darkButtons } = await NavigationBar.getNavigationBarColor();\n * console.log('Current color:', color);\n * console.log('Using dark buttons:', darkButtons);\n * ```\n */\n getNavigationBarColor(): Promise<{\n /** Current navigation bar color */\n color: string;\n /** Whether dark buttons are enabled */\n darkButtons: boolean;\n }>;\n\n /**\n * Get the native Capacitor plugin version.\n *\n * @returns Promise that resolves with the plugin version\n * @throws Error if getting the version fails\n * @since 1.0.0\n * @example\n * ```typescript\n * const { version } = await NavigationBar.getPluginVersion();\n * console.log('Plugin version:', version);\n * ```\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAN,IAAY,kBAOX;AAPD,WAAY,kBAAkB;IAC5B,kBAAkB;IAClB,uCAAiB,CAAA;IACjB,kBAAkB;IAClB,uCAAiB,CAAA;IACjB,wBAAwB;IACxB,iDAA2B,CAAA;AAC7B,CAAC,EAPW,kBAAkB,KAAlB,kBAAkB,QAO7B","sourcesContent":["/**\n * Predefined navigation bar colors.\n *\n * @since 1.0.0\n */\nexport enum NavigationBarColor {\n /** White color */\n WHITE = '#FFFFFF',\n /** Black color */\n BLACK = '#000000',\n /** Transparent color */\n TRANSPARENT = 'transparent',\n}\n\n/**\n * Capacitor Navigation Bar Plugin for customizing the Android navigation bar.\n *\n * @since 1.0.0\n */\nexport interface NavigationBarPlugin {\n /**\n * Set the navigation bar color and button theme.\n *\n * @param options - Configuration for navigation bar appearance\n * @returns Promise that resolves when the color is set\n * @throws Error if setting the color fails\n * @since 1.0.0\n * @example\n * ```typescript\n * // Set to white with dark buttons\n * await NavigationBar.setNavigationBarColor({\n * color: NavigationBarColor.WHITE,\n * darkButtons: true\n * });\n *\n * // Set to custom color\n * await NavigationBar.setNavigationBarColor({\n * color: '#FF5733',\n * darkButtons: false\n * });\n *\n * // Set a custom divider color on Android 9+\n * await NavigationBar.setNavigationBarColor({\n * color: NavigationBarColor.WHITE,\n * darkButtons: true,\n * dividerColor: '#D9D9D9'\n * });\n * ```\n */\n setNavigationBarColor(options: {\n /** Predefined colors or any valid hex color code */\n color: NavigationBarColor | string;\n /** Whether to use dark buttons. Defaults to true if not specified */\n darkButtons?: boolean;\n /** Divider color for Android 9+ (API 28+). Accepts predefined colors or any valid hex color code */\n dividerColor?: NavigationBarColor | string;\n }): Promise<void>;\n\n /**\n * Get the current navigation bar color and button theme.\n *\n * @returns Promise that resolves with the current navigation bar configuration\n * @throws Error if getting the color fails\n * @since 1.0.0\n * @example\n * ```typescript\n * const { color, darkButtons } = await NavigationBar.getNavigationBarColor();\n * console.log('Current color:', color);\n * console.log('Using dark buttons:', darkButtons);\n * ```\n */\n getNavigationBarColor(): Promise<{\n /** Current navigation bar color */\n color: string;\n /** Whether dark buttons are enabled */\n darkButtons: boolean;\n }>;\n\n /**\n * Get the native Capacitor plugin version.\n *\n * @returns Promise that resolves with the plugin version\n * @throws Error if getting the version fails\n * @since 1.0.0\n * @example\n * ```typescript\n * const { version } = await NavigationBar.getPluginVersion();\n * console.log('Plugin version:', version);\n * ```\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n"]}
|
package/dist/esm/web.d.ts
CHANGED
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAC7C,KAAK,CAAC,qBAAqB,CAAC,
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAC7C,KAAK,CAAC,qBAAqB,CAAC,OAAwE;QAClG,OAAO,CAAC,GAAG,CAAC,qCAAqC,EAAE,OAAO,CAAC,CAAC;QAC5D,OAAO;IACT,CAAC;IACD,KAAK,CAAC,qBAAqB;QAIzB,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;QACnD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { NavigationBarPlugin } from './definitions';\n\nexport class NavigationBarWeb extends WebPlugin implements NavigationBarPlugin {\n async setNavigationBarColor(options: { color: string; darkButtons?: boolean; dividerColor?: string }): Promise<void> {\n console.log('Cannot setNavigationBarColor on web', options);\n return;\n }\n async getNavigationBarColor(): Promise<{\n color: string;\n darkButtons: boolean;\n }> {\n console.log('Cannot getNavigationBarColor on web');\n return { color: '#000000', darkButtons: true };\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n}\n"]}
|
|
@@ -7,7 +7,7 @@ import Capacitor
|
|
|
7
7
|
*/
|
|
8
8
|
@objc(CapgoNavigationBarPlugin)
|
|
9
9
|
public class CapgoNavigationBarPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
10
|
-
private let pluginVersion: String = "8.
|
|
10
|
+
private let pluginVersion: String = "8.1.3"
|
|
11
11
|
public let identifier = "CapgoNavigationBarPlugin"
|
|
12
12
|
public let jsName = "NavigationBar"
|
|
13
13
|
public let pluginMethods: [CAPPluginMethod] = [
|
package/package.json
CHANGED