Skip to content

Commit

Permalink
chore: 가독성 증가
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyxxn committed Dec 3, 2024
1 parent 8acf0c4 commit 4c8754e
Showing 1 changed file with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,10 @@ final class EditPageCell: UITableViewCell {
description: media
)
case .video:
let view = MHVideoView()
attachment = MediaAttachment(
view: view,
description: media
)
attachment = MediaAttachment(
view: MHVideoView(),
description: media
)
case .audio:
// TODO: - audio 추가 필요
attachment = MediaAttachment(
Expand All @@ -204,10 +203,10 @@ final class EditPageCell: UITableViewCell {
)
case .video:
let view = MHVideoView()
attachment = MediaAttachment(
view: view,
description: media
)
attachment = MediaAttachment(
view: view,
description: media
)
case .audio:
// TODO: - audio 추가 필요
attachment = MediaAttachment(
Expand Down Expand Up @@ -245,7 +244,7 @@ final class EditPageCell: UITableViewCell {
in: NSRange(location: 0, length: textStorage.length)
) { value, _, _ in
guard let mediaAttachment = value as? MediaAttachment,
mediaAttachment.mediaDescription.id == media.id else { return }
mediaAttachment.mediaDescription.id == media.id else { return }
attachment = mediaAttachment
}
return attachment
Expand All @@ -254,11 +253,16 @@ final class EditPageCell: UITableViewCell {
private func appendAttachment(_ attachment: MediaAttachment) {
guard let textStorage else { return }
let text = NSMutableAttributedString(attachment: attachment)
text.addAttributes(defaultAttributes,
range: NSRange(location: 0, length: 1))
guard isAcceptableHeight(textStorage,
shouldChangeTextIn: NSRange(location: textStorage.length, length: 0),
replacementText: text) else { return }
text.addAttributes(
defaultAttributes,
range: NSRange(location: 0, length: 1)
)

guard isAcceptableHeight(
textStorage,
shouldChangeTextIn: NSRange(location: textStorage.length, length: 0),
replacementText: text
) else { return }
textStorage.beginEditing()
textStorage.append(text)
textStorage.endEditing()
Expand Down Expand Up @@ -311,7 +315,7 @@ extension EditPageCell: UITextViewDelegate {
return false
}
else if let attachment = attachmentAt(range.location+2), // Attachment 2칸 앞에 줄바꿈을 추가할때
textView.text[textView.text.index(textView.text.startIndex, offsetBy: range.location+1)] == "\n" {
textView.text[textView.text.index(textView.text.startIndex, offsetBy: range.location+1)] == "\n" {
attachment.cachedViewProvider = nil
}
}
Expand Down

0 comments on commit 4c8754e

Please sign in to comment.