From de316dc88c8de4b0d7c4d5c8d840720300375a2f Mon Sep 17 00:00:00 2001 From: Luko Date: Tue, 16 Jun 2020 00:12:14 -0300 Subject: [PATCH 1/3] feat: Offers Requests User Card --- .../OfferRequestCard/Body-OfferReqCard.swift | 27 ++++++ .../Footer-OfferReqCard.swift | 27 ++++++ .../Header-OfferReqCard.swift | 27 ++++++ .../OfferRequestCard/OfferRequestCard.swift | 88 +++++++++++++++++++ .../Subheader-OfferReqCard.swift | 27 ++++++ 5 files changed, 196 insertions(+) create mode 100644 FightPandemics/Features/Feed/OfferRequestCard/Body-OfferReqCard.swift create mode 100644 FightPandemics/Features/Feed/OfferRequestCard/Footer-OfferReqCard.swift create mode 100644 FightPandemics/Features/Feed/OfferRequestCard/Header-OfferReqCard.swift create mode 100644 FightPandemics/Features/Feed/OfferRequestCard/OfferRequestCard.swift create mode 100644 FightPandemics/Features/Feed/OfferRequestCard/Subheader-OfferReqCard.swift diff --git a/FightPandemics/Features/Feed/OfferRequestCard/Body-OfferReqCard.swift b/FightPandemics/Features/Feed/OfferRequestCard/Body-OfferReqCard.swift new file mode 100644 index 0000000..de73371 --- /dev/null +++ b/FightPandemics/Features/Feed/OfferRequestCard/Body-OfferReqCard.swift @@ -0,0 +1,27 @@ +// +// Body-OfferReqCard.swift +// FightPandemics +// +// Created by Luciano Schillagi on 6/15/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/OfferRequestCard/Footer-OfferReqCard.swift b/FightPandemics/Features/Feed/OfferRequestCard/Footer-OfferReqCard.swift new file mode 100644 index 0000000..9384de5 --- /dev/null +++ b/FightPandemics/Features/Feed/OfferRequestCard/Footer-OfferReqCard.swift @@ -0,0 +1,27 @@ +// +// Footer-OfferReqCard.swift +// FightPandemics +// +// Created by Luciano Schillagi on 6/15/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/OfferRequestCard/Header-OfferReqCard.swift b/FightPandemics/Features/Feed/OfferRequestCard/Header-OfferReqCard.swift new file mode 100644 index 0000000..b991fb8 --- /dev/null +++ b/FightPandemics/Features/Feed/OfferRequestCard/Header-OfferReqCard.swift @@ -0,0 +1,27 @@ +// +// Header-OfferReqCard.swift +// FightPandemics +// +// Created by Luciano Schillagi on 6/15/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/OfferRequestCard/OfferRequestCard.swift b/FightPandemics/Features/Feed/OfferRequestCard/OfferRequestCard.swift new file mode 100644 index 0000000..692d4cf --- /dev/null +++ b/FightPandemics/Features/Feed/OfferRequestCard/OfferRequestCard.swift @@ -0,0 +1,88 @@ +// +// Offer-Request-Card.swift +// FightPandemics +// +// Created by Luciano Schillagi on 6/15/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 OfferRequestCard: UIStackView { + // MARK: Properties 📥 + + var header = HeaderOfferRequestCard(postedDate: "Posted 14hrs ago", + offer: "Offers", + supplyType: "Medical Supplies") + + var subHeader = SubHeaderOfferRequestCard(iniciales: "AM", + nombre: "Ana Muller", + ubicacion: "Berlin, Germany") + + var body = BodyOfferRequestCard(tit: "I have 100 face Masks to give away", + message: "I have a small store and I would like to give away 100 mask but I don’t know where, please contact me if you need them. I have a small store and I would like to give away 100 mask but I don’t know where, please contact me if you need them. please contact m ...") + var footer = FooterOfferRequestCard(numOfLikes: 4, numOfComments: 7) + + override init(frame _: CGRect) { + super.init(frame: .zero) + } + + init() { + super.init(frame: .zero) + + header.translatesAutoresizingMaskIntoConstraints = false + subHeader.translatesAutoresizingMaskIntoConstraints = false + body.translatesAutoresizingMaskIntoConstraints = false + footer.translatesAutoresizingMaskIntoConstraints = false + + axis = NSLayoutConstraint.Axis.vertical + distribution = UIStackView.Distribution.fillProportionally + translatesAutoresizingMaskIntoConstraints = false + addArrangedSubview(header) + addArrangedSubview(subHeader) + addArrangedSubview(body) + addArrangedSubview(footer) + } + + required init(coder _: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + // MARK: UI Methods ⚙️ + + func setUp() { + header.translatesAutoresizingMaskIntoConstraints = false + subHeader.translatesAutoresizingMaskIntoConstraints = false + body.translatesAutoresizingMaskIntoConstraints = false + footer.translatesAutoresizingMaskIntoConstraints = false + + // Configure the vertical stack + axis = NSLayoutConstraint.Axis.vertical + distribution = UIStackView.Distribution.fillProportionally + alignment = .fill + translatesAutoresizingMaskIntoConstraints = false + addArrangedSubview(header) + addArrangedSubview(subHeader) + addArrangedSubview(body) + addArrangedSubview(footer) + } +} + diff --git a/FightPandemics/Features/Feed/OfferRequestCard/Subheader-OfferReqCard.swift b/FightPandemics/Features/Feed/OfferRequestCard/Subheader-OfferReqCard.swift new file mode 100644 index 0000000..e39f122 --- /dev/null +++ b/FightPandemics/Features/Feed/OfferRequestCard/Subheader-OfferReqCard.swift @@ -0,0 +1,27 @@ +// +// Subheader-OfferReqCard.swift +// FightPandemics +// +// Created by Luciano Schillagi on 6/15/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 dff6038ff90083b99a7aafbf1e220b2a75ec770c Mon Sep 17 00:00:00 2001 From: Luko Date: Tue, 16 Jun 2020 00:27:56 -0300 Subject: [PATCH 2/3] feat: Offers Requests User Card --- FightPandemics.xcodeproj/project.pbxproj | 28 +++++++ .../Features/Feed/Card/FeedCatTag.swift | 33 +++++---- .../Features/Feed/Card/FeedMenuCell.swift | 1 + .../Features/Feed/Card/FeedOfferReqTime.swift | 56 ++++---------- .../Features/Feed/Card/FeedViewCell.swift | 26 +++++++ .../Feed/FeedPost/PostReactionButton.swift | 41 ++++++----- .../Features/Feed/FeedViewController.swift | 6 +- .../OfferRequestCard/Body-OfferReqCard.swift | 32 +++++++- .../Footer-OfferReqCard.swift | 60 ++++++++++++++- .../Header-OfferReqCard.swift | 20 ++++- .../OfferRequestCard/OfferRequestCard.swift | 15 +--- .../Subheader-OfferReqCard.swift | 73 ++++++++++++++++++- .../Features/Shared/PillButton.swift | 11 ++- Podfile.lock | 3 +- 14 files changed, 303 insertions(+), 102 deletions(-) diff --git a/FightPandemics.xcodeproj/project.pbxproj b/FightPandemics.xcodeproj/project.pbxproj index c4038d7..9de960c 100644 --- a/FightPandemics.xcodeproj/project.pbxproj +++ b/FightPandemics.xcodeproj/project.pbxproj @@ -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 */; }; @@ -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 = ""; }; 976A98CA24782B8600604FFA /* GeneratedImagesList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeneratedImagesList.swift; sourceTree = ""; }; 976A98CC24782BC500604FFA /* GeneratedStoryboardsList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeneratedStoryboardsList.swift; sourceTree = ""; }; + A60FA8AC2498618B00B790DB /* OfferRequestCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OfferRequestCard.swift; sourceTree = ""; }; + A60FA8AE2498621900B790DB /* Header-OfferReqCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Header-OfferReqCard.swift"; sourceTree = ""; }; + A60FA8B02498625200B790DB /* Subheader-OfferReqCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Subheader-OfferReqCard.swift"; sourceTree = ""; }; + A60FA8B22498627F00B790DB /* Body-OfferReqCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Body-OfferReqCard.swift"; sourceTree = ""; }; + A60FA8B4249862AD00B790DB /* Footer-OfferReqCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Footer-OfferReqCard.swift"; sourceTree = ""; }; A681817B2482050A00E7EA43 /* PillButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PillButton.swift; sourceTree = ""; }; 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 = ""; }; @@ -280,6 +290,7 @@ 2F0420F5246A0D0D005FB1D0 /* Feed */ = { isa = PBXGroup; children = ( + A60FA8AB2498612200B790DB /* OfferRequestCard */, C018DD872479C26E00EEB3FC /* Card */, 2F0420F6246A0E71005FB1D0 /* Feed.storyboard */, 2F0420FA246A0EBA005FB1D0 /* FeedPost */, @@ -620,6 +631,18 @@ path = Constant; sourceTree = ""; }; + 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 = ""; + }; C013ACD8246FF3C500F22BE7 /* OfferRequest */ = { isa = PBXGroup; children = ( @@ -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 */, @@ -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 */, @@ -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 */, diff --git a/FightPandemics/Features/Feed/Card/FeedCatTag.swift b/FightPandemics/Features/Feed/Card/FeedCatTag.swift index 2a18ebd..24a47b5 100644 --- a/FightPandemics/Features/Feed/Card/FeedCatTag.swift +++ b/FightPandemics/Features/Feed/Card/FeedCatTag.swift @@ -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) } 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) - } } diff --git a/FightPandemics/Features/Feed/Card/FeedMenuCell.swift b/FightPandemics/Features/Feed/Card/FeedMenuCell.swift index 418a7a5..3e034ac 100644 --- a/FightPandemics/Features/Feed/Card/FeedMenuCell.swift +++ b/FightPandemics/Features/Feed/Card/FeedMenuCell.swift @@ -28,6 +28,7 @@ import UIKit class FeedMenuCell: UICollectionViewCell { static let reuseIdentifier = String(describing: self) + override init(frame: CGRect) { super.init(frame: frame) setupViews() diff --git a/FightPandemics/Features/Feed/Card/FeedOfferReqTime.swift b/FightPandemics/Features/Feed/Card/FeedOfferReqTime.swift index 3acdd1d..0546942 100644 --- a/FightPandemics/Features/Feed/Card/FeedOfferReqTime.swift +++ b/FightPandemics/Features/Feed/Card/FeedOfferReqTime.swift @@ -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") } } diff --git a/FightPandemics/Features/Feed/Card/FeedViewCell.swift b/FightPandemics/Features/Feed/Card/FeedViewCell.swift index ccf5080..f39dcf2 100644 --- a/FightPandemics/Features/Feed/Card/FeedViewCell.swift +++ b/FightPandemics/Features/Feed/Card/FeedViewCell.swift @@ -28,6 +28,13 @@ import UIKit class FeedViewCell: UICollectionViewCell { static let reuseIdentifier = String(describing: self) + + var characters = ["Link", "Zelda", "Ganondorf", "Midna"] + + let offerReqCard = OfferRequestCard() + + let postCardTableView = UITableView() + override init(frame: CGRect) { super.init(frame: frame) } @@ -35,4 +42,23 @@ class FeedViewCell: UICollectionViewCell { required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } + + func setupView() { + offerReqCard.makeSubview(of: contentView) + .pinToEdges(withInsets: UIEdgeInsets(top: 20, + left: 20, + bottom: 20, + right: -20)) + } +} + +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 + } } diff --git a/FightPandemics/Features/Feed/FeedPost/PostReactionButton.swift b/FightPandemics/Features/Feed/FeedPost/PostReactionButton.swift index 4c34957..b55416e 100644 --- a/FightPandemics/Features/Feed/FeedPost/PostReactionButton.swift +++ b/FightPandemics/Features/Feed/FeedPost/PostReactionButton.swift @@ -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() @@ -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 + imageView?.contentMode = .scaleAspectFit switch type { case .like: - rightPadding = 9.8 +// rightPadding = 0 // 9.8 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) } } diff --git a/FightPandemics/Features/Feed/FeedViewController.swift b/FightPandemics/Features/Feed/FeedViewController.swift index 161724c..33a77f7 100644 --- a/FightPandemics/Features/Feed/FeedViewController.swift +++ b/FightPandemics/Features/Feed/FeedViewController.swift @@ -91,11 +91,11 @@ extension FeedViewController: UICollectionViewDataSource { } if indexPath.row == 0 { - cell.backgroundColor = .orange + cell.setupView() } else if indexPath.row == 1 { - cell.backgroundColor = .green + cell.setupView() } else { - cell.backgroundColor = .purple + cell.setupView() } return cell } diff --git a/FightPandemics/Features/Feed/OfferRequestCard/Body-OfferReqCard.swift b/FightPandemics/Features/Feed/OfferRequestCard/Body-OfferReqCard.swift index de73371..9708e24 100644 --- a/FightPandemics/Features/Feed/OfferRequestCard/Body-OfferReqCard.swift +++ b/FightPandemics/Features/Feed/OfferRequestCard/Body-OfferReqCard.swift @@ -24,4 +24,34 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -import Foundation +import UIKit + +class BodyOfferRequestCard: UIStackView { + var title = UILabel() + var subTitle = UITextView() + + init(tit: String, message: String) { + super.init(frame: .zero) + + title.frame = CGRect(x: 0, y: 400, width: 200, height: 200) + title.attributedText = NSAttributedString(string: tit, + attributes: [NSAttributedString.Key.font: Fonts.poppinsBold.customFont(size: 22), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNero()]) + title.widthAnchor.constraint(equalToConstant: title.frame.width).isActive = true + title.heightAnchor.constraint(equalToConstant: 50.0).isActive = true + + subTitle.frame = CGRect(x: 0, y: 400, width: 200, height: 600) + subTitle.attributedText = NSAttributedString(string: message, + attributes: [NSAttributedString.Key.font: Fonts.poppinsRegular.customFont(size: 14), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNero()]) + subTitle.widthAnchor.constraint(equalToConstant: subTitle.frame.width).isActive = true + subTitle.heightAnchor.constraint(equalToConstant: 200).isActive = true + + axis = NSLayoutConstraint.Axis.vertical + translatesAutoresizingMaskIntoConstraints = false + addArrangedSubview(title) + addArrangedSubview(subTitle) + } + + required init(coder _: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} diff --git a/FightPandemics/Features/Feed/OfferRequestCard/Footer-OfferReqCard.swift b/FightPandemics/Features/Feed/OfferRequestCard/Footer-OfferReqCard.swift index 9384de5..85add7c 100644 --- a/FightPandemics/Features/Feed/OfferRequestCard/Footer-OfferReqCard.swift +++ b/FightPandemics/Features/Feed/OfferRequestCard/Footer-OfferReqCard.swift @@ -24,4 +24,62 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -import Foundation +import UIKit + +class FooterOfferRequestCard: UIStackView { + private var likeBtn = PostReactionButton(type: .like) + private var commentsBtn = PostReactionButton(type: .comments) + private var sendBtn = PostReactionButton(type: .send) + + var numberOfLikes = UILabel() + var numberOfComments = UILabel() + + private var likeStack = UIStackView() + private var commentStack = UIStackView() + + init(numOfLikes: Int, numOfComments: Int) { + super.init(frame: .zero) + + likeBtn.translatesAutoresizingMaskIntoConstraints = false + commentsBtn.translatesAutoresizingMaskIntoConstraints = false + sendBtn.translatesAutoresizingMaskIntoConstraints = false + numberOfLikes.translatesAutoresizingMaskIntoConstraints = false + numberOfComments.translatesAutoresizingMaskIntoConstraints = false + + numberOfLikes.text = String(numOfLikes) + numberOfComments.text = String(numOfComments) + + likeStack.axis = NSLayoutConstraint.Axis.horizontal + likeStack.distribution = UIStackView.Distribution.fillProportionally + // likeStack.frame = CGRect(x: 0, y: 0, width: 800, height: 200) + likeStack.translatesAutoresizingMaskIntoConstraints = false + likeStack.addArrangedSubview(likeBtn) + likeStack.addArrangedSubview(numberOfLikes) + + commentStack.axis = NSLayoutConstraint.Axis.horizontal + commentStack.distribution = UIStackView.Distribution.fillProportionally + // commentStack.frame = CGRect(x: 0, y: 0, width: 80, height: 200) + commentStack.translatesAutoresizingMaskIntoConstraints = false + commentStack.addArrangedSubview(commentsBtn) + commentStack.addArrangedSubview(numberOfComments) + + axis = NSLayoutConstraint.Axis.horizontal + distribution = UIStackView.Distribution.fillProportionally + spacing = 0 + translatesAutoresizingMaskIntoConstraints = false + + addArrangedSubview(likeStack) + addArrangedSubview(commentStack) + addArrangedSubview(sendBtn) + + // makeSubview(of: self) + // .left(to: \.leftAnchor, constant: 0) + // .top(to: \.topAnchor, constant: 0) + // .right(to: \.rightAnchor, constant: -80) + // .bottom(to: \.bottomAnchor, constant: 0) + } + + required init(coder _: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} diff --git a/FightPandemics/Features/Feed/OfferRequestCard/Header-OfferReqCard.swift b/FightPandemics/Features/Feed/OfferRequestCard/Header-OfferReqCard.swift index b991fb8..139c565 100644 --- a/FightPandemics/Features/Feed/OfferRequestCard/Header-OfferReqCard.swift +++ b/FightPandemics/Features/Feed/OfferRequestCard/Header-OfferReqCard.swift @@ -24,4 +24,22 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -import Foundation +import UIKit + +class HeaderOfferRequestCard: UIStackView { + let feedOfferRequestTime = FeedOfferReqTime(offerReq: .offers, timeStamp: "Posted 14hrs Ago") + let feedCategoryTag = FeedCatTag(categoryTagTxt: "Medical Supplies") + + init(postedDate _: String, offer _: String, supplyType _: String) { + super.init(frame: .zero) + axis = NSLayoutConstraint.Axis.horizontal + distribution = UIStackView.Distribution.fillProportionally + translatesAutoresizingMaskIntoConstraints = false + addArrangedSubview(feedOfferRequestTime) + addArrangedSubview(feedCategoryTag) + } + + required init(coder _: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} diff --git a/FightPandemics/Features/Feed/OfferRequestCard/OfferRequestCard.swift b/FightPandemics/Features/Feed/OfferRequestCard/OfferRequestCard.swift index 692d4cf..39c69cf 100644 --- a/FightPandemics/Features/Feed/OfferRequestCard/OfferRequestCard.swift +++ b/FightPandemics/Features/Feed/OfferRequestCard/OfferRequestCard.swift @@ -1,5 +1,5 @@ // -// Offer-Request-Card.swift +// OfferRequestCard.swift // FightPandemics // // Created by Luciano Schillagi on 6/15/20. @@ -27,15 +27,13 @@ import UIKit class OfferRequestCard: UIStackView { - // MARK: Properties 📥 - var header = HeaderOfferRequestCard(postedDate: "Posted 14hrs ago", offer: "Offers", supplyType: "Medical Supplies") - var subHeader = SubHeaderOfferRequestCard(iniciales: "AM", - nombre: "Ana Muller", - ubicacion: "Berlin, Germany") + var subHeader = SubHeaderOfferRequestCard(initials: "AM", + name: "Ana Muller", + location: "Berlin, Germany") var body = BodyOfferRequestCard(tit: "I have 100 face Masks to give away", message: "I have a small store and I would like to give away 100 mask but I don’t know where, please contact me if you need them. I have a small store and I would like to give away 100 mask but I don’t know where, please contact me if you need them. please contact m ...") @@ -66,15 +64,11 @@ class OfferRequestCard: UIStackView { fatalError("init(coder:) has not been implemented") } - // MARK: UI Methods ⚙️ - func setUp() { header.translatesAutoresizingMaskIntoConstraints = false subHeader.translatesAutoresizingMaskIntoConstraints = false body.translatesAutoresizingMaskIntoConstraints = false footer.translatesAutoresizingMaskIntoConstraints = false - - // Configure the vertical stack axis = NSLayoutConstraint.Axis.vertical distribution = UIStackView.Distribution.fillProportionally alignment = .fill @@ -85,4 +79,3 @@ class OfferRequestCard: UIStackView { addArrangedSubview(footer) } } - diff --git a/FightPandemics/Features/Feed/OfferRequestCard/Subheader-OfferReqCard.swift b/FightPandemics/Features/Feed/OfferRequestCard/Subheader-OfferReqCard.swift index e39f122..b1941c8 100644 --- a/FightPandemics/Features/Feed/OfferRequestCard/Subheader-OfferReqCard.swift +++ b/FightPandemics/Features/Feed/OfferRequestCard/Subheader-OfferReqCard.swift @@ -24,4 +24,75 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -import Foundation +import UIKit + +class SubHeaderOfferRequestCard: UIStackView { + let userInitials = UILabel() + let userName = UILabel() + let userLocationName = UILabel() + let userLocationStackView = UIStackView() + let userNameAndLocationStackView = UIStackView() + + init(initials: String, name: String, location: String) { + super.init(frame: .zero) + + // User Initials + let userInitialsSize = CGSize(width: 100, height: 500) + userInitials.frame.size = userInitialsSize + userInitials.layer.cornerRadius = frame.size.height / 2 + userInitials.text = initials + userInitials.textAlignment = .center + userInitials.backgroundColor = .fightPandemicsGhostWhite() + userInitials.layer.borderWidth = 1 + userInitials.layer.borderColor = UIColor.fightPandemicsNeonBlue().cgColor + userInitials.translatesAutoresizingMaskIntoConstraints = false + + // User Name + userName.translatesAutoresizingMaskIntoConstraints = false + userName.attributedText = NSAttributedString(string: name, + attributes: [NSAttributedString.Key.font: Fonts.poppinsMedium.customFont(size: 22), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNero()]) + + // Point + let point = UIImage(systemName: "circle.fill") + let pointImageView = UIImageView(image: point) + let size = CGSize(width: 10, height: 10) + pointImageView.size(size) + pointImageView.translatesAutoresizingMaskIntoConstraints = false + + // User Location + userLocationName.translatesAutoresizingMaskIntoConstraints = false + userLocationName.attributedText = NSAttributedString(string: location, + attributes: [NSAttributedString.Key.font: Fonts.poppinsRegular.customFont(size: 11), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNero()]) + + // Stacks + userLocationStackView.translatesAutoresizingMaskIntoConstraints = false + userLocationStackView.distribution = .fillProportionally + userLocationStackView.axis = .horizontal + userLocationStackView.addArrangedSubview(pointImageView) + userLocationStackView.addArrangedSubview(userLocationName) + + userNameAndLocationStackView.translatesAutoresizingMaskIntoConstraints = false + userNameAndLocationStackView.axis = .vertical + userNameAndLocationStackView.distribution = .fillProportionally + userNameAndLocationStackView.addArrangedSubview(userName) + userNameAndLocationStackView.addArrangedSubview(userLocationStackView) + + translatesAutoresizingMaskIntoConstraints = false + axis = .horizontal + spacing = 10 + distribution = .fillProportionally + + addArrangedSubview(userInitials) + addArrangedSubview(userNameAndLocationStackView) + +// makeSubview(of: self) +// .left(to: \.leftAnchor, constant: 0) +// .top(to: \.topAnchor, constant: 0) +// .right(to: \.rightAnchor, constant: -80) +// .bottom(to: \.bottomAnchor, constant: 0) + } + + required init(coder _: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} diff --git a/FightPandemics/Features/Shared/PillButton.swift b/FightPandemics/Features/Shared/PillButton.swift index 4395a7b..56b6746 100644 --- a/FightPandemics/Features/Shared/PillButton.swift +++ b/FightPandemics/Features/Shared/PillButton.swift @@ -27,7 +27,6 @@ import UIKit class PillButton: UIButton { - override init(frame: CGRect) { super.init(frame: frame) } @@ -39,24 +38,24 @@ class PillButton: UIButton { enum PillButtonType { case regular, outline, bold } - + init(buttonType: PillButtonType, title: String) { super.init(frame: .zero) setTitle(title, for: .normal) setTitleColor(.white, for: .normal) backgroundColor = .blue layer.cornerRadius = 25 - + switch buttonType { - case .regular: + case .regular: titleLabel?.font = Fonts.poppinsRegular.customFont(size: 22) - case .outline: + case .outline: titleLabel?.font = Fonts.poppinsRegular.customFont(size: 22) setTitleColor(.blue, for: .normal) layer.borderWidth = 1 layer.borderColor = UIColor.blue.cgColor backgroundColor = .clear - case .bold: + case .bold: titleLabel?.font = Fonts.poppinsBold.customFont(size: 22) } } diff --git a/Podfile.lock b/Podfile.lock index c8949a4..cafcc70 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -9,11 +9,10 @@ DEPENDENCIES: - SwiftLint SPEC REPOS: - https://github.com/CocoaPods/Specs.git: - - SwiftLint trunk: - SwiftFormat - SwiftGen + - SwiftLint SPEC CHECKSUMS: SwiftFormat: b72e592ea0979aeee53f6052abff291181364933 From e77722fa8d103b2cffb9f6b978c28a535d934740 Mon Sep 17 00:00:00 2001 From: Luko Date: Mon, 29 Jun 2020 23:14:37 -0300 Subject: [PATCH 3/3] feat: Create offer request user card --- .../Features/Feed/Card/FeedViewCell.swift | 11 ++-- .../Features/Feed/FeedPost/Avatar.swift | 16 ++--- .../Feed/FeedPrototypeViewController.swift | 48 +++++++------- .../OfferRequestCard/Body-OfferReqCard.swift | 60 +++++++++++++----- .../Footer-OfferReqCard.swift | 54 ++++++++-------- .../Header-OfferReqCard.swift | 5 +- .../OfferRequestCard/OfferRequestCard.swift | 63 +++++++++---------- .../Subheader-OfferReqCard.swift | 49 ++++++++------- 8 files changed, 169 insertions(+), 137 deletions(-) diff --git a/FightPandemics/Features/Feed/Card/FeedViewCell.swift b/FightPandemics/Features/Feed/Card/FeedViewCell.swift index f39dcf2..df799ab 100644 --- a/FightPandemics/Features/Feed/Card/FeedViewCell.swift +++ b/FightPandemics/Features/Feed/Card/FeedViewCell.swift @@ -31,6 +31,7 @@ class FeedViewCell: UICollectionViewCell { var characters = ["Link", "Zelda", "Ganondorf", "Midna"] + // The Offer Request Card (Feed) let offerReqCard = OfferRequestCard() let postCardTableView = UITableView() @@ -44,11 +45,13 @@ class FeedViewCell: UICollectionViewCell { } func setupView() { + // Offer Request Card Constraints offerReqCard.makeSubview(of: contentView) - .pinToEdges(withInsets: UIEdgeInsets(top: 20, - left: 20, - bottom: 20, - right: -20)) + .top(to: \.topAnchor, constant: 20) + .left(to: \.leftAnchor, constant: 20) + .right(to: \.rightAnchor, constant: -20) + .width(UIScreen.main.bounds.width) + .height(400) } } diff --git a/FightPandemics/Features/Feed/FeedPost/Avatar.swift b/FightPandemics/Features/Feed/FeedPost/Avatar.swift index 153a251..1d49334 100644 --- a/FightPandemics/Features/Feed/FeedPost/Avatar.swift +++ b/FightPandemics/Features/Feed/FeedPost/Avatar.swift @@ -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 @@ -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) { diff --git a/FightPandemics/Features/Feed/FeedPrototypeViewController.swift b/FightPandemics/Features/Feed/FeedPrototypeViewController.swift index 1e18ef4..0156826 100644 --- a/FightPandemics/Features/Feed/FeedPrototypeViewController.swift +++ b/FightPandemics/Features/Feed/FeedPrototypeViewController.swift @@ -39,30 +39,30 @@ class FeedPrototypeViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - setupUI() +// setupUI() } - private func setupUI() { - view.backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1) - - avatar.setUp(user: mockUser, image: nil) - avatarView = AvatarView() - avatarView.setUp(user: mockUser, avatar: avatar) - indivOrg.setUp() - visibility.setUp() - - let body = "Does anyone have an extra pack of disinfecting Clorox wipes? I would be very grateful if you could sell me one. Two people in our family have chronic pulmonary diseases, including my son. We are isolated, but my husband might infect us, as he works with people a lot." - let title = "Disinfecting clorox wipes needed" - - feedPost.setUp(title: title, body: body + body, type: "Medical Supplies") - postFooter.setUp(likeNum: 12, commentNum: 13, sendNum: 14) - - let firstView = UIView() - firstView.frame = CGRect(x: 0, y: 50, width: UIScreen.main.bounds.width, height: 600) - firstView.makeSubview(of: view) - visibility.makeSubview(of: firstView) - let secondView = UIView() - secondView.frame = CGRect(x: 0, y: 530, width: UIScreen.main.bounds.width - 47, height: 300) - view.addSubview(secondView) - } +// private func setupUI() { +// view.backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1) +// +// avatar.setUp(user: mockUser, image: nil) +// avatarView = AvatarView() +// avatarView.setUp(user: mockUser, avatar: avatar) +// indivOrg.setUp() +// visibility.setUp() +// +// let body = "Does anyone have an extra pack of disinfecting Clorox wipes? I would be very grateful if you could sell me one. Two people in our family have chronic pulmonary diseases, including my son. We are isolated, but my husband might infect us, as he works with people a lot." +// let title = "Disinfecting clorox wipes needed" +// +// feedPost.setUp(title: title, body: body + body, type: "Medical Supplies") +// postFooter.setUp(likeNum: 12, commentNum: 13, sendNum: 14) +// +// let firstView = UIView() +// firstView.frame = CGRect(x: 0, y: 50, width: UIScreen.main.bounds.width, height: 600) +// firstView.makeSubview(of: view) +// visibility.makeSubview(of: firstView) +// let secondView = UIView() +// secondView.frame = CGRect(x: 0, y: 530, width: UIScreen.main.bounds.width - 47, height: 300) +// view.addSubview(secondView) +// } } diff --git a/FightPandemics/Features/Feed/OfferRequestCard/Body-OfferReqCard.swift b/FightPandemics/Features/Feed/OfferRequestCard/Body-OfferReqCard.swift index 9708e24..ea973d4 100644 --- a/FightPandemics/Features/Feed/OfferRequestCard/Body-OfferReqCard.swift +++ b/FightPandemics/Features/Feed/OfferRequestCard/Body-OfferReqCard.swift @@ -27,28 +27,58 @@ import UIKit class BodyOfferRequestCard: UIStackView { - var title = UILabel() - var subTitle = UITextView() + + private var titleTextView = UITextView() + private var contentTextView = UITextView() + private var moreBtn = UIButton() init(tit: String, message: String) { super.init(frame: .zero) - title.frame = CGRect(x: 0, y: 400, width: 200, height: 200) - title.attributedText = NSAttributedString(string: tit, - attributes: [NSAttributedString.Key.font: Fonts.poppinsBold.customFont(size: 22), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNero()]) - title.widthAnchor.constraint(equalToConstant: title.frame.width).isActive = true - title.heightAnchor.constraint(equalToConstant: 50.0).isActive = true + titleTextView.attributedText = NSAttributedString(string: tit, + attributes: [.font: Fonts.poppinsBold.customFont(size: 22), + .foregroundColor: UIColor.fightPandemicsNero()]) + + contentTextView.attributedText = NSAttributedString(string: message, + attributes: [.font: Fonts.poppinsRegular.customFont(size: 14), .foregroundColor: UIColor.fightPandemicsNero()]) - subTitle.frame = CGRect(x: 0, y: 400, width: 200, height: 600) - subTitle.attributedText = NSAttributedString(string: message, - attributes: [NSAttributedString.Key.font: Fonts.poppinsRegular.customFont(size: 14), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNero()]) - subTitle.widthAnchor.constraint(equalToConstant: subTitle.frame.width).isActive = true - subTitle.heightAnchor.constraint(equalToConstant: 200).isActive = true + moreBtn.setTitle("FeedPostViewMoreCTA".localized, for: .normal) + moreBtn.setTitleColor(UIColor.fightPandemicsNeonBlue(), for: .normal) + moreBtn.titleLabel?.font = UIFont(name: "System", size: 14) - axis = NSLayoutConstraint.Axis.vertical + // Vertical Stack Config + axis = .vertical + distribution = .fillProportionally translatesAutoresizingMaskIntoConstraints = false - addArrangedSubview(title) - addArrangedSubview(subTitle) + addArrangedSubview(titleTextView) + addArrangedSubview(contentTextView) + addArrangedSubview(moreBtn) + + // Title Constraints + titleTextView.makeSubview(of: self) + .top(to: \.topAnchor, + relation: .equal, + constant: 8, + priority: .required) + .leading(to: \.leadingAnchor) + .width(UIScreen.main.bounds.width - 40) + .height(80) + + // Content Constraints + contentTextView.makeSubview(of: self) + .top(to: \.bottomAnchor, + of: titleTextView, + relation: .equal, + constant: 30, + priority: .required) + .leading(to: \.leadingAnchor) + .width(UIScreen.main.bounds.width) + .height(120) + + // Contraints to More Button + moreBtn.makeSubview(of: self) + .right(to: \.rightAnchor, constant: 270) + .bottom(to: \.bottomAnchor, constant: 10) } required init(coder _: NSCoder) { diff --git a/FightPandemics/Features/Feed/OfferRequestCard/Footer-OfferReqCard.swift b/FightPandemics/Features/Feed/OfferRequestCard/Footer-OfferReqCard.swift index 85add7c..276883e 100644 --- a/FightPandemics/Features/Feed/OfferRequestCard/Footer-OfferReqCard.swift +++ b/FightPandemics/Features/Feed/OfferRequestCard/Footer-OfferReqCard.swift @@ -27,56 +27,58 @@ import UIKit class FooterOfferRequestCard: UIStackView { - private var likeBtn = PostReactionButton(type: .like) - private var commentsBtn = PostReactionButton(type: .comments) - private var sendBtn = PostReactionButton(type: .send) - - var numberOfLikes = UILabel() - var numberOfComments = UILabel() + // Like private var likeStack = UIStackView() + private var likeBtn = PostReactionButton(type: .like) + private var numberOfLikes = UILabel() + // Comment private var commentStack = UIStackView() + private var commentsBtn = PostReactionButton(type: .comments) + private var numberOfComments = UILabel() + // Send + private var sendBtn = PostReactionButton(type: .send) init(numOfLikes: Int, numOfComments: Int) { super.init(frame: .zero) + translatesAutoresizingMaskIntoConstraints = false + likeStack.translatesAutoresizingMaskIntoConstraints = false likeBtn.translatesAutoresizingMaskIntoConstraints = false - commentsBtn.translatesAutoresizingMaskIntoConstraints = false - sendBtn.translatesAutoresizingMaskIntoConstraints = false numberOfLikes.translatesAutoresizingMaskIntoConstraints = false + commentStack.translatesAutoresizingMaskIntoConstraints = false + commentsBtn.translatesAutoresizingMaskIntoConstraints = false numberOfComments.translatesAutoresizingMaskIntoConstraints = false + sendBtn.translatesAutoresizingMaskIntoConstraints = false + // Pass the number of likes and comments numberOfLikes.text = String(numOfLikes) numberOfComments.text = String(numOfComments) - likeStack.axis = NSLayoutConstraint.Axis.horizontal - likeStack.distribution = UIStackView.Distribution.fillProportionally - // likeStack.frame = CGRect(x: 0, y: 0, width: 800, height: 200) - likeStack.translatesAutoresizingMaskIntoConstraints = false + // Like Stack Config + likeStack.axis = .horizontal + likeStack.distribution = .fillProportionally + + // Add arranged subviews to Like Stack likeStack.addArrangedSubview(likeBtn) likeStack.addArrangedSubview(numberOfLikes) - commentStack.axis = NSLayoutConstraint.Axis.horizontal - commentStack.distribution = UIStackView.Distribution.fillProportionally - // commentStack.frame = CGRect(x: 0, y: 0, width: 80, height: 200) - commentStack.translatesAutoresizingMaskIntoConstraints = false + // Comment Stack Config + commentStack.axis = .horizontal + commentStack.distribution = .fillProportionally + + // Add arranged subviews to Comment Stack commentStack.addArrangedSubview(commentsBtn) commentStack.addArrangedSubview(numberOfComments) - axis = NSLayoutConstraint.Axis.horizontal - distribution = UIStackView.Distribution.fillProportionally - spacing = 0 - translatesAutoresizingMaskIntoConstraints = false + // Footer Stack Config + axis = .horizontal + distribution = .fillProportionally + // Add arranged subviews to Footer Stack View addArrangedSubview(likeStack) addArrangedSubview(commentStack) addArrangedSubview(sendBtn) - - // makeSubview(of: self) - // .left(to: \.leftAnchor, constant: 0) - // .top(to: \.topAnchor, constant: 0) - // .right(to: \.rightAnchor, constant: -80) - // .bottom(to: \.bottomAnchor, constant: 0) } required init(coder _: NSCoder) { diff --git a/FightPandemics/Features/Feed/OfferRequestCard/Header-OfferReqCard.swift b/FightPandemics/Features/Feed/OfferRequestCard/Header-OfferReqCard.swift index 139c565..8340358 100644 --- a/FightPandemics/Features/Feed/OfferRequestCard/Header-OfferReqCard.swift +++ b/FightPandemics/Features/Feed/OfferRequestCard/Header-OfferReqCard.swift @@ -27,13 +27,14 @@ import UIKit class HeaderOfferRequestCard: UIStackView { + let feedOfferRequestTime = FeedOfferReqTime(offerReq: .offers, timeStamp: "Posted 14hrs Ago") let feedCategoryTag = FeedCatTag(categoryTagTxt: "Medical Supplies") init(postedDate _: String, offer _: String, supplyType _: String) { super.init(frame: .zero) - axis = NSLayoutConstraint.Axis.horizontal - distribution = UIStackView.Distribution.fillProportionally + axis = .horizontal + distribution = .fillProportionally translatesAutoresizingMaskIntoConstraints = false addArrangedSubview(feedOfferRequestTime) addArrangedSubview(feedCategoryTag) diff --git a/FightPandemics/Features/Feed/OfferRequestCard/OfferRequestCard.swift b/FightPandemics/Features/Feed/OfferRequestCard/OfferRequestCard.swift index 39c69cf..cbe0fb7 100644 --- a/FightPandemics/Features/Feed/OfferRequestCard/OfferRequestCard.swift +++ b/FightPandemics/Features/Feed/OfferRequestCard/OfferRequestCard.swift @@ -27,17 +27,20 @@ import UIKit class OfferRequestCard: UIStackView { - var header = HeaderOfferRequestCard(postedDate: "Posted 14hrs ago", - offer: "Offers", - supplyType: "Medical Supplies") - var subHeader = SubHeaderOfferRequestCard(initials: "AM", - name: "Ana Muller", - location: "Berlin, Germany") + var headerStack = HeaderOfferRequestCard(postedDate: "Posted 14hrs ago", + offer: "Offers", + supplyType: "Medical Supplies") - var body = BodyOfferRequestCard(tit: "I have 100 face Masks to give away", - message: "I have a small store and I would like to give away 100 mask but I don’t know where, please contact me if you need them. I have a small store and I would like to give away 100 mask but I don’t know where, please contact me if you need them. please contact m ...") - var footer = FooterOfferRequestCard(numOfLikes: 4, numOfComments: 7) + var subHeaderStack = SubHeaderOfferRequestCard(initials: "AM", + name: "Ana Muller", + location: "Berlin, Germany") + + var bodyStack = BodyOfferRequestCard(tit: "I have 100 face Masks to give away", + message: "I have a small store and I would like to give away 100 mask but I don’t know where, please contact me if you need them. I have a small store and I would like to give away 100 mask but I don’t know where, please contact me if you need them. please contact m ...") + + var footerStack = FooterOfferRequestCard(numOfLikes: 4, + numOfComments: 7) override init(frame _: CGRect) { super.init(frame: .zero) @@ -46,36 +49,28 @@ class OfferRequestCard: UIStackView { init() { super.init(frame: .zero) - header.translatesAutoresizingMaskIntoConstraints = false - subHeader.translatesAutoresizingMaskIntoConstraints = false - body.translatesAutoresizingMaskIntoConstraints = false - footer.translatesAutoresizingMaskIntoConstraints = false + headerStack.translatesAutoresizingMaskIntoConstraints = false + subHeaderStack.translatesAutoresizingMaskIntoConstraints = false + bodyStack.translatesAutoresizingMaskIntoConstraints = false + footerStack.translatesAutoresizingMaskIntoConstraints = false - axis = NSLayoutConstraint.Axis.vertical - distribution = UIStackView.Distribution.fillProportionally + // Offer Request Card Constraints translatesAutoresizingMaskIntoConstraints = false - addArrangedSubview(header) - addArrangedSubview(subHeader) - addArrangedSubview(body) - addArrangedSubview(footer) + axis = .vertical + distribution = .fillProportionally + spacing = 10 + addArrangedSubview(headerStack) + addArrangedSubview(subHeaderStack) + addArrangedSubview(bodyStack) + addArrangedSubview(footerStack) + + // Footer to Card Constraints + footerStack.makeSubview(of: self) + .right(to: \.rightAnchor, + constant: -160) } required init(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } - - func setUp() { - header.translatesAutoresizingMaskIntoConstraints = false - subHeader.translatesAutoresizingMaskIntoConstraints = false - body.translatesAutoresizingMaskIntoConstraints = false - footer.translatesAutoresizingMaskIntoConstraints = false - axis = NSLayoutConstraint.Axis.vertical - distribution = UIStackView.Distribution.fillProportionally - alignment = .fill - translatesAutoresizingMaskIntoConstraints = false - addArrangedSubview(header) - addArrangedSubview(subHeader) - addArrangedSubview(body) - addArrangedSubview(footer) - } } diff --git a/FightPandemics/Features/Feed/OfferRequestCard/Subheader-OfferReqCard.swift b/FightPandemics/Features/Feed/OfferRequestCard/Subheader-OfferReqCard.swift index b1941c8..0816694 100644 --- a/FightPandemics/Features/Feed/OfferRequestCard/Subheader-OfferReqCard.swift +++ b/FightPandemics/Features/Feed/OfferRequestCard/Subheader-OfferReqCard.swift @@ -27,30 +27,23 @@ import UIKit class SubHeaderOfferRequestCard: UIStackView { - let userInitials = UILabel() - let userName = UILabel() - let userLocationName = UILabel() - let userLocationStackView = UIStackView() - let userNameAndLocationStackView = UIStackView() + + private let avatar = Avatar() + private let userName = UILabel() + private let userLocationName = UILabel() + private let userLocationStackView = UIStackView() + private let userNameAndLocationStackView = UIStackView() init(initials: String, name: String, location: String) { super.init(frame: .zero) - // User Initials - let userInitialsSize = CGSize(width: 100, height: 500) - userInitials.frame.size = userInitialsSize - userInitials.layer.cornerRadius = frame.size.height / 2 - userInitials.text = initials - userInitials.textAlignment = .center - userInitials.backgroundColor = .fightPandemicsGhostWhite() - userInitials.layer.borderWidth = 1 - userInitials.layer.borderColor = UIColor.fightPandemicsNeonBlue().cgColor - userInitials.translatesAutoresizingMaskIntoConstraints = false + // Avatar + avatar.setUp(user: initials) // User Name userName.translatesAutoresizingMaskIntoConstraints = false userName.attributedText = NSAttributedString(string: name, - attributes: [NSAttributedString.Key.font: Fonts.poppinsMedium.customFont(size: 22), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNero()]) + attributes: [NSAttributedString.Key.font: Fonts.poppinsMedium.customFont(size: 16), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNero()]) // Point let point = UIImage(systemName: "circle.fill") @@ -64,32 +57,40 @@ class SubHeaderOfferRequestCard: UIStackView { userLocationName.attributedText = NSAttributedString(string: location, attributes: [NSAttributedString.Key.font: Fonts.poppinsRegular.customFont(size: 11), NSAttributedString.Key.foregroundColor: UIColor.fightPandemicsNero()]) - // Stacks + // User Location Stack View userLocationStackView.translatesAutoresizingMaskIntoConstraints = false userLocationStackView.distribution = .fillProportionally + userLocationStackView.spacing = 5 userLocationStackView.axis = .horizontal userLocationStackView.addArrangedSubview(pointImageView) userLocationStackView.addArrangedSubview(userLocationName) + // User Name & Location Stack View userNameAndLocationStackView.translatesAutoresizingMaskIntoConstraints = false userNameAndLocationStackView.axis = .vertical userNameAndLocationStackView.distribution = .fillProportionally userNameAndLocationStackView.addArrangedSubview(userName) userNameAndLocationStackView.addArrangedSubview(userLocationStackView) + // Subheader Stack View translatesAutoresizingMaskIntoConstraints = false axis = .horizontal spacing = 10 distribution = .fillProportionally - - addArrangedSubview(userInitials) + addArrangedSubview(avatar) addArrangedSubview(userNameAndLocationStackView) -// makeSubview(of: self) -// .left(to: \.leftAnchor, constant: 0) -// .top(to: \.topAnchor, constant: 0) -// .right(to: \.rightAnchor, constant: -80) -// .bottom(to: \.bottomAnchor, constant: 0) + // Constraints + avatar.makeSubview(of: self) + .top(to: \.topAnchor, relation: .equal, constant: 8, priority: .required) + .leading(to: \.leadingAnchor) + .width(50) + .height(35) + userNameAndLocationStackView.makeSubview(of: self) + .top(to: \.topAnchor) + .leading(to: \.trailingAnchor, of: avatar, constant: 10) + .width(100) + .height(35) } required init(coder _: NSCoder) {