diff --git a/Podfile b/Podfile index e1334fc8..6f9540bf 100644 --- a/Podfile +++ b/Podfile @@ -8,6 +8,7 @@ target 'xplan-ios' do # Pods for xplan-ios pod 'AFNetworking' pod 'YYText' + pod 'YYModel' pod 'Masonry' pod 'ReactiveObjC' pod 'MBProgressHUD' diff --git a/Podfile.lock b/Podfile.lock index c876a118..4cff4bb8 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -18,6 +18,7 @@ PODS: - MBProgressHUD (1.2.0) - NTESQuickPass (2.1.9) - ReactiveObjC (3.1.1) + - YYModel (1.0.4) - YYText (1.0.7) DEPENDENCIES: @@ -26,6 +27,7 @@ DEPENDENCIES: - MBProgressHUD - NTESQuickPass (~> 2.1.6) - ReactiveObjC + - YYModel - YYText SPEC REPOS: @@ -35,6 +37,7 @@ SPEC REPOS: - MBProgressHUD - NTESQuickPass - ReactiveObjC + - YYModel - YYText SPEC CHECKSUMS: @@ -43,8 +46,9 @@ SPEC CHECKSUMS: MBProgressHUD: 3ee5efcc380f6a79a7cc9b363dd669c5e1ae7406 NTESQuickPass: 8431dc52737c95883cd382c2ee75664d58f39377 ReactiveObjC: 011caa393aa0383245f2dcf9bf02e86b80b36040 + YYModel: 2a7fdd96aaa4b86a824e26d0c517de8928c04b30 YYText: 5c461d709e24d55a182d1441c41dc639a18a4849 -PODFILE CHECKSUM: f8d8c44df1ae85a1571fe37ee767fc992db1ff6b +PODFILE CHECKSUM: 34d6fc0f46b543fbcabfb886e7a531f43d5dd7f5 COCOAPODS: 1.10.1 diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index aec1b597..b323dbd7 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -7,6 +7,10 @@ objects = { /* Begin PBXBuildFile section */ + 187EEEDC26E89B32002833B2 /* BaseModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 187EEEDB26E89B32002833B2 /* BaseModel.m */; }; + 187EEEE126E89BFB002833B2 /* AccountModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 187EEEE026E89BFB002833B2 /* AccountModel.m */; }; + 187EEEF026E89FE8002833B2 /* AccountInfoStorage.m in Sources */ = {isa = PBXBuildFile; fileRef = 187EEEEE26E89FE8002833B2 /* AccountInfoStorage.m */; }; + 187EEEFE26E8A82C002833B2 /* NSObject+AutoCoding.m in Sources */ = {isa = PBXBuildFile; fileRef = 187EEEFC26E8A82C002833B2 /* NSObject+AutoCoding.m */; }; 189DD52E26DE255300AB55B1 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 189DD52D26DE255300AB55B1 /* AppDelegate.m */; }; 189DD53426DE255300AB55B1 /* TabbarViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 189DD53326DE255300AB55B1 /* TabbarViewController.m */; }; 189DD53926DE255600AB55B1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 189DD53826DE255600AB55B1 /* Assets.xcassets */; }; @@ -29,10 +33,21 @@ 189DD75026E21D9000AB55B1 /* GCDHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 189DD74E26E21D9000AB55B1 /* GCDHelper.m */; }; 189DD75926E6003C00AB55B1 /* Api.m in Sources */ = {isa = PBXBuildFile; fileRef = 189DD75826E6003C00AB55B1 /* Api.m */; }; 189DD76226E60DDC00AB55B1 /* Api+Login.m in Sources */ = {isa = PBXBuildFile; fileRef = 189DD76126E60DDC00AB55B1 /* Api+Login.m */; }; + 18E7B1B226E8AF980064BC9B /* MainPresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 18E7B1B126E8AF980064BC9B /* MainPresenter.m */; }; + 18E7B1B726E8B2D10064BC9B /* Api+Main.m in Sources */ = {isa = PBXBuildFile; fileRef = 18E7B1B626E8B2D10064BC9B /* Api+Main.m */; }; 73FFADDC93E195344047A2EC /* Pods_xplan_ios.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CACF623970097D653132D69A /* Pods_xplan_ios.framework */; }; + 9B0E1C5926E77022005D4442 /* BaseNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0E1C5826E77022005D4442 /* BaseNavigationController.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 187EEEDA26E89B32002833B2 /* BaseModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BaseModel.h; sourceTree = ""; }; + 187EEEDB26E89B32002833B2 /* BaseModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BaseModel.m; sourceTree = ""; }; + 187EEEDF26E89BFB002833B2 /* AccountModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AccountModel.h; sourceTree = ""; }; + 187EEEE026E89BFB002833B2 /* AccountModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AccountModel.m; sourceTree = ""; }; + 187EEEEE26E89FE8002833B2 /* AccountInfoStorage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AccountInfoStorage.m; sourceTree = ""; }; + 187EEEEF26E89FE8002833B2 /* AccountInfoStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccountInfoStorage.h; sourceTree = ""; }; + 187EEEFC26E8A82C002833B2 /* NSObject+AutoCoding.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+AutoCoding.m"; sourceTree = ""; }; + 187EEEFD26E8A82C002833B2 /* NSObject+AutoCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+AutoCoding.h"; sourceTree = ""; }; 189DD52926DE255300AB55B1 /* xplan-ios.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "xplan-ios.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 189DD52C26DE255300AB55B1 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 189DD52D26DE255300AB55B1 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; @@ -78,7 +93,14 @@ 189DD76026E60DDC00AB55B1 /* Api+Login.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Api+Login.h"; sourceTree = ""; }; 189DD76126E60DDC00AB55B1 /* Api+Login.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "Api+Login.m"; sourceTree = ""; }; 189DD78026E620FE00AB55B1 /* ApiHost.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ApiHost.h; sourceTree = ""; }; + 18E7B1AE26E8AD760064BC9B /* MainProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MainProtocol.h; sourceTree = ""; }; + 18E7B1B026E8AF980064BC9B /* MainPresenter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MainPresenter.h; sourceTree = ""; }; + 18E7B1B126E8AF980064BC9B /* MainPresenter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MainPresenter.m; sourceTree = ""; }; + 18E7B1B526E8B2D10064BC9B /* Api+Main.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Api+Main.h"; sourceTree = ""; }; + 18E7B1B626E8B2D10064BC9B /* Api+Main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "Api+Main.m"; sourceTree = ""; }; 7DB00EC07F1D0ADFF900B38D /* Pods-xplan-ios.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-xplan-ios.debug.xcconfig"; path = "Target Support Files/Pods-xplan-ios/Pods-xplan-ios.debug.xcconfig"; sourceTree = ""; }; + 9B0E1C5726E77022005D4442 /* BaseNavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BaseNavigationController.h; sourceTree = ""; }; + 9B0E1C5826E77022005D4442 /* BaseNavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BaseNavigationController.m; sourceTree = ""; }; B66633E061B1B34177CD011C /* Pods-xplan-ios.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-xplan-ios.release.xcconfig"; path = "Target Support Files/Pods-xplan-ios/Pods-xplan-ios.release.xcconfig"; sourceTree = ""; }; CACF623970097D653132D69A /* Pods_xplan_ios.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_xplan_ios.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -178,6 +200,14 @@ 189DD56026DE456100AB55B1 /* Model */ = { isa = PBXGroup; children = ( + 187EEEDA26E89B32002833B2 /* BaseModel.h */, + 187EEEDB26E89B32002833B2 /* BaseModel.m */, + 187EEEDF26E89BFB002833B2 /* AccountModel.h */, + 187EEEE026E89BFB002833B2 /* AccountModel.m */, + 187EEEEF26E89FE8002833B2 /* AccountInfoStorage.h */, + 187EEEEE26E89FE8002833B2 /* AccountInfoStorage.m */, + 187EEEFD26E8A82C002833B2 /* NSObject+AutoCoding.h */, + 187EEEFC26E8A82C002833B2 /* NSObject+AutoCoding.m */, ); path = Model; sourceTree = ""; @@ -185,10 +215,8 @@ 189DD56126DE45F800AB55B1 /* Main */ = { isa = PBXGroup; children = ( - 189DD54826DE327B00AB55B1 /* MVP */, + 18E7B1B426E8B2960064BC9B /* Tabbar */, 189DD56226DE460400AB55B1 /* Login */, - 189DD53226DE255300AB55B1 /* TabbarViewController.h */, - 189DD53326DE255300AB55B1 /* TabbarViewController.m */, ); path = Main; sourceTree = ""; @@ -208,6 +236,7 @@ 189DD56B26DF5B0900AB55B1 /* Base */ = { isa = PBXGroup; children = ( + 189DD54826DE327B00AB55B1 /* MVP */, 189DD61E26E0ED0100AB55B1 /* Net */, 189DD5A726DFA09700AB55B1 /* Tool */, 189DD56C26DF5B5400AB55B1 /* UI */, @@ -221,6 +250,8 @@ children = ( 189DD54926DE338800AB55B1 /* BaseViewController.h */, 189DD54A26DE338800AB55B1 /* BaseViewController.m */, + 9B0E1C5726E77022005D4442 /* BaseNavigationController.h */, + 9B0E1C5826E77022005D4442 /* BaseNavigationController.m */, 189DD67C26E1FD8900AB55B1 /* UIImage+Utils.h */, 189DD67D26E1FD8900AB55B1 /* UIImage+Utils.m */, 189DD68326E1FDBB00AB55B1 /* XCHUDTool.h */, @@ -332,6 +363,20 @@ path = Api; sourceTree = ""; }; + 18E7B1B426E8B2960064BC9B /* Tabbar */ = { + isa = PBXGroup; + children = ( + 18E7B1B526E8B2D10064BC9B /* Api+Main.h */, + 18E7B1B626E8B2D10064BC9B /* Api+Main.m */, + 18E7B1B026E8AF980064BC9B /* MainPresenter.h */, + 18E7B1B126E8AF980064BC9B /* MainPresenter.m */, + 18E7B1AE26E8AD760064BC9B /* MainProtocol.h */, + 189DD53226DE255300AB55B1 /* TabbarViewController.h */, + 189DD53326DE255300AB55B1 /* TabbarViewController.m */, + ); + path = Tabbar; + sourceTree = ""; + }; BFB922F5D81845AC32D1E1ED /* Frameworks */ = { isa = PBXGroup; children = ( @@ -482,18 +527,25 @@ 189DD76226E60DDC00AB55B1 /* Api+Login.m in Sources */, 189DD73E26E21C3F00AB55B1 /* YYUtility.m in Sources */, 189DD53426DE255300AB55B1 /* TabbarViewController.m in Sources */, + 187EEEFE26E8A82C002833B2 /* NSObject+AutoCoding.m in Sources */, 189DD55A26DE39D200AB55B1 /* BaseMvpPresenter.m in Sources */, 189DD6FF26E20E5900AB55B1 /* HttpRequestHelper.m in Sources */, 189DD74A26E21D8400AB55B1 /* SSKeychain.m in Sources */, 189DD68426E1FDBB00AB55B1 /* XCHUDTool.m in Sources */, 189DD73F26E21C3F00AB55B1 /* YYUtility+Carrier.m in Sources */, + 9B0E1C5926E77022005D4442 /* BaseNavigationController.m in Sources */, 189DD54B26DE338800AB55B1 /* BaseViewController.m in Sources */, + 18E7B1B726E8B2D10064BC9B /* Api+Main.m in Sources */, + 18E7B1B226E8AF980064BC9B /* MainPresenter.m in Sources */, 189DD67E26E1FD8900AB55B1 /* UIImage+Utils.m in Sources */, 189DD52E26DE255300AB55B1 /* AppDelegate.m in Sources */, 189DD56526DE465A00AB55B1 /* LoginViewController.m in Sources */, + 187EEEF026E89FE8002833B2 /* AccountInfoStorage.m in Sources */, 189DD73D26E21C3F00AB55B1 /* YYUtility+Device.m in Sources */, + 187EEEDC26E89B32002833B2 /* BaseModel.m in Sources */, 189DD74026E21C3F00AB55B1 /* YYUtility+App.m in Sources */, 189DD74526E21CCC00AB55B1 /* YYReachability.m in Sources */, + 187EEEE126E89BFB002833B2 /* AccountModel.m in Sources */, 189DD75026E21D9000AB55B1 /* GCDHelper.m in Sources */, 189DD75926E6003C00AB55B1 /* Api.m in Sources */, 189DD53F26DE255600AB55B1 /* main.m in Sources */, diff --git a/xplan-ios/AppDelegate.m b/xplan-ios/AppDelegate.m index 59247fa1..63b186ab 100644 --- a/xplan-ios/AppDelegate.m +++ b/xplan-ios/AppDelegate.m @@ -7,6 +7,7 @@ #import "AppDelegate.h" #import "TabbarViewController.h" +#import "BaseNavigationController.h" @interface AppDelegate () @@ -16,9 +17,10 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { TabbarViewController *vc = [[TabbarViewController alloc] init]; - UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; + BaseNavigationController *bnc = [[BaseNavigationController alloc] initWithRootViewController:vc]; + [bnc setNavigationBarHidden:YES]; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; - self.window.rootViewController = nav; + self.window.rootViewController = bnc; [self.window makeKeyAndVisible]; return YES; } diff --git a/xplan-ios/Assets.xcassets/Tabbar/Contents.json b/xplan-ios/Assets.xcassets/Tabbar/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/xplan-ios/Assets.xcassets/Tabbar/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_discover_normal.imageset/Contents.json b/xplan-ios/Assets.xcassets/Tabbar/tab_discover_normal.imageset/Contents.json new file mode 100644 index 00000000..e9625098 --- /dev/null +++ b/xplan-ios/Assets.xcassets/Tabbar/tab_discover_normal.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "tab_discover_normal@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "tab_discover_normal@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_discover_normal.imageset/tab_discover_normal@2x.png b/xplan-ios/Assets.xcassets/Tabbar/tab_discover_normal.imageset/tab_discover_normal@2x.png new file mode 100644 index 00000000..05dbdbad Binary files /dev/null and b/xplan-ios/Assets.xcassets/Tabbar/tab_discover_normal.imageset/tab_discover_normal@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_discover_normal.imageset/tab_discover_normal@3x.png b/xplan-ios/Assets.xcassets/Tabbar/tab_discover_normal.imageset/tab_discover_normal@3x.png new file mode 100644 index 00000000..09a4e8b5 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Tabbar/tab_discover_normal.imageset/tab_discover_normal@3x.png differ diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_discover_selected.imageset/Contents.json b/xplan-ios/Assets.xcassets/Tabbar/tab_discover_selected.imageset/Contents.json new file mode 100644 index 00000000..2d7bcc43 --- /dev/null +++ b/xplan-ios/Assets.xcassets/Tabbar/tab_discover_selected.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "tab_discover_selected@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "tab_discover_selected@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_discover_selected.imageset/tab_discover_selected@2x.png b/xplan-ios/Assets.xcassets/Tabbar/tab_discover_selected.imageset/tab_discover_selected@2x.png new file mode 100644 index 00000000..7932d34c Binary files /dev/null and b/xplan-ios/Assets.xcassets/Tabbar/tab_discover_selected.imageset/tab_discover_selected@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_discover_selected.imageset/tab_discover_selected@3x.png b/xplan-ios/Assets.xcassets/Tabbar/tab_discover_selected.imageset/tab_discover_selected@3x.png new file mode 100644 index 00000000..d7d7820e Binary files /dev/null and b/xplan-ios/Assets.xcassets/Tabbar/tab_discover_selected.imageset/tab_discover_selected@3x.png differ diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_gameHome_normal.imageset/Contents.json b/xplan-ios/Assets.xcassets/Tabbar/tab_gameHome_normal.imageset/Contents.json new file mode 100644 index 00000000..f9e07d2e --- /dev/null +++ b/xplan-ios/Assets.xcassets/Tabbar/tab_gameHome_normal.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "tab_gameHome_normal@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "tab_gameHome_normal@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_gameHome_normal.imageset/tab_gameHome_normal@2x.png b/xplan-ios/Assets.xcassets/Tabbar/tab_gameHome_normal.imageset/tab_gameHome_normal@2x.png new file mode 100644 index 00000000..ce8d3a9b Binary files /dev/null and b/xplan-ios/Assets.xcassets/Tabbar/tab_gameHome_normal.imageset/tab_gameHome_normal@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_gameHome_normal.imageset/tab_gameHome_normal@3x.png b/xplan-ios/Assets.xcassets/Tabbar/tab_gameHome_normal.imageset/tab_gameHome_normal@3x.png new file mode 100644 index 00000000..06841c1e Binary files /dev/null and b/xplan-ios/Assets.xcassets/Tabbar/tab_gameHome_normal.imageset/tab_gameHome_normal@3x.png differ diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_gameHome_selected.imageset/Contents.json b/xplan-ios/Assets.xcassets/Tabbar/tab_gameHome_selected.imageset/Contents.json new file mode 100644 index 00000000..7982e184 --- /dev/null +++ b/xplan-ios/Assets.xcassets/Tabbar/tab_gameHome_selected.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "tab_gameHome_selected@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "tab_gameHome_selected@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_gameHome_selected.imageset/tab_gameHome_selected@2x.png b/xplan-ios/Assets.xcassets/Tabbar/tab_gameHome_selected.imageset/tab_gameHome_selected@2x.png new file mode 100644 index 00000000..eb83be4f Binary files /dev/null and b/xplan-ios/Assets.xcassets/Tabbar/tab_gameHome_selected.imageset/tab_gameHome_selected@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_gameHome_selected.imageset/tab_gameHome_selected@3x.png b/xplan-ios/Assets.xcassets/Tabbar/tab_gameHome_selected.imageset/tab_gameHome_selected@3x.png new file mode 100644 index 00000000..905c58fb Binary files /dev/null and b/xplan-ios/Assets.xcassets/Tabbar/tab_gameHome_selected.imageset/tab_gameHome_selected@3x.png differ diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_game_normal.imageset/Contents.json b/xplan-ios/Assets.xcassets/Tabbar/tab_game_normal.imageset/Contents.json new file mode 100644 index 00000000..bee034b0 --- /dev/null +++ b/xplan-ios/Assets.xcassets/Tabbar/tab_game_normal.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "tab_game_normal@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "tab_game_normal@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_game_normal.imageset/tab_game_normal@2x.png b/xplan-ios/Assets.xcassets/Tabbar/tab_game_normal.imageset/tab_game_normal@2x.png new file mode 100644 index 00000000..a77bba46 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Tabbar/tab_game_normal.imageset/tab_game_normal@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_game_normal.imageset/tab_game_normal@3x.png b/xplan-ios/Assets.xcassets/Tabbar/tab_game_normal.imageset/tab_game_normal@3x.png new file mode 100644 index 00000000..3cc508ff Binary files /dev/null and b/xplan-ios/Assets.xcassets/Tabbar/tab_game_normal.imageset/tab_game_normal@3x.png differ diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_game_selected.imageset/Contents.json b/xplan-ios/Assets.xcassets/Tabbar/tab_game_selected.imageset/Contents.json new file mode 100644 index 00000000..a69f428f --- /dev/null +++ b/xplan-ios/Assets.xcassets/Tabbar/tab_game_selected.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "tab_game_selected@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "tab_game_selected@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_game_selected.imageset/tab_game_selected@2x.png b/xplan-ios/Assets.xcassets/Tabbar/tab_game_selected.imageset/tab_game_selected@2x.png new file mode 100644 index 00000000..f8f40788 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Tabbar/tab_game_selected.imageset/tab_game_selected@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_game_selected.imageset/tab_game_selected@3x.png b/xplan-ios/Assets.xcassets/Tabbar/tab_game_selected.imageset/tab_game_selected@3x.png new file mode 100644 index 00000000..8f6b5580 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Tabbar/tab_game_selected.imageset/tab_game_selected@3x.png differ diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_message_normal.imageset/Contents.json b/xplan-ios/Assets.xcassets/Tabbar/tab_message_normal.imageset/Contents.json new file mode 100644 index 00000000..931b135f --- /dev/null +++ b/xplan-ios/Assets.xcassets/Tabbar/tab_message_normal.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "tab_message_normal@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "tab_message_normal@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_message_normal.imageset/tab_message_normal@2x.png b/xplan-ios/Assets.xcassets/Tabbar/tab_message_normal.imageset/tab_message_normal@2x.png new file mode 100644 index 00000000..5fa6729d Binary files /dev/null and b/xplan-ios/Assets.xcassets/Tabbar/tab_message_normal.imageset/tab_message_normal@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_message_normal.imageset/tab_message_normal@3x.png b/xplan-ios/Assets.xcassets/Tabbar/tab_message_normal.imageset/tab_message_normal@3x.png new file mode 100644 index 00000000..eb614b61 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Tabbar/tab_message_normal.imageset/tab_message_normal@3x.png differ diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_message_selected.imageset/Contents.json b/xplan-ios/Assets.xcassets/Tabbar/tab_message_selected.imageset/Contents.json new file mode 100644 index 00000000..57e79920 --- /dev/null +++ b/xplan-ios/Assets.xcassets/Tabbar/tab_message_selected.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "tab_message_selected@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "tab_message_selected@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_message_selected.imageset/tab_message_selected@2x.png b/xplan-ios/Assets.xcassets/Tabbar/tab_message_selected.imageset/tab_message_selected@2x.png new file mode 100644 index 00000000..6971a600 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Tabbar/tab_message_selected.imageset/tab_message_selected@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_message_selected.imageset/tab_message_selected@3x.png b/xplan-ios/Assets.xcassets/Tabbar/tab_message_selected.imageset/tab_message_selected@3x.png new file mode 100644 index 00000000..1df17198 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Tabbar/tab_message_selected.imageset/tab_message_selected@3x.png differ diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_mine_normal.imageset/Contents.json b/xplan-ios/Assets.xcassets/Tabbar/tab_mine_normal.imageset/Contents.json new file mode 100644 index 00000000..892f413e --- /dev/null +++ b/xplan-ios/Assets.xcassets/Tabbar/tab_mine_normal.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "tab_mine_normal@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "tab_mine_normal@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_mine_normal.imageset/tab_mine_normal@2x.png b/xplan-ios/Assets.xcassets/Tabbar/tab_mine_normal.imageset/tab_mine_normal@2x.png new file mode 100644 index 00000000..6411eb10 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Tabbar/tab_mine_normal.imageset/tab_mine_normal@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_mine_normal.imageset/tab_mine_normal@3x.png b/xplan-ios/Assets.xcassets/Tabbar/tab_mine_normal.imageset/tab_mine_normal@3x.png new file mode 100644 index 00000000..05e319d7 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Tabbar/tab_mine_normal.imageset/tab_mine_normal@3x.png differ diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_mine_selected.imageset/Contents.json b/xplan-ios/Assets.xcassets/Tabbar/tab_mine_selected.imageset/Contents.json new file mode 100644 index 00000000..1c1a6f8a --- /dev/null +++ b/xplan-ios/Assets.xcassets/Tabbar/tab_mine_selected.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "tab_mine_selected@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "tab_mine_selected@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_mine_selected.imageset/tab_mine_selected@2x.png b/xplan-ios/Assets.xcassets/Tabbar/tab_mine_selected.imageset/tab_mine_selected@2x.png new file mode 100644 index 00000000..908f3a1a Binary files /dev/null and b/xplan-ios/Assets.xcassets/Tabbar/tab_mine_selected.imageset/tab_mine_selected@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Tabbar/tab_mine_selected.imageset/tab_mine_selected@3x.png b/xplan-ios/Assets.xcassets/Tabbar/tab_mine_selected.imageset/tab_mine_selected@3x.png new file mode 100644 index 00000000..012439be Binary files /dev/null and b/xplan-ios/Assets.xcassets/Tabbar/tab_mine_selected.imageset/tab_mine_selected@3x.png differ diff --git a/xplan-ios/Assets.xcassets/Tabbar/tabbar_bg.imageset/Contents.json b/xplan-ios/Assets.xcassets/Tabbar/tabbar_bg.imageset/Contents.json new file mode 100644 index 00000000..d6002dab --- /dev/null +++ b/xplan-ios/Assets.xcassets/Tabbar/tabbar_bg.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "tabbar_bg@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "tabbar_bg@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Tabbar/tabbar_bg.imageset/tabbar_bg@2x.png b/xplan-ios/Assets.xcassets/Tabbar/tabbar_bg.imageset/tabbar_bg@2x.png new file mode 100644 index 00000000..c4184cea Binary files /dev/null and b/xplan-ios/Assets.xcassets/Tabbar/tabbar_bg.imageset/tabbar_bg@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Tabbar/tabbar_bg.imageset/tabbar_bg@3x.png b/xplan-ios/Assets.xcassets/Tabbar/tabbar_bg.imageset/tabbar_bg@3x.png new file mode 100644 index 00000000..02bcff04 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Tabbar/tabbar_bg.imageset/tabbar_bg@3x.png differ diff --git a/xplan-ios/Base/Base.pch b/xplan-ios/Base/Base.pch index 68008557..c2eef4fd 100644 --- a/xplan-ios/Base/Base.pch +++ b/xplan-ios/Base/Base.pch @@ -11,6 +11,7 @@ // Include any system framework and library headers here that should be included in all compilation units. // You will also need to set the Prefix Header build setting of one or more of your targets to reference this file. #import +#import #define AppName ([[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]) @@ -36,6 +37,12 @@ isPhoneXSeries = [[UIApplication sharedApplication] delegate].window.safeAreaIns #define ThemeButtonGradientStartColor UIColorFromRGB(0x218EFF) /// 按钮渐变色 end #define ThemeButtonGradientEndColor UIColorFromRGB(0x7727E4) +/// Tabbar 未选中 +#define ThemeTabbarNormalColor UIColorFromRGB(0x555574) +/// Tabbar 选中 +#define ThemeTabbarSelectedColor UIColorFromRGB(0x248CFE) +/// Tabbar 背景色 +#define ThemeTabbarBackgroundColor UIColorFromRGB(0x2A2A39) #define KScreenWidth [[UIScreen mainScreen] bounds].size.width #define KScreenHeight [[UIScreen mainScreen] bounds].size.height diff --git a/xplan-ios/Main/MVP/Api/Api.h b/xplan-ios/Base/MVP/Api/Api.h similarity index 100% rename from xplan-ios/Main/MVP/Api/Api.h rename to xplan-ios/Base/MVP/Api/Api.h diff --git a/xplan-ios/Main/MVP/Api/Api.m b/xplan-ios/Base/MVP/Api/Api.m similarity index 100% rename from xplan-ios/Main/MVP/Api/Api.m rename to xplan-ios/Base/MVP/Api/Api.m diff --git a/xplan-ios/Base/MVP/Model/AccountInfoStorage.h b/xplan-ios/Base/MVP/Model/AccountInfoStorage.h new file mode 100644 index 00000000..8c60a8d7 --- /dev/null +++ b/xplan-ios/Base/MVP/Model/AccountInfoStorage.h @@ -0,0 +1,25 @@ +// +// DataUtils.h +// YYFaceAuth +// +// Created by chenran on 16/10/18. +// Copyright © 2016年 zhangji. All rights reserved. +// + +#import +#import "AccountModel.h" +@interface AccountInfoStorage : NSObject + ++ (instancetype)instance; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; +- (id)copy NS_UNAVAILABLE; +- (id)mutableCopy NS_UNAVAILABLE; + +- (AccountModel *)getCurrentAccountInfo; +- (void)saveAccountInfo:(AccountModel *)accountInfo; +- (void)saveTicket:(NSString *)ticket; +- (NSString *)getTicket; +- (NSString *)getUid; +@end diff --git a/xplan-ios/Base/MVP/Model/AccountInfoStorage.m b/xplan-ios/Base/MVP/Model/AccountInfoStorage.m new file mode 100644 index 00000000..32382bd2 --- /dev/null +++ b/xplan-ios/Base/MVP/Model/AccountInfoStorage.m @@ -0,0 +1,89 @@ +// +// DataUtils.m +// YYFaceAuth +// +// Created by chenran on 16/10/18. +// Copyright © 2016年 zhangji. All rights reserved. +// +#define kFileName @"AccountInfo.data" +#define kDataKey @"accountInfo" + +#import "AccountInfoStorage.h" + +@interface AccountInfoStorage() + +@property (nonatomic, copy) NSString *ticket; +@property (nonatomic, strong) AccountModel *accountModel; + +@end + +@implementation AccountInfoStorage + +static AccountInfoStorage *_instance = nil; + ++ (AccountInfoStorage *)instance { + + static dispatch_once_t onceToken; + + dispatch_once(&onceToken, ^{ + _instance = [[self alloc] init]; + }) ; + + return _instance; +} + +-(NSString *) getFilePath{ + NSArray *array = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + NSString *path = [[array objectAtIndex:0] stringByAppendingPathComponent:kFileName]; + if (![[NSFileManager defaultManager] fileExistsAtPath:path]) { + [[NSFileManager defaultManager] createFileAtPath:path contents:nil attributes:nil]; + } + return path; +} + +- (AccountModel *)getCurrentAccountInfo +{ + if (self.accountModel != nil) { + return self.accountModel; + } + NSData *data = [[NSData alloc] initWithContentsOfFile:[self getFilePath]]; + + NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data]; + //解档出数据模型 + self.accountModel = [unarchiver decodeObjectForKey:kDataKey]; + [unarchiver finishDecoding];//一定不要忘记finishDecoding,否则会报错 + return self.accountModel; +} + +- (void)saveAccountInfo:(AccountModel *)accountInfo +{ + if (accountInfo == nil) { + accountInfo = [[AccountModel alloc] init]; + } + self.accountModel = accountInfo; + NSMutableData *data = [[NSMutableData alloc] init]; + NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data]; + [archiver encodeObject:accountInfo forKey:kDataKey]; + [archiver finishEncoding]; + [data writeToFile:[self getFilePath] atomically:YES]; +} + +- (void)saveTicket:(NSString *)t +{ + self.ticket = t; +} + +- (NSString *)getTicket +{ + return self.ticket; +} + +- (NSString *)getUid +{ + AccountModel *am = [self getCurrentAccountInfo]; + if (am == nil) { + return @""; + } + return am.uid; +} +@end diff --git a/xplan-ios/Base/MVP/Model/AccountModel.h b/xplan-ios/Base/MVP/Model/AccountModel.h new file mode 100644 index 00000000..ce532cd7 --- /dev/null +++ b/xplan-ios/Base/MVP/Model/AccountModel.h @@ -0,0 +1,24 @@ +// +// TokenModel.h +// xplan-ios +// +// Created by zu on 2021/9/8. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface AccountModel : NSObject + +@property (nonatomic , assign) NSString *uid; +@property (nonatomic , copy) NSString *jti; +@property (nonatomic , copy) NSString *token_type; +@property (nonatomic , copy) NSString *refresh_token; +@property (nonatomic , copy) NSString *netEaseToken; +@property (nonatomic , copy) NSString *access_token; +@property (nonatomic , assign) NSNumber *expires_in; + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Base/MVP/Model/AccountModel.m b/xplan-ios/Base/MVP/Model/AccountModel.m new file mode 100644 index 00000000..de7f90e4 --- /dev/null +++ b/xplan-ios/Base/MVP/Model/AccountModel.m @@ -0,0 +1,12 @@ +// +// TokenModel.m +// xplan-ios +// +// Created by zu on 2021/9/8. +// + +#import "AccountModel.h" + +@implementation AccountModel + +@end diff --git a/xplan-ios/Base/MVP/Model/BaseModel.h b/xplan-ios/Base/MVP/Model/BaseModel.h new file mode 100644 index 00000000..48f1e813 --- /dev/null +++ b/xplan-ios/Base/MVP/Model/BaseModel.h @@ -0,0 +1,20 @@ +// +// BaseModel.h +// xplan-ios +// +// Created by zu on 2021/9/8. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface BaseModel : NSObject + +@property (nonatomic , strong) id data; +@property (nonatomic , assign) NSInteger code; +@property (nonatomic , copy) NSString *message; + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Base/MVP/Model/BaseModel.m b/xplan-ios/Base/MVP/Model/BaseModel.m new file mode 100644 index 00000000..d158734d --- /dev/null +++ b/xplan-ios/Base/MVP/Model/BaseModel.m @@ -0,0 +1,12 @@ +// +// BaseModel.m +// xplan-ios +// +// Created by zu on 2021/9/8. +// + +#import "BaseModel.h" + +@implementation BaseModel + +@end diff --git a/xplan-ios/Base/MVP/Model/NSObject+AutoCoding.h b/xplan-ios/Base/MVP/Model/NSObject+AutoCoding.h new file mode 100644 index 00000000..76b615f7 --- /dev/null +++ b/xplan-ios/Base/MVP/Model/NSObject+AutoCoding.h @@ -0,0 +1,25 @@ +// +// NSObject+AutoCoding.h +// YYMobileFramework +// +// Created by wuwei on 14/6/13. +// Copyright (c) 2014年 YY Inc. All rights reserved. +// + +#import + +@interface NSObject (AutoCoding) + +// Coding ++ (NSDictionary *)codableProperties; +- (void)setWithCoder:(NSCoder *)aDecoder; + +// Properties access +- (NSDictionary *)codableProperties; +- (NSDictionary *)dictionaryRepresentation; + +// Loading / Saving ++ (instancetype)objectWithContentsOfFile:(NSString *)path; +- (BOOL)writeToFile:(NSString *)filePath atomically:(BOOL)useAuxiliaryFile; + +@end \ No newline at end of file diff --git a/xplan-ios/Base/MVP/Model/NSObject+AutoCoding.m b/xplan-ios/Base/MVP/Model/NSObject+AutoCoding.m new file mode 100644 index 00000000..b66e955e --- /dev/null +++ b/xplan-ios/Base/MVP/Model/NSObject+AutoCoding.m @@ -0,0 +1,245 @@ +// +// NSObject+AutoCoding.m +// YYMobileFramework +// +// Created by wuwei on 14/6/13. +// Copyright (c) 2014年 YY Inc. All rights reserved. +// + +#import "NSObject+AutoCoding.h" +#import + +#pragma GCC diagnostic ignored "-Wgnu" + +static NSString *const AutocodingException = @"AutocodingException"; + +@implementation NSObject (AutoCoding) + ++ (BOOL)supportsSecureCoding +{ + return YES; +} + ++ (instancetype)objectWithContentsOfFile:(NSString *)filePath +{ + //load the file + NSData *data = [NSData dataWithContentsOfFile:filePath]; + + //attempt to deserialise data as a plist + id object = nil; + if (data) + { + NSPropertyListFormat format; + object = [NSPropertyListSerialization propertyListWithData:data options:NSPropertyListImmutable format:&format error:NULL]; + + //success? + if (object) + { + //check if object is an NSCoded unarchive + if ([object respondsToSelector:@selector(objectForKey:)] && [(NSDictionary *)object objectForKey:@"$archiver"]) + { + object = [NSKeyedUnarchiver unarchiveObjectWithData:data]; + } + } + else + { + //return raw data + object = data; + } + } + + //return object + return object; +} + +- (BOOL)writeToFile:(NSString *)filePath atomically:(BOOL)useAuxiliaryFile +{ + //note: NSData, NSDictionary and NSArray already implement this method + //and do not save using NSCoding, however the objectWithContentsOfFile + //method will correctly recover these objects anyway + + //archive object + NSData *data = [NSKeyedArchiver archivedDataWithRootObject:self]; + return [data writeToFile:filePath atomically:useAuxiliaryFile]; +} + ++ (NSDictionary *)codableProperties +{ + unsigned int propertyCount; + __autoreleasing NSMutableDictionary *codableProperties = [NSMutableDictionary dictionary]; + objc_property_t *properties = class_copyPropertyList(self, &propertyCount); + for (unsigned int i = 0; i < propertyCount; i++) + { + //get property name + objc_property_t property = properties[i]; + const char *propertyName = property_getName(property); + __autoreleasing NSString *key = @(propertyName); + + //check if codable + //get property type + Class propertyClass = nil; + char *typeEncoding = property_copyAttributeValue(property, "T"); + switch (typeEncoding[0]) + { + case '@': + { + if (strlen(typeEncoding) >= 3) + { + char *className = strndup(typeEncoding + 2, strlen(typeEncoding) - 3); + __autoreleasing NSString *name = @(className); + NSRange range = [name rangeOfString:@"<"]; + if (range.location != NSNotFound) + { + name = [name substringToIndex:range.location]; + } + propertyClass = NSClassFromString(name) ?: [NSObject class]; + free(className); + } + break; + } + case 'c': + case 'i': + case 's': + case 'l': + case 'q': + case 'C': + case 'I': + case 'S': + case 'L': + case 'Q': + case 'f': + case 'd': + case 'B': + { + propertyClass = [NSNumber class]; + break; + } + case '{': + { + propertyClass = [NSValue class]; + break; + } + default: + break; + } + free(typeEncoding); + + if (propertyClass && [propertyClass conformsToProtocol:@protocol(NSSecureCoding)]) + { + //check if there is a backing ivar + char *ivar = property_copyAttributeValue(property, "V"); + if (ivar) + { + //check if ivar has KVC-compliant name + __autoreleasing NSString *ivarName = @(ivar); + if ([ivarName isEqualToString:key] || [ivarName isEqualToString:[@"_" stringByAppendingString:key]]) + { + //no setter, but setValue:forKey: will still work + codableProperties[key] = propertyClass; + } + free(ivar); + } + else + { + //check if property is dynamic and readwrite + char *dynamic = property_copyAttributeValue(property, "D"); + char *readonly = property_copyAttributeValue(property, "R"); + if (dynamic && !readonly) + { + //no ivar, but setValue:forKey: will still work + codableProperties[key] = propertyClass; + } + free(dynamic); + free(readonly); + } + } + } + + free(properties); + return codableProperties; +} + +- (NSDictionary *)codableProperties +{ + __autoreleasing NSDictionary *codableProperties = objc_getAssociatedObject([self class], _cmd); + if (!codableProperties) + { + codableProperties = [NSMutableDictionary dictionary]; + Class subclass = [self class]; + while (subclass != [NSObject class]) + { + [(NSMutableDictionary *)codableProperties addEntriesFromDictionary:[subclass codableProperties]]; + subclass = [subclass superclass]; + } + codableProperties = [NSDictionary dictionaryWithDictionary:codableProperties]; + + //make the association atomically so that we don't need to bother with an @synchronize + objc_setAssociatedObject([self class], _cmd, codableProperties, OBJC_ASSOCIATION_RETAIN); + } + return codableProperties; +} + +- (NSDictionary *)dictionaryRepresentation +{ + NSMutableDictionary *dict = [NSMutableDictionary dictionary]; + for (__unsafe_unretained NSString *key in [self codableProperties]) + { + id value = [self valueForKey:key]; + if (value) + dict[key] = value; + else + dict[key] = @"nil"; + } + return dict; +} + +- (void)setWithCoder:(NSCoder *)aDecoder +{ + BOOL secureAvailable = [aDecoder respondsToSelector:@selector(decodeObjectOfClass:forKey:)]; + BOOL secureSupported = [[self class] supportsSecureCoding]; + NSDictionary *properties = [self codableProperties]; + for (NSString *key in properties) + { + id object = nil; + Class propertyClass = properties[key]; + if (secureAvailable) + { + if ([propertyClass isEqual:[NSMutableAttributedString class]]) { + continue; + } + object = [aDecoder decodeObjectOfClass:propertyClass forKey:key]; + } + else + { + if ([propertyClass isEqual:[NSMutableAttributedString class]]) { + continue; + } + object = [aDecoder decodeObjectForKey:key]; + } + if (object) + { + if (secureSupported && ![object isKindOfClass:propertyClass]) + { + [NSException raise:AutocodingException format:@"Expected '%@' to be a %@, but was actually a %@", key, propertyClass, [object class]]; + } + [self setValue:object forKey:key]; + } + } +} + +- (instancetype)initWithCoder:(NSCoder *)aDecoder +{ + [self setWithCoder:aDecoder]; + return self; +} + +- (void)encodeWithCoder:(NSCoder *)aCoder +{ + for (NSString *key in [self codableProperties]) + { + id object = [self valueForKey:key]; + if (object) [aCoder encodeObject:object forKey:key]; + } +} + +@end diff --git a/xplan-ios/Main/MVP/Presenter/BaseMvpPresenter.h b/xplan-ios/Base/MVP/Presenter/BaseMvpPresenter.h similarity index 92% rename from xplan-ios/Main/MVP/Presenter/BaseMvpPresenter.h rename to xplan-ios/Base/MVP/Presenter/BaseMvpPresenter.h index 69307d88..7fe8a91b 100644 --- a/xplan-ios/Main/MVP/Presenter/BaseMvpPresenter.h +++ b/xplan-ios/Base/MVP/Presenter/BaseMvpPresenter.h @@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN -typedef void(^HttpSuccess)(id _Nonnull data); +typedef void(^HttpSuccess)(BaseModel *data); typedef void(^HttpFail)(NSNumber * _Nonnull code, NSString * _Nullable msg); @interface BaseMvpPresenter : NSObject diff --git a/xplan-ios/Main/MVP/Presenter/BaseMvpPresenter.m b/xplan-ios/Base/MVP/Presenter/BaseMvpPresenter.m similarity index 89% rename from xplan-ios/Main/MVP/Presenter/BaseMvpPresenter.m rename to xplan-ios/Base/MVP/Presenter/BaseMvpPresenter.m index 974593e3..b6dd58a5 100644 --- a/xplan-ios/Main/MVP/Presenter/BaseMvpPresenter.m +++ b/xplan-ios/Base/MVP/Presenter/BaseMvpPresenter.m @@ -28,7 +28,10 @@ if (loading) { [XCHUDTool showLoading]; } - return ^(id _Nullable data, NSNumber * _Nonnull code, NSString * _Nullable msg) { + return ^(BaseModel *data, NSNumber * _Nonnull code, NSString * _Nullable msg) { + if (loading) { + [XCHUDTool hideHUD]; + } if (data != nil) { NSString *message = [data valueForKey:@"message"]; NSNumber *resCode = [data valueForKey:@"code"]; diff --git a/xplan-ios/Main/MVP/Protocol/BaseMvpProtocol.h b/xplan-ios/Base/MVP/Protocol/BaseMvpProtocol.h similarity index 100% rename from xplan-ios/Main/MVP/Protocol/BaseMvpProtocol.h rename to xplan-ios/Base/MVP/Protocol/BaseMvpProtocol.h diff --git a/xplan-ios/Main/MVP/View/MvpViewController.h b/xplan-ios/Base/MVP/View/MvpViewController.h similarity index 85% rename from xplan-ios/Main/MVP/View/MvpViewController.h rename to xplan-ios/Base/MVP/View/MvpViewController.h index 27a404cc..b86f249b 100644 --- a/xplan-ios/Main/MVP/View/MvpViewController.h +++ b/xplan-ios/Base/MVP/View/MvpViewController.h @@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN @interface MvpViewController : BaseViewController -@property (nonatomic,strong) __kindof T presenter; +@property (nonatomic, strong) __kindof T presenter; - (__kindof T)createPresenter; diff --git a/xplan-ios/Main/MVP/View/MvpViewController.m b/xplan-ios/Base/MVP/View/MvpViewController.m similarity index 100% rename from xplan-ios/Main/MVP/View/MvpViewController.m rename to xplan-ios/Base/MVP/View/MvpViewController.m diff --git a/xplan-ios/Base/Net/HttpRequestHelper.h b/xplan-ios/Base/Net/HttpRequestHelper.h index 6fcfd512..f3e85f45 100644 --- a/xplan-ios/Base/Net/HttpRequestHelper.h +++ b/xplan-ios/Base/Net/HttpRequestHelper.h @@ -6,6 +6,7 @@ // #import +#import "BaseModel.h" typedef NS_ENUM(NSUInteger, HttpRequestHelperMethod) { HttpRequestHelperMethodPOST, @@ -14,39 +15,27 @@ typedef NS_ENUM(NSUInteger, HttpRequestHelperMethod) { static dispatch_once_t onceToken; -typedef void(^HttpRequestHelperCompletion)(id _Nullable data, NSNumber * _Nullable code, NSString * _Nullable msg); +typedef void(^HttpRequestHelperCompletion)(BaseModel* _Nullable data, NSNumber * _Nullable code, NSString * _Nullable msg); NS_ASSUME_NONNULL_BEGIN @interface HttpRequestHelper : NSObject + (void)GET:(NSString *)method - params:(NSDictionary *)params - success:(void (^)(id data))success - failure:(void (^)(NSNumber *resCode, NSString *message))failure; - -+ (void)GET:(NSString *)interfaceUrl - method:(NSString *)method - params:(NSDictionary *)params - success:(void (^)(id data))success +params:(NSDictionary *)params +success:(void (^)(BaseModel *data))success failure:(void (^)(NSNumber *resCode, NSString *message))failure; + (void)POST:(NSString *)method params:(NSDictionary *)params - success:(void (^)(id data))success - failure:(void (^)(NSNumber *resCode, NSString *message))failure; - -+ (void)POST:(NSString *)interfaceUrl - method:(NSString *)method - params:(NSDictionary *)params - success:(void (^)(id data))success + success:(void (^)(BaseModel *data))success failure:(void (^)(NSNumber *resCode, NSString *message))failure; + (void)request:(NSString *)url method:(HttpRequestHelperMethod)method params:(NSDictionary *)params - success:(void (^)(id data))success + success:(void (^)(BaseModel *data))success failure:(void (^)(NSNumber *resCode, NSString *message))failure; + (void)request:(NSString *)path diff --git a/xplan-ios/Base/Net/HttpRequestHelper.m b/xplan-ios/Base/Net/HttpRequestHelper.m index 03e50974..8d1b10e7 100644 --- a/xplan-ios/Base/Net/HttpRequestHelper.m +++ b/xplan-ios/Base/Net/HttpRequestHelper.m @@ -8,6 +8,7 @@ #import "HttpRequestHelper.h" #import "ApiHost.h" #import "YYUtility.h" +#import "AccountInfoStorage.h" #import "YYReachability.h" #import @@ -18,8 +19,7 @@ static AFHTTPSessionManager *manager = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - NSURLSessionConfiguration * config = [NSURLSessionConfiguration defaultSessionConfiguration]; - manager = [[AFHTTPSessionManager alloc]initWithSessionConfiguration:config]; + manager = [[AFHTTPSessionManager manager]initWithBaseURL:[NSURL URLWithString:API_HOST_URL]]; manager.requestSerializer.timeoutInterval = 15; manager.responseSerializer = [AFJSONResponseSerializer serializer]; manager.requestSerializer.HTTPShouldHandleCookies = YES; @@ -36,83 +36,72 @@ + (void)GET:(NSString *)method params:(NSDictionary *)params - success:(void (^)(id data))success + success:(void (^)(BaseModel *data))success failure:(void (^)(NSNumber *resCode, NSString *message))failure -{ - [self GET:API_HOST_URL method:method params:params success:success failure:failure]; - -} - -+ (void)GET:(NSString *)interfaceUrl method:(NSString *)method params:(NSDictionary *)params success:(void (^)(id))success failure:(void (^)(NSNumber *, NSString *))failure { if ([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == 0) { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - + failure([NSNumber numberWithInt:-1], @"请检查网络连接。"); }); + return; } - AFHTTPSessionManager *manager = [HttpRequestHelper requestManager]; - - NSString *url = [NSString stringWithFormat:@"%@/%@", interfaceUrl, method]; - -#ifdef DEBUG - NSLog(@"url:%@, parameter:%@", url, params); -#endif - - [manager GET:url parameters:params headers:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { - - } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { - - }]; -} - -+ (void)POST:(NSString *)method - params:(NSDictionary *)params - success:(void (^)(id data))success - failure:(void (^)(NSNumber *resCode, NSString *message))failure -{ - [self POST:API_HOST_URL method:method params:params success:success failure:failure]; -} - -+ (void)POST:(NSString *)interfaceUrl - method:(NSString *)method - params:(NSDictionary *)params - success:(void (^)(id data))success - failure:(void (^)(NSNumber *resCode, NSString *message))failure -{ - if ([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == 0) { - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - - }); - } - - AFHTTPSessionManager *manager = [HttpRequestHelper requestManager]; - - NSString *url = [NSString stringWithFormat:@"%@/%@", interfaceUrl, method]; params = [self configBaseParmars:params]; #ifdef DEBUG - NSLog(@"\nurl:\n%@\nparameter:\n%@", url, params); + NSLog(@"\nmethod:\n%@\nparameter:\n%@", method, params); #endif - [manager POST:url parameters:params headers:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { + AFHTTPSessionManager *manager = [HttpRequestHelper requestManager]; + [manager GET:method parameters:params headers:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { #ifdef DEBUG - NSLog(@"\n%@", responseObject); + NSLog(@"\n%@", [responseObject yy_modelToJSONString]); #endif success(responseObject); } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { #ifdef DEBUG NSLog(@"\n%@", error); #endif + failure([NSNumber numberWithLong:error.code], error.domain); + }]; +} + ++ (void)POST:(NSString *)method + params:(NSDictionary *)params + success:(void (^)(BaseModel *data))success + failure:(void (^)(NSNumber *resCode, NSString *message))failure +{ + if ([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == 0) { + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + failure([NSNumber numberWithInt:-1], @"请检查网络连接。"); + }); + return; + } + + params = [self configBaseParmars:params]; +#ifdef DEBUG + NSLog(@"\nmethod:\n%@\nparameter:\n%@", method, params); +#endif + + AFHTTPSessionManager *manager = [HttpRequestHelper requestManager]; + [manager POST:method parameters:params headers:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { +#ifdef DEBUG + NSLog(@"\n%@", [responseObject yy_modelToJSONString]); +#endif + success([BaseModel yy_modelWithDictionary:responseObject]); + } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { +#ifdef DEBUG + NSLog(@"\n%@", error); +#endif + failure([NSNumber numberWithLong:error.code], error.domain); }]; } + (void)request:(NSString *)url method:(HttpRequestHelperMethod)method params:(NSDictionary *)params - success:(void (^)(id data))success + success:(void (^)(BaseModel *data))success failure:(void (^)(NSNumber *resCode, NSString *message))failure { - switch (method) { case HttpRequestHelperMethodGET: { [self GET:url params:params success:success failure:failure]; @@ -130,10 +119,7 @@ params:(NSDictionary *)params completion:(HttpRequestHelperCompletion)completion { - if ([path hasPrefix:@"/"]) { - path = [path substringFromIndex:1]; - } - [self request:path method:method params:params success:^(id data) { + [self request:path method:method params:params success:^(BaseModel *data) { if (completion) { completion(data, nil, nil); } @@ -144,7 +130,19 @@ }]; } -+ (NSDictionary*)configBaseParmars:(NSDictionary *)parmars { ++ (NSDictionary*)configBaseParmars:(NSDictionary *)parmars +{ + AFHTTPSessionManager *client = [HttpRequestHelper requestManager]; + if ([[AccountInfoStorage instance] getUid].length > 0) { + [client.requestSerializer setValue:[[AccountInfoStorage instance] getUid] forHTTPHeaderField:@"pub_uid"]; + } else { + [client.requestSerializer setValue:nil forHTTPHeaderField:@"pub_uid"]; + } + if ([[AccountInfoStorage instance] getTicket].length > 0) { + [client.requestSerializer setValue:[[AccountInfoStorage instance] getTicket] forHTTPHeaderField:@"pub_ticket"]; + }else { + [client.requestSerializer setValue:nil forHTTPHeaderField:@"pub_ticket"]; + } NSDictionary *defaultBasciParame = @{ @"os" : @"iOS", @"osVersion" : [YYUtility systemVersion], diff --git a/xplan-ios/Base/UI/BaseNavigationController.h b/xplan-ios/Base/UI/BaseNavigationController.h new file mode 100644 index 00000000..f6a9f12e --- /dev/null +++ b/xplan-ios/Base/UI/BaseNavigationController.h @@ -0,0 +1,16 @@ +// +// BaseNavigationController.h +// xplan-ios +// +// Created by zu on 2021/9/7. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface BaseNavigationController : UINavigationController + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Base/UI/BaseNavigationController.m b/xplan-ios/Base/UI/BaseNavigationController.m new file mode 100644 index 00000000..2f8766c5 --- /dev/null +++ b/xplan-ios/Base/UI/BaseNavigationController.m @@ -0,0 +1,36 @@ +// +// BaseNavigationController.m +// xplan-ios +// +// Created by zu on 2021/9/7. +// + +#import "BaseNavigationController.h" + +@interface BaseNavigationController () + +@end + +@implementation BaseNavigationController + +- (void)viewDidLoad { + [super viewDidLoad]; + [self themeConfig]; +} + +- (void)themeConfig { + self.navigationBar.shadowImage = [[UIImage alloc] init]; + self.navigationBar.barTintColor = ThemeBackgroundColor; + self.navigationBar.tintColor = [UIColor whiteColor]; + self.navigationBar.translucent = NO; + + UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil]; + self.navigationItem.backBarButtonItem = item; + + [self.navigationBar setTitleTextAttributes:@{ + NSFontAttributeName:[UIFont systemFontOfSize:18], + NSForegroundColorAttributeName:UIColor.whiteColor + }]; +} + +@end diff --git a/xplan-ios/Base/UI/BaseViewController.m b/xplan-ios/Base/UI/BaseViewController.m index 646da5b7..05681c89 100644 --- a/xplan-ios/Base/UI/BaseViewController.m +++ b/xplan-ios/Base/UI/BaseViewController.m @@ -20,21 +20,7 @@ - (void)themeConfig { self.view.backgroundColor = ThemeBackgroundColor; - [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent; - self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init]; - self.navigationController.navigationBar.barTintColor = ThemeBackgroundColor; - self.navigationController.navigationBar.tintColor = [UIColor whiteColor]; - self.navigationController.navigationBar.translucent = NO; - - UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil]; - self.navigationItem.backBarButtonItem = item; - - [self.navigationController.navigationBar setTitleTextAttributes:@{ - NSFontAttributeName:[UIFont systemFontOfSize:18], - NSForegroundColorAttributeName:UIColor.whiteColor - }]; - self.navigationItem.title = @"音游"; } /** diff --git a/xplan-ios/Main/Login/Api/Api+Login.m b/xplan-ios/Main/Login/Api/Api+Login.m index 0abc8258..4a82e84b 100644 --- a/xplan-ios/Main/Login/Api/Api+Login.m +++ b/xplan-ios/Main/Login/Api/Api+Login.m @@ -10,9 +10,7 @@ @implementation Api (Login) + (void)phoneQuickLogin:(HttpRequestHelperCompletion)completion accessToken:(NSString *)accessToken token:(NSString *)token { - [self makeRequest:@"acc/oneclick/login" method:HttpRequestHelperMethodPOST completion:^(id _Nullable data, NSNumber * _Nonnull code, NSString * _Nullable msg) { - completion(data, code, msg); - }, __FUNCTION__, accessToken, token, nil]; + [self makeRequest:@"acc/oneclick/login" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, accessToken, token, nil]; } @end diff --git a/xplan-ios/Main/Login/Presenter/LoginPresenter.m b/xplan-ios/Main/Login/Presenter/LoginPresenter.m index 34bba0a7..f9b970ad 100644 --- a/xplan-ios/Main/Login/Presenter/LoginPresenter.m +++ b/xplan-ios/Main/Login/Presenter/LoginPresenter.m @@ -8,6 +8,7 @@ #import "LoginPresenter.h" #import "LoginProtocol.h" #import "Api+Login.h" +#import "AccountInfoStorage.h" @implementation LoginPresenter @@ -16,7 +17,8 @@ } - (void)phoneQuickLogin:(NSString *)accessToken token:(NSString *)token { - [Api phoneQuickLogin:[self createHttpCompletion:^(id _Nonnull data) { + [Api phoneQuickLogin:[self createHttpCompletion:^(BaseModel *data) { + [[AccountInfoStorage instance] saveAccountInfo:[AccountModel yy_modelWithDictionary:data.data]]; [[self getView] phoneQuickLoginSuccess]; } fail:^(NSNumber * _Nonnull code, NSString * _Nullable msg) { // todo fail diff --git a/xplan-ios/Main/Login/View/LoginViewController.m b/xplan-ios/Main/Login/View/LoginViewController.m index e107cf3a..e4e95738 100644 --- a/xplan-ios/Main/Login/View/LoginViewController.m +++ b/xplan-ios/Main/Login/View/LoginViewController.m @@ -41,9 +41,9 @@ typedef NS_ENUM(NSInteger,XYThirdLoginType) { @interface LLButtonView : UIView //icon -@property (nonatomic,strong) UIImageView *logoImageView; +@property (nonatomic, strong) UIImageView *logoImageView; //title -@property (nonatomic,strong) UILabel *titleLabel; +@property (nonatomic, strong) UILabel *titleLabel; @end @implementation LLButtonView @@ -106,13 +106,13 @@ typedef NS_ENUM(NSInteger,XYThirdLoginType) { /** 登录按钮*/ @property (nonatomic, strong) UIButton *loginButton; -@property (nonatomic,strong) UIStackView *stackView; +@property (nonatomic, strong) UIStackView *stackView; ///手机 -@property (nonatomic,strong) LLButtonView *qqButtonView; +@property (nonatomic, strong) LLButtonView *qqButtonView; ///wx -@property (nonatomic,strong) LLButtonView *wxButtonView; +@property (nonatomic, strong) LLButtonView *wxButtonView; ///qq -@property (nonatomic,strong) LLButtonView *phoneButtonView; +@property (nonatomic, strong) LLButtonView *phoneButtonView; /** 同意勾选按钮*/ @property (nonatomic, strong) UIButton *agreeButton; @@ -132,7 +132,7 @@ typedef NS_ENUM(NSInteger,XYThirdLoginType) { } - (void)phoneQuickLoginSuccess { - [XCHUDTool showSuccessWithMessage:@"一键登录成功。"]; + [self.navigationController popToRootViewControllerAnimated:YES]; } - (void)viewDidLoad { diff --git a/xplan-ios/Main/Tabbar/Api+Main.h b/xplan-ios/Main/Tabbar/Api+Main.h new file mode 100644 index 00000000..8a329a3a --- /dev/null +++ b/xplan-ios/Main/Tabbar/Api+Main.h @@ -0,0 +1,18 @@ +// +// Api+Main.h +// xplan-ios +// +// Created by apple on 2021/9/8. +// + +#import "Api.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface Api (Main) + ++ (void)requestTicket:(HttpRequestHelperCompletion)completion access_token:(NSString *)accessToken issue_type:(NSString *)issueType; + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Tabbar/Api+Main.m b/xplan-ios/Main/Tabbar/Api+Main.m new file mode 100644 index 00000000..45daa353 --- /dev/null +++ b/xplan-ios/Main/Tabbar/Api+Main.m @@ -0,0 +1,16 @@ +// +// Api+Main.m +// xplan-ios +// +// Created by apple on 2021/9/8. +// + +#import "Api+Main.h" + +@implementation Api (Main) + ++ (void)requestTicket:(HttpRequestHelperCompletion)completion access_token:(NSString *)accessToken issue_type:(NSString *)issueType { + [self makeRequest:@"oauth/ticket" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, accessToken, issueType, nil]; +} + +@end diff --git a/xplan-ios/Main/Tabbar/MainPresenter.h b/xplan-ios/Main/Tabbar/MainPresenter.h new file mode 100644 index 00000000..d40329d7 --- /dev/null +++ b/xplan-ios/Main/Tabbar/MainPresenter.h @@ -0,0 +1,18 @@ +// +// MainPresenter.h +// xplan-ios +// +// Created by apple on 2021/9/8. +// + +#import "BaseMvpPresenter.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface MainPresenter : BaseMvpPresenter + +- (void)autoLogin; + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Tabbar/MainPresenter.m b/xplan-ios/Main/Tabbar/MainPresenter.m new file mode 100644 index 00000000..c72647b8 --- /dev/null +++ b/xplan-ios/Main/Tabbar/MainPresenter.m @@ -0,0 +1,35 @@ +// +// MainPresenter.m +// xplan-ios +// +// Created by apple on 2021/9/8. +// + +#import "MainPresenter.h" +#import "AccountInfoStorage.h" +#import "AccountModel.h" +#import "Api+Main.h" +#import "MainProtocol.h" + +@implementation MainPresenter + +- (void)autoLogin { + AccountModel *accountModel = [[AccountInfoStorage instance] getCurrentAccountInfo]; + if (accountModel == nil) { + [[self getView] tokenInvalid]; + return; + } + if ([[AccountInfoStorage instance] getTicket] != nil) { + return; + } + [Api requestTicket:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + NSArray *tickets = [data.data valueForKey:@"tickets"]; + NSString *ticket = [tickets[0] valueForKey:@"ticket"]; + [[AccountInfoStorage instance] saveTicket:ticket]; + [[self getView] autoLoginSuccess]; + } fail:^(NSNumber * _Nonnull code, NSString * _Nullable msg) { + + } showLoading:NO errorToast:YES] access_token:accountModel.access_token issue_type:@"multi"]; +} + +@end diff --git a/xplan-ios/Main/Tabbar/MainProtocol.h b/xplan-ios/Main/Tabbar/MainProtocol.h new file mode 100644 index 00000000..e51db52d --- /dev/null +++ b/xplan-ios/Main/Tabbar/MainProtocol.h @@ -0,0 +1,18 @@ +// +// MainProtocol.h +// xplan-ios +// +// Created by apple on 2021/9/8. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol MainProtocol + +- (void)autoLoginSuccess; + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/TabbarViewController.h b/xplan-ios/Main/Tabbar/TabbarViewController.h similarity index 50% rename from xplan-ios/Main/TabbarViewController.h rename to xplan-ios/Main/Tabbar/TabbarViewController.h index e9c9b71a..c4ef3f33 100644 --- a/xplan-ios/Main/TabbarViewController.h +++ b/xplan-ios/Main/Tabbar/TabbarViewController.h @@ -5,9 +5,7 @@ // Created by zu on 2021/8/31. // -#import "MvpViewController.h" - -@interface TabbarViewController : MvpViewController +@interface TabbarViewController : UITabBarController @end diff --git a/xplan-ios/Main/Tabbar/TabbarViewController.m b/xplan-ios/Main/Tabbar/TabbarViewController.m new file mode 100644 index 00000000..6aa84045 --- /dev/null +++ b/xplan-ios/Main/Tabbar/TabbarViewController.m @@ -0,0 +1,85 @@ +// +// ViewController.m +// xplan-ios +// +// Created by zu on 2021/8/31. +// +#import +#import "TabbarViewController.h" +#import "BaseViewController.h" +#import "UIImage+Utils.h" +#import "LoginViewController.h" +#import "MainPresenter.h" +#import "MainProtocol.h" + +@interface TabbarViewController () + +@property (nonatomic, strong) MainPresenter *presenter; + +@end + +@implementation TabbarViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + [self configTheme]; + [self initTabs]; +} + +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + [self.presenter autoLogin]; +} + +- (MainPresenter *)presenter { + if (_presenter == nil) { + _presenter = [[MainPresenter alloc] init]; + [_presenter attatchView:self]; + } + return _presenter; +} + +- (void)tokenInvalid { + LoginViewController *lvc = [[LoginViewController alloc] init]; + [self.navigationController pushViewController:lvc animated:YES]; +} + +- (void)completeUserInfo { + +} + +- (void)autoLoginSuccess { + +} + +- (void)configTheme { + [[UITabBar appearance] setBackgroundImage:[UIImage imageWithColor:ThemeTabbarBackgroundColor size:CGSizeMake(KScreenWidth, kTabBarHeight)]]; + [[UITabBar appearance] setShadowImage:[[UIImage alloc]init]]; + if (@available(iOS 10.0, *)) { + [[UITabBar appearance] setUnselectedItemTintColor:ThemeTabbarNormalColor]; + } +} + +- (void)initTabs { + NSArray *normalImageNames = @[@"tab_game_normal", @"tab_mine_normal"]; + NSArray *selectImageNames = @[@"tab_game_selected", @"tab_mine_selected"]; + NSArray *tabLabel = @[@"赛事", @"我的"]; + + BaseViewController *bvcGame = [[BaseViewController alloc] init]; + [self createTabBarItem:bvcGame title:tabLabel[0] image:normalImageNames[0] selectedImage:selectImageNames[0]]; + [self addChildViewController:bvcGame]; + + BaseViewController *bvcMe = [[BaseViewController alloc] init]; + [self createTabBarItem:bvcMe title:tabLabel[1] image:normalImageNames[1] selectedImage:selectImageNames[1]]; + [self addChildViewController:bvcMe]; +} + +- (void)createTabBarItem:(UIViewController *)itemVc title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage{ + itemVc.title = title; + itemVc.tabBarItem.image = [[UIImage imageNamed:image] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; + itemVc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; + [itemVc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:ThemeTabbarSelectedColor} forState:UIControlStateSelected]; + [itemVc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:ThemeTabbarNormalColor} forState:UIControlStateNormal]; +} + +@end diff --git a/xplan-ios/Main/TabbarViewController.m b/xplan-ios/Main/TabbarViewController.m deleted file mode 100644 index 0824294e..00000000 --- a/xplan-ios/Main/TabbarViewController.m +++ /dev/null @@ -1,22 +0,0 @@ -// -// ViewController.m -// xplan-ios -// -// Created by zu on 2021/8/31. -// - -#import "TabbarViewController.h" -#import "LoginViewController.h" - -@interface TabbarViewController () - -@end - -@implementation TabbarViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - [self tokenInvalid]; -} - -@end