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..0efbb93 --- /dev/null +++ b/FightPandemics/Features/Feed/Card/FeedBodyTxt.swift @@ -0,0 +1,64 @@ +// +// 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 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) { + fatalError("init(coder:) has not been implemented") + } + + func setUp() { + 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 = 5 + bodyLbl.lineBreakMode = .byWordWrapping + bodyLbl.makeSubview(of: self) + .width(self.frame.size.width) + .height(heightOfBody(text: newTxt)) + viewMore.makeSubview(of: self) + .width(72) + .height(16) + .right(to: \.rightAnchor, of: bodyLbl, constant: -5) + .bottom(to: \.bottomAnchor, of: bodyLbl, constant: -15) + } + + 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 new file mode 100644 index 0000000..a218f3e --- /dev/null +++ b/FightPandemics/Features/Feed/Card/FeedTitle.swift @@ -0,0 +1,55 @@ +// +// 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 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: 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 - 40) + .height(heightOfTitle(title: title)) + } + + 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 + } +} diff --git a/FightPandemics/Features/Feed/Card/FeedViewMoreBtn.swift b/FightPandemics/Features/Feed/Card/FeedViewMoreBtn.swift new file mode 100644 index 0000000..c95cc65 --- /dev/null +++ b/FightPandemics/Features/Feed/Card/FeedViewMoreBtn.swift @@ -0,0 +1,43 @@ +// +// 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 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() { + 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/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 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() 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