Fix bug where small black text appears during image upload
Changelog-Fixed: Fix bug where small black text appears during image upload
This commit is contained in:
@@ -154,6 +154,20 @@ struct PostView: View {
|
||||
.padding([.top, .bottom], 4)
|
||||
}
|
||||
|
||||
func append_url(_ url: String) {
|
||||
let uploadedImageURL = NSMutableAttributedString(string: url)
|
||||
let combinedAttributedString = NSMutableAttributedString()
|
||||
combinedAttributedString.append(post)
|
||||
if !post.string.hasSuffix(" ") {
|
||||
combinedAttributedString.append(NSAttributedString(string: " "))
|
||||
}
|
||||
combinedAttributedString.append(uploadedImageURL)
|
||||
|
||||
// make sure we have a space at the end
|
||||
combinedAttributedString.append(NSAttributedString(string: " "))
|
||||
post = combinedAttributedString
|
||||
}
|
||||
|
||||
func handle_upload(image: UIImage) {
|
||||
let uploader = get_image_uploader(damus_state.pubkey)
|
||||
|
||||
@@ -162,17 +176,7 @@ struct PostView: View {
|
||||
|
||||
switch res {
|
||||
case .success(let url):
|
||||
let uploadedImageURL = NSMutableAttributedString(string: url, attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 18.0), NSAttributedString.Key.foregroundColor: UIColor.label])
|
||||
let combinedAttributedString = NSMutableAttributedString()
|
||||
combinedAttributedString.append(post)
|
||||
if !post.string.hasSuffix(" ") {
|
||||
combinedAttributedString.append(NSAttributedString(string: " "))
|
||||
}
|
||||
combinedAttributedString.append(uploadedImageURL)
|
||||
|
||||
// make sure we have a space at the end
|
||||
combinedAttributedString.append(NSAttributedString(string: " "))
|
||||
post = combinedAttributedString
|
||||
append_url(url)
|
||||
|
||||
case .failed(let error):
|
||||
if let error {
|
||||
|
||||
@@ -13,16 +13,21 @@ struct TextViewWrapper: UIViewRepresentable {
|
||||
func makeUIView(context: Context) -> UITextView {
|
||||
let textView = UITextView()
|
||||
textView.delegate = context.coordinator
|
||||
textView.font = UIFont.preferredFont(forTextStyle: .body)
|
||||
textView.textColor = UIColor.label
|
||||
TextViewWrapper.setTextProperties(textView)
|
||||
return textView
|
||||
}
|
||||
|
||||
static func setTextProperties(_ uiView: UITextView) {
|
||||
uiView.textColor = UIColor.label
|
||||
uiView.font = UIFont.preferredFont(forTextStyle: .body)
|
||||
let linkAttributes: [NSAttributedString.Key : Any] = [
|
||||
NSAttributedString.Key.foregroundColor: UIColor(Color.accentColor)]
|
||||
textView.linkTextAttributes = linkAttributes
|
||||
return textView
|
||||
uiView.linkTextAttributes = linkAttributes
|
||||
}
|
||||
|
||||
func updateUIView(_ uiView: UITextView, context: Context) {
|
||||
uiView.attributedText = attributedText
|
||||
TextViewWrapper.setTextProperties(uiView)
|
||||
}
|
||||
|
||||
func makeCoordinator() -> Coordinator {
|
||||
|
||||
Reference in New Issue
Block a user