@independo/capacitor-emoji-picker 1.0.2 → 1.1.0-dev.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.
- package/README.md +13 -5
- package/android/src/main/java/app/independo/capacitoremojipicker/EmojiPicker.java +3 -0
- package/android/src/main/java/app/independo/capacitoremojipicker/presenter/DefaultEmojiPickerDialogFactory.java +26 -6
- package/android/src/main/java/app/independo/capacitoremojipicker/presenter/DispatchingEmojiPickerPresenter.java +8 -2
- package/android/src/main/java/app/independo/capacitoremojipicker/presenter/EmojiPickerDialogFactory.java +1 -1
- package/android/src/main/java/app/independo/capacitoremojipicker/presenter/EmojiPickerPresenter.java +7 -1
- package/android/src/main/java/app/independo/capacitoremojipicker/presenter/NativeEmojiPickerPresenter.java +12 -5
- package/android/src/main/java/app/independo/capacitoremojipicker/presenter/WebFallbackEmojiPickerPresenter.java +20 -7
- package/android/src/main/java/app/independo/capacitoremojipicker/service/EmojiPickerService.java +8 -1
- package/dist/docs.json +33 -0
- package/dist/esm/definitions.d.ts +15 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/platform/web/WebEmojiPickerPresenter.js +45 -7
- package/dist/esm/platform/web/WebEmojiPickerPresenter.js.map +1 -1
- package/dist/plugin.cjs.js +45 -7
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +45 -7
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/EmojiPicker/Bridge/EmojiPicker.swift +4 -1
- package/ios/Sources/EmojiPicker/Presenter/DefaultEmojiKeyboardPresentationFactory.swift +42 -3
- package/ios/Sources/EmojiPicker/Presenter/EmojiKeyboardPresentationFactory.swift +1 -0
- package/ios/Sources/EmojiPicker/Presenter/EmojiPickerPresenter.swift +2 -0
- package/ios/Sources/EmojiPicker/Presenter/NativeEmojiPickerPresenter.swift +5 -1
- package/ios/Sources/EmojiPicker/Presenter/WebFallbackEmojiPickerPresenter.swift +10 -6
- package/package.json +2 -2
|
@@ -21,6 +21,7 @@ public class EmojiPicker: CAPPlugin, CAPBridgedPlugin {
|
|
|
21
21
|
|
|
22
22
|
private static let validCloseButtonSizes: Set<String> = ["xSmall", "small", "medium", "large"]
|
|
23
23
|
private static let validCloseButtonPositions: Set<String> = ["left", "center", "right"]
|
|
24
|
+
private static let validThemes: Set<String> = ["system", "light", "dark"]
|
|
24
25
|
|
|
25
26
|
/// Initializes dependencies after the plugin loads.
|
|
26
27
|
public override func load() {
|
|
@@ -58,6 +59,7 @@ public class EmojiPicker: CAPPlugin, CAPBridgedPlugin {
|
|
|
58
59
|
let closeButtonObject = call.getObject("closeButton")
|
|
59
60
|
let size = closeButtonObject?["size"] as? String ?? "medium"
|
|
60
61
|
let position = closeButtonObject?["position"] as? String ?? "right"
|
|
62
|
+
let theme = call.getString("theme") ?? "system"
|
|
61
63
|
let options = EmojiPickerPresentOptions(
|
|
62
64
|
presentation: call.getString("presentation") ?? "auto",
|
|
63
65
|
closeButton: EmojiCloseButtonOptions(
|
|
@@ -65,7 +67,8 @@ public class EmojiPicker: CAPPlugin, CAPBridgedPlugin {
|
|
|
65
67
|
position: Self.validCloseButtonPositions.contains(position) ? position : "right",
|
|
66
68
|
hidden: closeButtonObject?["hidden"] as? Bool ?? false
|
|
67
69
|
),
|
|
68
|
-
dismissOnBackdropTap: call.getBool("dismissOnBackdropTap") ?? true
|
|
70
|
+
dismissOnBackdropTap: call.getBool("dismissOnBackdropTap") ?? true,
|
|
71
|
+
theme: Self.validThemes.contains(theme) ? theme : "system"
|
|
69
72
|
)
|
|
70
73
|
service.present(options: options) { result in
|
|
71
74
|
switch result {
|
|
@@ -25,6 +25,7 @@ final class DefaultEmojiKeyboardPresentationFactory: EmojiKeyboardPresentationFa
|
|
|
25
25
|
hostViewController: UIViewController,
|
|
26
26
|
closeButtonOptions: EmojiCloseButtonOptions,
|
|
27
27
|
dismissOnBackdropTap: Bool,
|
|
28
|
+
theme: String,
|
|
28
29
|
listener: EmojiKeyboardPresentationListener
|
|
29
30
|
) -> EmojiKeyboardPresentationHandle {
|
|
30
31
|
guard hostViewController.presentedViewController == nil else {
|
|
@@ -37,10 +38,15 @@ final class DefaultEmojiKeyboardPresentationFactory: EmojiKeyboardPresentationFa
|
|
|
37
38
|
let container = EmojiKeyboardContainerViewController(
|
|
38
39
|
listener: listener,
|
|
39
40
|
closeButtonOptions: closeButtonOptions,
|
|
40
|
-
dismissOnBackdropTap: dismissOnBackdropTap
|
|
41
|
+
dismissOnBackdropTap: dismissOnBackdropTap,
|
|
42
|
+
theme: theme
|
|
41
43
|
)
|
|
42
44
|
container.modalPresentationStyle = .overFullScreen
|
|
43
45
|
container.modalTransitionStyle = .crossDissolve
|
|
46
|
+
// Themes the container's own view subtree (backdrop, close button tint) - separate from
|
|
47
|
+
// `emojiField.keyboardAppearance` below, which is what the system emoji keyboard itself
|
|
48
|
+
// (a separate window/process) actually honors.
|
|
49
|
+
container.overrideUserInterfaceStyle = Self.resolveInterfaceStyle(theme)
|
|
44
50
|
// Must happen AFTER modalPresentationStyle is set: reading `presentationController`
|
|
45
51
|
// lazily creates and caches one matching whatever style was active at that moment. Doing
|
|
46
52
|
// this in the view controller's own init (before this call sets .overFullScreen) caches a
|
|
@@ -57,6 +63,16 @@ final class DefaultEmojiKeyboardPresentationFactory: EmojiKeyboardPresentationFa
|
|
|
57
63
|
func dismiss() {}
|
|
58
64
|
}
|
|
59
65
|
|
|
66
|
+
/// Maps the JS `theme` string to the container's own trait override. `"system"` (or any
|
|
67
|
+
/// unrecognized value) leaves it `.unspecified`, following the app/OS setting as before.
|
|
68
|
+
fileprivate static func resolveInterfaceStyle(_ theme: String) -> UIUserInterfaceStyle {
|
|
69
|
+
switch theme {
|
|
70
|
+
case "light": return .light
|
|
71
|
+
case "dark": return .dark
|
|
72
|
+
default: return .unspecified
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
60
76
|
private final class ContainerHandle: EmojiKeyboardPresentationHandle {
|
|
61
77
|
private weak var container: EmojiKeyboardContainerViewController?
|
|
62
78
|
|
|
@@ -124,16 +140,25 @@ final class EmojiKeyboardContainerViewController: UIViewController, UITextFieldD
|
|
|
124
140
|
/// never leave the user with zero ways to dismiss the keyboard, so hiding it force-enables
|
|
125
141
|
/// backdrop-tap-to-dismiss regardless of what was explicitly requested.
|
|
126
142
|
private let effectiveDismissOnBackdropTap: Bool
|
|
127
|
-
private let
|
|
143
|
+
private let theme: String
|
|
144
|
+
/// Internal (not `private`) so `EmojiTextFieldDelegateTests` can assert `keyboardAppearance`
|
|
145
|
+
/// after `viewDidLoad` - mirrors the class-level visibility rationale above.
|
|
146
|
+
let emojiField = EmojiTextField()
|
|
128
147
|
private let closeButton: UIButton
|
|
129
148
|
private var modeChangeObserver: NSObjectProtocol?
|
|
130
149
|
private var verificationTimeoutWorkItem: DispatchWorkItem?
|
|
131
150
|
private var hasReportedOutcome = false
|
|
132
151
|
|
|
133
|
-
init(
|
|
152
|
+
init(
|
|
153
|
+
listener: EmojiKeyboardPresentationListener,
|
|
154
|
+
closeButtonOptions: EmojiCloseButtonOptions,
|
|
155
|
+
dismissOnBackdropTap: Bool,
|
|
156
|
+
theme: String
|
|
157
|
+
) {
|
|
134
158
|
self.listener = listener
|
|
135
159
|
self.closeButtonOptions = closeButtonOptions
|
|
136
160
|
self.effectiveDismissOnBackdropTap = dismissOnBackdropTap || closeButtonOptions.hidden
|
|
161
|
+
self.theme = theme
|
|
137
162
|
self.closeButton = Self.makeCloseButton(options: closeButtonOptions)
|
|
138
163
|
super.init(nibName: nil, bundle: nil)
|
|
139
164
|
}
|
|
@@ -150,6 +175,10 @@ final class EmojiKeyboardContainerViewController: UIViewController, UITextFieldD
|
|
|
150
175
|
emojiField.delegate = self
|
|
151
176
|
emojiField.alpha = 0
|
|
152
177
|
emojiField.frame = CGRect(x: 0, y: 0, width: 1, height: 1)
|
|
178
|
+
// The system emoji keyboard lives in a separate window/process and does not follow
|
|
179
|
+
// `overrideUserInterfaceStyle` (set on this container for the plugin's own chrome, below);
|
|
180
|
+
// `keyboardAppearance` is the mechanism the system keyboard itself honors.
|
|
181
|
+
emojiField.keyboardAppearance = Self.resolveKeyboardAppearance(theme)
|
|
153
182
|
view.addSubview(emojiField)
|
|
154
183
|
|
|
155
184
|
setUpCloseButton()
|
|
@@ -206,6 +235,16 @@ final class EmojiKeyboardContainerViewController: UIViewController, UITextFieldD
|
|
|
206
235
|
verificationTimeoutWorkItem = nil
|
|
207
236
|
}
|
|
208
237
|
|
|
238
|
+
/// Maps the JS `theme` string to `UIKeyboardAppearance`. `"system"` (or any unrecognized
|
|
239
|
+
/// value) leaves it `.default`, following the system keyboard's own OS-level setting as before.
|
|
240
|
+
private static func resolveKeyboardAppearance(_ theme: String) -> UIKeyboardAppearance {
|
|
241
|
+
switch theme {
|
|
242
|
+
case "light": return .light
|
|
243
|
+
case "dark": return .dark
|
|
244
|
+
default: return .default
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
209
248
|
/// A close button styled to match the system's own controls (Liquid Glass capsule on iOS 26+,
|
|
210
249
|
/// a plain circular glyph button on earlier versions), pinned to `keyboardLayoutGuide` so it
|
|
211
250
|
/// tracks the keyboard's position/animation directly, with a gap above it - rather than an
|
|
@@ -14,6 +14,7 @@ protocol EmojiKeyboardPresentationFactory {
|
|
|
14
14
|
hostViewController: UIViewController,
|
|
15
15
|
closeButtonOptions: EmojiCloseButtonOptions,
|
|
16
16
|
dismissOnBackdropTap: Bool,
|
|
17
|
+
theme: String,
|
|
17
18
|
listener: EmojiKeyboardPresentationListener
|
|
18
19
|
) -> EmojiKeyboardPresentationHandle
|
|
19
20
|
}
|
|
@@ -18,6 +18,8 @@ struct EmojiPickerPresentOptions {
|
|
|
18
18
|
let closeButton: EmojiCloseButtonOptions
|
|
19
19
|
/// Only consulted by presenters that render a close affordance; ignored elsewhere.
|
|
20
20
|
let dismissOnBackdropTap: Bool
|
|
21
|
+
/// `"system"`, `"light"`, or `"dark"`.
|
|
22
|
+
let theme: String
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
/// Performs the platform-specific presentation.
|
|
@@ -63,6 +63,7 @@ final class NativeEmojiPickerPresenter: EmojiPickerPresenter {
|
|
|
63
63
|
self?.presentOnMainThread(
|
|
64
64
|
closeButton: options.closeButton,
|
|
65
65
|
dismissOnBackdropTap: options.dismissOnBackdropTap,
|
|
66
|
+
theme: options.theme,
|
|
66
67
|
completion: completion
|
|
67
68
|
)
|
|
68
69
|
}
|
|
@@ -71,6 +72,7 @@ final class NativeEmojiPickerPresenter: EmojiPickerPresenter {
|
|
|
71
72
|
private func presentOnMainThread(
|
|
72
73
|
closeButton: EmojiCloseButtonOptions,
|
|
73
74
|
dismissOnBackdropTap: Bool,
|
|
75
|
+
theme: String,
|
|
74
76
|
completion: @escaping (Result<EmojiPickerResult, EmojiPickerError>) -> Void
|
|
75
77
|
) {
|
|
76
78
|
let host = hostViewControllerProvider()
|
|
@@ -89,7 +91,7 @@ final class NativeEmojiPickerPresenter: EmojiPickerPresenter {
|
|
|
89
91
|
let presentation = Presentation(completion: completion)
|
|
90
92
|
current = presentation
|
|
91
93
|
presentation.owner = self
|
|
92
|
-
presentation.start(host: host, closeButton: closeButton, dismissOnBackdropTap: dismissOnBackdropTap, factory: factory)
|
|
94
|
+
presentation.start(host: host, closeButton: closeButton, dismissOnBackdropTap: dismissOnBackdropTap, theme: theme, factory: factory)
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
/// Owns everything about ONE presentation attempt: its handle, its cleanup, and whether it
|
|
@@ -110,12 +112,14 @@ final class NativeEmojiPickerPresenter: EmojiPickerPresenter {
|
|
|
110
112
|
host: UIViewController,
|
|
111
113
|
closeButton: EmojiCloseButtonOptions,
|
|
112
114
|
dismissOnBackdropTap: Bool,
|
|
115
|
+
theme: String,
|
|
113
116
|
factory: EmojiKeyboardPresentationFactory
|
|
114
117
|
) {
|
|
115
118
|
let createdHandle = factory.create(
|
|
116
119
|
hostViewController: host,
|
|
117
120
|
closeButtonOptions: closeButton,
|
|
118
121
|
dismissOnBackdropTap: dismissOnBackdropTap,
|
|
122
|
+
theme: theme,
|
|
119
123
|
listener: self
|
|
120
124
|
)
|
|
121
125
|
|
|
@@ -65,7 +65,11 @@ final class WebFallbackEmojiPickerPresenter: EmojiPickerPresenter {
|
|
|
65
65
|
|
|
66
66
|
pending[requestId] = PendingRequest(completion: completion, resignActiveObserver: resignActiveObserver)
|
|
67
67
|
|
|
68
|
-
let json = Self.encodeOptionsJson(
|
|
68
|
+
let json = Self.encodeOptionsJson(
|
|
69
|
+
dismissOnBackdropTap: options.dismissOnBackdropTap,
|
|
70
|
+
closeButton: options.closeButton,
|
|
71
|
+
theme: options.theme
|
|
72
|
+
)
|
|
69
73
|
// The eval "completion" here only means the script at least started executing (i.e. the
|
|
70
74
|
// bridge/webview is alive) - it cancels the timeout WITHOUT settling the request, which
|
|
71
75
|
// stays pending for the real result reported later via handleBridgeMessage.
|
|
@@ -107,11 +111,11 @@ final class WebFallbackEmojiPickerPresenter: EmojiPickerPresenter {
|
|
|
107
111
|
}
|
|
108
112
|
}
|
|
109
113
|
|
|
110
|
-
/// Hand-rolled instead of `JSONSerialization`: `size`/`position` are always one of a
|
|
111
|
-
/// fixed set of ASCII enum values validated/defaulted when the plugin call is parsed,
|
|
112
|
-
/// arbitrary user text, so plain string interpolation is safe here.
|
|
113
|
-
private static func encodeOptionsJson(dismissOnBackdropTap: Bool, closeButton: EmojiCloseButtonOptions) -> String {
|
|
114
|
-
"{\"dismissOnBackdropTap\":\(dismissOnBackdropTap),\"closeButton\":{\"size\":\"\(closeButton.size)\",\"position\":\"\(closeButton.position)\",\"hidden\":\(closeButton.hidden)}}"
|
|
114
|
+
/// Hand-rolled instead of `JSONSerialization`: `size`/`position`/`theme` are always one of a
|
|
115
|
+
/// small fixed set of ASCII enum values validated/defaulted when the plugin call is parsed,
|
|
116
|
+
/// never arbitrary user text, so plain string interpolation is safe here.
|
|
117
|
+
private static func encodeOptionsJson(dismissOnBackdropTap: Bool, closeButton: EmojiCloseButtonOptions, theme: String) -> String {
|
|
118
|
+
"{\"dismissOnBackdropTap\":\(dismissOnBackdropTap),\"closeButton\":{\"size\":\"\(closeButton.size)\",\"position\":\"\(closeButton.position)\",\"hidden\":\(closeButton.hidden)},\"theme\":\"\(theme)\"}"
|
|
115
119
|
}
|
|
116
120
|
|
|
117
121
|
private struct PendingRequest {
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"url": "https://github.com/independo-gmbh/capacitor-emoji-picker.git"
|
|
14
14
|
},
|
|
15
15
|
"description": "Emoji picker plugin for Capacitor 8 with native Android support, iOS system emoji keyboard integration, and a web fallback.",
|
|
16
|
-
"version": "1.0.
|
|
16
|
+
"version": "1.1.0-dev.1",
|
|
17
17
|
"packageManager": "pnpm@11.8.0",
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@capacitor/android": "catalog:",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@types/jest": "^30.0.0",
|
|
32
32
|
"@types/node": "^26.2.0",
|
|
33
33
|
"conventional-changelog-conventionalcommits": "^9.3.1",
|
|
34
|
-
"eslint": "10.8.
|
|
34
|
+
"eslint": "10.8.1",
|
|
35
35
|
"globals": "17.9.0",
|
|
36
36
|
"jest": "^30.4.2",
|
|
37
37
|
"jest-environment-jsdom": "^30.4.1",
|