123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- //
- // SPSBGeneralManager.m
- // 我的社保
- //
- // Created by shanp on 2021/4/19.
- //
- #import "SPSBGeneralManager.h"
- #import "SPSBNavigationController.h"
- #import "SPSBTabBarView.h"
- #import "SPSBHomeViewController.h"
- #import "SPSBQueryHomeViewController.h"
- #import "SPSBConsultationViewController.h"
- #import "SPSBMineViewController.h"
- #import "SPSBColorProfile.h"
- #import "SPSBStartPageViewController.h"
- #import <JXHSystemShortcut.h>
- #import <AdSupport/AdSupport.h>
- #import "YYKeychain.h"
- #import "SPSBKeyProfile.h"
- #import <AppTrackingTransparency/AppTrackingTransparency.h>
- #import "SPSBConfirmAlertViewController.h"
- #pragma mark - Font
- UIFont *spsb_font(CGFloat font) {
- // NSArray *familyNames = [UIFont familyNames];
- //
- // for (NSString *familyName in familyNames) {
- // printf("familyNames = %s\n",[familyName UTF8String]);
- //
- // NSArray *fontNames = [UIFont fontNamesForFamilyName:familyName];
- //
- // for (NSString *fontName in fontNames) {
- // printf("\tfontName = %s\n",[fontName UTF8String]);
- // }
- // }
- UIFont *_font = [UIFont fontWithName:@"PingFangSC-Regular" size:font];
- return _font ?: [UIFont systemFontOfSize:font];
- }
- UIFont *spsb_ThinFont(CGFloat font) {
- UIFont *_font = [UIFont fontWithName:@"PingFangSC-Thin" size:font];
- return _font ?: [UIFont systemFontOfSize:font];
- }
- UIFont *spsb_lightFont(CGFloat font) {
- UIFont *_font = [UIFont fontWithName:@"PingFangSC-Light" size:font];
- return _font ?: [UIFont systemFontOfSize:font];
- }
- UIFont *spsb_mediumFont(CGFloat font) {
- UIFont *_font = [UIFont fontWithName:@"PingFangSC-Medium" size:font];
- return _font ?: [UIFont boldSystemFontOfSize:font];
- }
- UIFont *spsb_semiboldFont(CGFloat font) {
- UIFont *_font = [UIFont fontWithName:@"PingFangSC-Semibold" size:font];
- return _font ?: [UIFont boldSystemFontOfSize:font];
- }
- static UIWindow *_spsb_keyWindow = nil;
- UIWindow *_Nullable spsb_keyWindow() {
- return _spsb_keyWindow;
- }
- UIWindow *spsb_setKeyWindow(id windowScene) {
- _spsb_keyWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
- _spsb_keyWindow.backgroundColor = spsb_FFFFFF_color(1.f);
- if (windowScene) {
- if (@available(iOS 13.0, *)) {
- _spsb_keyWindow.windowScene = (UIWindowScene *)windowScene;
- }
- }
- _spsb_keyWindow.rootViewController = SPSBStartPageViewController.new;
- [_spsb_keyWindow makeKeyAndVisible];
- return _spsb_keyWindow;
- }
- SPSBDate spsb_getNewDate() {
- NSDate *new = [NSDate new];
- NSString *str = [jxh_dateFormatter() stringFromDate:new];
- SPSBDate date;
- date.spsb_year = [str substringWithRange:NSMakeRange(0, 4)];
- date.spsb_month = [str substringWithRange:NSMakeRange(5, 2)];
- date.spsb_day = [str substringWithRange:NSMakeRange(8, 2)];
- return date;
- }
- NSString *spsb_getIDFA() {
- __block NSString *idfa = @"";
- ASIdentifierManager *manager = [ASIdentifierManager sharedManager];
- if (@available(iOS 14, *)) {
- [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
- if (status == ATTrackingManagerAuthorizationStatusAuthorized) {
- idfa = [[manager advertisingIdentifier] UUIDString];
- }
- }];
- } else {
- if ([manager isAdvertisingTrackingEnabled]) {
- idfa = [[manager advertisingIdentifier] UUIDString];
- }
- }
- return idfa;
- }
- NSString *spsb_getUniquenessString() {
- NSString *reg = spsb_getIDFA();
- if (reg.length == 0) {
- reg = [YYKeychain getPasswordForService:SPSBJudgeFirstInstallKeychainServiece account:SPSBJudgeFirstInstallKeyKeychainAccount];
- reg = [reg stringByReplacingOccurrencesOfString:@"-" withString:@""];
- reg = [NSString stringWithFormat:@"uuid%@", reg];
- }
-
- return reg;
- }
- void spsb_singleAlertShow(NSString *title, UIViewController *controller) {
- SPSBConfirmAlertViewController *vc = [SPSBConfirmAlertViewController alertWithTitle:title content:nil];
- [vc setConfirmButtonTitle:nil titleColor:nil action:^{
- }];
- [controller presentViewController:vc animated:false completion:nil];
- }
- #pragma mark - TabBar
- static SPSBHomeViewController *_spsb_homeVC = nil;
- SPSBHomeViewController *spsb_homeVC() {
- if (!_spsb_homeVC) {
- _spsb_homeVC = SPSBHomeViewController.new;
- }
- return _spsb_homeVC;
- }
- static SPSBNavigationController *_spsb_homeNavVC = nil;
- SPSBNavigationController *spsb_homeNavVC() {
- if (!_spsb_homeNavVC) {
- _spsb_homeNavVC = [[SPSBNavigationController alloc] initWithRootViewController:spsb_homeVC()];
- }
- return _spsb_homeNavVC;
- }
- static SPSBQueryHomeViewController *_spsb_queryHomeVC = nil;
- SPSBQueryHomeViewController *spsb_queryHomeVC() {
- if (!_spsb_queryHomeVC) {
- _spsb_queryHomeVC = SPSBQueryHomeViewController.new;
- }
- return _spsb_queryHomeVC;
- }
- static SPSBNavigationController *_spsb_queryHomeNavVC = nil;
- SPSBNavigationController *spsb_queryHomeNavVC() {
- if (!_spsb_queryHomeNavVC) {
- _spsb_queryHomeNavVC = [[SPSBNavigationController alloc] initWithRootViewController:spsb_queryHomeVC()];
- }
- return _spsb_queryHomeNavVC;
- }
- static SPSBConsultationViewController *_spsb_consultationHomeVC = nil;
- SPSBConsultationViewController *spsb_consultationHomeVC() {
- if (!_spsb_consultationHomeVC) {
- _spsb_consultationHomeVC = SPSBConsultationViewController.new;
- }
- return _spsb_consultationHomeVC;
- }
- static SPSBNavigationController *_spsb_consultationHomeNavVC = nil;
- SPSBNavigationController *spsb_consultationHomeNavVC() {
- if (!_spsb_consultationHomeNavVC) {
- _spsb_consultationHomeNavVC = [[SPSBNavigationController alloc] initWithRootViewController:spsb_consultationHomeVC()];
- }
- return _spsb_consultationHomeNavVC;
- }
- static SPSBMineViewController *_spsb_mineVC = nil;
- SPSBMineViewController *spsb_mineVC() {
- if (!_spsb_mineVC) {
- _spsb_mineVC = SPSBMineViewController.new;
- }
- return _spsb_mineVC;
- }
- static SPSBNavigationController *_spsb_mineNavVC = nil;
- SPSBNavigationController *spsb_mineNavVC() {
- if (!_spsb_mineNavVC) {
- _spsb_mineNavVC = [[SPSBNavigationController alloc] initWithRootViewController:spsb_mineVC()];
- }
- return _spsb_mineNavVC;
- }
- static SPSBTabBarView *_spsb_tabBarView = nil;
- SPSBTabBarView *spsb_tabBarView() {
- if (!_spsb_tabBarView) {
- _spsb_tabBarView = SPSBTabBarView.new;
- }
- return _spsb_tabBarView;
- }
|