diff --git a/Mastodon/Diffiable/Profile/ProfileFieldSection.swift b/Mastodon/Diffiable/Profile/ProfileFieldSection.swift index 332916a02..98acbb73c 100644 --- a/Mastodon/Diffiable/Profile/ProfileFieldSection.swift +++ b/Mastodon/Diffiable/Profile/ProfileFieldSection.swift @@ -49,6 +49,10 @@ extension ProfileFieldSection { do { let mastodonContent = MastodonContent(content: field.value.value, emojis: field.emojiMeta) let metaContent = try MastodonMetaContent.convert(document: mastodonContent) + cell.valueMetaLabel.linkAttributes[.foregroundColor] = Asset.Colors.brand.color + if field.verifiedAt.value != nil { + cell.valueMetaLabel.linkAttributes[.foregroundColor] = Asset.Scene.Profile.About.bioAboutFieldValidatedLink.color + } cell.valueMetaLabel.configure(content: metaContent) } catch { let content = PlaintextMetaContent(string: field.value.value) @@ -67,7 +71,10 @@ extension ProfileFieldSection { cell.checkmark.isHidden = true if let verifiedAt = field.verifiedAt.value { cell.checkmark.isHidden = false - cell.checkmark.accessibilityLabel = "Ownership of this link was checked on \(verifiedAt)" // TODO: I18N / L10N + let formatter = DateFormatter() + formatter.dateStyle = .medium + formatter.timeStyle = .short + cell.checkmark.accessibilityLabel = "Ownership of this link was checked on \(formatter.string(from: verifiedAt))" // TODO: I18N / L10N } cell.delegate = configuration.profileFieldCollectionViewCellDelegate diff --git a/Mastodon/Scene/Profile/About/Cell/ProfileFieldCollectionViewCell.swift b/Mastodon/Scene/Profile/About/Cell/ProfileFieldCollectionViewCell.swift index 076b8373e..2841ba664 100644 --- a/Mastodon/Scene/Profile/About/Cell/ProfileFieldCollectionViewCell.swift +++ b/Mastodon/Scene/Profile/About/Cell/ProfileFieldCollectionViewCell.swift @@ -14,6 +14,11 @@ import MastodonLocalization protocol ProfileFieldCollectionViewCellDelegate: AnyObject { func profileFieldCollectionViewCell(_ cell: ProfileFieldCollectionViewCell, metaLebel: MetaLabel, didSelectMeta meta: Meta) + func profileFieldCollectionViewCell(_ cell: ProfileFieldCollectionViewCell, didTapAction: ProfileFieldCollectionViewCellAction) +} + +enum ProfileFieldCollectionViewCellAction { + case Checkmark } final class ProfileFieldCollectionViewCell: UICollectionViewCell { @@ -27,6 +32,7 @@ final class ProfileFieldCollectionViewCell: UICollectionViewCell { let valueMetaLabel = MetaLabel(style: .profileFieldValue) let checkmark = UIImageView(image: Asset.Editing.checkmark.image.withRenderingMode(.alwaysTemplate)) + let tapGesture = UITapGestureRecognizer(); override func prepareForReuse() { super.prepareForReuse() @@ -49,8 +55,14 @@ final class ProfileFieldCollectionViewCell: UICollectionViewCell { extension ProfileFieldCollectionViewCell { private func _init() { + // Setup colors checkmark.tintColor = Asset.Scene.Profile.About.bioAboutFieldValidatedCheckmark.color; + // Setup gestures + tapGesture.addTarget(self, action: #selector(ProfileFieldCollectionViewCell.didTapCheckmark(_:))) + checkmark.addGestureRecognizer(tapGesture) + checkmark.isUserInteractionEnabled = true + // containerStackView: V - [ metaContainer | plainContainer ] let containerStackView = UIStackView() containerStackView.axis = .vertical @@ -87,6 +99,10 @@ extension ProfileFieldCollectionViewCell { valueMetaLabel.linkDelegate = self } + @objc public func didTapCheckmark(_: UITapGestureRecognizer) { + delegate?.profileFieldCollectionViewCell(self, didTapAction: .Checkmark) + } + } // MARK: - MetaLabelDelegate diff --git a/Mastodon/Scene/Profile/About/ProfileAboutViewController.swift b/Mastodon/Scene/Profile/About/ProfileAboutViewController.swift index eb1e6b39c..bf77c05b9 100644 --- a/Mastodon/Scene/Profile/About/ProfileAboutViewController.swift +++ b/Mastodon/Scene/Profile/About/ProfileAboutViewController.swift @@ -16,6 +16,7 @@ import MastodonCore protocol ProfileAboutViewControllerDelegate: AnyObject { func profileAboutViewController(_ viewController: ProfileAboutViewController, profileFieldCollectionViewCell: ProfileFieldCollectionViewCell, metaLabel: MetaLabel, didSelectMeta meta: Meta) + func profileAboutViewController(_ viewController: ProfileAboutViewController, didTapCheckmarkFor field: ProfileFieldItem.FieldValue) } final class ProfileAboutViewController: UIViewController { @@ -152,6 +153,21 @@ extension ProfileAboutViewController: ProfileFieldCollectionViewCellDelegate { func profileFieldCollectionViewCell(_ cell: ProfileFieldCollectionViewCell, metaLebel: MetaLabel, didSelectMeta meta: Meta) { delegate?.profileAboutViewController(self, profileFieldCollectionViewCell: cell, metaLabel: metaLebel, didSelectMeta: meta) } + + func profileFieldCollectionViewCell(_ cell: ProfileFieldCollectionViewCell, didTapAction action: ProfileFieldCollectionViewCellAction) { + guard let diffableDataSource = viewModel.diffableDataSource else { return } + guard let indexPath = collectionView.indexPath(for: cell) else { return } + guard let item = diffableDataSource.itemIdentifier(for: indexPath) else { return } + + switch item { + case .field(let field): + delegate?.profileAboutViewController(self, didTapCheckmarkFor: field) + case .addEntry: fallthrough + case .editField: fallthrough + case .noResult: + break + } + } } // MARK: - ProfileFieldEditCollectionViewCellDelegate diff --git a/Mastodon/Scene/Profile/ProfileViewController.swift b/Mastodon/Scene/Profile/ProfileViewController.swift index 3ce1fd33a..908725e43 100644 --- a/Mastodon/Scene/Profile/ProfileViewController.swift +++ b/Mastodon/Scene/Profile/ProfileViewController.swift @@ -854,6 +854,22 @@ extension ProfileViewController: ProfileAboutViewControllerDelegate { ) { handleMetaPress(meta) } + + func profileAboutViewController(_ viewController: ProfileAboutViewController, didTapCheckmarkFor field: ProfileFieldItem.FieldValue) { + guard let verifiedAt = field.verifiedAt.value else { + return + } + + let formatter = DateFormatter() + formatter.dateStyle = .medium + formatter.timeStyle = .short + let alert = UIAlertController(title: "Validated", message: "Ownership of this link was checked on \(formatter.string(from: verifiedAt))", preferredStyle: .alert) // TODO: I18N / L10N + alert.addAction(UIAlertAction(title: L10n.Common.Controls.Actions.ok, style: .default) { _ in + alert.dismiss(animated: true) + }) + + self.present(alert, animated: true) + } } // MARK: - MastodonMenuDelegate diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Scene/Profile/About/bio.about.field.validated.link.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Scene/Profile/About/bio.about.field.validated.link.colorset/Contents.json new file mode 100644 index 000000000..f5112f04f --- /dev/null +++ b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Scene/Profile/About/bio.about.field.validated.link.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.371", + "green" : "0.565", + "red" : "0.290" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.603", + "green" : "0.742", + "red" : "0.476" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/MastodonSDK/Sources/MastodonAsset/Generated/Assets.swift b/MastodonSDK/Sources/MastodonAsset/Generated/Assets.swift index 45861c583..986215f5f 100644 --- a/MastodonSDK/Sources/MastodonAsset/Generated/Assets.swift +++ b/MastodonSDK/Sources/MastodonAsset/Generated/Assets.swift @@ -166,6 +166,7 @@ public enum Asset { public enum About { public static let bioAboutFieldValidatedBackground = ColorAsset(name: "Scene/Profile/About/bio.about.field.validated.background") public static let bioAboutFieldValidatedCheckmark = ColorAsset(name: "Scene/Profile/About/bio.about.field.validated.checkmark") + public static let bioAboutFieldValidatedLink = ColorAsset(name: "Scene/Profile/About/bio.about.field.validated.link") } public enum Banner { public static let bioEditBackgroundGray = ColorAsset(name: "Scene/Profile/Banner/bio.edit.background.gray")