커뮤니티 게시글 - 링크적용
This commit is contained in:
		| @@ -16,9 +16,9 @@ struct CreatorCommunityAllItemView: View { | |||||||
|     let onClickWriteComment: (String) -> Void |     let onClickWriteComment: (String) -> Void | ||||||
|     let onClickShowReportMenu: () -> Void |     let onClickShowReportMenu: () -> Void | ||||||
|      |      | ||||||
|     @State var isExpandContent = false |  | ||||||
|     @State var isLike = false |     @State var isLike = false | ||||||
|     @State var likeCount = 0 |     @State var likeCount = 0 | ||||||
|  |     @State private var textHeight: CGFloat = .zero | ||||||
|      |      | ||||||
|     init( |     init( | ||||||
|         item: GetCommunityPostListResponse, |         item: GetCommunityPostListResponse, | ||||||
| @@ -48,11 +48,11 @@ struct CreatorCommunityAllItemView: View { | |||||||
|                 VStack(alignment: .leading, spacing: 3) { |                 VStack(alignment: .leading, spacing: 3) { | ||||||
|                     Text(item.creatorNickname) |                     Text(item.creatorNickname) | ||||||
|                         .font(.custom(Font.medium.rawValue, size: 13.3)) |                         .font(.custom(Font.medium.rawValue, size: 13.3)) | ||||||
|                         .foregroundColor(Color(hex: "eeeeee")) |                         .foregroundColor(Color.grayee) | ||||||
|                      |                      | ||||||
|                     Text(item.date) |                     Text(item.date) | ||||||
|                         .font(.custom(Font.light.rawValue, size: 13.3)) |                         .font(.custom(Font.light.rawValue, size: 13.3)) | ||||||
|                         .foregroundColor(Color(hex: "777777")) |                         .foregroundColor(Color.gray77) | ||||||
|                 } |                 } | ||||||
|                 .padding(.leading, 11) |                 .padding(.leading, 11) | ||||||
|                  |                  | ||||||
| @@ -63,13 +63,23 @@ struct CreatorCommunityAllItemView: View { | |||||||
|                     .onTapGesture { onClickShowReportMenu() } |                     .onTapGesture { onClickShowReportMenu() } | ||||||
|             } |             } | ||||||
|              |              | ||||||
|             Text(item.content) |             DetectableTextView(text: item.content, textSize: 13.3, font: Font.medium.rawValue) | ||||||
|                 .font(.custom(Font.medium.rawValue, size: 13.3)) |                 .frame( | ||||||
|                 .foregroundColor(Color(hex: "bbbbbb")) |                     width: screenSize().width - 16, | ||||||
|                 .fixedSize(horizontal: false, vertical: true) |                     height: textHeight | ||||||
|                 .frame(maxWidth: .infinity, alignment: .leading) |                 ) | ||||||
|                 .lineLimit(isExpandContent ? Int.max : 3) |                 .onAppear { | ||||||
|                 .onTapGesture { isExpandContent.toggle() } |                     self.textHeight = self.estimatedHeight( | ||||||
|  |                         for: item.content, | ||||||
|  |                         width: screenSize().width - 16 | ||||||
|  |                     ) | ||||||
|  |                 } | ||||||
|  |                 .onChange(of: item.content) { newText in | ||||||
|  |                     self.textHeight = self.estimatedHeight( | ||||||
|  |                         for: newText, | ||||||
|  |                         width: screenSize().width - 16 | ||||||
|  |                     ) | ||||||
|  |                 } | ||||||
|              |              | ||||||
|             if let imageUrl = item.imageUrl { |             if let imageUrl = item.imageUrl { | ||||||
|                 KFImage(URL(string: imageUrl)) |                 KFImage(URL(string: imageUrl)) | ||||||
| @@ -112,9 +122,16 @@ struct CreatorCommunityAllItemView: View { | |||||||
|         } |         } | ||||||
|         .padding(.horizontal, 8) |         .padding(.horizontal, 8) | ||||||
|         .padding(.vertical, 11) |         .padding(.vertical, 11) | ||||||
|         .background(Color(hex: "222222")) |         .background(Color.gray22) | ||||||
|         .cornerRadius(5.3) |         .cornerRadius(5.3) | ||||||
|     } |     } | ||||||
|  |      | ||||||
|  |     private func estimatedHeight(for text: String, width: CGFloat) -> CGFloat { | ||||||
|  |         let textView = UITextView(frame: CGRect(x: 0, y: 0, width: width, height: .greatestFiniteMagnitude)) | ||||||
|  |         textView.font = UIFont.systemFont(ofSize: 13.3) | ||||||
|  |         textView.text = text | ||||||
|  |         return textView.sizeThatFits(CGSize(width: width, height: .greatestFiniteMagnitude)).height | ||||||
|  |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| struct CreatorCommunityAllItemView_Previews: PreviewProvider { | struct CreatorCommunityAllItemView_Previews: PreviewProvider { | ||||||
|   | |||||||
| @@ -10,6 +10,8 @@ import UIKit | |||||||
|  |  | ||||||
| struct DetectableTextView: UIViewRepresentable { | struct DetectableTextView: UIViewRepresentable { | ||||||
|     var text: String |     var text: String | ||||||
|  |     var textSize: CGFloat = 11.3 | ||||||
|  |     var font: String = Font.light.rawValue | ||||||
|      |      | ||||||
|     func makeUIView(context: Context) -> UITextView { |     func makeUIView(context: Context) -> UITextView { | ||||||
|         let textView = UITextView() |         let textView = UITextView() | ||||||
| @@ -17,7 +19,7 @@ struct DetectableTextView: UIViewRepresentable { | |||||||
|         textView.backgroundColor = .clear |         textView.backgroundColor = .clear | ||||||
|         textView.isScrollEnabled = true |         textView.isScrollEnabled = true | ||||||
|         textView.dataDetectorTypes = .link |         textView.dataDetectorTypes = .link | ||||||
|         textView.font = UIFont(name: Font.light.rawValue, size: 11.3) |         textView.font = UIFont(name: font, size: textSize) | ||||||
|         textView.textColor = .white |         textView.textColor = .white | ||||||
|         textView.textContainer.lineFragmentPadding = 0 |         textView.textContainer.lineFragmentPadding = 0 | ||||||
|         textView.textContainerInset = .zero |         textView.textContainerInset = .zero | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Yu Sung
					Yu Sung