mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
a9fbe9747d
@ -11,8 +11,9 @@ public enum PointerStyle {
|
||||
}
|
||||
|
||||
@available(iOSApplicationExtension 13.4, iOS 13.4, *)
|
||||
private final class PointerInteractionImpl: NSObject, UIPointerInteractionDelegate {
|
||||
weak var pointerInteraction: UIPointerInteraction?
|
||||
private final class PointerInteractionImpl: NSObject {
|
||||
//UIPointerInteractionDelegate {
|
||||
// weak var pointerInteraction: UIPointerInteraction?
|
||||
|
||||
private let style: PointerStyle
|
||||
|
||||
@ -28,63 +29,63 @@ private final class PointerInteractionImpl: NSObject, UIPointerInteractionDelega
|
||||
}
|
||||
|
||||
deinit {
|
||||
if let pointerInteraction = self.pointerInteraction {
|
||||
pointerInteraction.view?.removeInteraction(pointerInteraction)
|
||||
}
|
||||
// if let pointerInteraction = self.pointerInteraction {
|
||||
// pointerInteraction.view?.removeInteraction(pointerInteraction)
|
||||
// }
|
||||
}
|
||||
|
||||
func setup(view: UIView) {
|
||||
let pointerInteraction = UIPointerInteraction(delegate: self)
|
||||
view.addInteraction(pointerInteraction)
|
||||
self.pointerInteraction = pointerInteraction
|
||||
// let pointerInteraction = UIPointerInteraction(delegate: self)
|
||||
// view.addInteraction(pointerInteraction)
|
||||
// self.pointerInteraction = pointerInteraction
|
||||
}
|
||||
|
||||
func pointerInteraction(_ interaction: UIPointerInteraction, styleFor region: UIPointerRegion) -> UIPointerStyle? {
|
||||
var pointerStyle: UIPointerStyle? = nil
|
||||
if let interactionView = interaction.view {
|
||||
let targetedPreview = UITargetedPreview(view: interactionView)
|
||||
switch self.style {
|
||||
case .default:
|
||||
let horizontalPadding: CGFloat = 10.0
|
||||
let verticalPadding: CGFloat = 4.0
|
||||
let minHeight: CGFloat = 40.0
|
||||
let size: CGSize = CGSize(width: targetedPreview.size.width + horizontalPadding * 2.0, height: max(minHeight, targetedPreview.size.height + verticalPadding * 2.0))
|
||||
pointerStyle = UIPointerStyle(effect: .highlight(targetedPreview), shape: .roundedRect(CGRect(origin: CGPoint(x: targetedPreview.view.center.x - size.width / 2.0, y: targetedPreview.view.center.y - size.height / 2.0), size: size), radius: UIPointerShape.defaultCornerRadius))
|
||||
case let .rectangle(size):
|
||||
pointerStyle = UIPointerStyle(effect: .highlight(targetedPreview), shape: .roundedRect(CGRect(origin: CGPoint(x: targetedPreview.view.center.x - size.width / 2.0, y: targetedPreview.view.center.y - size.height / 2.0), size: size), radius: UIPointerShape.defaultCornerRadius))
|
||||
case .circle:
|
||||
let maxSide = max(targetedPreview.size.width, targetedPreview.size.height)
|
||||
pointerStyle = UIPointerStyle(effect: .highlight(targetedPreview), shape: .path(UIBezierPath(ovalIn: CGRect(origin: CGPoint(), size: CGSize(width: maxSide, height: maxSide)))))
|
||||
case .caret:
|
||||
pointerStyle = UIPointerStyle(shape: .verticalBeam(length: 24.0), constrainedAxes: .vertical)
|
||||
case .lift:
|
||||
pointerStyle = UIPointerStyle(effect: .lift(targetedPreview))
|
||||
case .hover:
|
||||
pointerStyle = UIPointerStyle(effect: .hover(targetedPreview, preferredTintMode: .none, prefersShadow: false, prefersScaledContent: false))
|
||||
}
|
||||
}
|
||||
return pointerStyle
|
||||
}
|
||||
|
||||
func pointerInteraction(_ interaction: UIPointerInteraction, willEnter region: UIPointerRegion, animator: UIPointerInteractionAnimating) {
|
||||
guard let _ = interaction.view else {
|
||||
return
|
||||
}
|
||||
|
||||
animator.addAnimations {
|
||||
self.willEnter()
|
||||
}
|
||||
}
|
||||
|
||||
func pointerInteraction(_ interaction: UIPointerInteraction, willExit region: UIPointerRegion, animator: UIPointerInteractionAnimating) {
|
||||
guard let _ = interaction.view else {
|
||||
return
|
||||
}
|
||||
|
||||
animator.addAnimations {
|
||||
self.willExit()
|
||||
}
|
||||
}
|
||||
// func pointerInteraction(_ interaction: UIPointerInteraction, styleFor region: UIPointerRegion) -> UIPointerStyle? {
|
||||
// var pointerStyle: UIPointerStyle? = nil
|
||||
// if let interactionView = interaction.view {
|
||||
// let targetedPreview = UITargetedPreview(view: interactionView)
|
||||
// switch self.style {
|
||||
// case .default:
|
||||
// let horizontalPadding: CGFloat = 10.0
|
||||
// let verticalPadding: CGFloat = 4.0
|
||||
// let minHeight: CGFloat = 40.0
|
||||
// let size: CGSize = CGSize(width: targetedPreview.size.width + horizontalPadding * 2.0, height: max(minHeight, targetedPreview.size.height + verticalPadding * 2.0))
|
||||
// pointerStyle = UIPointerStyle(effect: .highlight(targetedPreview), shape: .roundedRect(CGRect(origin: CGPoint(x: targetedPreview.view.center.x - size.width / 2.0, y: targetedPreview.view.center.y - size.height / 2.0), size: size), radius: UIPointerShape.defaultCornerRadius))
|
||||
// case let .rectangle(size):
|
||||
// pointerStyle = UIPointerStyle(effect: .highlight(targetedPreview), shape: .roundedRect(CGRect(origin: CGPoint(x: targetedPreview.view.center.x - size.width / 2.0, y: targetedPreview.view.center.y - size.height / 2.0), size: size), radius: UIPointerShape.defaultCornerRadius))
|
||||
// case .circle:
|
||||
// let maxSide = max(targetedPreview.size.width, targetedPreview.size.height)
|
||||
// pointerStyle = UIPointerStyle(effect: .highlight(targetedPreview), shape: .path(UIBezierPath(ovalIn: CGRect(origin: CGPoint(), size: CGSize(width: maxSide, height: maxSide)))))
|
||||
// case .caret:
|
||||
// pointerStyle = UIPointerStyle(shape: .verticalBeam(length: 24.0), constrainedAxes: .vertical)
|
||||
// case .lift:
|
||||
// pointerStyle = UIPointerStyle(effect: .lift(targetedPreview))
|
||||
// case .hover:
|
||||
// pointerStyle = UIPointerStyle(effect: .hover(targetedPreview, preferredTintMode: .none, prefersShadow: false, prefersScaledContent: false))
|
||||
// }
|
||||
// }
|
||||
// return pointerStyle
|
||||
// }
|
||||
//
|
||||
// func pointerInteraction(_ interaction: UIPointerInteraction, willEnter region: UIPointerRegion, animator: UIPointerInteractionAnimating) {
|
||||
// guard let _ = interaction.view else {
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// animator.addAnimations {
|
||||
// self.willEnter()
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func pointerInteraction(_ interaction: UIPointerInteraction, willExit region: UIPointerRegion, animator: UIPointerInteractionAnimating) {
|
||||
// guard let _ = interaction.view else {
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// animator.addAnimations {
|
||||
// self.willExit()
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
public final class PointerInteraction {
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
const CGFloat TGMenuSheetButtonItemViewHeight = 57.0f;
|
||||
|
||||
@interface TGMenuSheetButtonItemView () <UIPointerInteractionDelegate>
|
||||
@interface TGMenuSheetButtonItemView () //<UIPointerInteractionDelegate>
|
||||
{
|
||||
bool _dark;
|
||||
bool _requiresDivider;
|
||||
@ -58,36 +58,36 @@ const CGFloat TGMenuSheetButtonItemViewHeight = 57.0f;
|
||||
strongSelf.highlightUpdateBlock(highlighted);
|
||||
};
|
||||
|
||||
if (iosMajorVersion() > 13 || (iosMajorVersion() == 13 && iosMinorVersion() >= 4)) {
|
||||
UIPointerInteraction *pointerInteraction = [[UIPointerInteraction alloc] initWithDelegate:self];
|
||||
[self addInteraction:pointerInteraction];
|
||||
}
|
||||
// if (iosMajorVersion() > 13 || (iosMajorVersion() == 13 && iosMinorVersion() >= 4)) {
|
||||
// UIPointerInteraction *pointerInteraction = [[UIPointerInteraction alloc] initWithDelegate:self];
|
||||
// [self addInteraction:pointerInteraction];
|
||||
// }
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (UIPointerStyle *)pointerInteraction:(UIPointerInteraction *)interaction styleForRegion:(UIPointerRegion *)region {
|
||||
if (interaction.view != nil) {
|
||||
UITargetedPreview *targetedPreview = [[UITargetedPreview alloc] initWithView:interaction.view];
|
||||
UIPointerHoverEffect *effect = [UIPointerHoverEffect effectWithPreview:targetedPreview];
|
||||
effect.preferredTintMode = UIPointerEffectTintModeNone;
|
||||
effect.prefersScaledContent = false;
|
||||
return [UIPointerStyle styleWithEffect:effect shape:nil];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)pointerInteraction:(UIPointerInteraction *)interaction willEnterRegion:(UIPointerRegion *)region animator:(id<UIPointerInteractionAnimating>)animator {
|
||||
[animator addAnimations:^{
|
||||
_highlightView.alpha = 0.75f;
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)pointerInteraction:(UIPointerInteraction *)interaction willExitRegion:(UIPointerRegion *)region animator:(id<UIPointerInteractionAnimating>)animator {
|
||||
[animator addAnimations:^{
|
||||
_highlightView.alpha = 0.0f;
|
||||
}];
|
||||
}
|
||||
//- (UIPointerStyle *)pointerInteraction:(UIPointerInteraction *)interaction styleForRegion:(UIPointerRegion *)region {
|
||||
// if (interaction.view != nil) {
|
||||
// UITargetedPreview *targetedPreview = [[UITargetedPreview alloc] initWithView:interaction.view];
|
||||
// UIPointerHoverEffect *effect = [UIPointerHoverEffect effectWithPreview:targetedPreview];
|
||||
// effect.preferredTintMode = UIPointerEffectTintModeNone;
|
||||
// effect.prefersScaledContent = false;
|
||||
// return [UIPointerStyle styleWithEffect:effect shape:nil];
|
||||
// }
|
||||
// return nil;
|
||||
//}
|
||||
//
|
||||
//- (void)pointerInteraction:(UIPointerInteraction *)interaction willEnterRegion:(UIPointerRegion *)region animator:(id<UIPointerInteractionAnimating>)animator {
|
||||
// [animator addAnimations:^{
|
||||
// _highlightView.alpha = 0.75f;
|
||||
// }];
|
||||
//}
|
||||
//
|
||||
//- (void)pointerInteraction:(UIPointerInteraction *)interaction willExitRegion:(UIPointerRegion *)region animator:(id<UIPointerInteractionAnimating>)animator {
|
||||
// [animator addAnimations:^{
|
||||
// _highlightView.alpha = 0.0f;
|
||||
// }];
|
||||
//}
|
||||
|
||||
- (void)setDark
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user