@momo-kits/native-kits 0.160.1-scrolltotop.23-debug → 0.160.1-scrolltotop.24-debug

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,7 +40,7 @@ kotlin {
40
40
  }
41
41
 
42
42
  cocoapods {
43
- version = "0.160.1-scrolltotop.23-debug"
43
+ version = "0.160.1-scrolltotop.24-debug"
44
44
  summary = "IOS Shared module"
45
45
  homepage = "https://momo.vn"
46
46
  ios.deploymentTarget = "15.0"
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |spec|
2
2
  spec.name = 'compose'
3
- spec.version = '0.159.1-beta.12'
3
+ spec.version = '0.160.1-scrolltotop.23'
4
4
  spec.homepage = 'https://momo.vn'
5
5
  spec.source = { :http=> ''}
6
6
  spec.authors = ''
package/gradle.properties CHANGED
@@ -18,7 +18,7 @@ kotlin.apple.xcodeCompatibility.nowarn=true
18
18
  name="ComposeKits"
19
19
  group=vn.momo.kits
20
20
  artifact.id=kits
21
- version=0.160.1-scrolltotop.23
21
+ version=0.160.1-scrolltotop.24
22
22
 
23
23
  repo=GitLab
24
24
  url=https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven
@@ -0,0 +1,13 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ NS_ASSUME_NONNULL_BEGIN
4
+
5
+ /// Posts `MoMoStatusBarTap.notificationName` on every status-bar tap.
6
+ /// The swizzle installs automatically at framework load (`+load`) — calling
7
+ /// `install` is a no-op kept for explicit/manual triggering.
8
+ @interface MoMoStatusBarTap : NSObject
9
+ @property (class, nonatomic, readonly) NSNotificationName notificationName;
10
+ + (void)install;
11
+ @end
12
+
13
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,67 @@
1
+ #import <UIKit/UIKit.h>
2
+ #import <objc/message.h>
3
+ #import <objc/runtime.h>
4
+ #import "StatusBarTap.h"
5
+
6
+ @implementation MoMoStatusBarTap
7
+ + (NSNotificationName)notificationName { return @"statusBarSelected"; }
8
+ + (void)install { /* installed automatically via +load below */ }
9
+ @end
10
+
11
+ // MARK: - Swizzle on UIStatusBarManager
12
+ // Runs once at framework-load time. Uses the canonical add-or-exchange
13
+ // idiom so we never accidentally swizzle an inherited (superclass) IMP.
14
+
15
+ @interface UIStatusBarManager (MoMoStatusBarTap)
16
+ @end
17
+
18
+ @implementation UIStatusBarManager (MoMoStatusBarTap)
19
+
20
+ + (void)load {
21
+ static dispatch_once_t onceToken;
22
+ dispatch_once(&onceToken, ^{
23
+ Class cls = [self class];
24
+ SEL originalSelector = NSSelectorFromString(@"handleTapAction:");
25
+ SEL swizzledSelector = @selector(mm_handleTapAction:);
26
+
27
+ Method originalMethod = class_getInstanceMethod(cls, originalSelector);
28
+ Method swizzledMethod = class_getInstanceMethod(cls, swizzledSelector);
29
+ if (!originalMethod || !swizzledMethod) return;
30
+
31
+ // Verify the original method matches the (id) -> void shape we expect.
32
+ // Encoding may include byte offsets (e.g. "v32@0:8@16") so we filter
33
+ // digits out before comparing.
34
+ const char *encPtr = method_getTypeEncoding(originalMethod);
35
+ if (encPtr) {
36
+ NSMutableString *enc = [NSMutableString string];
37
+ for (const char *p = encPtr; *p; p++) {
38
+ if (!(*p >= '0' && *p <= '9')) [enc appendFormat:@"%c", *p];
39
+ }
40
+ if (![enc isEqualToString:@"v@:@"]) return;
41
+ }
42
+
43
+ BOOL didAdd = class_addMethod(cls,
44
+ originalSelector,
45
+ method_getImplementation(swizzledMethod),
46
+ method_getTypeEncoding(swizzledMethod));
47
+ if (didAdd) {
48
+ class_replaceMethod(cls,
49
+ swizzledSelector,
50
+ method_getImplementation(originalMethod),
51
+ method_getTypeEncoding(originalMethod));
52
+ } else {
53
+ method_exchangeImplementations(originalMethod, swizzledMethod);
54
+ }
55
+ });
56
+ }
57
+
58
+ - (void)mm_handleTapAction:(id)action {
59
+ // After the swap, this selector points at the original UIKit IMP —
60
+ // call it first so UIScrollView.scrollsToTop and other UIKit side
61
+ // effects fire normally, then notify our observers.
62
+ [self mm_handleTapAction:action];
63
+ [[NSNotificationCenter defaultCenter] postNotificationName:MoMoStatusBarTap.notificationName
64
+ object:nil];
65
+ }
66
+
67
+ @end
@@ -10,7 +10,8 @@ Pod::Spec.new do |s|
10
10
  s.ios.deployment_target = '15.0'
11
11
  s.swift_version = '5.0'
12
12
 
13
- s.source_files = "**/*.swift"
13
+ s.source_files = "**/*.{swift,m,h}"
14
+ s.public_header_files = "StatusBarTap/*.h"
14
15
  s.framework = 'SwiftUI', 'Combine'
15
16
  s.dependency 'SDWebImageSwiftUI'
16
17
  s.dependency 'lottie-ios'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.160.1-scrolltotop.23-debug",
3
+ "version": "0.160.1-scrolltotop.24-debug",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},
@@ -1,42 +0,0 @@
1
- import UIKit
2
- import ObjectiveC.runtime
3
-
4
- extension UIStatusBarManager {
5
- public static var statusBarTappedNotification: Notification.Name = {
6
- let name = Notification.Name("statusBarSelected")
7
- guard let original = class_getInstanceMethod(UIStatusBarManager.self, Selector(("handleTapAction:"))) else {
8
- NSLog("[MoMoStatusBarTap] original handleTapAction: not found — skip")
9
- return name
10
- }
11
- // Verify the method takes (self, _cmd, id) and returns void.
12
- // Encoding may include offsets (e.g. "v32@0:8@16") so strip digits before comparing.
13
- if let encPtr = method_getTypeEncoding(original) {
14
- let enc = String(cString: encPtr).filter { !$0.isNumber }
15
- guard enc == "v@:@" else {
16
- NSLog("[MoMoStatusBarTap] unexpected encoding \(enc) — skip")
17
- return name
18
- }
19
- }
20
- guard let swizzled = class_getInstanceMethod(UIStatusBarManager.self, #selector(_mm_handleTapAction)) else {
21
- NSLog("[MoMoStatusBarTap] replacement _mm_handleTapAction not found — skip")
22
- return name
23
- }
24
- method_exchangeImplementations(original, swizzled)
25
- NSLog("[MoMoStatusBarTap] swizzle installed")
26
- return name
27
- }()
28
-
29
- @objc dynamic private func _mm_handleTapAction(_ action: Any?) {
30
- _mm_handleTapAction(action)
31
- NotificationCenter.default.post(name: UIStatusBarManager.statusBarTappedNotification, object: nil)
32
- }
33
- }
34
-
35
- @objc(MoMoStatusBarTap)
36
- public final class MoMoStatusBarTap: NSObject {
37
- @objc public static let notificationName: String = "statusBarSelected"
38
-
39
- @objc public static func install() {
40
- _ = UIStatusBarManager.statusBarTappedNotification
41
- }
42
- }