From 85d45a85c265011d4c47020477cffbe03b7a17cb Mon Sep 17 00:00:00 2001 From: ethanswift Date: Tue, 26 May 2020 04:50:47 +0430 Subject: [PATCH 1/9] Avatar font modified --- FightPandemics/Features/Feed/FeedPost/Avatar.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FightPandemics/Features/Feed/FeedPost/Avatar.swift b/FightPandemics/Features/Feed/FeedPost/Avatar.swift index 153a251..caa2920 100644 --- a/FightPandemics/Features/Feed/FeedPost/Avatar.swift +++ b/FightPandemics/Features/Feed/FeedPost/Avatar.swift @@ -49,7 +49,7 @@ class Avatar: UIView { label.clipsToBounds = true label.layer.masksToBounds = true label.layer.cornerRadius = frame.size.height / 2 - label.font = UIFont(name: "System", size: 18) + label.font = Fonts.poppinsRegular.customFont(size: 16) label.textColor = UIColor.fightPandemicsNeonBlue() label.backgroundColor = UIColor.fightPandemicsGhostWhite() label.layer.borderWidth = 1 From 01466d36e2a0e1c1ca6cbeef866e0152325ceaf7 Mon Sep 17 00:00:00 2001 From: ethanswift Date: Tue, 26 May 2020 04:51:56 +0430 Subject: [PATCH 2/9] Feed files created --- FightPandemics.xcodeproj/project.pbxproj | 12 +++++++++ .../Features/Feed/Card/FeedBodyTxt.swift | 27 +++++++++++++++++++ .../Features/Feed/Card/FeedTitle.swift | 27 +++++++++++++++++++ .../Features/Feed/Card/FeedViewMoreBtn.swift | 27 +++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 FightPandemics/Features/Feed/Card/FeedBodyTxt.swift create mode 100644 FightPandemics/Features/Feed/Card/FeedTitle.swift create mode 100644 FightPandemics/Features/Feed/Card/FeedViewMoreBtn.swift diff --git a/FightPandemics.xcodeproj/project.pbxproj b/FightPandemics.xcodeproj/project.pbxproj index f6ce9d9..7e757af 100644 --- a/FightPandemics.xcodeproj/project.pbxproj +++ b/FightPandemics.xcodeproj/project.pbxproj @@ -80,6 +80,9 @@ C018DD862477313F00EEB3FC /* ApplyFilterBtn.swift in Sources */ = {isa = PBXBuildFile; fileRef = C018DD852477313F00EEB3FC /* ApplyFilterBtn.swift */; }; C018DD892479C41D00EEB3FC /* FeedCatTag.swift in Sources */ = {isa = PBXBuildFile; fileRef = C018DD882479C41D00EEB3FC /* FeedCatTag.swift */; }; C018DD8B2479D9C900EEB3FC /* FeedOfferReqTime.swift in Sources */ = {isa = PBXBuildFile; fileRef = C018DD8A2479D9C900EEB3FC /* FeedOfferReqTime.swift */; }; + C018DD94247C987900EEB3FC /* FeedTitle.swift in Sources */ = {isa = PBXBuildFile; fileRef = C018DD93247C987900EEB3FC /* FeedTitle.swift */; }; + C018DD96247C988700EEB3FC /* FeedBodyTxt.swift in Sources */ = {isa = PBXBuildFile; fileRef = C018DD95247C988700EEB3FC /* FeedBodyTxt.swift */; }; + C018DD98247C989800EEB3FC /* FeedViewMoreBtn.swift in Sources */ = {isa = PBXBuildFile; fileRef = C018DD97247C989800EEB3FC /* FeedViewMoreBtn.swift */; }; C0E5EDFB2470AA4E00F42319 /* Duration.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0E5EDFA2470AA4E00F42319 /* Duration.swift */; }; DC807E59246FAC8B00046D67 /* CreatePostEntitySelectionModal.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC807E58246FAC8B00046D67 /* CreatePostEntitySelectionModal.swift */; }; DC807E5B246FB02300046D67 /* Entity.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC807E5A246FB02300046D67 /* Entity.swift */; }; @@ -199,6 +202,9 @@ C018DD852477313F00EEB3FC /* ApplyFilterBtn.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplyFilterBtn.swift; sourceTree = ""; }; C018DD882479C41D00EEB3FC /* FeedCatTag.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedCatTag.swift; sourceTree = ""; }; C018DD8A2479D9C900EEB3FC /* FeedOfferReqTime.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedOfferReqTime.swift; sourceTree = ""; }; + C018DD93247C987900EEB3FC /* FeedTitle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedTitle.swift; sourceTree = ""; }; + C018DD95247C988700EEB3FC /* FeedBodyTxt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedBodyTxt.swift; sourceTree = ""; }; + C018DD97247C989800EEB3FC /* FeedViewMoreBtn.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedViewMoreBtn.swift; sourceTree = ""; }; C0E5EDF724705CC200F42319 /* PostVisibilitySelectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostVisibilitySelectionView.swift; sourceTree = ""; }; C0E5EDFA2470AA4E00F42319 /* Duration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Duration.swift; sourceTree = ""; }; DC807E58246FAC8B00046D67 /* CreatePostEntitySelectionModal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreatePostEntitySelectionModal.swift; sourceTree = ""; }; @@ -597,6 +603,9 @@ children = ( C018DD882479C41D00EEB3FC /* FeedCatTag.swift */, C018DD8A2479D9C900EEB3FC /* FeedOfferReqTime.swift */, + C018DD93247C987900EEB3FC /* FeedTitle.swift */, + C018DD95247C988700EEB3FC /* FeedBodyTxt.swift */, + C018DD97247C989800EEB3FC /* FeedViewMoreBtn.swift */, ); path = Card; sourceTree = ""; @@ -898,14 +907,17 @@ 2FB342042468FFCC007E397F /* Navigator.swift in Sources */, 2F0C3C44246F51BB0002B384 /* PostReactionButton.swift in Sources */, 2FF5627E2476035C00194144 /* LocationServicesObserver.swift in Sources */, + C018DD94247C987900EEB3FC /* FeedTitle.swift in Sources */, 2F042190246CCD4A005FB1D0 /* ProfileViewController.swift in Sources */, 2F426BA024735B89007A4796 /* OpenSourceLicense.swift in Sources */, 2F0421A4246D04B9005FB1D0 /* AutoLogInFakeLaunchScreen.swift in Sources */, C0E5EDFB2470AA4E00F42319 /* Duration.swift in Sources */, + C018DD98247C989800EEB3FC /* FeedViewMoreBtn.swift in Sources */, 2F72CE4D2468785200750785 /* HTTPClientError.swift in Sources */, 2F72CE532468785200750785 /* HTTPClient.swift in Sources */, C018DD84247722FB00EEB3FC /* ClearFilterBtn.swift in Sources */, 2F0B515C246E009400BE42BC /* CreatePostViewController.swift in Sources */, + C018DD96247C988700EEB3FC /* FeedBodyTxt.swift in Sources */, 2F0B516B246E15B400BE42BC /* IndividualOrg.swift in Sources */, 2F0C3C40246ECA5C0002B384 /* Constraints+FightPandemics.swift in Sources */, 2F042110246A1021005FB1D0 /* PostFooter.swift in Sources */, diff --git a/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift b/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift new file mode 100644 index 0000000..bb57548 --- /dev/null +++ b/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift @@ -0,0 +1,27 @@ +// +// FeedBodyTxt.swift +// FightPandemics +// +// Created by ehsan sat on 5/26/20. +// +// Copyright (c) 2020 FightPandemics +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation diff --git a/FightPandemics/Features/Feed/Card/FeedTitle.swift b/FightPandemics/Features/Feed/Card/FeedTitle.swift new file mode 100644 index 0000000..61fd800 --- /dev/null +++ b/FightPandemics/Features/Feed/Card/FeedTitle.swift @@ -0,0 +1,27 @@ +// +// FeedTitle.swift +// FightPandemics +// +// Created by ehsan sat on 5/26/20. +// +// Copyright (c) 2020 FightPandemics +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation diff --git a/FightPandemics/Features/Feed/Card/FeedViewMoreBtn.swift b/FightPandemics/Features/Feed/Card/FeedViewMoreBtn.swift new file mode 100644 index 0000000..4de4633 --- /dev/null +++ b/FightPandemics/Features/Feed/Card/FeedViewMoreBtn.swift @@ -0,0 +1,27 @@ +// +// FeedViewMoreBtn.swift +// FightPandemics +// +// Created by ehsan sat on 5/26/20. +// +// Copyright (c) 2020 FightPandemics +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation From 9a29581eec3007c7f6919a0ee4d7d938b4bd4f3f Mon Sep 17 00:00:00 2001 From: ethanswift Date: Tue, 26 May 2020 06:29:07 +0430 Subject: [PATCH 3/9] feed title file modified --- .../Features/Feed/Card/FeedTitle.swift | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/FightPandemics/Features/Feed/Card/FeedTitle.swift b/FightPandemics/Features/Feed/Card/FeedTitle.swift index 61fd800..fc37fe0 100644 --- a/FightPandemics/Features/Feed/Card/FeedTitle.swift +++ b/FightPandemics/Features/Feed/Card/FeedTitle.swift @@ -24,4 +24,32 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -import Foundation +import UIKit + +class FeedTitle: UIView { + private var titleLbl = UILabel() + var title: String + init(title: String) { + self.title = title + super.init(frame: .zero) + setUp() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + func setUp() { + titleLbl.attributedText = NSAttributedString(string: self.title, attributes: [NSAttributedString.Key.font: Fonts.poppinsBold.customFont(size: 22), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNero()]) + titleLbl.numberOfLines = 0 + titleLbl.lineBreakMode = .byWordWrapping + titleLbl.makeSubview(of: self) + .width(UIScreen.main.bounds.size.width) + .height(heighOfTitle(title: self.title)) + } + + func heighOfTitle(title: String) -> CGFloat { + let boundingBox = NSString(string: title).boundingRect(with: CGSize(width: (UIScreen.main.bounds.width - 40), height: .greatestFiniteMagnitude), options: .usesLineFragmentOrigin, attributes: [NSAttributedString.Key.font: Fonts.poppinsBold.customFont(size: 22)], context: nil) + return boundingBox.height + } +} From a6ecf52ef9e6863be81bcc6f9b5c259652eb0047 Mon Sep 17 00:00:00 2001 From: ethanswift Date: Tue, 26 May 2020 19:28:29 +0430 Subject: [PATCH 4/9] feed body file modified --- .../Features/Feed/Card/FeedBodyTxt.swift | 46 ++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift b/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift index bb57548..dd35466 100644 --- a/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift +++ b/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift @@ -24,4 +24,48 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -import Foundation +import UIKit + +class FeedBodyTxt: UIView { + private var bodyLbl = UILabel() + var text: String + init(text: String) { + self.text = text + super.init(frame: .zero) + setUp() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + func setUp() { + bodyLbl.attributedText = NSAttributedString(string: self.text, attributes: [NSAttributedString.Key.font: Fonts.poppinsRegular.customFont(size: 14), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNero()]) + bodyLbl.textAlignment = .left + bodyLbl.numberOfLines = 0 + bodyLbl.lineBreakMode = .byWordWrapping + bodyLbl.makeSubview(of: self) + .width(UIScreen.main.bounds.width - 40) + .height(110, relation: .lessThanOrEqual, priority: .required) + } + func heighOfBody(text: String) -> CGFloat { + let boundingBox = NSString(string: text).boundingRect(with: CGSize(width: (UIScreen.main.bounds.width - 40), height: .greatestFiniteMagnitude), options: .usesLineFragmentOrigin, attributes: [NSAttributedString.Key.font: Fonts.poppinsBold.customFont(size: 22)], context: nil) + return boundingBox.height + } + func lastWordPosition(text: String) -> CGPoint { + let lblSize = CGSize(width: (UIScreen.main.bounds.width - 40), height: .infinity) + let layoutManager = NSLayoutManager() + let textStorage = NSTextStorage(attributedString: NSAttributedString(string: text, attributes: [NSAttributedString.Key.font: Fonts.dmSansRegular.customFont(size: 14)])) + let textContainer = NSTextContainer(size: lblSize) + layoutManager.addTextContainer(textContainer) + textStorage.addLayoutManager(layoutManager) + + textContainer.lineFragmentPadding = 0 + textContainer.lineBreakMode = .byWordWrapping + textContainer.maximumNumberOfLines = 6 + + let lastGlyphIndex = layoutManager.glyphIndexForCharacter(at: text.count - 1) + let lastLineFragmentRect = layoutManager.lineFragmentUsedRect(forGlyphAt: lastGlyphIndex, effectiveRange: nil) + + return CGPoint(x: lastLineFragmentRect.maxX, y: lastLineFragmentRect.maxY) + } +} From 617f72d913acb67ffc9979fb6fd1aac1b3020fa3 Mon Sep 17 00:00:00 2001 From: ethanswift Date: Tue, 26 May 2020 20:10:35 +0430 Subject: [PATCH 5/9] view more button modified --- .../Features/Feed/Card/FeedBodyTxt.swift | 2 +- .../Features/Feed/Card/FeedViewMoreBtn.swift | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift b/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift index dd35466..fc6dcc6 100644 --- a/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift +++ b/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift @@ -45,7 +45,7 @@ class FeedBodyTxt: UIView { bodyLbl.lineBreakMode = .byWordWrapping bodyLbl.makeSubview(of: self) .width(UIScreen.main.bounds.width - 40) - .height(110, relation: .lessThanOrEqual, priority: .required) + .height(heighOfBody(text: text)) } func heighOfBody(text: String) -> CGFloat { let boundingBox = NSString(string: text).boundingRect(with: CGSize(width: (UIScreen.main.bounds.width - 40), height: .greatestFiniteMagnitude), options: .usesLineFragmentOrigin, attributes: [NSAttributedString.Key.font: Fonts.poppinsBold.customFont(size: 22)], context: nil) diff --git a/FightPandemics/Features/Feed/Card/FeedViewMoreBtn.swift b/FightPandemics/Features/Feed/Card/FeedViewMoreBtn.swift index 4de4633..81c490a 100644 --- a/FightPandemics/Features/Feed/Card/FeedViewMoreBtn.swift +++ b/FightPandemics/Features/Feed/Card/FeedViewMoreBtn.swift @@ -24,4 +24,19 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -import Foundation +import UIKit + +class FeedViewMoreBtn: UIButton { + override init(frame: CGRect) { + super.init(frame: frame) + setUp() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + func setUp() { + self.setAttributedTitle(NSAttributedString(string: "View More", attributes: [NSAttributedString.Key.font: Fonts.dmSansRegular.customFont(size: 14)]), for: .normal) + self.backgroundColor = UIColor.clear + } +} From 22dd0a7ed7e05f42ece97c86d2c9d0504e274f02 Mon Sep 17 00:00:00 2001 From: ethanswift Date: Wed, 27 May 2020 01:26:36 +0430 Subject: [PATCH 6/9] view more added --- .../Features/Feed/Card/FeedBodyTxt.swift | 33 +++++++------------ .../Features/Feed/Card/FeedTitle.swift | 11 ++++--- .../Features/Feed/Card/FeedViewMoreBtn.swift | 9 ++--- .../Features/Feed/FeedPost/AvatarView.swift | 2 +- 4 files changed, 24 insertions(+), 31 deletions(-) diff --git a/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift b/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift index fc6dcc6..05a94a9 100644 --- a/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift +++ b/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift @@ -28,44 +28,35 @@ import UIKit class FeedBodyTxt: UIView { private var bodyLbl = UILabel() + private var viewMore = FeedViewMoreBtn() var text: String init(text: String) { self.text = text super.init(frame: .zero) setUp() } - - required init?(coder: NSCoder) { + + required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } + func setUp() { - bodyLbl.attributedText = NSAttributedString(string: self.text, attributes: [NSAttributedString.Key.font: Fonts.poppinsRegular.customFont(size: 14), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNero()]) + bodyLbl.attributedText = NSAttributedString(string: text, attributes: [NSAttributedString.Key.font: Fonts.poppinsRegular.customFont(size: 14), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNero()]) bodyLbl.textAlignment = .left bodyLbl.numberOfLines = 0 bodyLbl.lineBreakMode = .byWordWrapping bodyLbl.makeSubview(of: self) .width(UIScreen.main.bounds.width - 40) .height(heighOfBody(text: text)) + viewMore.makeSubview(of: self) + .width(85) + .height(16) + .right(to: \.rightAnchor, constant: -5) + .bottom(to: \.bottomAnchor, constant: -5) } + func heighOfBody(text: String) -> CGFloat { - let boundingBox = NSString(string: text).boundingRect(with: CGSize(width: (UIScreen.main.bounds.width - 40), height: .greatestFiniteMagnitude), options: .usesLineFragmentOrigin, attributes: [NSAttributedString.Key.font: Fonts.poppinsBold.customFont(size: 22)], context: nil) + let boundingBox = NSString(string: text).boundingRect(with: CGSize(width: UIScreen.main.bounds.width - 40, height: .greatestFiniteMagnitude), options: NSStringDrawingOptions.usesFontLeading.union(.usesLineFragmentOrigin), attributes: [NSAttributedString.Key.font: Fonts.poppinsBold.customFont(size: 14)], context: nil) return boundingBox.height } - func lastWordPosition(text: String) -> CGPoint { - let lblSize = CGSize(width: (UIScreen.main.bounds.width - 40), height: .infinity) - let layoutManager = NSLayoutManager() - let textStorage = NSTextStorage(attributedString: NSAttributedString(string: text, attributes: [NSAttributedString.Key.font: Fonts.dmSansRegular.customFont(size: 14)])) - let textContainer = NSTextContainer(size: lblSize) - layoutManager.addTextContainer(textContainer) - textStorage.addLayoutManager(layoutManager) - - textContainer.lineFragmentPadding = 0 - textContainer.lineBreakMode = .byWordWrapping - textContainer.maximumNumberOfLines = 6 - - let lastGlyphIndex = layoutManager.glyphIndexForCharacter(at: text.count - 1) - let lastLineFragmentRect = layoutManager.lineFragmentUsedRect(forGlyphAt: lastGlyphIndex, effectiveRange: nil) - - return CGPoint(x: lastLineFragmentRect.maxX, y: lastLineFragmentRect.maxY) - } } diff --git a/FightPandemics/Features/Feed/Card/FeedTitle.swift b/FightPandemics/Features/Feed/Card/FeedTitle.swift index fc37fe0..57ae41d 100644 --- a/FightPandemics/Features/Feed/Card/FeedTitle.swift +++ b/FightPandemics/Features/Feed/Card/FeedTitle.swift @@ -35,21 +35,22 @@ class FeedTitle: UIView { setUp() } - required init?(coder: NSCoder) { + required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } func setUp() { - titleLbl.attributedText = NSAttributedString(string: self.title, attributes: [NSAttributedString.Key.font: Fonts.poppinsBold.customFont(size: 22), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNero()]) + titleLbl.attributedText = NSAttributedString(string: title, attributes: [NSAttributedString.Key.font: Fonts.poppinsBold.customFont(size: 22), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNero()]) titleLbl.numberOfLines = 0 titleLbl.lineBreakMode = .byWordWrapping + titleLbl.backgroundColor = #colorLiteral(red: 0.8039215803, green: 0.8039215803, blue: 0.8039215803, alpha: 1) titleLbl.makeSubview(of: self) - .width(UIScreen.main.bounds.size.width) - .height(heighOfTitle(title: self.title)) + .width(UIScreen.main.bounds.size.width - 40) + .height(heighOfTitle(title: title)) } func heighOfTitle(title: String) -> CGFloat { - let boundingBox = NSString(string: title).boundingRect(with: CGSize(width: (UIScreen.main.bounds.width - 40), height: .greatestFiniteMagnitude), options: .usesLineFragmentOrigin, attributes: [NSAttributedString.Key.font: Fonts.poppinsBold.customFont(size: 22)], context: nil) + let boundingBox = NSString(string: title).boundingRect(with: CGSize(width: UIScreen.main.bounds.width - 40, height: .greatestFiniteMagnitude), options: NSStringDrawingOptions.usesFontLeading.union(.usesLineFragmentOrigin), attributes: [NSAttributedString.Key.font: Fonts.poppinsBold.customFont(size: 22)], context: nil) return boundingBox.height } } diff --git a/FightPandemics/Features/Feed/Card/FeedViewMoreBtn.swift b/FightPandemics/Features/Feed/Card/FeedViewMoreBtn.swift index 81c490a..8c47ee4 100644 --- a/FightPandemics/Features/Feed/Card/FeedViewMoreBtn.swift +++ b/FightPandemics/Features/Feed/Card/FeedViewMoreBtn.swift @@ -31,12 +31,13 @@ class FeedViewMoreBtn: UIButton { super.init(frame: frame) setUp() } - - required init?(coder: NSCoder) { + + required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } + func setUp() { - self.setAttributedTitle(NSAttributedString(string: "View More", attributes: [NSAttributedString.Key.font: Fonts.dmSansRegular.customFont(size: 14)]), for: .normal) - self.backgroundColor = UIColor.clear + setAttributedTitle(NSAttributedString(string: " ... View More", attributes: [NSAttributedString.Key.font: Fonts.dmSansRegular.customFont(size: 14), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNeonBlue()]), for: .normal) + backgroundColor = UIColor.white } } diff --git a/FightPandemics/Features/Feed/FeedPost/AvatarView.swift b/FightPandemics/Features/Feed/FeedPost/AvatarView.swift index 481f922..655b1a4 100644 --- a/FightPandemics/Features/Feed/FeedPost/AvatarView.swift +++ b/FightPandemics/Features/Feed/FeedPost/AvatarView.swift @@ -30,7 +30,7 @@ class AvatarView: UIView { private var userNameLbl = UILabel() private var userLocLbl = UILabel() private var dotView = UIView() - func setUp(user: User, avatar: Avatar) { + func setUp(user: User, avatar _: Avatar) { userNameLbl.attributedText = NSAttributedString(string: user.firstName + " " + user.lastName, attributes: [NSAttributedString.Key.font: Fonts.poppinsRegular.customFont(size: 14), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNero()]) userNameLbl.textAlignment = .left userNameLbl.sizeToFit() From f86ec842e062f0ea5a0cce37a4f5cc267033e186 Mon Sep 17 00:00:00 2001 From: ethanswift Date: Wed, 27 May 2020 05:17:13 +0430 Subject: [PATCH 7/9] final modification and localization --- FightPandemics/Features/Feed/Card/FeedBodyTxt.swift | 7 ++++--- FightPandemics/Features/Feed/Card/FeedTitle.swift | 1 - FightPandemics/Features/Feed/Card/FeedViewMoreBtn.swift | 2 +- FightPandemics/Resources/en.lproj/Localizable.strings | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift b/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift index 05a94a9..1e7aa0c 100644 --- a/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift +++ b/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift @@ -41,15 +41,16 @@ class FeedBodyTxt: UIView { } func setUp() { - bodyLbl.attributedText = NSAttributedString(string: text, attributes: [NSAttributedString.Key.font: Fonts.poppinsRegular.customFont(size: 14), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNero()]) + let newTxt = text.components(separatedBy: " ").dropLast().dropLast().dropLast().joined(separator: " ") + bodyLbl.attributedText = NSAttributedString(string: newTxt, attributes: [NSAttributedString.Key.font: Fonts.poppinsRegular.customFont(size: 14), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNero()]) bodyLbl.textAlignment = .left bodyLbl.numberOfLines = 0 bodyLbl.lineBreakMode = .byWordWrapping bodyLbl.makeSubview(of: self) .width(UIScreen.main.bounds.width - 40) - .height(heighOfBody(text: text)) + .height(heighOfBody(text: newTxt)) viewMore.makeSubview(of: self) - .width(85) + .width(72) .height(16) .right(to: \.rightAnchor, constant: -5) .bottom(to: \.bottomAnchor, constant: -5) diff --git a/FightPandemics/Features/Feed/Card/FeedTitle.swift b/FightPandemics/Features/Feed/Card/FeedTitle.swift index 57ae41d..c4d5cbc 100644 --- a/FightPandemics/Features/Feed/Card/FeedTitle.swift +++ b/FightPandemics/Features/Feed/Card/FeedTitle.swift @@ -43,7 +43,6 @@ class FeedTitle: UIView { titleLbl.attributedText = NSAttributedString(string: title, attributes: [NSAttributedString.Key.font: Fonts.poppinsBold.customFont(size: 22), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNero()]) titleLbl.numberOfLines = 0 titleLbl.lineBreakMode = .byWordWrapping - titleLbl.backgroundColor = #colorLiteral(red: 0.8039215803, green: 0.8039215803, blue: 0.8039215803, alpha: 1) titleLbl.makeSubview(of: self) .width(UIScreen.main.bounds.size.width - 40) .height(heighOfTitle(title: title)) diff --git a/FightPandemics/Features/Feed/Card/FeedViewMoreBtn.swift b/FightPandemics/Features/Feed/Card/FeedViewMoreBtn.swift index 8c47ee4..c95cc65 100644 --- a/FightPandemics/Features/Feed/Card/FeedViewMoreBtn.swift +++ b/FightPandemics/Features/Feed/Card/FeedViewMoreBtn.swift @@ -37,7 +37,7 @@ class FeedViewMoreBtn: UIButton { } func setUp() { - setAttributedTitle(NSAttributedString(string: " ... View More", attributes: [NSAttributedString.Key.font: Fonts.dmSansRegular.customFont(size: 14), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNeonBlue()]), for: .normal) + setAttributedTitle(NSAttributedString(string: "ViewMoreBtn".localized, attributes: [NSAttributedString.Key.font: Fonts.dmSansRegular.customFont(size: 14), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNeonBlue()]), for: .normal) backgroundColor = UIColor.white } } diff --git a/FightPandemics/Resources/en.lproj/Localizable.strings b/FightPandemics/Resources/en.lproj/Localizable.strings index 9727e65..b92e693 100644 --- a/FightPandemics/Resources/en.lproj/Localizable.strings +++ b/FightPandemics/Resources/en.lproj/Localizable.strings @@ -60,6 +60,7 @@ "ClearFilterBtn" = "Clear filters"; "ApplyFilterBtn" = "Apply filters"; "FilterLocationCellSearchBar" = "Zip code, neighborhood or city"; +"ViewMoreBtn" = "View More"; // MARK: Profile From 1188487605fad149d0a1b0c5c356bcbf65e12d4b Mon Sep 17 00:00:00 2001 From: ethanswift Date: Sat, 30 May 2020 20:33:52 +0430 Subject: [PATCH 8/9] minor modifications --- FightPandemics/Features/Feed/Card/FeedBodyTxt.swift | 13 +++++++------ FightPandemics/Features/Feed/Card/FeedTitle.swift | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift b/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift index 1e7aa0c..a376619 100644 --- a/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift +++ b/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift @@ -44,20 +44,21 @@ class FeedBodyTxt: UIView { let newTxt = text.components(separatedBy: " ").dropLast().dropLast().dropLast().joined(separator: " ") bodyLbl.attributedText = NSAttributedString(string: newTxt, attributes: [NSAttributedString.Key.font: Fonts.poppinsRegular.customFont(size: 14), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNero()]) bodyLbl.textAlignment = .left - bodyLbl.numberOfLines = 0 + bodyLbl.numberOfLines = 5 bodyLbl.lineBreakMode = .byWordWrapping bodyLbl.makeSubview(of: self) .width(UIScreen.main.bounds.width - 40) - .height(heighOfBody(text: newTxt)) + .height(heightOfBody(text: newTxt)) viewMore.makeSubview(of: self) .width(72) .height(16) - .right(to: \.rightAnchor, constant: -5) - .bottom(to: \.bottomAnchor, constant: -5) + .right(to: \.rightAnchor, of: bodyLbl, constant: -5) + .bottom(to: \.bottomAnchor, of: bodyLbl, constant: -15) } - func heighOfBody(text: String) -> CGFloat { - let boundingBox = NSString(string: text).boundingRect(with: CGSize(width: UIScreen.main.bounds.width - 40, height: .greatestFiniteMagnitude), options: NSStringDrawingOptions.usesFontLeading.union(.usesLineFragmentOrigin), attributes: [NSAttributedString.Key.font: Fonts.poppinsBold.customFont(size: 14)], context: nil) + func heightOfBody(text: String) -> CGFloat { + let options = NSStringDrawingOptions.usesFontLeading.union(.usesLineFragmentOrigin) + let boundingBox = NSString(string: text).boundingRect(with: CGSize(width: UIScreen.main.bounds.width - 40, height: .greatestFiniteMagnitude), options: options, attributes: [NSAttributedString.Key.font: Fonts.poppinsBold.customFont(size: 14)], context: nil) return boundingBox.height } } diff --git a/FightPandemics/Features/Feed/Card/FeedTitle.swift b/FightPandemics/Features/Feed/Card/FeedTitle.swift index c4d5cbc..a218f3e 100644 --- a/FightPandemics/Features/Feed/Card/FeedTitle.swift +++ b/FightPandemics/Features/Feed/Card/FeedTitle.swift @@ -45,10 +45,10 @@ class FeedTitle: UIView { titleLbl.lineBreakMode = .byWordWrapping titleLbl.makeSubview(of: self) .width(UIScreen.main.bounds.size.width - 40) - .height(heighOfTitle(title: title)) + .height(heightOfTitle(title: title)) } - func heighOfTitle(title: String) -> CGFloat { + func heightOfTitle(title: String) -> CGFloat { let boundingBox = NSString(string: title).boundingRect(with: CGSize(width: UIScreen.main.bounds.width - 40, height: .greatestFiniteMagnitude), options: NSStringDrawingOptions.usesFontLeading.union(.usesLineFragmentOrigin), attributes: [NSAttributedString.Key.font: Fonts.poppinsBold.customFont(size: 22)], context: nil) return boundingBox.height } From b781857dc16d2deceec28cd01e2113298866f644 Mon Sep 17 00:00:00 2001 From: ethanswift Date: Sun, 31 May 2020 22:25:52 +0430 Subject: [PATCH 9/9] frame fixed --- FightPandemics/Features/Feed/Card/FeedBodyTxt.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift b/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift index a376619..0efbb93 100644 --- a/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift +++ b/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift @@ -47,7 +47,7 @@ class FeedBodyTxt: UIView { bodyLbl.numberOfLines = 5 bodyLbl.lineBreakMode = .byWordWrapping bodyLbl.makeSubview(of: self) - .width(UIScreen.main.bounds.width - 40) + .width(self.frame.size.width) .height(heightOfBody(text: newTxt)) viewMore.makeSubview(of: self) .width(72)