Tusker/Tusker/Screens/Compose/ComposeReplyContentView.swift

45 lines
1.1 KiB
Swift
Raw Normal View History

2020-08-31 23:28:50 +00:00
//
// ComposeReplyContentView.swift
// Tusker
//
// Created by Shadowfacts on 8/22/20.
// Copyright © 2020 Shadowfacts. All rights reserved.
//
import SwiftUI
struct ComposeReplyContentView: UIViewRepresentable {
typealias UIViewType = ComposeReplyContentTextView
let status: StatusMO
@EnvironmentObject var mastodonController: MastodonController
let heightChanged: (CGFloat) -> Void
2020-08-31 23:28:50 +00:00
func makeUIView(context: Context) -> ComposeReplyContentTextView {
let view = ComposeReplyContentTextView()
view.overrideMastodonController = mastodonController
view.setTextFrom(status: status)
view.isUserInteractionEnabled = false
view.backgroundColor = .clear
2020-08-31 23:28:50 +00:00
return view
}
func updateUIView(_ uiView: ComposeReplyContentTextView, context: Context) {
uiView.heightChanged = heightChanged
2020-08-31 23:28:50 +00:00
}
}
class ComposeReplyContentTextView: StatusContentTextView {
var heightChanged: ((CGFloat) -> Void)?
2020-08-31 23:28:50 +00:00
override func layoutSubviews() {
super.layoutSubviews()
2020-08-31 23:28:50 +00:00
heightChanged?(contentSize.height)
2020-08-31 23:28:50 +00:00
}
}