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, *)
|
@available(iOSApplicationExtension 13.4, iOS 13.4, *)
|
||||||
private final class PointerInteractionImpl: NSObject, UIPointerInteractionDelegate {
|
private final class PointerInteractionImpl: NSObject {
|
||||||
weak var pointerInteraction: UIPointerInteraction?
|
//UIPointerInteractionDelegate {
|
||||||
|
// weak var pointerInteraction: UIPointerInteraction?
|
||||||
|
|
||||||
private let style: PointerStyle
|
private let style: PointerStyle
|
||||||
|
|
||||||
@ -28,63 +29,63 @@ private final class PointerInteractionImpl: NSObject, UIPointerInteractionDelega
|
|||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
if let pointerInteraction = self.pointerInteraction {
|
// if let pointerInteraction = self.pointerInteraction {
|
||||||
pointerInteraction.view?.removeInteraction(pointerInteraction)
|
// pointerInteraction.view?.removeInteraction(pointerInteraction)
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
func setup(view: UIView) {
|
func setup(view: UIView) {
|
||||||
let pointerInteraction = UIPointerInteraction(delegate: self)
|
// let pointerInteraction = UIPointerInteraction(delegate: self)
|
||||||
view.addInteraction(pointerInteraction)
|
// view.addInteraction(pointerInteraction)
|
||||||
self.pointerInteraction = pointerInteraction
|
// self.pointerInteraction = pointerInteraction
|
||||||
}
|
}
|
||||||
|
|
||||||
func pointerInteraction(_ interaction: UIPointerInteraction, styleFor region: UIPointerRegion) -> UIPointerStyle? {
|
// func pointerInteraction(_ interaction: UIPointerInteraction, styleFor region: UIPointerRegion) -> UIPointerStyle? {
|
||||||
var pointerStyle: UIPointerStyle? = nil
|
// var pointerStyle: UIPointerStyle? = nil
|
||||||
if let interactionView = interaction.view {
|
// if let interactionView = interaction.view {
|
||||||
let targetedPreview = UITargetedPreview(view: interactionView)
|
// let targetedPreview = UITargetedPreview(view: interactionView)
|
||||||
switch self.style {
|
// switch self.style {
|
||||||
case .default:
|
// case .default:
|
||||||
let horizontalPadding: CGFloat = 10.0
|
// let horizontalPadding: CGFloat = 10.0
|
||||||
let verticalPadding: CGFloat = 4.0
|
// let verticalPadding: CGFloat = 4.0
|
||||||
let minHeight: CGFloat = 40.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))
|
// 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))
|
// 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):
|
// 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))
|
// 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:
|
// case .circle:
|
||||||
let maxSide = max(targetedPreview.size.width, targetedPreview.size.height)
|
// 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)))))
|
// pointerStyle = UIPointerStyle(effect: .highlight(targetedPreview), shape: .path(UIBezierPath(ovalIn: CGRect(origin: CGPoint(), size: CGSize(width: maxSide, height: maxSide)))))
|
||||||
case .caret:
|
// case .caret:
|
||||||
pointerStyle = UIPointerStyle(shape: .verticalBeam(length: 24.0), constrainedAxes: .vertical)
|
// pointerStyle = UIPointerStyle(shape: .verticalBeam(length: 24.0), constrainedAxes: .vertical)
|
||||||
case .lift:
|
// case .lift:
|
||||||
pointerStyle = UIPointerStyle(effect: .lift(targetedPreview))
|
// pointerStyle = UIPointerStyle(effect: .lift(targetedPreview))
|
||||||
case .hover:
|
// case .hover:
|
||||||
pointerStyle = UIPointerStyle(effect: .hover(targetedPreview, preferredTintMode: .none, prefersShadow: false, prefersScaledContent: false))
|
// pointerStyle = UIPointerStyle(effect: .hover(targetedPreview, preferredTintMode: .none, prefersShadow: false, prefersScaledContent: false))
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return pointerStyle
|
// return pointerStyle
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
func pointerInteraction(_ interaction: UIPointerInteraction, willEnter region: UIPointerRegion, animator: UIPointerInteractionAnimating) {
|
// func pointerInteraction(_ interaction: UIPointerInteraction, willEnter region: UIPointerRegion, animator: UIPointerInteractionAnimating) {
|
||||||
guard let _ = interaction.view else {
|
// guard let _ = interaction.view else {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
animator.addAnimations {
|
// animator.addAnimations {
|
||||||
self.willEnter()
|
// self.willEnter()
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
func pointerInteraction(_ interaction: UIPointerInteraction, willExit region: UIPointerRegion, animator: UIPointerInteractionAnimating) {
|
// func pointerInteraction(_ interaction: UIPointerInteraction, willExit region: UIPointerRegion, animator: UIPointerInteractionAnimating) {
|
||||||
guard let _ = interaction.view else {
|
// guard let _ = interaction.view else {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
animator.addAnimations {
|
// animator.addAnimations {
|
||||||
self.willExit()
|
// self.willExit()
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class PointerInteraction {
|
public final class PointerInteraction {
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
const CGFloat TGMenuSheetButtonItemViewHeight = 57.0f;
|
const CGFloat TGMenuSheetButtonItemViewHeight = 57.0f;
|
||||||
|
|
||||||
@interface TGMenuSheetButtonItemView () <UIPointerInteractionDelegate>
|
@interface TGMenuSheetButtonItemView () //<UIPointerInteractionDelegate>
|
||||||
{
|
{
|
||||||
bool _dark;
|
bool _dark;
|
||||||
bool _requiresDivider;
|
bool _requiresDivider;
|
||||||
@ -58,36 +58,36 @@ const CGFloat TGMenuSheetButtonItemViewHeight = 57.0f;
|
|||||||
strongSelf.highlightUpdateBlock(highlighted);
|
strongSelf.highlightUpdateBlock(highlighted);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (iosMajorVersion() > 13 || (iosMajorVersion() == 13 && iosMinorVersion() >= 4)) {
|
// if (iosMajorVersion() > 13 || (iosMajorVersion() == 13 && iosMinorVersion() >= 4)) {
|
||||||
UIPointerInteraction *pointerInteraction = [[UIPointerInteraction alloc] initWithDelegate:self];
|
// UIPointerInteraction *pointerInteraction = [[UIPointerInteraction alloc] initWithDelegate:self];
|
||||||
[self addInteraction:pointerInteraction];
|
// [self addInteraction:pointerInteraction];
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (UIPointerStyle *)pointerInteraction:(UIPointerInteraction *)interaction styleForRegion:(UIPointerRegion *)region {
|
//- (UIPointerStyle *)pointerInteraction:(UIPointerInteraction *)interaction styleForRegion:(UIPointerRegion *)region {
|
||||||
if (interaction.view != nil) {
|
// if (interaction.view != nil) {
|
||||||
UITargetedPreview *targetedPreview = [[UITargetedPreview alloc] initWithView:interaction.view];
|
// UITargetedPreview *targetedPreview = [[UITargetedPreview alloc] initWithView:interaction.view];
|
||||||
UIPointerHoverEffect *effect = [UIPointerHoverEffect effectWithPreview:targetedPreview];
|
// UIPointerHoverEffect *effect = [UIPointerHoverEffect effectWithPreview:targetedPreview];
|
||||||
effect.preferredTintMode = UIPointerEffectTintModeNone;
|
// effect.preferredTintMode = UIPointerEffectTintModeNone;
|
||||||
effect.prefersScaledContent = false;
|
// effect.prefersScaledContent = false;
|
||||||
return [UIPointerStyle styleWithEffect:effect shape:nil];
|
// return [UIPointerStyle styleWithEffect:effect shape:nil];
|
||||||
}
|
// }
|
||||||
return nil;
|
// return nil;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
- (void)pointerInteraction:(UIPointerInteraction *)interaction willEnterRegion:(UIPointerRegion *)region animator:(id<UIPointerInteractionAnimating>)animator {
|
//- (void)pointerInteraction:(UIPointerInteraction *)interaction willEnterRegion:(UIPointerRegion *)region animator:(id<UIPointerInteractionAnimating>)animator {
|
||||||
[animator addAnimations:^{
|
// [animator addAnimations:^{
|
||||||
_highlightView.alpha = 0.75f;
|
// _highlightView.alpha = 0.75f;
|
||||||
}];
|
// }];
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
- (void)pointerInteraction:(UIPointerInteraction *)interaction willExitRegion:(UIPointerRegion *)region animator:(id<UIPointerInteractionAnimating>)animator {
|
//- (void)pointerInteraction:(UIPointerInteraction *)interaction willExitRegion:(UIPointerRegion *)region animator:(id<UIPointerInteractionAnimating>)animator {
|
||||||
[animator addAnimations:^{
|
// [animator addAnimations:^{
|
||||||
_highlightView.alpha = 0.0f;
|
// _highlightView.alpha = 0.0f;
|
||||||
}];
|
// }];
|
||||||
}
|
//}
|
||||||
|
|
||||||
- (void)setDark
|
- (void)setDark
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user