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. * Make BLE Transport an actor to fix background discovery crashes * Update protobufs * 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 * 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: 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>
80 lines
2.5 KiB
Swift
80 lines
2.5 KiB
Swift
import SwiftUI
|
|
import UIKit
|
|
|
|
struct TapbackInputView: View {
|
|
@Binding var text: String
|
|
@Binding var isPresented: Bool
|
|
let onEmojiSelected: (String) -> Void
|
|
|
|
var body: some View {
|
|
NavigationView {
|
|
VStack(spacing: 0) {
|
|
TextField("Tap to enter emoji", text: $text)
|
|
.keyboardType(.emoji)
|
|
.frame(height: 50)
|
|
.padding(.horizontal)
|
|
.background(
|
|
RoundedRectangle(cornerRadius: 10)
|
|
.strokeBorder(.tertiary, lineWidth: 1)
|
|
.background(RoundedRectangle(cornerRadius: 10).fill(Color(.systemBackground)))
|
|
)
|
|
.padding(.horizontal)
|
|
.padding(.top, 8)
|
|
.onChange(of: text) { oldValue, newValue in
|
|
// Extract first emoji character and send it
|
|
if !newValue.isEmpty, let firstEmoji = extractFirstEmoji(from: newValue) {
|
|
onEmojiSelected(firstEmoji)
|
|
// Clear the text box after getting the emoji
|
|
text = ""
|
|
}
|
|
}
|
|
}
|
|
.navigationTitle("Tapback")
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
.toolbar {
|
|
ToolbarItem(placement: .navigationBarTrailing) {
|
|
Button("Cancel") {
|
|
isPresented = false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.presentationDetents([.height(120)])
|
|
}
|
|
|
|
private func extractFirstEmoji(from string: String) -> String? {
|
|
// Extract the first emoji character(s) - handle both single and multi-scalar emojis
|
|
guard !string.isEmpty else { return nil }
|
|
|
|
// Try to get the first character
|
|
let firstChar = string[string.startIndex]
|
|
|
|
// Check if it's an emoji using the existing extension
|
|
if firstChar.isEmoji {
|
|
// For multi-scalar emojis (like emojis with skin tones), we need to find the full emoji sequence
|
|
var emojiEnd = string.index(after: string.startIndex)
|
|
|
|
// Check if there are continuation scalars (for emojis with skin tones, variation selectors, etc.)
|
|
while emojiEnd < string.endIndex {
|
|
let nextChar = string[emojiEnd]
|
|
// Check if this is a continuation (variation selector, skin tone modifier, zero-width joiner, etc.)
|
|
if let scalar = nextChar.unicodeScalars.first,
|
|
(scalar.properties.isVariationSelector ||
|
|
scalar.value == 0xFE0F || // Variation selector
|
|
(scalar.value >= 0x1F3FB && scalar.value <= 0x1F3FF) || // Skin tone modifiers
|
|
scalar.value == 0x200D) { // Zero-width joiner
|
|
emojiEnd = string.index(after: emojiEnd)
|
|
} else if nextChar.isEmoji {
|
|
// If it's another emoji, include it (for compound emojis like flags)
|
|
emojiEnd = string.index(after: emojiEnd)
|
|
} else {
|
|
break
|
|
}
|
|
}
|
|
|
|
return String(string[string.startIndex..<emojiEnd])
|
|
}
|
|
|
|
return nil
|
|
}
|
|
}
|