mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Add experimental blur
This commit is contained in:
parent
3fb24f79e2
commit
f3067392d9
@ -753,6 +753,12 @@ public extension CALayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public extension CALayer {
|
||||||
|
static func blur() -> NSObject? {
|
||||||
|
return makeBlurFilter()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public extension CALayer {
|
public extension CALayer {
|
||||||
var layerTintColor: CGColor? {
|
var layerTintColor: CGColor? {
|
||||||
get {
|
get {
|
||||||
|
@ -194,6 +194,7 @@ public final class StoryPeerListComponent: Component {
|
|||||||
|
|
||||||
private final class VisibleItem {
|
private final class VisibleItem {
|
||||||
let view = ComponentView<Empty>()
|
let view = ComponentView<Empty>()
|
||||||
|
var hasBlur: Bool = false
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
}
|
}
|
||||||
@ -369,6 +370,8 @@ public final class StoryPeerListComponent: Component {
|
|||||||
private var currentTitleWidth: CGFloat = 0.0
|
private var currentTitleWidth: CGFloat = 0.0
|
||||||
private var currentActivityFraction: CGFloat = 0.0
|
private var currentActivityFraction: CGFloat = 0.0
|
||||||
|
|
||||||
|
private var sharedBlurEffect: NSObject?
|
||||||
|
|
||||||
public override init(frame: CGRect) {
|
public override init(frame: CGRect) {
|
||||||
self.collapsedButton = HighlightableButton()
|
self.collapsedButton = HighlightableButton()
|
||||||
|
|
||||||
@ -690,6 +693,21 @@ public final class StoryPeerListComponent: Component {
|
|||||||
expandBoundsFraction = 0.0
|
expandBoundsFraction = 0.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let blurRadius: CGFloat = collapsedState.sideAlphaFraction * 0.0 + (1.0 - collapsedState.sideAlphaFraction) * 14.0
|
||||||
|
if blurRadius == 0.0 {
|
||||||
|
self.sharedBlurEffect = nil
|
||||||
|
} else {
|
||||||
|
if let current = self.sharedBlurEffect, (current.value(forKey: "inputRadius") as? NSNumber)?.doubleValue == blurRadius {
|
||||||
|
} else {
|
||||||
|
if let sharedBlurEffect = CALayer.blur() {
|
||||||
|
sharedBlurEffect.setValue(blurRadius as NSNumber, forKey: "inputRadius")
|
||||||
|
self.sharedBlurEffect = sharedBlurEffect
|
||||||
|
} else {
|
||||||
|
self.sharedBlurEffect = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var targetCollapsedContentWidth: CGFloat = 0.0
|
var targetCollapsedContentWidth: CGFloat = 0.0
|
||||||
if collapsedItemCount > 0 {
|
if collapsedItemCount > 0 {
|
||||||
targetCollapsedContentWidth = 1.0 * collapsedItemWidth + (collapsedItemDistance) * max(0.0, collapsedItemCount - 1.0)
|
targetCollapsedContentWidth = 1.0 * collapsedItemWidth + (collapsedItemDistance) * max(0.0, collapsedItemCount - 1.0)
|
||||||
@ -819,8 +837,8 @@ public final class StoryPeerListComponent: Component {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
//let isReallyVisible = effectiveVisibleBounds.intersects(regularItemFrame)
|
let isReallyVisible = effectiveVisibleBounds.intersects(regularItemFrame)
|
||||||
//let _ = isReallyVisible
|
let _ = isReallyVisible
|
||||||
|
|
||||||
validIds.append(itemSet.peer.id)
|
validIds.append(itemSet.peer.id)
|
||||||
|
|
||||||
@ -943,6 +961,16 @@ public final class StoryPeerListComponent: Component {
|
|||||||
itemTransition.setScale(view: itemView.backgroundContainer, scale: 1.0)
|
itemTransition.setScale(view: itemView.backgroundContainer, scale: 1.0)
|
||||||
|
|
||||||
itemView.updateIsPreviewing(isPreviewing: self.previewedItemId == itemSet.peer.id)
|
itemView.updateIsPreviewing(isPreviewing: self.previewedItemId == itemSet.peer.id)
|
||||||
|
|
||||||
|
if (i >= collapseStartIndex && i <= collapseEndIndex) || !isReallyVisible {
|
||||||
|
itemView.layer.filters = nil
|
||||||
|
} else {
|
||||||
|
if let sharedBlurEffect = self.sharedBlurEffect {
|
||||||
|
itemView.layer.filters = [sharedBlurEffect]
|
||||||
|
} else {
|
||||||
|
itemView.layer.filters = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1067,8 +1095,6 @@ public final class StoryPeerListComponent: Component {
|
|||||||
itemTransition.setFrame(view: itemView.backgroundContainer, frame: measuredItem.itemFrame)
|
itemTransition.setFrame(view: itemView.backgroundContainer, frame: measuredItem.itemFrame)
|
||||||
itemTransition.setAlpha(view: itemView.backgroundContainer, alpha: itemAlpha)
|
itemTransition.setAlpha(view: itemView.backgroundContainer, alpha: itemAlpha)
|
||||||
itemTransition.setScale(view: itemView.backgroundContainer, scale: 1.0)
|
itemTransition.setScale(view: itemView.backgroundContainer, scale: 1.0)
|
||||||
|
|
||||||
itemView.updateIsPreviewing(isPreviewing: self.previewedItemId == itemSet.peer.id)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,3 +24,5 @@ void applySmoothRoundedCornersImpl(CALayer * _Nonnull layer);
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
UIView<UIKitPortalViewProtocol> * _Nullable makePortalView(bool matchPosition);
|
UIView<UIKitPortalViewProtocol> * _Nullable makePortalView(bool matchPosition);
|
||||||
|
|
||||||
|
NSObject * _Nullable makeBlurFilter();
|
||||||
|
@ -200,3 +200,13 @@ UIView<UIKitPortalViewProtocol> * _Nullable makePortalView(bool matchPosition) {
|
|||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@protocol GraphicsFilterProtocol <NSObject>
|
||||||
|
|
||||||
|
- (NSObject * _Nullable)filterWithName:(NSString * _Nonnull)name;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NSObject * _Nullable makeBlurFilter() {
|
||||||
|
return [(id<GraphicsFilterProtocol>)NSClassFromString(@"CAFilter") filterWithName:@"gaussianBlur"];
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user