@capgo/capacitor-navigation-bar 7.1.33 → 7.2.1

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.
@@ -3,14 +3,14 @@ require 'json'
3
3
  package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
4
 
5
5
  Pod::Spec.new do |s|
6
- s.name = 'CapgoCapacitorNavigationBar'
6
+ s.name = 'CapgoNavigationBar'
7
7
  s.version = package['version']
8
8
  s.summary = package['description']
9
9
  s.license = package['license']
10
10
  s.homepage = package['repository']['url']
11
11
  s.author = package['author']
12
12
  s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
- s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
13
+ s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
14
14
  s.ios.deployment_target = '14.0'
15
15
  s.dependency 'Capacitor'
16
16
  s.swift_version = '5.1'
package/Package.swift ADDED
@@ -0,0 +1,35 @@
1
+ // swift-tools-version:5.9
2
+ import PackageDescription
3
+
4
+ let package = Package(
5
+ name: "CapgoNavigationBar",
6
+ platforms: [
7
+ .iOS(.v14)
8
+ ],
9
+ products: [
10
+ .library(
11
+ name: "CapgoNavigationBar",
12
+ targets: ["CapgoNavigationBar"]
13
+ )
14
+ ],
15
+ dependencies: [
16
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.4.3")
17
+ ],
18
+ targets: [
19
+ .target(
20
+ name: "CapgoNavigationBar",
21
+ dependencies: [
22
+ .product(name: "Capacitor", package: "capacitor-swift-pm"),
23
+ .product(name: "Cordova", package: "capacitor-swift-pm")
24
+ ],
25
+ path: "ios/Sources/CapgoNavigationBarPlugin"
26
+ ),
27
+ .testTarget(
28
+ name: "CapgoNavigationBarTests",
29
+ dependencies: ["CapgoNavigationBar"],
30
+ path: "ios/Tests/CapgoNavigationBarTests")
31
+ ],
32
+ swiftLanguageVersions: [
33
+ .v5
34
+ ]
35
+ )
package/README.md CHANGED
@@ -16,6 +16,11 @@ npm install @capgo/capacitor-navigation-bar
16
16
  npx cap sync
