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

Add missing social sharing icons #23918

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
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
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* [*] [internal] Update Gravatar SDK to 3.0.0 [#23701]
* [*] (Hidden under a feature flag) User Management for self-hosted sites. [#23768]
* [*] Fix sorting in Stats Subscriber Emails (latest first) [#23913]
* [*] Fix some missing or invalid social sharing icons [#23918]
* [*] Add URL and ID to the Media details screen, add IDs for posts [#23887]
* [*] Reader: Enable quick access to notifications on iPad [#23882]
* [*] Add support for restricted posts in Reader [#23853]
Expand Down
1 change: 1 addition & 0 deletions WordPress/Classes/Models/PublicizeService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ extension PublicizeService {
case linkedin
case instagram = "instagram-business"
case mastodon
case threads
case unknown

/// Returns the local image for the icon representing the social network.
Expand Down
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.")
}
74 changes: 23 additions & 51 deletions WordPress/Classes/ViewRelated/Blog/Sharing/SharingViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ - (void)viewDidLoad
action:@selector(doneButtonTapped)];
}

[self.tableView registerClass:[PublicizeServiceCell class] forCellReuseIdentifier:PublicizeServiceCell.cellId];
self.tableView.cellLayoutMarginsFollowReadableWidth = YES;
[WPStyleGuide configureColorsForView:self.view andTableView:self.tableView];
[self.publicizeServicesState addInitialConnections:[self allConnections]];
Expand Down Expand Up @@ -237,32 +238,16 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
WPTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[WPTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
}

[WPStyleGuide configureTableViewCell:cell];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

SharingSectionType sectionType = [self sectionTypeForIndex:indexPath.section];
switch (sectionType) {
case SharingSectionAvailableServices: // fallthrough
case SharingSectionUnsupported:
[self configurePublicizeCell:cell atIndexPath:indexPath];
break;

return [self makePublicizeCellAtIndexPath:indexPath];
case SharingSectionSharingButtons:
cell.textLabel.text = NSLocalizedString(@"Manage", @"Verb. Text label. Tapping displays a screen where the user can configure 'share' buttons for third-party services.");
cell.detailTextLabel.text = nil;
cell.imageView.image = nil;
break;

return [self makeManageButtonCell];
default:
return [UITableViewCell new];
}

return cell;
}

- (PublicizeService *)publicizeServiceForIndexPath:(NSIndexPath *)indexPath
Expand All @@ -278,51 +263,38 @@ - (PublicizeService *)publicizeServiceForIndexPath:(NSIndexPath *)indexPath
}
}

- (void)configurePublicizeCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath
- (UITableViewCell *)makePublicizeCellAtIndexPath:(NSIndexPath *)indexPath
{
PublicizeServiceCell *cell = [self.tableView dequeueReusableCellWithIdentifier:PublicizeServiceCell.cellId];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

PublicizeService *publicizer = [self publicizeServiceForIndexPath:indexPath];
NSArray *connections = [self connectionsForService:publicizer];

// TODO: Remove?
if ([publicizer.serviceID isEqualToString:PublicizeService.googlePlusServiceID] && [connections count] == 0) { // Temporarily hiding Google+
cell.hidden = YES;
return;
}

// Configure the image
UIImage *image = [WPStyleGuide socialIconFor:publicizer.serviceID];
[cell.imageView setImage:image];

// Configure the text
cell.textLabel.text = publicizer.label;

// Show the name(s) or number of connections.
NSString *str = @"";
if ([connections count] > 2) {
NSString *format = NSLocalizedString(@"%d accounts", @"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.");
str = [NSString stringWithFormat:format, [connections count]];
} else {
NSMutableArray *names = [NSMutableArray array];
for (PublicizeConnection *pubConn in connections) {
[names addObject:pubConn.externalDisplay];
}
str = [names componentsJoinedByString:@", "];
return cell;
}

cell.detailTextLabel.text = str;
[cell configureWith:publicizer connections:connections];
return cell;
}

if (![publicizer isSupported]) {
cell.accessoryView = [WPStyleGuide sharingCellErrorAccessoryImageView];
return;
- (UITableViewCell *)makeManageButtonCell
{
WPTableViewCell *cell = [self.
tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[WPTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
}

// Check if any of the connections are broken.
for (PublicizeConnection *pubConn in connections) {
if ([pubConn requiresUserAction]) {
cell.accessoryView = [WPStyleGuide sharingCellWarningAccessoryImageView];
break;
}
}
[WPStyleGuide configureTableViewCell:cell];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.text = NSLocalizedString(@"Manage", @"Verb. Text label. Tapping displays a screen where the user can configure 'share' buttons for third-party services.");
cell.detailTextLabel.text = nil;
cell.imageView.image = nil;
return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct JetpackSocialNoConnectionView: View {
}

func iconImage(image: UIImage, url: URL?) -> some View {
AsyncImage(url: url) { image in
CachedAsyncImage(url: url) { image in
image
.icon(backgroundColor: viewModel.preferredBackgroundColor)
} placeholder: {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
}
}