Add animation plist key

This commit is contained in:
Ali
2021-09-28 15:06:13 +04:00
parent b90e16d94e
commit 2a61eee4a6
6 changed files with 54 additions and 24 deletions

View File

@@ -1793,6 +1793,8 @@ plist_fragment(
</dict> </dict>
</dict> </dict>
</array> </array>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
""".format( """.format(
telegram_bundle_id = telegram_bundle_id, telegram_bundle_id = telegram_bundle_id,
) )

View File

@@ -2,6 +2,7 @@ import UIKit
import AsyncDisplayKit import AsyncDisplayKit
import SwiftSignalKit import SwiftSignalKit
import UIKitRuntimeUtils import UIKitRuntimeUtils
import ObjCRuntimeUtils
private let infiniteScrollSize: CGFloat = 10000.0 private let infiniteScrollSize: CGFloat = 10000.0
private let insertionAnimationDuration: Double = 0.4 private let insertionAnimationDuration: Double = 0.4
@@ -822,12 +823,28 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
} }
private var generalAccumulatedDeltaY: CGFloat = 0.0 private var generalAccumulatedDeltaY: CGFloat = 0.0
private var previousDidScrollTimestamp: Double = 0.0
private func updateScrollViewDidScroll(_ scrollView: UIScrollView, synchronous: Bool) { private func updateScrollViewDidScroll(_ scrollView: UIScrollView, synchronous: Bool) {
if self.ignoreScrollingEvents || scroller !== self.scroller { if self.ignoreScrollingEvents || scroller !== self.scroller {
return return
} }
/*let timestamp = CACurrentMediaTime()
if !self.previousDidScrollTimestamp.isZero {
let delta = timestamp - self.previousDidScrollTimestamp
if delta < 0.1 {
print("Scrolling delta: \(delta)")
}
}
self.previousDidScrollTimestamp = timestamp
if let displayLink = self.scroller.getIvarValue("_scrollHeartbeat") as? CADisplayLink {
if #available(iOS 10.0, *) {
displayLink.preferredFramesPerSecond = 120
}
}*/
//CATransaction.begin() //CATransaction.begin()
//CATransaction.setDisableActions(true) //CATransaction.setDisableActions(true)
@@ -854,7 +871,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
self.trackingOffset += -deltaY self.trackingOffset += -deltaY
} }
self.enqueueUpdateVisibleItems(synchronous: synchronous) self.enqueueUpdateVisibleItems(synchronous: true)
var useScrollDynamics = false var useScrollDynamics = false

View File

@@ -22,6 +22,8 @@ typedef enum {
- (id _Nullable)associatedObjectForKey:(void const * _Nonnull)key; - (id _Nullable)associatedObjectForKey:(void const * _Nonnull)key;
- (bool)checkObjectIsKindOfClass:(Class _Nonnull)targetClass; - (bool)checkObjectIsKindOfClass:(Class _Nonnull)targetClass;
- (void)setClass:(Class _Nonnull)newClass; - (void)setClass:(Class _Nonnull)newClass;
+ (NSArray<NSString *> * _Nonnull)getIvarList:(Class _Nonnull)classValue;
- (id _Nullable)getIvarValue:(NSString * _Nonnull)name;
@end @end

View File

@@ -98,27 +98,34 @@
object_setClass(self, newClass); object_setClass(self, newClass);
} }
static Class freedomMakeClass(Class superclass, Class subclass, SEL *copySelectors, int copySelectorsCount) + (NSArray<NSString *> * _Nonnull)getIvarList:(Class _Nonnull)classValue {
{ NSMutableArray<NSString *> *result = [[NSMutableArray alloc] init];
if (superclass == Nil || subclass == Nil)
unsigned int varCount;
Ivar *vars = class_copyIvarList(classValue, &varCount);
for (int i = 0; i < varCount; i++) {
Ivar var = vars[i];
const char* name = ivar_getName(var);
const char* typeEncoding = ivar_getTypeEncoding(var);
[result addObject:[NSString stringWithFormat:@"%s: %s", name, typeEncoding]];
}
free(vars);
return result;
}
- (id _Nullable)getIvarValue:(NSString * _Nonnull)name {
Ivar ivar = class_getInstanceVariable([self class], [name UTF8String]);
if (!ivar){
return nil; return nil;
Class decoratedClass = objc_allocateClassPair(superclass, [[NSString alloc] initWithFormat:@"%@_%@", NSStringFromClass(superclass), NSStringFromClass(subclass)].UTF8String, 0);
unsigned int count = 0;
Method *methodList = class_copyMethodList(subclass, &count);
if (methodList != NULL) {
for (unsigned int i = 0; i < count; i++) {
SEL methodName = method_getName(methodList[i]);
class_addMethod(decoratedClass, methodName, method_getImplementation(methodList[i]), method_getTypeEncoding(methodList[i]));
} }
id value = object_getIvar(self, ivar);
free(methodList); return value;
}
objc_registerClassPair(decoratedClass);
return decoratedClass;
} }
@end @end

View File

@@ -20,8 +20,8 @@ public struct ChatTheme: PostboxCoding, Equatable {
public init(decoder: PostboxDecoder) { public init(decoder: PostboxDecoder) {
self.emoji = decoder.decodeStringForKey("e", orElse: "") self.emoji = decoder.decodeStringForKey("e", orElse: "")
self.theme = decoder.decodeObjectForKey("t") as! TelegramTheme self.theme = decoder.decodeObjectForKey("t", decoder: { TelegramTheme(decoder: $0) }) as! TelegramTheme
self.darkTheme = decoder.decodeObjectForKey("dt") as! TelegramTheme self.darkTheme = decoder.decodeObjectForKey("dt", decoder: { TelegramTheme(decoder: $0) }) as! TelegramTheme
} }
public func encode(_ encoder: PostboxEncoder) { public func encode(_ encoder: PostboxEncoder) {

View File

@@ -1067,6 +1067,8 @@ final class PeerInfoVisualMediaPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScro
self.updateHeaderFlashing(animated: true) self.updateHeaderFlashing(animated: true)
} }
private var previousDidScrollTimestamp: Double = 0.0
func scrollViewDidScroll(_ scrollView: UIScrollView) { func scrollViewDidScroll(_ scrollView: UIScrollView) {
if let (size, sideInset, bottomInset, visibleHeight, _, _, presentationData) = self.currentParams { if let (size, sideInset, bottomInset, visibleHeight, _, _, presentationData) = self.currentParams {
self.updateVisibleItems(size: size, sideInset: sideInset, bottomInset: bottomInset, visibleHeight: visibleHeight, theme: presentationData.theme, strings: presentationData.strings, synchronousLoad: false) self.updateVisibleItems(size: size, sideInset: sideInset, bottomInset: bottomInset, visibleHeight: visibleHeight, theme: presentationData.theme, strings: presentationData.strings, synchronousLoad: false)