-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
127 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
WordPress/Classes/ViewRelated/Blog/Sharing/PublicizeServiceCell.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import UIKit | ||
import WordPressUI | ||
|
||
final class PublicizeServiceCell: UITableViewCell { | ||
let iconView = AsyncImageView() | ||
let titleLabel = UILabel() | ||
let detailsLabel = UILabel() | ||
|
||
@objc class var cellId: String { "PublicizeServiceCell" } | ||
|
||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | ||
super.init(style: style, reuseIdentifier: reuseIdentifier) | ||
|
||
detailsLabel.font = .preferredFont(forTextStyle: .footnote) | ||
detailsLabel.textColor = .secondaryLabel | ||
|
||
let stackView = UIStackView(alignment: .center, spacing: 12, [ | ||
iconView, | ||
UIStackView(axis: .vertical, alignment: .leading, spacing: 2, [titleLabel, detailsLabel]) | ||
]) | ||
contentView.addSubview(stackView) | ||
stackView.pinEdges(to: contentView.layoutMarginsGuide) | ||
|
||
NSLayoutConstraint.activate([ | ||
iconView.widthAnchor.constraint(equalToConstant: 28), | ||
iconView.heightAnchor.constraint(equalToConstant: 28), | ||
]) | ||
iconView.layer.cornerRadius = 8 | ||
iconView.layer.masksToBounds = true | ||
iconView.backgroundColor = UIColor.white | ||
|
||
iconView.contentMode = .scaleAspectFit | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
override func prepareForReuse() { | ||
super.prepareForReuse() | ||
|
||
accessoryView = .none | ||
iconView.prepareForReuse() | ||
} | ||
|
||
@objc func configure(with service: PublicizeService, connections: [PublicizeConnection]) { | ||
let name = service.name | ||
if name != .unknown && !name.hasModernRemoteLogo { | ||
iconView.image = name.localIconImage | ||
} else if let imageURL = URL(string: service.icon) { | ||
iconView.setImage(with: imageURL) | ||
} else { | ||
iconView.image = UIImage(named: "social-default") | ||
} | ||
|
||
titleLabel.text = service.label | ||
|
||
detailsLabel.isHidden = connections.isEmpty | ||
if connections.count > 2 { | ||
detailsLabel.text = String(format: Strings.numberOfAccounts, connections.count) | ||
} else { | ||
detailsLabel.text = connections | ||
.map(\.externalDisplay) | ||
.joined(separator: ", ") | ||
} | ||
|
||
if service.isSupported { | ||
if connections.contains(where: { $0.requiresUserAction() }) { | ||
accessoryView = WPStyleGuide.sharingCellWarningAccessoryImageView() | ||
} | ||
} else { | ||
accessoryView = WPStyleGuide.sharingCellErrorAccessoryImageView() | ||
} | ||
} | ||
} | ||
|
||
private extension PublicizeService.ServiceName { | ||
/// We no longer need to provide local overrides for these on this screen | ||
/// as the remote images are good. | ||
var hasModernRemoteLogo: Bool { | ||
[ | ||
PublicizeService.ServiceName.instagram, | ||
PublicizeService.ServiceName.mastodon | ||
].contains(self) | ||
} | ||
} | ||
|
||
private enum Strings { | ||
static let numberOfAccounts = NSLocalizedString("socialSharing.connectionDetails.nAccount", value: "%d accounts", comment: "The number of connected accounts on a third party sharing service connected to the user's blog. The '%d' is a placeholder for the number of accounts.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+7.51 KB
...ial/icon-threads.imageset/361591942_304761532104096_2740029438399114184_n-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions
12
WordPress/Jetpack/AppImages.xcassets/Social/icon-threads.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "361591942_304761532104096_2740029438399114184_n-2.png", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |