fix: typo

This commit is contained in:
CMK 2021-06-02 14:59:39 +08:00
parent 634aef0de3
commit 4e6423929f
2 changed files with 18 additions and 18 deletions

View File

@ -730,7 +730,7 @@ extension ComposeViewController: TextEditorViewTextAttributesDelegate {
guard let emoji = customEmojiViewModel.emoji(shortcode: name) else { continue } guard let emoji = customEmojiViewModel.emoji(shortcode: name) else { continue }
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: handle emoji: %s", ((#file as NSString).lastPathComponent), #line, #function, name) os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: handle emoji: %s", ((#file as NSString).lastPathComponent), #line, #function, name)
// set emoji token invisiable (without upper bounce space) // set emoji token invisible (without upper bounce space)
var attributes = [NSAttributedString.Key: Any]() var attributes = [NSAttributedString.Key: Any]()
attributes[.font] = UIFont.systemFont(ofSize: 0.01) attributes[.font] = UIFont.systemFont(ofSize: 0.01)
attributedString.addAttributes(attributes, range: match.range) attributedString.addAttributes(attributes, range: match.range)
@ -812,15 +812,15 @@ extension ComposeViewController: TextEditorViewTextAttributesDelegate {
extension ComposeViewController: TextEditorViewChangeObserver { extension ComposeViewController: TextEditorViewChangeObserver {
func textEditorView(_ textEditorView: TextEditorView, didChangeWithChangeResult changeResult: TextEditorViewChangeResult) { func textEditorView(_ textEditorView: TextEditorView, didChangeWithChangeResult changeResult: TextEditorViewChangeResult) {
guard var autoCompeletion = ComposeViewController.scanAutoCompleteInfo(textEditorView: textEditorView) else { guard var autoCompletion = ComposeViewController.scanAutoCompleteInfo(textEditorView: textEditorView) else {
viewModel.autoCompleteInfo.value = nil viewModel.autoCompleteInfo.value = nil
return return
} }
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: auto complete %s (%s)", ((#file as NSString).lastPathComponent), #line, #function, String(autoCompeletion.toHighlightEndString), String(autoCompeletion.toCursorString)) os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: auto complete %s (%s)", ((#file as NSString).lastPathComponent), #line, #function, String(autoCompletion.toHighlightEndString), String(autoCompletion.toCursorString))
// get layout text bounding rect // get layout text bounding rect
var glyphRange = NSRange() var glyphRange = NSRange()
textEditorView.layoutManager.characterRange(forGlyphRange: NSRange(autoCompeletion.toCursorRange, in: textEditorView.text), actualGlyphRange: &glyphRange) textEditorView.layoutManager.characterRange(forGlyphRange: NSRange(autoCompletion.toCursorRange, in: textEditorView.text), actualGlyphRange: &glyphRange)
let textContainer = textEditorView.layoutManager.textContainers[0] let textContainer = textEditorView.layoutManager.textContainers[0]
let textBoundingRect = textEditorView.layoutManager.boundingRect(forGlyphRange: glyphRange, in: textContainer) let textBoundingRect = textEditorView.layoutManager.boundingRect(forGlyphRange: glyphRange, in: textContainer)
@ -838,13 +838,13 @@ extension ComposeViewController: TextEditorViewChangeObserver {
viewModel.autoCompleteRetryLayoutTimes.value = 0 viewModel.autoCompleteRetryLayoutTimes.value = 0
// get symbol bounding rect // get symbol bounding rect
textEditorView.layoutManager.characterRange(forGlyphRange: NSRange(autoCompeletion.symbolRange, in: textEditorView.text), actualGlyphRange: &glyphRange) textEditorView.layoutManager.characterRange(forGlyphRange: NSRange(autoCompletion.symbolRange, in: textEditorView.text), actualGlyphRange: &glyphRange)
let symbolBoundingRect = textEditorView.layoutManager.boundingRect(forGlyphRange: glyphRange, in: textContainer) let symbolBoundingRect = textEditorView.layoutManager.boundingRect(forGlyphRange: glyphRange, in: textContainer)
// set bounding rect and trigger layout // set bounding rect and trigger layout
autoCompeletion.textBoundingRect = textBoundingRect autoCompletion.textBoundingRect = textBoundingRect
autoCompeletion.symbolBoundingRect = symbolBoundingRect autoCompletion.symbolBoundingRect = symbolBoundingRect
viewModel.autoCompleteInfo.value = autoCompeletion viewModel.autoCompleteInfo.value = autoCompletion
} }
struct AutoCompleteInfo { struct AutoCompleteInfo {
@ -1017,7 +1017,7 @@ extension ComposeViewController: UICollectionViewDelegate {
let emoji = attribute.emoji let emoji = attribute.emoji
let textEditorView = self.textEditorView() let textEditorView = self.textEditorView()
// retrive active text input and insert emoji // retrieve active text input and insert emoji
// the leading and trailing space is REQUIRED to fix `UITextStorage` layout issue // the leading and trailing space is REQUIRED to fix `UITextStorage` layout issue
let reference = viewModel.customEmojiPickerInputViewModel.insertText(" :\(emoji.shortcode): ") let reference = viewModel.customEmojiPickerInputViewModel.insertText(" :\(emoji.shortcode): ")
@ -1070,7 +1070,7 @@ extension ComposeViewController: PHPickerViewControllerDelegate {
let service = MastodonAttachmentService( let service = MastodonAttachmentService(
context: context, context: context,
pickerResult: result, pickerResult: result,
initalAuthenticationBox: viewModel.activeAuthenticationBox.value initialAuthenticationBox: viewModel.activeAuthenticationBox.value
) )
return service return service
} }
@ -1089,7 +1089,7 @@ extension ComposeViewController: UIImagePickerControllerDelegate & UINavigationC
let attachmentService = MastodonAttachmentService( let attachmentService = MastodonAttachmentService(
context: context, context: context,
image: image, image: image,
initalAuthenticationBox: viewModel.activeAuthenticationBox.value initialAuthenticationBox: viewModel.activeAuthenticationBox.value
) )
viewModel.attachmentServices.value = viewModel.attachmentServices.value + [attachmentService] viewModel.attachmentServices.value = viewModel.attachmentServices.value + [attachmentService]
} }
@ -1108,7 +1108,7 @@ extension ComposeViewController: UIDocumentPickerDelegate {
let attachmentService = MastodonAttachmentService( let attachmentService = MastodonAttachmentService(
context: context, context: context,
documentURL: url, documentURL: url,
initalAuthenticationBox: viewModel.activeAuthenticationBox.value initialAuthenticationBox: viewModel.activeAuthenticationBox.value
) )
viewModel.attachmentServices.value = viewModel.attachmentServices.value + [attachmentService] viewModel.attachmentServices.value = viewModel.attachmentServices.value + [attachmentService]
} }

View File

@ -52,10 +52,10 @@ final class MastodonAttachmentService {
init( init(
context: AppContext, context: AppContext,
pickerResult: PHPickerResult, pickerResult: PHPickerResult,
initalAuthenticationBox: AuthenticationService.MastodonAuthenticationBox? initialAuthenticationBox: AuthenticationService.MastodonAuthenticationBox?
) { ) {
self.context = context self.context = context
self.authenticationBox = initalAuthenticationBox self.authenticationBox = initialAuthenticationBox
// end init // end init
setupServiceObserver() setupServiceObserver()
@ -90,10 +90,10 @@ final class MastodonAttachmentService {
init( init(
context: AppContext, context: AppContext,
image: UIImage, image: UIImage,
initalAuthenticationBox: AuthenticationService.MastodonAuthenticationBox? initialAuthenticationBox: AuthenticationService.MastodonAuthenticationBox?
) { ) {
self.context = context self.context = context
self.authenticationBox = initalAuthenticationBox self.authenticationBox = initialAuthenticationBox
// end init // end init
setupServiceObserver() setupServiceObserver()
@ -105,10 +105,10 @@ final class MastodonAttachmentService {
init( init(
context: AppContext, context: AppContext,
documentURL: URL, documentURL: URL,
initalAuthenticationBox: AuthenticationService.MastodonAuthenticationBox? initialAuthenticationBox: AuthenticationService.MastodonAuthenticationBox?
) { ) {
self.context = context self.context = context
self.authenticationBox = initalAuthenticationBox self.authenticationBox = initialAuthenticationBox
// end init // end init
setupServiceObserver() setupServiceObserver()