1
0
mirror of https://github.com/mastodon/mastodon-ios.git synced 2024-12-16 18:58:45 +01:00

Use different assets for dark/light-mode (IOS-130)

This commit is contained in:
Nathan Mattes 2023-11-04 23:52:43 +01:00
parent c0bdcc43a1
commit c764db270e
7 changed files with 65 additions and 96 deletions

View File

@ -25,7 +25,7 @@ final class ProfileFieldCollectionViewCell: UICollectionViewCell {
let keyMetaLabel = MetaLabel(style: .profileFieldName)
let valueMetaLabel = MetaLabel(style: .profileFieldValue)
let checkmark = UIImageView(image: UIImage(systemName: "checkmark.seal"))
let checkmark: UIImageView
var checkmarkPopoverString: String? = nil;
let tapGesture = UITapGestureRecognizer();
var editMenuInteraction: UIEditMenuInteraction!
@ -37,25 +37,15 @@ final class ProfileFieldCollectionViewCell: UICollectionViewCell {
}
override init(frame: CGRect) {
super.init(frame: frame)
_init()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
_init()
}
}
extension ProfileFieldCollectionViewCell {
private func _init() {
editMenuInteraction = UIEditMenuInteraction(delegate: self)
// Setup colors
checkmark = UIImageView(image: Asset.Scene.Profile.About.verifiedCheckmark.image.withRenderingMode(.alwaysTemplate))
checkmark.tintColor = Asset.Colors.Brand.blurple.color
checkmark.translatesAutoresizingMaskIntoConstraints = false
super.init(frame: frame)
editMenuInteraction = UIEditMenuInteraction(delegate: self)
// Setup gestures
tapGesture.addTarget(self, action: #selector(ProfileFieldCollectionViewCell.didTapCheckmark(_:)))
@ -82,6 +72,8 @@ extension ProfileFieldCollectionViewCell {
containerStackView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
contentView.trailingAnchor.constraint(equalTo: containerStackView.trailingAnchor),
contentView.bottomAnchor.constraint(equalTo: containerStackView.bottomAnchor, constant: 11),
checkmark.heightAnchor.constraint(equalToConstant: 22),
checkmark.widthAnchor.constraint(equalTo: checkmark.heightAnchor),
])
// metaContainer: h - [ keyValueContainer | checkmark ]
@ -108,7 +100,11 @@ extension ProfileFieldCollectionViewCell {
isAccessibilityElement = true
}
required init?(coder: NSCoder) { fatalError("Just ... don't.") }
//MARK: - Actions
@objc public func didTapCheckmark(_ recognizer: UITapGestureRecognizer) {
editMenuInteraction?.presentEditMenu(with: UIEditMenuConfiguration(identifier: nil, sourcePoint: recognizer.location(in: checkmark)))
}
@ -123,6 +119,7 @@ extension ProfileFieldCollectionViewCell {
return result
}
//MARK: - Accessibility
override func accessibilityActivate() -> Bool {
if let (_, meta) = valueMetas.first {
delegate?.profileFieldCollectionViewCell(self, metaLabel: valueMetaLabel, didSelectMeta: meta)
@ -146,6 +143,11 @@ extension ProfileFieldCollectionViewCell {
}
set {}
}
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
checkmark.image = Asset.Scene.Profile.About.verifiedCheckmark.image.withRenderingMode(.alwaysTemplate)
}
}
// MARK: - MetaLabelDelegate

View File

@ -1,38 +0,0 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.852",
"green" : "0.894",
"red" : "0.835"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.354",
"green" : "0.353",
"red" : "0.268"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -1,38 +0,0 @@
{
"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
}
}

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"filename" : "checkmark.seal.svg",
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "checkmark.seal.fill.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--Generator: Apple Native CoreSVG 175.5-->
<!DOCTYPE svg
PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="44.3701" height="44.3897">
<g>
<rect height="44.3897" opacity="0" width="44.3701" x="0" y="0"/>
<path d="M10.3491 39.1187L14.5874 39.1187C14.978 39.1187 15.271 39.2358 15.564 39.5288L18.5718 42.5171C21.0327 44.9976 23.3179 44.978 25.7788 42.5171L28.7866 39.5288C29.0991 39.2358 29.3726 39.1187 29.7827 39.1187L34.0015 39.1187C37.4976 39.1187 39.1187 37.5171 39.1187 34.0015L39.1187 29.7827C39.1187 29.3726 39.2358 29.0991 39.5288 28.7866L42.5171 25.7788C44.9976 23.3179 44.978 21.0327 42.5171 18.5718L39.5288 15.564C39.2358 15.271 39.1187 14.978 39.1187 14.5874L39.1187 10.3491C39.1187 6.87257 37.5171 5.23194 34.0015 5.23194L29.7827 5.23194C29.3726 5.23194 29.0991 5.13428 28.7866 4.84132L25.7788 1.85303C23.3179-0.627434 21.0327-0.607903 18.5718 1.85303L15.564 4.84132C15.271 5.13428 14.978 5.23194 14.5874 5.23194L10.3491 5.23194C6.85303 5.23194 5.23194 6.8335 5.23194 10.3491L5.23194 14.5874C5.23194 14.978 5.13428 15.271 4.84132 15.564L1.85303 18.5718C-0.627434 21.0327-0.607903 23.3179 1.85303 25.7788L4.84132 28.7866C5.13428 29.0991 5.23194 29.3726 5.23194 29.7827L5.23194 34.0015C5.23194 37.4976 6.85303 39.1187 10.3491 39.1187ZM19.9976 31.7163C19.3335 31.7163 18.7866 31.4624 18.2788 30.7788L13.3765 24.7632C13.0835 24.3726 12.9077 23.9233 12.9077 23.4937C12.9077 22.5952 13.5913 21.8726 14.4898 21.8726C15.0366 21.8726 15.4663 22.0679 15.9546 22.7124L19.9194 27.8296L28.2593 14.4312C28.6304 13.8257 29.1382 13.5327 29.6655 13.5327C30.5054 13.5327 31.3062 14.1187 31.3062 15.0171C31.3062 15.4663 31.0523 15.9155 30.8179 16.3062L21.6382 30.7788C21.228 31.4038 20.6616 31.7163 19.9976 31.7163Z" fill="#ffffff" fill-opacity="0.85"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--Generator: Apple Native CoreSVG 175.5-->
<!DOCTYPE svg
PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="44.3506" height="44.5459">
<g>
<rect height="44.5459" opacity="0" width="44.3506" x="0" y="0"/>
<path d="M10.3491 39.1187L14.5679 39.1187C14.978 39.1187 15.271 39.2358 15.564 39.5288L18.5718 42.5171C21.0327 44.9976 23.3179 44.978 25.7788 42.5171L28.7866 39.5288C29.0796 39.2358 29.3726 39.1187 29.7827 39.1187L34.0015 39.1187C37.4976 39.1187 39.1187 37.5171 39.1187 34.0015L39.1187 29.7827C39.1187 29.3726 39.2358 29.0991 39.5288 28.7866L42.4976 25.7788C44.978 23.3179 44.9585 21.0523 42.4976 18.5718L39.5288 15.564C39.2358 15.271 39.1187 14.978 39.1187 14.5874L39.1187 10.3491C39.1187 6.87257 37.5171 5.23194 34.0015 5.23194L29.7827 5.23194C29.3726 5.23194 29.0796 5.13428 28.7866 4.84132L25.7788 1.85303C23.3179-0.627434 21.0327-0.607903 18.5718 1.85303L15.564 4.84132C15.271 5.13428 14.978 5.23194 14.5679 5.23194L10.3491 5.23194C6.85303 5.23194 5.23194 6.8335 5.23194 10.3491L5.23194 14.5874C5.23194 14.978 5.13428 15.271 4.84132 15.564L1.85303 18.5718C-0.627434 21.0523-0.607903 23.3179 1.85303 25.7788L4.84132 28.7866C5.13428 29.0991 5.23194 29.3726 5.23194 29.7827L5.23194 34.0015C5.23194 37.4976 6.85303 39.1187 10.3491 39.1187ZM10.3491 36.0132C8.61085 36.0132 8.33741 35.7398 8.33741 34.0015L8.33741 28.7476C8.33741 28.1616 8.16163 27.7124 7.73194 27.2827L4.04053 23.6108C2.81007 22.3608 2.81007 22.0093 4.04053 20.7593L7.73194 17.0874C8.16163 16.6577 8.33741 16.2085 8.33741 15.603L8.33741 10.3491C8.33741 8.59132 8.59132 8.33741 10.3491 8.33741L15.603 8.33741C16.2085 8.33741 16.6577 8.18116 17.0874 7.73194L20.7593 4.04053C22.0093 2.81007 22.3608 2.81007 23.5913 4.04053L27.2827 7.73194C27.6929 8.18116 28.1616 8.33741 28.7476 8.33741L34.0015 8.33741C35.7398 8.33741 36.0132 8.61085 36.0132 10.3491L36.0132 15.603C36.0132 16.2085 36.2085 16.6577 36.6382 17.0874L40.3296 20.7593C41.5601 22.0093 41.5601 22.3608 40.3296 23.6108L36.6382 27.2827C36.2085 27.7124 36.0132 28.1616 36.0132 28.7476L36.0132 34.0015C36.0132 35.7398 35.7398 36.0132 34.0015 36.0132L28.7476 36.0132C28.1616 36.0132 27.6929 36.189 27.2827 36.6382L23.5913 40.3296C22.3608 41.5601 22.0093 41.5601 20.7593 40.3296L17.0874 36.6382C16.6577 36.189 16.2085 36.0132 15.603 36.0132ZM20.0562 31.4429C20.7007 31.4429 21.2476 31.1304 21.6382 30.5444L30.564 16.4819C30.7788 16.1108 31.0327 15.6812 31.0327 15.2319C31.0327 14.3726 30.2515 13.8062 29.4507 13.8062C28.9429 13.8062 28.4546 14.0991 28.0835 14.6851L19.978 27.6929L16.1304 22.7124C15.6616 22.0874 15.2319 21.9116 14.7046 21.9116C13.8452 21.9116 13.1812 22.5952 13.1812 23.4741C13.1812 23.8843 13.3569 24.314 13.6304 24.6851L18.396 30.5444C18.8843 31.189 19.4116 31.4429 20.0562 31.4429Z" fill="#ffffff" fill-opacity="0.85"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -180,8 +180,7 @@ public enum Asset {
}
public enum Profile {
public enum About {
public static let bioAboutFieldVerifiedBackground = ColorAsset(name: "Scene/Profile/About/bio.about.field.verified.background")
public static let bioAboutFieldVerifiedText = ColorAsset(name: "Scene/Profile/About/bio.about.field.verified.text")
public static let verifiedCheckmark = ImageAsset(name: "Scene/Profile/About/verified_checkmark")
}
public enum Banner {
public static let bioEditBackgroundGray = ColorAsset(name: "Scene/Profile/Banner/bio.edit.background.gray")