mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
* Bump version * update the translations (#1540) update the translations * Don't alert (with sound: .default) when updating Live Activity (#1536) * Fix adding channels (#1532) * Full translation into Spanish (#1529) * tapback with any emoji (#1538) * Call clearStaleNodes at start of sendWantConfig (#1535) * NFC Tag contact (#1537) * Accessorymanager background discovery (#1542) * Don't add new BLE devices to the device list in the backgournd * Bump version * Update Meshtastic/MeshtasticApp.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/MeshtasticApp.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Revert "Full translation into Spanish (#1529)" (#1543) This reverts commitf25fdfb89f. * Revert "update the translations (#1540)" (#1544) This reverts commitcb2fd8cc15. * Revert "NFC Tag contact (#1537)" (#1545) This reverts commit5c22b8b6e0. * Update Meshtastic/Views/Messages/TapbackInputView.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Helpers/EmojiOnlyTextField.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Revert "Accessorymanager background discovery (#1542)" (#1553) This reverts commit487f24b99a. * Update protobufs * Remove UI Kit code, clean up waypoint form emoji picker * Remove redundant nested Task in tapback emoji handler (#1552) * Initial plan * Remove nested Task block in tapback handler Co-authored-by: garthvh <1795163+garthvh@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: garthvh <1795163+garthvh@users.noreply.github.com> * Delete empty file * Handle nil for emoji keyboard type extension * Remove UI kit method from waypoint form emoji picker * Remove UI kit emoji picker from tapback * Add Exchange User Info (#1550) * Emoji keyboard (#1559) * Add file missing from project, must have merged badly * Remove ui kit emoji keyboard * Discovery background fixes (#1561) * Make BLE Transport an actor to fix background discovery crashes * Protobufs * Update Meshtastic/Accessory/Transports/Bluetooth Low Energy/BLETransport.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Throw too many retries error again, remove return --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Increase connection timeout * Update protobufs * Revert "Fix adding channels (#1532)" (#1562) This reverts commitbff8ca018b. --------- Co-authored-by: MGJ <62177301+MGJ520@users.noreply.github.com> Co-authored-by: Mike Robbins <mrobbins@alum.mit.edu> Co-authored-by: Benjamin Faershtein <119711889+RCGV1@users.noreply.github.com> Co-authored-by: Alvaro Samudio <alvarosamudio@protonmail.com> Co-authored-by: Mathew Kamkar <578302+matkam@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: garthvh <1795163+garthvh@users.noreply.github.com> Co-authored-by: Brian Hardie <777730+bhardie@users.noreply.github.com>
105 lines
2.9 KiB
Swift
105 lines
2.9 KiB
Swift
//
|
|
// EmojiKeyboard.swift
|
|
// Meshtastic
|
|
//
|
|
// Copyright(c) Garth Vander Houwen 1/10/23.
|
|
//
|
|
import SwiftUI
|
|
|
|
class SwiftUIEmojiTextField: UITextField {
|
|
var shouldBecomeFirstResponderOnAppear = false
|
|
|
|
func setEmoji() {
|
|
_ = self.textInputMode
|
|
}
|
|
|
|
override var textInputContextIdentifier: String? {
|
|
return ""
|
|
}
|
|
|
|
override var textInputMode: UITextInputMode? {
|
|
for mode in UITextInputMode.activeInputModes where mode.primaryLanguage == "emoji" {
|
|
self.keyboardType = .default // do not remove this
|
|
return mode
|
|
}
|
|
return nil
|
|
}
|
|
|
|
override func didMoveToWindow() {
|
|
super.didMoveToWindow()
|
|
if shouldBecomeFirstResponderOnAppear && window != nil {
|
|
DispatchQueue.main.async { [weak self] in
|
|
self?.becomeFirstResponder()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
struct EmojiOnlyTextField: UIViewRepresentable {
|
|
@Binding var text: String
|
|
var placeholder: String = ""
|
|
var onBecomeFirstResponder: (() -> Void)?
|
|
var onKeyboardTypeChanged: ((Bool) -> Void)? // true if NOT emoji (should dismiss), false if emoji
|
|
var onKeyboardDismissed: (() -> Void)? // Called when keyboard is dismissed
|
|
|
|
func makeUIView(context: Context) -> SwiftUIEmojiTextField {
|
|
let emojiTextField = SwiftUIEmojiTextField()
|
|
emojiTextField.placeholder = placeholder
|
|
emojiTextField.text = text
|
|
emojiTextField.delegate = context.coordinator
|
|
emojiTextField.shouldBecomeFirstResponderOnAppear = true
|
|
context.coordinator.textField = emojiTextField
|
|
return emojiTextField
|
|
}
|
|
|
|
func updateUIView(_ uiView: SwiftUIEmojiTextField, context: Context) {
|
|
uiView.text = text
|
|
context.coordinator.onBecomeFirstResponder = onBecomeFirstResponder
|
|
context.coordinator.onKeyboardTypeChanged = onKeyboardTypeChanged
|
|
context.coordinator.onKeyboardDismissed = onKeyboardDismissed
|
|
}
|
|
|
|
func makeCoordinator() -> Coordinator {
|
|
Coordinator(parent: self)
|
|
}
|
|
|
|
class Coordinator: NSObject, UITextFieldDelegate {
|
|
var parent: EmojiOnlyTextField
|
|
var textField: SwiftUIEmojiTextField?
|
|
var onBecomeFirstResponder: (() -> Void)?
|
|
var onKeyboardTypeChanged: ((Bool) -> Void)?
|
|
var onKeyboardDismissed: (() -> Void)?
|
|
var previousInputMode: String?
|
|
|
|
init(parent: EmojiOnlyTextField) {
|
|
self.parent = parent
|
|
}
|
|
|
|
func textFieldDidBeginEditing(_ textField: UITextField) {
|
|
onBecomeFirstResponder?()
|
|
checkInputMode(textField)
|
|
}
|
|
|
|
func textFieldDidEndEditing(_ textField: UITextField) {
|
|
// Keyboard was dismissed
|
|
onKeyboardDismissed?()
|
|
}
|
|
|
|
func textFieldDidChangeSelection(_ textField: UITextField) {
|
|
DispatchQueue.main.async { [weak self] in
|
|
self?.parent.text = textField.text ?? ""
|
|
}
|
|
checkInputMode(textField)
|
|
}
|
|
|
|
private func checkInputMode(_ textField: UITextField) {
|
|
if let inputMode = textField.textInputMode {
|
|
let isEmoji = inputMode.primaryLanguage == "emoji"
|
|
if previousInputMode != inputMode.primaryLanguage {
|
|
previousInputMode = inputMode.primaryLanguage
|
|
onKeyboardTypeChanged?(!isEmoji) // true if NOT emoji (should dismiss)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|