Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ struct CustomTextEditor: UIViewRepresentable {
var maxWidth: CGFloat
var maxHeight: CGFloat
var font: UIFont
@Binding var currentHeight: CGFloat

class Coordinator: NSObject, UITextViewDelegate {
var parent: CustomTextEditor
Expand All @@ -24,6 +25,8 @@ struct CustomTextEditor: UIViewRepresentable {
func textViewDidChange(_ textView: UITextView) {
let size = textView.sizeThatFits(CGSize(width: parent.maxWidth, height: CGFloat.greatestFiniteMagnitude))

parent.currentHeight = size.height

if size.height > parent.maxHeight {
textView.text = parent.text
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,9 @@ struct MiniTabBarView: View {
.background(viewModel.isFontEdit ? Color.clear : Color(.primary300))
.clipShape(Capsule())
}
.disabled(viewModel.isFontEdit ? false : true)
.onChange(of: viewModel.texts) {
if viewModel.texts.contains(where: { !$0.isEmpty }) {
viewModel.isFontEdit = false
} else {
viewModel.isFontEdit = true
}
.disabled(!viewModel.isFontEdit)
.onChange(of: viewModel.currentHeight) {
viewModel.updateFontEditState()
}

Button {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ struct ScrollableLetterView: View {
text: $viewModel.texts[i],
maxWidth: geo.size.width,
maxHeight: geo.size.height,
font: FontUtility.selectedUIFont(font: letterContent.fontString ?? "", size: FontUtility.fontSize(font: letterContent.fontString ?? ""))
font: FontUtility.selectedUIFont(font: letterContent.fontString ?? "", size: FontUtility.fontSize(font: letterContent.fontString ?? "")),
currentHeight: $viewModel.currentHeight
//lineSpacing: FontUtility.lineSpacing(font: letterContent.fontString ?? ""),
//kerning: FontUtility.kerning(font: letterContent.fontString ?? "")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ class ContentWriteViewModel: ObservableObject {

@Published var showFontMenu: Bool = false
@Published var isFontEdit: Bool = true

@Published var currentHeight: CGFloat = 0.0

func updateFontEditState() {
isFontEdit = currentHeight < UIScreen.main.bounds.height * 0.3
}

func toggleFontView() {
showFontMenu.toggle()
Expand Down
Loading