Skip to content
Open
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
12 changes: 12 additions & 0 deletions FightPandemics.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -199,6 +202,9 @@
C018DD852477313F00EEB3FC /* ApplyFilterBtn.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplyFilterBtn.swift; sourceTree = "<group>"; };
C018DD882479C41D00EEB3FC /* FeedCatTag.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedCatTag.swift; sourceTree = "<group>"; };
C018DD8A2479D9C900EEB3FC /* FeedOfferReqTime.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedOfferReqTime.swift; sourceTree = "<group>"; };
C018DD93247C987900EEB3FC /* FeedTitle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedTitle.swift; sourceTree = "<group>"; };
C018DD95247C988700EEB3FC /* FeedBodyTxt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedBodyTxt.swift; sourceTree = "<group>"; };
C018DD97247C989800EEB3FC /* FeedViewMoreBtn.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedViewMoreBtn.swift; sourceTree = "<group>"; };
C0E5EDF724705CC200F42319 /* PostVisibilitySelectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostVisibilitySelectionView.swift; sourceTree = "<group>"; };
C0E5EDFA2470AA4E00F42319 /* Duration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Duration.swift; sourceTree = "<group>"; };
DC807E58246FAC8B00046D67 /* CreatePostEntitySelectionModal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreatePostEntitySelectionModal.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -597,6 +603,9 @@
children = (
C018DD882479C41D00EEB3FC /* FeedCatTag.swift */,
C018DD8A2479D9C900EEB3FC /* FeedOfferReqTime.swift */,
C018DD93247C987900EEB3FC /* FeedTitle.swift */,
C018DD95247C988700EEB3FC /* FeedBodyTxt.swift */,
C018DD97247C989800EEB3FC /* FeedViewMoreBtn.swift */,
);
path = Card;
sourceTree = "<group>";
Expand Down Expand Up @@ -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 */,
Expand Down
64 changes: 64 additions & 0 deletions FightPandemics/Features/Feed/Card/FeedBodyTxt.swift
Original file line number Diff line number Diff line change
@@ -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: " ")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the purpose of this code here, please can you help put me through?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the words that appear at the end of text sometimes overlapped with the button, I tried to fix this.

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To position the viewMore button correctly, check out the code snippet below:
viewMore.makeSubview(of: self) .top(to: \.bottomAnchor, of: bodyLbl, relation: .equal, constant: -20, priority: .required) .trailing(to: \.trailingAnchor, of: bodyLbl, relation: .equal, constant: -10, priority: .required) .height(16)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was looking for a way to attach the button to the end of text (which has different length), do you have any solution for that?
I mean for example if the text ends in the beginning of the line, the button appears there, if the text appear in the middle of the text the button appears there if the text ends at the end of the line the button appears there.

.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
}
}
55 changes: 55 additions & 0 deletions FightPandemics/Features/Feed/Card/FeedTitle.swift
Original file line number Diff line number Diff line change
@@ -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
}
}
43 changes: 43 additions & 0 deletions FightPandemics/Features/Feed/Card/FeedViewMoreBtn.swift
Original file line number Diff line number Diff line change
@@ -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
}
}
2 changes: 1 addition & 1 deletion FightPandemics/Features/Feed/FeedPost/Avatar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion FightPandemics/Features/Feed/FeedPost/AvatarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions FightPandemics/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"ClearFilterBtn" = "Clear filters";
"ApplyFilterBtn" = "Apply filters";
"FilterLocationCellSearchBar" = "Zip code, neighborhood or city";
"ViewMoreBtn" = "View More";

// MARK: Profile

Expand Down