-
-
Notifications
You must be signed in to change notification settings - Fork 988
Split user status and user message in separate screens #3890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 12 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
5ea5172
WIP
mpivchev 3892467
WIP
mpivchev 18cd604
WIP
mpivchev 9b8b989
WIP
mpivchev 5569363
WIP
mpivchev 67500a2
WIP
mpivchev 41a4c1e
WIP
mpivchev f4b3bc7
WIP
mpivchev 93e745e
WIP
mpivchev a08ab71
Remove old code
mpivchev ade9bfb
Remove comments
mpivchev d6a612c
Merge branch 'master' of https://github.com/nextcloud/ios into split-…
mpivchev c576fd9
PR fixes
mpivchev c2e8d47
Merge branch 'master' of https://github.com/nextcloud/ios into handle…
mpivchev 1260500
WIP
mpivchev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| // SPDX-FileCopyrightText: Nextcloud GmbH | ||
| // SPDX-FileCopyrightText: 2025 Milen Pivchev | ||
| // SPDX-License-Identifier: GPL-3.0-or-later | ||
|
|
||
| import SwiftUI | ||
|
|
||
| // UIKit-backed emoji-only text field that forces the Emoji keyboard | ||
| final class EmojiTextField: UITextField { | ||
| override var textInputContextIdentifier: String? { "" } // return non-nil to show the Emoji keyboard | ||
|
|
||
| override var textInputMode: UITextInputMode? { | ||
| for mode in UITextInputMode.activeInputModes { | ||
| if mode.primaryLanguage == "emoji" { | ||
| return mode | ||
| } | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| override init(frame: CGRect) { | ||
| super.init(frame: frame) | ||
| commonInit() | ||
| } | ||
|
|
||
| required init?(coder: NSCoder) { | ||
| super.init(coder: coder) | ||
| commonInit() | ||
| } | ||
|
|
||
| private func commonInit() { | ||
| NotificationCenter.default.addObserver(self, selector: #selector(inputModeDidChange), name: UITextInputMode.currentInputModeDidChangeNotification, object: nil) | ||
| addTarget(self, action: #selector(textChanged), for: .editingChanged) | ||
| } | ||
|
|
||
| @objc func inputModeDidChange(_ notification: Notification) { | ||
| guard isFirstResponder else { | ||
| return | ||
| } | ||
|
|
||
| DispatchQueue.main.async { [weak self] in | ||
| self?.reloadInputViews() | ||
| } | ||
| } | ||
|
|
||
| // Keep only a single emoji character | ||
| @objc private func textChanged() { | ||
| guard let t = text, !t.isEmpty else { return } | ||
| // Trim to first extended grapheme cluster (so flags/skin tones stay intact) | ||
| let first = String(t.prefix(1)) | ||
| if first != t { text = first } | ||
| } | ||
| } | ||
|
|
||
| struct EmojiField: UIViewRepresentable { | ||
| @Binding var text: String | ||
|
|
||
| func makeUIView(context: Context) -> EmojiTextField { | ||
| let tf = EmojiTextField(frame: .zero) | ||
| tf.delegate = context.coordinator | ||
| tf.text = text | ||
| tf.setContentHuggingPriority(.required, for: .horizontal) | ||
| tf.setContentCompressionResistancePriority(.required, for: .horizontal) | ||
| return tf | ||
| } | ||
|
|
||
| func updateUIView(_ uiView: EmojiTextField, context: Context) { | ||
| if uiView.text != text { | ||
| uiView.text = text | ||
| } | ||
| } | ||
|
|
||
| func makeCoordinator() -> Coordinator { Coordinator(self) } | ||
|
|
||
| final class Coordinator: NSObject, UITextFieldDelegate { | ||
| var parent: EmojiField | ||
| init(_ parent: EmojiField) { self.parent = parent } | ||
|
|
||
| func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { | ||
| if textField is EmojiTextField { | ||
| if string.isEmpty { | ||
| textField.text = "😀" | ||
| return false | ||
| } | ||
| textField.text = string | ||
| textField.endEditing(true) | ||
| } | ||
| return true | ||
| } | ||
|
|
||
| func textFieldShouldReturn(_ textField: UITextField) -> Bool { | ||
| textField.resignFirstResponder() | ||
| return false | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.