From 36246dc12856cf25b2fb297d567c078da992cbec Mon Sep 17 00:00:00 2001 From: Adam Sharp Date: Wed, 30 Oct 2024 13:34:33 -0400 Subject: [PATCH] Make unread filter icon turn blue when activated --- .../Contents.json | 29 ++++++++++++++ .../Chat List/ChatListFilterControl.swift | 40 +++++++++++++++++-- 2 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 Signal/Colors.xcassets/Signal/Background/secondaryUltramarineBackground.colorset/Contents.json diff --git a/Signal/Colors.xcassets/Signal/Background/secondaryUltramarineBackground.colorset/Contents.json b/Signal/Colors.xcassets/Signal/Background/secondaryUltramarineBackground.colorset/Contents.json new file mode 100644 index 0000000000..6fd026cbd1 --- /dev/null +++ b/Signal/Colors.xcassets/Signal/Background/secondaryUltramarineBackground.colorset/Contents.json @@ -0,0 +1,29 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xFB", + "green" : "0xDD", + "red" : "0xC7" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Signal/src/ViewControllers/HomeView/Chat List/ChatListFilterControl.swift b/Signal/src/ViewControllers/HomeView/Chat List/ChatListFilterControl.swift index 7ab9bdbbaa..14ce648b7e 100644 --- a/Signal/src/ViewControllers/HomeView/Chat List/ChatListFilterControl.swift +++ b/Signal/src/ViewControllers/HomeView/Chat List/ChatListFilterControl.swift @@ -591,6 +591,7 @@ final class ChatListFilterControl: UIView, UIScrollViewDelegate { return } + let filterIconImageView = UIImageView(image: animationFrames.last!.image.withConfiguration(.filterIconDisappearing)) let transitionView = TransitionEffectView(effect: UIBlurEffect(style: .systemUltraThinMaterial)) let endFrame = clearButton.frame @@ -604,14 +605,19 @@ final class ChatListFilterControl: UIView, UIScrollViewDelegate { clearButton.configuration?.background = .clear() UIView.performWithoutAnimation { + imageContainer.alpha = 0 + + transitionView.contentView.backgroundColor = .filterIconActiveBackground transitionView.frame = startFrame + transitionView.contentView.addSubview(filterIconImageView) contentView.insertSubview(transitionView, belowSubview: imageContainer) + filterIconImageView.frame = transitionView.contentView.convert(imageViews.last!.frame, from: imageContainer) } let transitionAnimator = UIViewPropertyAnimator(duration: animationDuration(0.7), dampingRatio: 0.75) - transitionAnimator.addAnimations(withDurationFactor: 0.1) { [imageContainer] in - imageContainer.alpha = 0 + transitionAnimator.addAnimations(withDurationFactor: 0.1) { + filterIconImageView.alpha = 0 } transitionAnimator.addAnimations({ [clearButton] in @@ -619,7 +625,9 @@ final class ChatListFilterControl: UIView, UIScrollViewDelegate { }, delayFactor: 0.33) transitionAnimator.addAnimations { + transitionView.contentView.backgroundColor = .clear transitionView.frame = endFrame + filterIconImageView.center = transitionView.contentView.bounds.center } transitionAnimator.addCompletion { [self] _ in @@ -648,7 +656,33 @@ private extension UIImage.Configuration { } static var filterIconFiltering: UIImage.SymbolConfiguration { - filterIconBase.applying(UIImage.SymbolConfiguration(paletteColors: [.Signal.ultramarine, .Signal.secondaryBackground])) + filterIconBase.applying(UIImage.SymbolConfiguration(paletteColors: [.filterIconActiveForeground, .filterIconActiveBackground])) + } + + static var filterIconDisappearing: UIImage.SymbolConfiguration { + filterIconBase.applying(UIImage.SymbolConfiguration(paletteColors: [.filterIconActiveForeground, .clear])) + } +} + +private extension UIColor { + static var filterIconActiveForeground: UIColor { + UIColor { traitCollection in + if traitCollection.userInterfaceStyle == .dark { + .Signal.label + } else { + .Signal.ultramarine + } + } + } + + static var filterIconActiveBackground: UIColor { + UIColor { traitCollection in + if traitCollection.userInterfaceStyle == .dark { + .Signal.ultramarine + } else { + .Signal.secondaryUltramarineBackground + } + } } }