17
17
  ```
18
18
 
19
+ ## Example Apps
20
+
21
+ - `example-app`: Interactive showcase that exercises all plugin options (color presets, custom hex, dark buttons, state reading).
22
+
23
+
19
24
  ## API
20
25
 
21
26
  <docgen-index>
@@ -60,8 +65,8 @@ getNavigationBarColor() => Promise<{ color: string; darkButtons: boolean; }>
60
65
 
61
66
  | Members | Value |
62
67
  | ----------------- | -------------------------- |
63
- | **`WHITE`** | <code>"#FFFFFF"</code> |
64
- | **`BLACK`** | <code>"#000000"</code> |
65
- | **`TRANSPARENT`** | <code>"transparent"</code> |
68
+ | **`WHITE`** | <code>'#FFFFFF'</code> |
69
+ | **`BLACK`** | <code>'#000000'</code> |
70
+ | **`TRANSPARENT`** | <code>'transparent'</code> |
66
71
 
67
72
  </docgen-api>
@@ -0,0 +1,115 @@
1
+ package ee.forgr.capacitor_navigation_bar;
2
+
3
+ import android.graphics.Color;
4
+ import android.os.Build;
5
+ import android.view.View;
6
+ import android.view.WindowInsetsController;
7
+ import com.getcapacitor.JSObject;
8
+ import com.getcapacitor.Plugin;
9
+ import com.getcapacitor.PluginCall;
10
+ import com.getcapacitor.PluginMethod;
11
+ import com.getcapacitor.annotation.CapacitorPlugin;
12
+ import com.getcapacitor.util.WebColor;
13
+ import java.util.Locale;
14
+
15
+ @CapacitorPlugin(name = "NavigationBar")
16
+ public class CapgoNavigationBarPlugin extends Plugin {
17
+
18
+ @PluginMethod
19
+ public void setNavigationBarColor(PluginCall call) {
20
+ final String color = call.getString("color");
21
+ final boolean darkButtons = Boolean.TRUE.equals(call.getBoolean("darkButtons", true));
22
+
23
+ if (color == null) {
24
+ call.reject("Color must be provided");
25
+ return;
26
+ }
27
+
28
+ getBridge().executeOnMainThread(() -> {
29
+ try {
30
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
31
+ if ("transparent".equalsIgnoreCase(color)) {
32
+ int flags = getActivity().getWindow().getDecorView().getSystemUiVisibility();
33
+ flags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
34
+ getActivity().getWindow().getDecorView().setSystemUiVisibility(flags);
35
+ getActivity().getWindow().setNavigationBarColor(Color.TRANSPARENT);
36
+ } else {
37
+ final int parsedColor = WebColor.parseColor(color);
38
+ View decor = getActivity().getWindow().getDecorView();
39
+ int flags = decor.getSystemUiVisibility();
40
+ flags &= ~View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION & ~View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
41
+ decor.setSystemUiVisibility(flags);
42
+ getActivity().getWindow().setNavigationBarColor(parsedColor);
43
+ }
44
+
45
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
46
+ WindowInsetsController insetsController = getActivity().getWindow().getInsetsController();
47
+ if (insetsController != null) {
48
+ if (darkButtons) {
49
+ insetsController.setSystemBarsAppearance(
50
+ WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS,
51
+ WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS
52
+ );
53
+ } else {
54
+ insetsController.setSystemBarsAppearance(0, WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS);
55
+ }
56
+ }
57
+ } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
58
+ int flags = getActivity().getWindow().getDecorView().getSystemUiVisibility();
59
+ if (darkButtons) {
60
+ flags |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
61
+ } else {
62
+ flags &= ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
63
+ }
64
+ getActivity().getWindow().getDecorView().setSystemUiVisibility(flags);
65
+ }
66
+ } else {
67
+ call.reject("Navigation bar color customization is not supported on this Android version.");
68
+ return;
69
+ }
70
+ call.resolve();
71
+ } catch (IllegalArgumentException ex) {
72
+ call.reject("Invalid color provided. Must be a hex color (#RRGGBB) or 'transparent'");
73
+ }
74
+ });
75
+ }
76
+
77
+ @PluginMethod
78
+ public void getNavigationBarColor(PluginCall call) {
79
+ getBridge().executeOnMainThread(() -> {
80
+ try {
81
+ JSObject ret = new JSObject();
82
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
83
+ int intColor = getActivity().getWindow().getNavigationBarColor();
84
+ String hexColor = String.format("#%06X", (0xFFFFFF & intColor));
85
+ ret.put("color", hexColor);
86
+
87
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
88
+ WindowInsetsController insetsController = getActivity().getWindow().getInsetsController();
89
+ if (insetsController != null) {
90
+ int appearance = insetsController.getSystemBarsAppearance();
91
+ boolean isLight = (appearance & WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS) != 0;
92
+ ret.put("darkButtons", !isLight);
93
+ } else {
94
+ ret.put("darkButtons", true);
95
+ }
96
+ } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
97
+ int flags = getActivity().getWindow().getDecorView().getSystemUiVisibility();
98
+ boolean isLight = (flags & View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR) != 0;
99
+ ret.put("darkButtons", !isLight);
100
+ } else {
101
+ ret.put("darkButtons", true);
102
+ }
103
+
104
+ call.resolve(ret);
105
+ } else {
106
+ ret.put("color", "#000000");
107
+ ret.put("darkButtons", true);
108
+ call.resolve(ret);
109
+ }
110
+ } catch (Exception ex) {
111
+ call.reject("Failed to get navigation bar color or button style", ex);
112
+ }
113
+ });
114
+ }
115
+ }
package/dist/docs.json CHANGED
@@ -44,19 +44,19 @@
44
44
  "members": [
45
45
  {
46
46
  "name": "WHITE",
47
- "value": "\"#FFFFFF\"",
47
+ "value": "'#FFFFFF'",
48
48
  "tags": [],
49
49
  "docs": ""
50
50
  },
51
51
  {
52
52
  "name": "BLACK",
53
- "value": "\"#000000\"",
53
+ "value": "'#000000'",
54
54
  "tags": [],
55
55
  "docs": ""
56
56
  },
57
57
  {
58
58
  "name": "TRANSPARENT",
59
- "value": "\"transparent\"",
59
+ "value": "'transparent'",
60
60
  "tags": [],
61
61
  "docs": ""
62
62
  }
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,uCAAiB,CAAA;IACjB,uCAAiB,CAAA;IACjB,iDAA2B,CAAA;AAC7B,CAAC,EAJW,kBAAkB,KAAlB,kBAAkB,QAI7B","sourcesContent":["export enum NavigationBarColor {\n WHITE = \"#FFFFFF\",\n BLACK = \"#000000\",\n TRANSPARENT = \"transparent\",\n}\n\nexport interface NavigationBarPlugin {\n setNavigationBarColor(options: {\n color: NavigationBarColor | string; // Predefined colors or any valid hex\n darkButtons?: boolean; // Set to true when not specified\n }): Promise<void>;\n getNavigationBarColor(): Promise<{\n color: string;\n darkButtons: boolean;\n }>;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,uCAAiB,CAAA;IACjB,uCAAiB,CAAA;IACjB,iDAA2B,CAAA;AAC7B,CAAC,EAJW,kBAAkB,KAAlB,kBAAkB,QAI7B","sourcesContent":["export enum NavigationBarColor {\n WHITE = '#FFFFFF',\n BLACK = '#000000',\n TRANSPARENT = 'transparent',\n}\n\nexport interface NavigationBarPlugin {\n setNavigationBarColor(options: {\n color: NavigationBarColor | string; // Predefined colors or any valid hex\n darkButtons?: boolean; // Set to true when not specified\n }): Promise<void>;\n getNavigationBarColor(): Promise<{\n color: string;\n darkButtons: boolean;\n }>;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { NavigationBarPlugin } from "./definitions";
1
+ import type { NavigationBarPlugin } from './definitions';
2
2
  declare const NavigationBar: NavigationBarPlugin;
3
- export * from "./definitions";
3
+ export * from './definitions';
4
4
  export { NavigationBar };
package/dist/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { registerPlugin } from "@capacitor/core";
2
- const NavigationBar = registerPlugin("NavigationBar", {
3
- web: () => import("./web").then((m) => new m.NavigationBarWeb()),
1
+ import { registerPlugin } from '@capacitor/core';
2
+ const NavigationBar = registerPlugin('NavigationBar', {
3
+ web: () => import('./web').then((m) => new m.NavigationBarWeb()),
4
4
  });
5
- export * from "./definitions";
5
+ export * from './definitions';
6
6
  export { NavigationBar };
7
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,aAAa,GAAG,cAAc,CAAsB,eAAe,EAAE;IACzE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;CACjE,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import { registerPlugin } from \"@capacitor/core\";\n\nimport type { NavigationBarPlugin } from \"./definitions\";\n\nconst NavigationBar = registerPlugin<NavigationBarPlugin>(\"NavigationBar\", {\n web: () => import(\"./web\").then((m) => new m.NavigationBarWeb()),\n});\n\nexport * from \"./definitions\";\nexport { NavigationBar };\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,aAAa,GAAG,cAAc,CAAsB,eAAe,EAAE;IACzE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;CACjE,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { NavigationBarPlugin } from './definitions';\n\nconst NavigationBar = registerPlugin<NavigationBarPlugin>('NavigationBar', {\n web: () => import('./web').then((m) => new m.NavigationBarWeb()),\n});\n\nexport * from './definitions';\nexport { NavigationBar };\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { WebPlugin } from "@capacitor/core";
2
- import type { NavigationBarPlugin } from "./definitions";
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { NavigationBarPlugin } from './definitions';
3
3
  export declare class NavigationBarWeb extends WebPlugin implements NavigationBarPlugin {
4
4
  setNavigationBarColor(options: {
5
5
  color: string;
package/dist/esm/web.js CHANGED
@@ -1,12 +1,12 @@
1
- import { WebPlugin } from "@capacitor/core";
1
+ import { WebPlugin } from '@capacitor/core';
2
2
  export class NavigationBarWeb extends WebPlugin {
3
3
  async setNavigationBarColor(options) {
4
- console.log("Cannot setNavigationBarColor on web", options);
4
+ console.log('Cannot setNavigationBarColor on web', options);
5
5
  return;
6
6
  }
7
7
  async getNavigationBarColor() {
8
- console.log("Cannot getNavigationBarColor on web");
9
- return { color: "#000000", darkButtons: true };
8
+ console.log('Cannot getNavigationBarColor on web');
9
+ return { color: '#000000', darkButtons: true };
10
10
  }
11
11
  }
12
12
  //# sourceMappingURL=web.js.map
@@ -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,OAG3B;QACC,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;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: {\n color: string;\n darkButtons?: boolean;\n }): 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"]}
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,OAAiD;QAC3E,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;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 }): 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"]}
@@ -9,18 +9,18 @@ exports.NavigationBarColor = void 0;
9
9
  NavigationBarColor["TRANSPARENT"] = "transparent";
10
10
  })(exports.NavigationBarColor || (exports.NavigationBarColor = {}));
11
11
 
12
- const NavigationBar = core.registerPlugin("NavigationBar", {
12
+ const NavigationBar = core.registerPlugin('NavigationBar', {
13
13
  web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.NavigationBarWeb()),
14
14
  });
15
15
 
16
16
  class NavigationBarWeb extends core.WebPlugin {
17
17
  async setNavigationBarColor(options) {
18
- console.log("Cannot setNavigationBarColor on web", options);
18
+ console.log('Cannot setNavigationBarColor on web', options);
19
19
  return;
20
20
  }
21
21
  async getNavigationBarColor() {
22
- console.log("Cannot getNavigationBarColor on web");
23
- return { color: "#000000", darkButtons: true };
22
+ console.log('Cannot getNavigationBarColor on web');
23
+ return { color: '#000000', darkButtons: true };
24
24
  }
25
25
  }
26
26
 
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var NavigationBarColor;\n(function (NavigationBarColor) {\n NavigationBarColor[\"WHITE\"] = \"#FFFFFF\";\n NavigationBarColor[\"BLACK\"] = \"#000000\";\n NavigationBarColor[\"TRANSPARENT\"] = \"transparent\";\n})(NavigationBarColor || (NavigationBarColor = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from \"@capacitor/core\";\nconst NavigationBar = registerPlugin(\"NavigationBar\", {\n web: () => import(\"./web\").then((m) => new m.NavigationBarWeb()),\n});\nexport * from \"./definitions\";\nexport { NavigationBar };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport class NavigationBarWeb extends WebPlugin {\n async setNavigationBarColor(options) {\n console.log(\"Cannot setNavigationBarColor on web\", options);\n return;\n }\n async getNavigationBarColor() {\n console.log(\"Cannot getNavigationBarColor on web\");\n return { color: \"#000000\", darkButtons: true };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["NavigationBarColor","registerPlugin","WebPlugin"],"mappings":";;;;AAAWA;AACX,CAAC,UAAU,kBAAkB,EAAE;AAC/B,IAAI,kBAAkB,CAAC,OAAO,CAAC,GAAG,SAAS;AAC3C,IAAI,kBAAkB,CAAC,OAAO,CAAC,GAAG,SAAS;AAC3C,IAAI,kBAAkB,CAAC,aAAa,CAAC,GAAG,aAAa;AACrD,CAAC,EAAEA,0BAAkB,KAAKA,0BAAkB,GAAG,EAAE,CAAC,CAAC;;ACJ9C,MAAC,aAAa,GAAGC,mBAAc,CAAC,eAAe,EAAE;AACtD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;AACpE,CAAC;;ACFM,MAAM,gBAAgB,SAASC,cAAS,CAAC;AAChD,IAAI,MAAM,qBAAqB,CAAC,OAAO,EAAE;AACzC,QAAQ,OAAO,CAAC,GAAG,CAAC,qCAAqC,EAAE,OAAO,CAAC;AACnE,QAAQ;AACR;AACA,IAAI,MAAM,qBAAqB,GAAG;AAClC,QAAQ,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC;AAC1D,QAAQ,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE;AACtD;AACA;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var NavigationBarColor;\n(function (NavigationBarColor) {\n NavigationBarColor[\"WHITE\"] = \"#FFFFFF\";\n NavigationBarColor[\"BLACK\"] = \"#000000\";\n NavigationBarColor[\"TRANSPARENT\"] = \"transparent\";\n})(NavigationBarColor || (NavigationBarColor = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst NavigationBar = registerPlugin('NavigationBar', {\n web: () => import('./web').then((m) => new m.NavigationBarWeb()),\n});\nexport * from './definitions';\nexport { NavigationBar };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class NavigationBarWeb extends WebPlugin {\n async setNavigationBarColor(options) {\n console.log('Cannot setNavigationBarColor on web', options);\n return;\n }\n async getNavigationBarColor() {\n console.log('Cannot getNavigationBarColor on web');\n return { color: '#000000', darkButtons: true };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["NavigationBarColor","registerPlugin","WebPlugin"],"mappings":";;;;AAAWA;AACX,CAAC,UAAU,kBAAkB,EAAE;AAC/B,IAAI,kBAAkB,CAAC,OAAO,CAAC,GAAG,SAAS;AAC3C,IAAI,kBAAkB,CAAC,OAAO,CAAC,GAAG,SAAS;AAC3C,IAAI,kBAAkB,CAAC,aAAa,CAAC,GAAG,aAAa;AACrD,CAAC,EAAEA,0BAAkB,KAAKA,0BAAkB,GAAG,EAAE,CAAC,CAAC;;ACJ9C,MAAC,aAAa,GAAGC,mBAAc,CAAC,eAAe,EAAE;AACtD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;AACpE,CAAC;;ACFM,MAAM,gBAAgB,SAASC,cAAS,CAAC;AAChD,IAAI,MAAM,qBAAqB,CAAC,OAAO,EAAE;AACzC,QAAQ,OAAO,CAAC,GAAG,CAAC,qCAAqC,EAAE,OAAO,CAAC;AACnE,QAAQ;AACR,IAAI;AACJ,IAAI,MAAM,qBAAqB,GAAG;AAClC,QAAQ,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC;AAC1D,QAAQ,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE;AACtD,IAAI;AACJ;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -8,18 +8,18 @@ var NavigationBarPlugin = (function (exports, core) {
8
8
  NavigationBarColor["TRANSPARENT"] = "transparent";
9
9
  })(exports.NavigationBarColor || (exports.NavigationBarColor = {}));
10
10
 
11
- const NavigationBar = core.registerPlugin("NavigationBar", {
11
+ const NavigationBar = core.registerPlugin('NavigationBar', {
12
12
  web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.NavigationBarWeb()),
13
13
  });
14
14
 
15
15
  class NavigationBarWeb extends core.WebPlugin {
16
16
  async setNavigationBarColor(options) {
17
- console.log("Cannot setNavigationBarColor on web", options);
17
+ console.log('Cannot setNavigationBarColor on web', options);
18
18
  return;
19
19
  }
20
20
  async getNavigationBarColor() {
21
- console.log("Cannot getNavigationBarColor on web");
22
- return { color: "#000000", darkButtons: true };
21
+ console.log('Cannot getNavigationBarColor on web');
22
+ return { color: '#000000', darkButtons: true };
23
23
  }
24
24
  }
25
25
 
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var NavigationBarColor;\n(function (NavigationBarColor) {\n NavigationBarColor[\"WHITE\"] = \"#FFFFFF\";\n NavigationBarColor[\"BLACK\"] = \"#000000\";\n NavigationBarColor[\"TRANSPARENT\"] = \"transparent\";\n})(NavigationBarColor || (NavigationBarColor = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from \"@capacitor/core\";\nconst NavigationBar = registerPlugin(\"NavigationBar\", {\n web: () => import(\"./web\").then((m) => new m.NavigationBarWeb()),\n});\nexport * from \"./definitions\";\nexport { NavigationBar };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport class NavigationBarWeb extends WebPlugin {\n async setNavigationBarColor(options) {\n console.log(\"Cannot setNavigationBarColor on web\", options);\n return;\n }\n async getNavigationBarColor() {\n console.log(\"Cannot getNavigationBarColor on web\");\n return { color: \"#000000\", darkButtons: true };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["NavigationBarColor","registerPlugin","WebPlugin"],"mappings":";;;AAAWA;IACX,CAAC,UAAU,kBAAkB,EAAE;IAC/B,IAAI,kBAAkB,CAAC,OAAO,CAAC,GAAG,SAAS;IAC3C,IAAI,kBAAkB,CAAC,OAAO,CAAC,GAAG,SAAS;IAC3C,IAAI,kBAAkB,CAAC,aAAa,CAAC,GAAG,aAAa;IACrD,CAAC,EAAEA,0BAAkB,KAAKA,0BAAkB,GAAG,EAAE,CAAC,CAAC;;ACJ9C,UAAC,aAAa,GAAGC,mBAAc,CAAC,eAAe,EAAE;IACtD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACpE,CAAC;;ICFM,MAAM,gBAAgB,SAASC,cAAS,CAAC;IAChD,IAAI,MAAM,qBAAqB,CAAC,OAAO,EAAE;IACzC,QAAQ,OAAO,CAAC,GAAG,CAAC,qCAAqC,EAAE,OAAO,CAAC;IACnE,QAAQ;IACR;IACA,IAAI,MAAM,qBAAqB,GAAG;IAClC,QAAQ,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC;IAC1D,QAAQ,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE;IACtD;IACA;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var NavigationBarColor;\n(function (NavigationBarColor) {\n NavigationBarColor[\"WHITE\"] = \"#FFFFFF\";\n NavigationBarColor[\"BLACK\"] = \"#000000\";\n NavigationBarColor[\"TRANSPARENT\"] = \"transparent\";\n})(NavigationBarColor || (NavigationBarColor = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst NavigationBar = registerPlugin('NavigationBar', {\n web: () => import('./web').then((m) => new m.NavigationBarWeb()),\n});\nexport * from './definitions';\nexport { NavigationBar };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class NavigationBarWeb extends WebPlugin {\n async setNavigationBarColor(options) {\n console.log('Cannot setNavigationBarColor on web', options);\n return;\n }\n async getNavigationBarColor() {\n console.log('Cannot getNavigationBarColor on web');\n return { color: '#000000', darkButtons: true };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["NavigationBarColor","registerPlugin","WebPlugin"],"mappings":";;;AAAWA;IACX,CAAC,UAAU,kBAAkB,EAAE;IAC/B,IAAI,kBAAkB,CAAC,OAAO,CAAC,GAAG,SAAS;IAC3C,IAAI,kBAAkB,CAAC,OAAO,CAAC,GAAG,SAAS;IAC3C,IAAI,kBAAkB,CAAC,aAAa,CAAC,GAAG,aAAa;IACrD,CAAC,EAAEA,0BAAkB,KAAKA,0BAAkB,GAAG,EAAE,CAAC,CAAC;;ACJ9C,UAAC,aAAa,GAAGC,mBAAc,CAAC,eAAe,EAAE;IACtD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACpE,CAAC;;ICFM,MAAM,gBAAgB,SAASC,cAAS,CAAC;IAChD,IAAI,MAAM,qBAAqB,CAAC,OAAO,EAAE;IACzC,QAAQ,OAAO,CAAC,GAAG,CAAC,qCAAqC,EAAE,OAAO,CAAC;IACnE,QAAQ;IACR,IAAI;IACJ,IAAI,MAAM,qBAAqB,GAAG;IAClC,QAAQ,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC;IAC1D,QAAQ,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE;IACtD,IAAI;IACJ;;;;;;;;;;;;;;;"}
package/ios/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /Packages
2
+ xcuserdata/
3
+ DerivedData/
4
+ .swiftpm/configuration/registries.json
5
+ .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
6
+ .netrc
7
+ .DS_Store
8
+ .build
@@ -5,9 +5,9 @@ import Capacitor
5
5
  * Please read the Capacitor iOS Plugin Development Guide
6
6
  * here: https://capacitorjs.com/docs/plugins/ios
7
7
  */
8
- @objc(NavigationBarPlugin)
9
- public class NavigationBarPlugin: CAPPlugin, CAPBridgedPlugin {
10
- public let identifier = "NavigationBarPlugin"
8
+ @objc(CapgoNavigationBarPlugin)
9
+ public class CapgoNavigationBarPlugin: CAPPlugin, CAPBridgedPlugin {
10
+ public let identifier = "CapgoNavigationBarPlugin"
11
11
  public let jsName = "NavigationBar"
12
12
  public let pluginMethods: [CAPPluginMethod] = [
13
13
  CAPPluginMethod(name: "setNavigationBarColor", returnType: CAPPluginReturnPromise),
@@ -0,0 +1,39 @@
1
+ import XCTest
2
+ import Capacitor
3
+ @testable import CapgoNavigationBar
4
+
5
+ final class CapgoNavigationBarTests: XCTestCase {
6
+ private func makeCall(method: String, options: [String: Any] = [:], errorHandler: @escaping (CAPPluginCallError) -> Void) -> CAPPluginCall {
7
+ CAPPluginCall(
8
+ callbackId: "test",
9
+ methodName: method,
10
+ options: options as NSDictionary,
11
+ success: { _, _ in },
12
+ error: errorHandler
13
+ )
14
+ }
15
+
16
+ func testSetNavigationBarColorRejectsOnIOS() {
17
+ let plugin = NavigationBarPlugin()
18
+ var capturedError: CAPPluginCallError?
19
+ let call = makeCall(method: "setNavigationBarColor", options: ["color": "#FFFFFF"]) { error in
20
+ capturedError = error
21
+ }
22
+
23
+ plugin.setNavigationBarColor(call)
24
+
25
+ XCTAssertEqual(capturedError?.message, "Cannot set navigation bar color in ios")
26
+ }
27
+
28
+ func testGetNavigationBarColorRejectsOnIOS() {
29
+ let plugin = NavigationBarPlugin()
30
+ var capturedError: CAPPluginCallError?
31
+ let call = makeCall(method: "getNavigationBarColor") { error in
32
+ capturedError = error
33
+ }
34
+
35
+ plugin.getNavigationBarColor(call)
36
+
37
+ XCTAssertEqual(capturedError?.message, "Cannot get navigation bar color in ios")
38
+ }
39
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-navigation-bar",
3
- "version": "7.1.33",
4
- "description": "Set navigation bar color for android lolipop and higher",
3
+ "version": "7.2.1",
4
+ "description": "Capacitor plugin Set navigation bar color for android lolipop and higher",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
7
7
  "types": "dist/esm/index.d.ts",
@@ -10,8 +10,11 @@
10
10
  "android/src/main/",
11
11
  "android/build.gradle",
12
12
  "dist/",
13
- "ios/Plugin/",
14
- "CapgoCapacitorNavigationBar.podspec"
13
+ "ios/Sources/",
14
+ "ios/Tests",
15
+ "CapgoNavigationBar.podspec",
16
+ "Package.swift",
17
+ "ios/.gitignore"
15
18
  ],
16
19
  "author": "Cap-go <contact@capgo.app>",
17
20
  "license": "MIT",
@@ -31,13 +34,13 @@
31
34
  ],
32
35
  "scripts": {
33
36
  "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
34
- "verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -sdk iphoneos -scheme Plugin && cd ..",
37
+ "verify:ios": "xcodebuild -scheme CapgoNavigationBar -destination generic/platform=iOS",
35
38
  "verify:android": "cd android && ./gradlew clean build test && cd ..",
36
39
  "verify:web": "npm run build",
37
40
  "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
38
41
  "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --autocorrect --format",
39
42
  "eslint": "eslint .",
40
- "prettier": "prettier --config .prettierrc.js \"**/*.{css,html,ts,js,java}\"",
43
+ "prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
41
44
  "swiftlint": "node-swiftlint",
42
45
  "docgen": "docgen --api NavigationBarPlugin --output-readme README.md --output-json dist/docs.json",
43
46
  "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
@@ -1,155 +0,0 @@
1
- package ee.forgr.capacitor_navigation_bar;
2
-
3
- import android.graphics.Color;
4
- import android.os.Build;
5
- import android.view.View;
6
- import android.view.WindowInsetsController;
7
- import com.getcapacitor.JSObject;
8
- import com.getcapacitor.Plugin;
9
- import com.getcapacitor.PluginCall;
10
- import com.getcapacitor.PluginMethod;
11
- import com.getcapacitor.annotation.CapacitorPlugin;
12
- import com.getcapacitor.util.WebColor;
13
- import java.util.Locale;
14
-
15
- @CapacitorPlugin(name = "NavigationBar")
16
- public class NavigationBarPlugin extends Plugin {
17
-
18
- @PluginMethod
19
- public void setNavigationBarColor(PluginCall call) {
20
- final String color = call.getString("color");
21
- final boolean darkButtons = Boolean.TRUE.equals(
22
- call.getBoolean("darkButtons", true)
23
- );
24
-
25
- if (color == null) {
26
- call.reject("Color must be provided");
27
- return;
28
- }
29
-
30
- getBridge()
31
- .executeOnMainThread(() -> {
32
- try {
33
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
34
- if ("transparent".equalsIgnoreCase(color)) {
35
- int flags = getActivity()
36
- .getWindow()
37
- .getDecorView()
38
- .getSystemUiVisibility();
39
- flags |=
40
- View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
41
- View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
42
- getActivity()
43
- .getWindow()
44
- .getDecorView()
45
- .setSystemUiVisibility(flags);
46
- getActivity()
47
- .getWindow()
48
- .setNavigationBarColor(Color.TRANSPARENT);
49
- } else {
50
- final int parsedColor = WebColor.parseColor(color);
51
- View decor = getActivity().getWindow().getDecorView();
52
- int flags = decor.getSystemUiVisibility();
53
- flags &=
54
- ~View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION &
55
- ~View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
56
- decor.setSystemUiVisibility(flags);
57
- getActivity().getWindow().setNavigationBarColor(parsedColor);
58
- }
59
-
60
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
61
- WindowInsetsController insetsController = getActivity()
62
- .getWindow()
63
- .getInsetsController();
64
- if (insetsController != null) {
65
- if (darkButtons) {
66
- insetsController.setSystemBarsAppearance(
67
- WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS,
68
- WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS
69
- );
70
- } else {
71
- insetsController.setSystemBarsAppearance(
72
- 0,
73
- WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS
74
- );
75
- }
76
- }
77
- } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
78
- int flags = getActivity()
79
- .getWindow()
80
- .getDecorView()
81
- .getSystemUiVisibility();
82
- if (darkButtons) {
83
- flags |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
84
- } else {
85
- flags &= ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
86
- }
87
- getActivity()
88
- .getWindow()
89
- .getDecorView()
90
- .setSystemUiVisibility(flags);
91
- }
92
- } else {
93
- call.reject(
94
- "Navigation bar color customization is not supported on this Android version."
95
- );
96
- return;
97
- }
98
- call.resolve();
99
- } catch (IllegalArgumentException ex) {
100
- call.reject(
101
- "Invalid color provided. Must be a hex color (#RRGGBB) or 'transparent'"
102
- );
103
- }
104
- });
105
- }
106
-
107
- @PluginMethod
108
- public void getNavigationBarColor(PluginCall call) {
109
- getBridge()
110
- .executeOnMainThread(() -> {
111
- try {
112
- JSObject ret = new JSObject();
113
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
114
- int intColor = getActivity().getWindow().getNavigationBarColor();
115
- String hexColor = String.format("#%06X", (0xFFFFFF & intColor));
116
- ret.put("color", hexColor);
117
-
118
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
119
- WindowInsetsController insetsController = getActivity()
120
- .getWindow()
121
- .getInsetsController();
122
- if (insetsController != null) {
123
- int appearance = insetsController.getSystemBarsAppearance();
124
- boolean isLight =
125
- (appearance &
126
- WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS) !=
127
- 0;
128
- ret.put("darkButtons", !isLight);
129
- } else {
130
- ret.put("darkButtons", true);
131
- }
132
- } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
133
- int flags = getActivity()
134
- .getWindow()
135
- .getDecorView()
136
- .getSystemUiVisibility();
137
- boolean isLight =
138
- (flags & View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR) != 0;
139
- ret.put("darkButtons", !isLight);
140
- } else {
141
- ret.put("darkButtons", true);
142
- }
143
-
144
- call.resolve(ret);
145
- } else {
146
- ret.put("color", "#000000");
147
- ret.put("darkButtons", true);
148
- call.resolve(ret);
149
- }
150
- } catch (Exception ex) {
151
- call.reject("Failed to get navigation bar color or button style", ex);
152
- }
153
- });
154
- }
155
- }
@@ -1,24 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>CFBundleDevelopmentRegion</key>
6
- <string>$(DEVELOPMENT_LANGUAGE)</string>
7
- <key>CFBundleExecutable</key>
8
- <string>$(EXECUTABLE_NAME)</string>
9
- <key>CFBundleIdentifier</key>
10
- <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11
- <key>CFBundleInfoDictionaryVersion</key>
12
- <string>6.0</string>
13
- <key>CFBundleName</key>
14
- <string>$(PRODUCT_NAME)</string>
15
- <key>CFBundlePackageType</key>
16
- <string>FMWK</string>
17
- <key>CFBundleShortVersionString</key>
18
- <string>1.0</string>
19
- <key>CFBundleVersion</key>
20
- <string>$(CURRENT_PROJECT_VERSION)</string>
21
- <key>NSPrincipalClass</key>
22
- <string></string>
23
- </dict>
24
- </plist>
@@ -1,10 +0,0 @@
1
- #import <UIKit/UIKit.h>
2
-
3
- //! Project version number for Plugin.
4
- FOUNDATION_EXPORT double PluginVersionNumber;
5
-
6
- //! Project version string for Plugin.
7
- FOUNDATION_EXPORT const unsigned char PluginVersionString[];
8
-
9
- // In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
10
-
@@ -1,9 +0,0 @@
1
- #import <Foundation/Foundation.h>
2
- #import <Capacitor/Capacitor.h>
3
-
4
- // Define the plugin using the CAP_PLUGIN Macro, and
5
- // each method the plugin supports using the CAP_PLUGIN_METHOD macro.
6
- CAP_PLUGIN(NavigationBarPlugin, "NavigationBar",
7
- CAP_PLUGIN_METHOD(setNavigationBarColor, CAPPluginReturnPromise);
8
- CAP_PLUGIN_METHOD(getNavigationBarColor, CAPPluginReturnPromise);
9
- )