Alert validation time on tapping field checkmark, make validated field links green
This commit is contained in:
parent
c3009d6009
commit
35775a5b43
@ -49,6 +49,10 @@ extension ProfileFieldSection {
|
|||||||
do {
|
do {
|
||||||
let mastodonContent = MastodonContent(content: field.value.value, emojis: field.emojiMeta)
|
let mastodonContent = MastodonContent(content: field.value.value, emojis: field.emojiMeta)
|
||||||
let metaContent = try MastodonMetaContent.convert(document: mastodonContent)
|
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)
|
cell.valueMetaLabel.configure(content: metaContent)
|
||||||
} catch {
|
} catch {
|
||||||
let content = PlaintextMetaContent(string: field.value.value)
|
let content = PlaintextMetaContent(string: field.value.value)
|
||||||
@ -67,7 +71,10 @@ extension ProfileFieldSection {
|
|||||||
cell.checkmark.isHidden = true
|
cell.checkmark.isHidden = true
|
||||||
if let verifiedAt = field.verifiedAt.value {
|
if let verifiedAt = field.verifiedAt.value {
|
||||||
cell.checkmark.isHidden = false
|
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
|
cell.delegate = configuration.profileFieldCollectionViewCellDelegate
|
||||||
|
@ -14,6 +14,11 @@ import MastodonLocalization
|
|||||||
|
|
||||||
protocol ProfileFieldCollectionViewCellDelegate: AnyObject {
|
protocol ProfileFieldCollectionViewCellDelegate: AnyObject {
|
||||||
func profileFieldCollectionViewCell(_ cell: ProfileFieldCollectionViewCell, metaLebel: MetaLabel, didSelectMeta meta: Meta)
|
func profileFieldCollectionViewCell(_ cell: ProfileFieldCollectionViewCell, metaLebel: MetaLabel, didSelectMeta meta: Meta)
|
||||||
|
func profileFieldCollectionViewCell(_ cell: ProfileFieldCollectionViewCell, didTapAction: ProfileFieldCollectionViewCellAction)
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ProfileFieldCollectionViewCellAction {
|
||||||
|
case Checkmark
|
||||||
}
|
}
|
||||||
|
|
||||||
final class ProfileFieldCollectionViewCell: UICollectionViewCell {
|
final class ProfileFieldCollectionViewCell: UICollectionViewCell {
|
||||||
@ -27,6 +32,7 @@ final class ProfileFieldCollectionViewCell: UICollectionViewCell {
|
|||||||
let valueMetaLabel = MetaLabel(style: .profileFieldValue)
|
let valueMetaLabel = MetaLabel(style: .profileFieldValue)
|
||||||
|
|
||||||
let checkmark = UIImageView(image: Asset.Editing.checkmark.image.withRenderingMode(.alwaysTemplate))
|
let checkmark = UIImageView(image: Asset.Editing.checkmark.image.withRenderingMode(.alwaysTemplate))
|
||||||
|
let tapGesture = UITapGestureRecognizer();
|
||||||
|
|
||||||
override func prepareForReuse() {
|
override func prepareForReuse() {
|
||||||
super.prepareForReuse()
|
super.prepareForReuse()
|
||||||
@ -49,8 +55,14 @@ final class ProfileFieldCollectionViewCell: UICollectionViewCell {
|
|||||||
extension ProfileFieldCollectionViewCell {
|
extension ProfileFieldCollectionViewCell {
|
||||||
|
|
||||||
private func _init() {
|
private func _init() {
|
||||||
|
// Setup colors
|
||||||
checkmark.tintColor = Asset.Scene.Profile.About.bioAboutFieldValidatedCheckmark.color;
|
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 ]
|
// containerStackView: V - [ metaContainer | plainContainer ]
|
||||||
let containerStackView = UIStackView()
|
let containerStackView = UIStackView()
|
||||||
containerStackView.axis = .vertical
|
containerStackView.axis = .vertical
|
||||||
@ -87,6 +99,10 @@ extension ProfileFieldCollectionViewCell {
|
|||||||
valueMetaLabel.linkDelegate = self
|
valueMetaLabel.linkDelegate = self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc public func didTapCheckmark(_: UITapGestureRecognizer) {
|
||||||
|
delegate?.profileFieldCollectionViewCell(self, didTapAction: .Checkmark)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - MetaLabelDelegate
|
// MARK: - MetaLabelDelegate
|
||||||
|
@ -16,6 +16,7 @@ import MastodonCore
|
|||||||
|
|
||||||
protocol ProfileAboutViewControllerDelegate: AnyObject {
|
protocol ProfileAboutViewControllerDelegate: AnyObject {
|
||||||
func profileAboutViewController(_ viewController: ProfileAboutViewController, profileFieldCollectionViewCell: ProfileFieldCollectionViewCell, metaLabel: MetaLabel, didSelectMeta meta: Meta)
|
func profileAboutViewController(_ viewController: ProfileAboutViewController, profileFieldCollectionViewCell: ProfileFieldCollectionViewCell, metaLabel: MetaLabel, didSelectMeta meta: Meta)
|
||||||
|
func profileAboutViewController(_ viewController: ProfileAboutViewController, didTapCheckmarkFor field: ProfileFieldItem.FieldValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
final class ProfileAboutViewController: UIViewController {
|
final class ProfileAboutViewController: UIViewController {
|
||||||
@ -152,6 +153,21 @@ extension ProfileAboutViewController: ProfileFieldCollectionViewCellDelegate {
|
|||||||
func profileFieldCollectionViewCell(_ cell: ProfileFieldCollectionViewCell, metaLebel: MetaLabel, didSelectMeta meta: Meta) {
|
func profileFieldCollectionViewCell(_ cell: ProfileFieldCollectionViewCell, metaLebel: MetaLabel, didSelectMeta meta: Meta) {
|
||||||
delegate?.profileAboutViewController(self, profileFieldCollectionViewCell: cell, metaLabel: metaLebel, didSelectMeta: 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
|
// MARK: - ProfileFieldEditCollectionViewCellDelegate
|
||||||
|
@ -854,6 +854,22 @@ extension ProfileViewController: ProfileAboutViewControllerDelegate {
|
|||||||
) {
|
) {
|
||||||
handleMetaPress(meta)
|
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
|
// MARK: - MastodonMenuDelegate
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
@ -166,6 +166,7 @@ public enum Asset {
|
|||||||
public enum About {
|
public enum About {
|
||||||
public static let bioAboutFieldValidatedBackground = ColorAsset(name: "Scene/Profile/About/bio.about.field.validated.background")
|
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 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 enum Banner {
|
||||||
public static let bioEditBackgroundGray = ColorAsset(name: "Scene/Profile/Banner/bio.edit.background.gray")
|
public static let bioEditBackgroundGray = ColorAsset(name: "Scene/Profile/Banner/bio.edit.background.gray")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user