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