SPSBGeneralManager.m 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. //
  2. // SPSBGeneralManager.m
  3. // 我的社保
  4. //
  5. // Created by shanp on 2021/4/19.
  6. //
  7. #import "SPSBGeneralManager.h"
  8. #import "SPSBNavigationController.h"
  9. #import "SPSBTabBarView.h"
  10. #import "SPSBHomeViewController.h"
  11. #import "SPSBQueryHomeViewController.h"
  12. #import "SPSBConsultationViewController.h"
  13. #import "SPSBMineViewController.h"
  14. #import "SPSBColorProfile.h"
  15. #import "SPSBStartPageViewController.h"
  16. #import <JXHSystemShortcut.h>
  17. #import <AdSupport/AdSupport.h>
  18. #import "YYKeychain.h"
  19. #import "SPSBKeyProfile.h"
  20. #import <AppTrackingTransparency/AppTrackingTransparency.h>
  21. #import "SPSBConfirmAlertViewController.h"
  22. #pragma mark - Font
  23. UIFont *spsb_font(CGFloat font) {
  24. // NSArray *familyNames = [UIFont familyNames];
  25. //
  26. // for (NSString *familyName in familyNames) {
  27. // printf("familyNames = %s\n",[familyName UTF8String]);
  28. //
  29. // NSArray *fontNames = [UIFont fontNamesForFamilyName:familyName];
  30. //
  31. // for (NSString *fontName in fontNames) {
  32. // printf("\tfontName = %s\n",[fontName UTF8String]);
  33. // }
  34. // }
  35. UIFont *_font = [UIFont fontWithName:@"PingFangSC-Regular" size:font];
  36. return _font ?: [UIFont systemFontOfSize:font];
  37. }
  38. UIFont *spsb_ThinFont(CGFloat font) {
  39. UIFont *_font = [UIFont fontWithName:@"PingFangSC-Thin" size:font];
  40. return _font ?: [UIFont systemFontOfSize:font];
  41. }
  42. UIFont *spsb_lightFont(CGFloat font) {
  43. UIFont *_font = [UIFont fontWithName:@"PingFangSC-Light" size:font];
  44. return _font ?: [UIFont systemFontOfSize:font];
  45. }
  46. UIFont *spsb_mediumFont(CGFloat font) {
  47. UIFont *_font = [UIFont fontWithName:@"PingFangSC-Medium" size:font];
  48. return _font ?: [UIFont boldSystemFontOfSize:font];
  49. }
  50. UIFont *spsb_semiboldFont(CGFloat font) {
  51. UIFont *_font = [UIFont fontWithName:@"PingFangSC-Semibold" size:font];
  52. return _font ?: [UIFont boldSystemFontOfSize:font];
  53. }
  54. static UIWindow *_spsb_keyWindow = nil;
  55. UIWindow *_Nullable spsb_keyWindow() {
  56. return _spsb_keyWindow;
  57. }
  58. UIWindow *spsb_setKeyWindow(id windowScene) {
  59. _spsb_keyWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  60. _spsb_keyWindow.backgroundColor = spsb_FFFFFF_color(1.f);
  61. if (windowScene) {
  62. if (@available(iOS 13.0, *)) {
  63. _spsb_keyWindow.windowScene = (UIWindowScene *)windowScene;
  64. }
  65. }
  66. _spsb_keyWindow.rootViewController = SPSBStartPageViewController.new;
  67. [_spsb_keyWindow makeKeyAndVisible];
  68. return _spsb_keyWindow;
  69. }
  70. SPSBDate spsb_getNewDate() {
  71. NSDate *new = [NSDate new];
  72. NSString *str = [jxh_dateFormatter() stringFromDate:new];
  73. SPSBDate date;
  74. date.spsb_year = [str substringWithRange:NSMakeRange(0, 4)];
  75. date.spsb_month = [str substringWithRange:NSMakeRange(5, 2)];
  76. date.spsb_day = [str substringWithRange:NSMakeRange(8, 2)];
  77. return date;
  78. }
  79. NSString *spsb_getIDFA() {
  80. __block NSString *idfa = @"";
  81. ASIdentifierManager *manager = [ASIdentifierManager sharedManager];
  82. if (@available(iOS 14, *)) {
  83. [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
  84. if (status == ATTrackingManagerAuthorizationStatusAuthorized) {
  85. idfa = [[manager advertisingIdentifier] UUIDString];
  86. }
  87. }];
  88. } else {
  89. if ([manager isAdvertisingTrackingEnabled]) {
  90. idfa = [[manager advertisingIdentifier] UUIDString];
  91. }
  92. }
  93. return idfa;
  94. }
  95. NSString *spsb_getUniquenessString() {
  96. NSString *reg = spsb_getIDFA();
  97. if (reg.length == 0) {
  98. reg = [YYKeychain getPasswordForService:SPSBJudgeFirstInstallKeychainServiece account:SPSBJudgeFirstInstallKeyKeychainAccount];
  99. reg = [reg stringByReplacingOccurrencesOfString:@"-" withString:@""];
  100. reg = [NSString stringWithFormat:@"uuid%@", reg];
  101. }
  102. return reg;
  103. }
  104. void spsb_singleAlertShow(NSString *title, UIViewController *controller) {
  105. SPSBConfirmAlertViewController *vc = [SPSBConfirmAlertViewController alertWithTitle:title content:nil];
  106. [vc setConfirmButtonTitle:nil titleColor:nil action:^{
  107. }];
  108. [controller presentViewController:vc animated:false completion:nil];
  109. }
  110. #pragma mark - TabBar
  111. static SPSBHomeViewController *_spsb_homeVC = nil;
  112. SPSBHomeViewController *spsb_homeVC() {
  113. if (!_spsb_homeVC) {
  114. _spsb_homeVC = SPSBHomeViewController.new;
  115. }
  116. return _spsb_homeVC;
  117. }
  118. static SPSBNavigationController *_spsb_homeNavVC = nil;
  119. SPSBNavigationController *spsb_homeNavVC() {
  120. if (!_spsb_homeNavVC) {
  121. _spsb_homeNavVC = [[SPSBNavigationController alloc] initWithRootViewController:spsb_homeVC()];
  122. }
  123. return _spsb_homeNavVC;
  124. }
  125. static SPSBQueryHomeViewController *_spsb_queryHomeVC = nil;
  126. SPSBQueryHomeViewController *spsb_queryHomeVC() {
  127. if (!_spsb_queryHomeVC) {
  128. _spsb_queryHomeVC = SPSBQueryHomeViewController.new;
  129. }
  130. return _spsb_queryHomeVC;
  131. }
  132. static SPSBNavigationController *_spsb_queryHomeNavVC = nil;
  133. SPSBNavigationController *spsb_queryHomeNavVC() {
  134. if (!_spsb_queryHomeNavVC) {
  135. _spsb_queryHomeNavVC = [[SPSBNavigationController alloc] initWithRootViewController:spsb_queryHomeVC()];
  136. }
  137. return _spsb_queryHomeNavVC;
  138. }
  139. static SPSBConsultationViewController *_spsb_consultationHomeVC = nil;
  140. SPSBConsultationViewController *spsb_consultationHomeVC() {
  141. if (!_spsb_consultationHomeVC) {
  142. _spsb_consultationHomeVC = SPSBConsultationViewController.new;
  143. }
  144. return _spsb_consultationHomeVC;
  145. }
  146. static SPSBNavigationController *_spsb_consultationHomeNavVC = nil;
  147. SPSBNavigationController *spsb_consultationHomeNavVC() {
  148. if (!_spsb_consultationHomeNavVC) {
  149. _spsb_consultationHomeNavVC = [[SPSBNavigationController alloc] initWithRootViewController:spsb_consultationHomeVC()];
  150. }
  151. return _spsb_consultationHomeNavVC;
  152. }
  153. static SPSBMineViewController *_spsb_mineVC = nil;
  154. SPSBMineViewController *spsb_mineVC() {
  155. if (!_spsb_mineVC) {
  156. _spsb_mineVC = SPSBMineViewController.new;
  157. }
  158. return _spsb_mineVC;
  159. }
  160. static SPSBNavigationController *_spsb_mineNavVC = nil;
  161. SPSBNavigationController *spsb_mineNavVC() {
  162. if (!_spsb_mineNavVC) {
  163. _spsb_mineNavVC = [[SPSBNavigationController alloc] initWithRootViewController:spsb_mineVC()];
  164. }
  165. return _spsb_mineNavVC;
  166. }
  167. static SPSBTabBarView *_spsb_tabBarView = nil;
  168. SPSBTabBarView *spsb_tabBarView() {
  169. if (!_spsb_tabBarView) {
  170. _spsb_tabBarView = SPSBTabBarView.new;
  171. }
  172. return _spsb_tabBarView;
  173. }