Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Luko/offer req card user profile #180

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
28 changes: 28 additions & 0 deletions FightPandemics.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
7DEF116C7BC2A4F6BA56F4F0 /* Pods_FightPandemics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AC14540D23239E4E26F554CF /* Pods_FightPandemics.framework */; };
976A98CB24782B8600604FFA /* GeneratedImagesList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 976A98CA24782B8600604FFA /* GeneratedImagesList.swift */; };
976A98CD24782BC500604FFA /* GeneratedStoryboardsList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 976A98CC24782BC500604FFA /* GeneratedStoryboardsList.swift */; };
A60FA8AD2498618B00B790DB /* OfferRequestCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = A60FA8AC2498618B00B790DB /* OfferRequestCard.swift */; };
A60FA8AF2498621900B790DB /* Header-OfferReqCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = A60FA8AE2498621900B790DB /* Header-OfferReqCard.swift */; };
A60FA8B12498625200B790DB /* Subheader-OfferReqCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = A60FA8B02498625200B790DB /* Subheader-OfferReqCard.swift */; };
A60FA8B32498627F00B790DB /* Body-OfferReqCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = A60FA8B22498627F00B790DB /* Body-OfferReqCard.swift */; };
A60FA8B5249862AD00B790DB /* Footer-OfferReqCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = A60FA8B4249862AD00B790DB /* Footer-OfferReqCard.swift */; };
A681817C2482050A00E7EA43 /* PillButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = A681817B2482050A00E7EA43 /* PillButton.swift */; };
C013ACDA246FF3E200F22BE7 /* OfferRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C013ACD9246FF3E200F22BE7 /* OfferRequest.swift */; };
C016A4DD248AC1C30012B185 /* CommentFooter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C016A4DC248AC1C30012B185 /* CommentFooter.swift */; };
Expand Down Expand Up @@ -205,6 +210,11 @@
74D3F30914E75C1D9DB78030 /* Pods-FightPandemics.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FightPandemics.debug.xcconfig"; path = "Target Support Files/Pods-FightPandemics/Pods-FightPandemics.debug.xcconfig"; sourceTree = "<group>"; };
976A98CA24782B8600604FFA /* GeneratedImagesList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeneratedImagesList.swift; sourceTree = "<group>"; };
976A98CC24782BC500604FFA /* GeneratedStoryboardsList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeneratedStoryboardsList.swift; sourceTree = "<group>"; };
A60FA8AC2498618B00B790DB /* OfferRequestCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OfferRequestCard.swift; sourceTree = "<group>"; };
A60FA8AE2498621900B790DB /* Header-OfferReqCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Header-OfferReqCard.swift"; sourceTree = "<group>"; };
A60FA8B02498625200B790DB /* Subheader-OfferReqCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Subheader-OfferReqCard.swift"; sourceTree = "<group>"; };
A60FA8B22498627F00B790DB /* Body-OfferReqCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Body-OfferReqCard.swift"; sourceTree = "<group>"; };
A60FA8B4249862AD00B790DB /* Footer-OfferReqCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Footer-OfferReqCard.swift"; sourceTree = "<group>"; };
A681817B2482050A00E7EA43 /* PillButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PillButton.swift; sourceTree = "<group>"; };
AC14540D23239E4E26F554CF /* Pods_FightPandemics.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_FightPandemics.framework; sourceTree = BUILT_PRODUCTS_DIR; };
C013ACD9246FF3E200F22BE7 /* OfferRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OfferRequest.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -280,6 +290,7 @@
2F0420F5246A0D0D005FB1D0 /* Feed */ = {
isa = PBXGroup;
children = (
A60FA8AB2498612200B790DB /* OfferRequestCard */,
C018DD872479C26E00EEB3FC /* Card */,
2F0420F6246A0E71005FB1D0 /* Feed.storyboard */,
2F0420FA246A0EBA005FB1D0 /* FeedPost */,
Expand Down Expand Up @@ -620,6 +631,18 @@
path = Constant;
sourceTree = "<group>";
};
A60FA8AB2498612200B790DB /* OfferRequestCard */ = {
isa = PBXGroup;
children = (
A60FA8AC2498618B00B790DB /* OfferRequestCard.swift */,
A60FA8AE2498621900B790DB /* Header-OfferReqCard.swift */,
A60FA8B02498625200B790DB /* Subheader-OfferReqCard.swift */,
A60FA8B22498627F00B790DB /* Body-OfferReqCard.swift */,
A60FA8B4249862AD00B790DB /* Footer-OfferReqCard.swift */,
);
path = OfferRequestCard;
sourceTree = "<group>";
};
C013ACD8246FF3C500F22BE7 /* OfferRequest */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -927,6 +950,7 @@
2F72CE502468785200750785 /* JSON.swift in Sources */,
2F04219E246CE99C005FB1D0 /* Success.swift in Sources */,
2F426BA6247365FB007A4796 /* OpenSourceCreditsViewController.swift in Sources */,
A60FA8B5249862AD00B790DB /* Footer-OfferReqCard.swift in Sources */,
2FB341F92468F9F0007E397F /* RootTabBarController.swift in Sources */,
2F0C3C6C2471E1130002B384 /* FiltersModal.swift in Sources */,
2F72CE5B2468790200750785 /* APIError.swift in Sources */,
Expand Down Expand Up @@ -976,6 +1000,7 @@
2F72CE4D2468785200750785 /* HTTPClientError.swift in Sources */,
2F72CE532468785200750785 /* HTTPClient.swift in Sources */,
C018DD84247722FB00EEB3FC /* ClearFilterBtn.swift in Sources */,
A60FA8B12498625200B790DB /* Subheader-OfferReqCard.swift in Sources */,
2F0B515C246E009400BE42BC /* CreatePostViewController.swift in Sources */,
2F0B516B246E15B400BE42BC /* IndividualOrg.swift in Sources */,
A681817C2482050A00E7EA43 /* PillButton.swift in Sources */,
Expand All @@ -993,8 +1018,11 @@
DC807E66246FB37000046D67 /* BottomModalPresentationController.swift in Sources */,
DDF9290C2472055600973488 /* PostTagCell.swift in Sources */,
2F9EFE53245DFB1700E86700 /* SceneDelegate.swift in Sources */,
A60FA8AF2498621900B790DB /* Header-OfferReqCard.swift in Sources */,
DC807E5B246FB02300046D67 /* Entity.swift in Sources */,
976A98CB24782B8600604FFA /* GeneratedImagesList.swift in Sources */,
A60FA8B32498627F00B790DB /* Body-OfferReqCard.swift in Sources */,
A60FA8AD2498618B00B790DB /* OfferRequestCard.swift in Sources */,
2F426BAF24736E3D007A4796 /* OpenSourceTableViewCell.swift in Sources */,
2F426B3C2472C2A3007A4796 /* PostVisibilitySelectionView.swift in Sources */,
976A98CD24782BC500604FFA /* GeneratedStoryboardsList.swift in Sources */,
Expand Down
33 changes: 17 additions & 16 deletions FightPandemics/Features/Feed/Card/FeedCatTag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,30 @@

import UIKit

class FeedCatTag: UIView {
private var categoryLbl = UILabel()
class FeedCatTag: UILabel {
var categoryTagTxt: String

init(categoryTagTxt: String) {
self.categoryTagTxt = categoryTagTxt
super.init(frame: .zero)
setUp()
frame = CGRect(x: 0, y: 0, width: 150, height: 50)
widthAnchor.constraint(equalToConstant: frame.width).isActive = true
heightAnchor.constraint(equalToConstant: 50.0).isActive = true
attributedText = NSAttributedString(string: categoryTagTxt,
attributes: [NSAttributedString.Key.font: Fonts.dmSansRegular.customFont(size: 12), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNeonBlue()])

backgroundColor = UIColor.fightPandemicsGhostWhite()

textAlignment = .center
layer.masksToBounds = true
layer.cornerRadius = 4

// makeSubview(of: self)
// .width(frame.size.width)
// .height(30)
stavares843 marked this conversation as resolved.
Show resolved Hide resolved
}

required init?(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

func setUp() {
categoryLbl.attributedText = NSAttributedString(string: categoryTagTxt, attributes: [NSAttributedString.Key.font: Fonts.dmSansRegular.customFont(size: 12), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNeonBlue()])
categoryLbl.backgroundColor = UIColor.fightPandemicsGhostWhite()
let lblWidth = (categoryLbl.attributedText?.size().width)
categoryLbl.frame.size = CGSize(width: lblWidth! + 20, height: 30)
categoryLbl.textAlignment = .center
categoryLbl.layer.masksToBounds = true
categoryLbl.layer.cornerRadius = 4
categoryLbl.makeSubview(of: self)
.width(categoryLbl.frame.size.width)
.height(30)
}
}
1 change: 1 addition & 0 deletions FightPandemics/Features/Feed/Card/FeedMenuCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import UIKit

class FeedMenuCell: UICollectionViewCell {
static let reuseIdentifier = String(describing: self)

override init(frame: CGRect) {
super.init(frame: frame)
setupViews()
Expand Down
56 changes: 15 additions & 41 deletions FightPandemics/Features/Feed/Card/FeedOfferReqTime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,60 +27,34 @@
import UIKit

enum OfferRequestType: String {
case offer = "Offer"
case request = "Request"
case offers = "Offers •"
case requests = "Requests •"
}

class FeedOfferReqTime: UIView {
class FeedOfferReqTime: UIStackView {
private var offerReqLbl = UILabel()
private var timeStampLbl = UILabel()
private var dotView = UIView()

private var offerReq: OfferRequestType
var timeStamp: String?

init(offerReq: OfferRequestType, timeStamp: String) {
self.offerReq = offerReq
self.timeStamp = timeStamp
super.init(frame: .zero)
setUp()
}

required init?(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

func setUp() {
offerReqLbl.attributedText = NSAttributedString(string: offerReq.rawValue, attributes: [NSAttributedString.Key.font: Fonts.poppinsRegular.customFont(size: 12), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNeonBlue()])
offerReqLbl.sizeToFit()
offerReqLbl.layoutIfNeeded()
offerReqLbl.lineBreakMode = .byClipping
addSubview(offerReqLbl)
dotView.backgroundColor = UIColor.fightPandemicsNeonBlue()
dotView.frame.size = CGSize(width: 2, height: 2)
dotView.layer.masksToBounds = true
dotView.layer.cornerRadius = dotView.frame.size.height / 2
addSubview(dotView)
timeStampLbl.attributedText = NSAttributedString(string: timeStamp!, attributes: [NSAttributedString.Key.font: Fonts.poppinsRegular.customFont(size: 12), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsSuvaGrey()])
timeStampLbl.sizeToFit()
timeStampLbl.layoutIfNeeded()
timeStampLbl.lineBreakMode = .byClipping
addSubview(timeStampLbl)
makeConstraints()

timeStampLbl.attributedText = NSAttributedString(string: timeStamp, attributes: [NSAttributedString.Key.font: Fonts.poppinsRegular.customFont(size: 12), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsSuvaGrey()])

axis = NSLayoutConstraint.Axis.horizontal
distribution = .fillProportionally
translatesAutoresizingMaskIntoConstraints = false
addArrangedSubview(offerReqLbl)
addArrangedSubview(timeStampLbl)
}

func makeConstraints() {
offerReqLbl.makeSubview(of: self)
.width((offerReqLbl.attributedText?.size().width)!)
.height(16)
.right(to: \.leftAnchor, of: dotView, relation: .equal, constant: -7, priority: .required)
dotView.makeSubview(of: self)
.width(2)
.height(2)
.top(to: \.topAnchor, constant: 8)
.left(to: \.rightAnchor, of: offerReqLbl, relation: .equal, constant: 7, priority: .required)
.right(to: \.leftAnchor, of: timeStampLbl, relation: .equal, constant: -9, priority: .required)
timeStampLbl.makeSubview(of: self)
.width((timeStampLbl.attributedText?.size().width)!)
.height(16)
.left(to: \.rightAnchor, of: dotView, constant: 9)
required init(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
29 changes: 29 additions & 0 deletions FightPandemics/Features/Feed/Card/FeedViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,40 @@ import UIKit

class FeedViewCell: UICollectionViewCell {
static let reuseIdentifier = String(describing: self)

var characters = ["Link", "Zelda", "Ganondorf", "Midna"]

// The Offer Request Card (Feed)
let offerReqCard = OfferRequestCard()

let postCardTableView = UITableView()
Copy link
Collaborator

Choose a reason for hiding this comment

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

This tableView appears not used, we need to populate this tableView with list of offers, requests, or all as the case maybe. Let me know if you don't understand so that I can explain more.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I understand.
But I think that this implementation maybe should be in another ticket. What do you think?


override init(frame: CGRect) {
super.init(frame: frame)
}

required init?(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

func setupView() {
// Offer Request Card Constraints
offerReqCard.makeSubview(of: contentView)
.top(to: \.topAnchor, constant: 20)
.left(to: \.leftAnchor, constant: 20)
.right(to: \.rightAnchor, constant: -20)
.width(UIScreen.main.bounds.width)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't actually need this width constraint since you have already constrained the view to the left and right by some margin.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I have remove it.

.height(400)
}
}

extension FeedViewCell: UITableViewDataSource {
func tableView(_: UITableView, numberOfRowsInSection _: Int) -> Int {
return characters.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = characters[indexPath.row]
return cell
}
}
16 changes: 8 additions & 8 deletions FightPandemics/Features/Feed/FeedPost/Avatar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,15 @@
import UIKit

class Avatar: UIView {
func setUp(user: User, image: UIImage? = nil) {
func setUp(user: String, image: UIImage? = nil) {
if let image = image {
setUpWithImage(image: image)
} else {
setUpWithInitials(initials: user.initials)
setUpWithInitials(initials: user)
}
}

private func setUpWithInitials(initials: String?) {
frame.origin.x = 23
frame.origin.y = 23
frame.size.width = 35
frame.size.height = 35
let label = UILabel()
label.text = initials
label.textAlignment = .center
Expand All @@ -48,13 +44,17 @@ class Avatar: UIView {
label.frame.size.height = frame.size.height
label.clipsToBounds = true
label.layer.masksToBounds = true
label.layer.cornerRadius = frame.size.height / 2
label.font = UIFont(name: "System", size: 18)
label.layer.cornerRadius = 20
label.attributedText = NSAttributedString(string: initials!,
attributes: [NSAttributedString.Key.font: Fonts.poppinsMedium.customFont(size: 14), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNero()])
label.font = UIFont(name: "System", size: 14)
label.textColor = UIColor.fightPandemicsNeonBlue()
label.backgroundColor = UIColor.fightPandemicsGhostWhite()
label.layer.borderWidth = 1
label.layer.borderColor = UIColor.fightPandemicsNeonBlue().cgColor
label.makeSubview(of: self)
.width(40)
.height(40)
}

private func setUpWithImage(image: UIImage) {
Expand Down
41 changes: 22 additions & 19 deletions FightPandemics/Features/Feed/FeedPost/PostReactionButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,22 @@ import UIKit

enum PostReactionButtonType {
case like
case message
case comments
case send
}

class PostReactionButton: UIButton {
private var type: PostReactionButtonType

init(_ type: PostReactionButtonType) {
var count: Int? {
didSet {
if let count = count, type == .like || type == .comments {
setTitle(String(count), for: .normal)
}
}
}

init(type: PostReactionButtonType) {
self.type = type
super.init(frame: .zero)
configureButton()
Expand All @@ -45,37 +53,32 @@ class PostReactionButton: UIButton {
fatalError("init(coder:) has not been implemented")
}

var count: Int? {
didSet {
if let count = count, type == .like || type == .message {
setTitle(String(count), for: .normal)
}
}
}

@objc func tap() {
isSelected.toggle()
}

private func configureButton() {
translatesAutoresizingMaskIntoConstraints = false
let rightPadding: CGFloat
// translatesAutoresizingMaskIntoConstraints = false
// let rightPadding: CGFloat

// backgroundColor = .yellow
stavares843 marked this conversation as resolved.
Show resolved Hide resolved

imageView?.contentMode = .scaleAspectFit
switch type {
case .like:
rightPadding = 9.8
// rightPadding = 0 // 9.8
stavares843 marked this conversation as resolved.
Show resolved Hide resolved
setImage(#imageLiteral(resourceName: "heart"), for: .normal)
setImage(#imageLiteral(resourceName: "heart_filled"), for: .selected)
case .message:
rightPadding = 11.8
case .comments:
// rightPadding = 11.8
setImage(#imageLiteral(resourceName: "message-square"), for: .normal)
case .send:
rightPadding = 0.0
// rightPadding = 0.0
setImage(#imageLiteral(resourceName: "send"), for: .normal)
}
imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: rightPadding)
titleLabel?.font = Fonts.poppinsRegular.customFont(size: 14)
setTitleColor(#colorLiteral(red: 0.5764705882, green: 0.5764705882, blue: 0.5764705882, alpha: 1), for: .normal)
// imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
// titleLabel?.font = Fonts.poppinsRegular.customFont(size: 14)
// setTitleColor(#colorLiteral(red: 0.5764705882, green: 0.5764705882, blue: 0.5764705882, alpha: 1), for: .normal)
addTarget(self, action: #selector(tap), for: .touchUpInside)
}
}
Loading