├── .gitignore ├── HybridPageKit.podspec ├── HybridPageKit ├── HybridPageKit-Demo │ ├── HybridPageKit-Demo.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── HybridPageKit-Demo │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-120@2x.png │ │ │ ├── Icon-120@3x.png │ │ │ ├── Icon-180@3x.png │ │ │ ├── Icon-40@2x.png │ │ │ ├── Icon-58@2x.png │ │ │ ├── Icon-60@3x.png │ │ │ ├── Icon-80@2x.png │ │ │ ├── Icon-87@3x.png │ │ │ └── icon-1024.png │ │ ├── Contents.json │ │ └── LaunchImage.launchimage │ │ │ ├── 320x480pt@2x.png │ │ │ ├── 320x568pt@2x.png │ │ │ ├── 375x667pt@2x.png │ │ │ ├── 375x812pt@3x.png │ │ │ ├── 414x736pt@3x.png │ │ │ └── Contents.json │ │ ├── Controller │ │ ├── ListViewController.h │ │ ├── ListViewController.m │ │ ├── NativeComponentController.h │ │ ├── NativeComponentController.m │ │ ├── NestingBannerController.h │ │ ├── NestingBannerController.m │ │ ├── NestingWebViewController.h │ │ ├── NestingWebViewController.m │ │ ├── SingleWebViewController.h │ │ ├── SingleWebViewController.m │ │ ├── WebComponentController.h │ │ └── WebComponentController.m │ │ ├── Data │ │ ├── ArticleModel.h │ │ ├── ArticleModel.m │ │ ├── articleContent.txt │ │ ├── gif1.jpeg │ │ ├── gif2.jpeg │ │ ├── icon.png │ │ └── play.png │ │ ├── Feature │ │ ├── AD │ │ │ ├── AdController.h │ │ │ ├── AdController.m │ │ │ ├── AdModel.h │ │ │ ├── AdModel.m │ │ │ ├── AdView.h │ │ │ └── AdView.m │ │ ├── ArticleFeatureDef.h │ │ ├── BlockNews │ │ │ ├── BlockNewsController.h │ │ │ ├── BlockNewsController.m │ │ │ ├── BlockNewsModel.h │ │ │ ├── BlockNewsModel.m │ │ │ ├── BlockNewsView.h │ │ │ └── BlockNewsView.m │ │ ├── Comment │ │ │ ├── HotCommentController.h │ │ │ ├── HotCommentController.m │ │ │ ├── HotCommentModel.h │ │ │ ├── HotCommentModel.m │ │ │ ├── HotCommentView.h │ │ │ └── HotCommentView.m │ │ ├── ComponentBaseController.h │ │ ├── ComponentBaseController.m │ │ ├── Gif │ │ │ ├── GifController.h │ │ │ ├── GifController.m │ │ │ ├── GifModel.h │ │ │ ├── GifModel.m │ │ │ ├── GifView.h │ │ │ └── GifView.m │ │ ├── Image │ │ │ ├── ImageController.h │ │ │ ├── ImageController.m │ │ │ ├── ImageModel.h │ │ │ ├── ImageModel.m │ │ │ ├── ImageView.h │ │ │ └── ImageView.m │ │ ├── MediaInfo │ │ │ ├── MediaController.h │ │ │ ├── MediaController.m │ │ │ ├── MediaModel.h │ │ │ ├── MediaModel.m │ │ │ ├── MediaView.h │ │ │ └── MediaView.m │ │ ├── RelateNews │ │ │ ├── RelateNewsController.h │ │ │ ├── RelateNewsController.m │ │ │ ├── RelateNewsModel.h │ │ │ ├── RelateNewsModel.m │ │ │ ├── RelateNewsView.h │ │ │ └── RelateNewsView.m │ │ ├── Title │ │ │ ├── TitleController.h │ │ │ ├── TitleController.m │ │ │ ├── TitleModel.h │ │ │ ├── TitleModel.m │ │ │ ├── TitleView.h │ │ │ └── TitleView.m │ │ └── Video │ │ │ ├── VideoController.h │ │ │ ├── VideoController.m │ │ │ ├── VideoModel.h │ │ │ ├── VideoModel.m │ │ │ ├── VideoView.h │ │ │ └── VideoView.m │ │ ├── Info.plist │ │ ├── PrefixHeader.pch │ │ └── main.m ├── HybridPageKit.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── HybridPageKit │ ├── HybridPageKit.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ ├── HybridPageKit │ ├── HPKControllerProtocol.h │ ├── HPKModelProtocol.h │ ├── HPKPageHandler.h │ ├── HPKPageManager.h │ ├── HPKViewProtocol.h │ ├── HPKWebView.h │ ├── Info.plist │ └── Source │ │ ├── HPKCommonViewPool.h │ │ ├── HPKCommonViewPool.m │ │ ├── HPKDefaultWebViewControl.h │ │ ├── HPKDefaultWebViewControl.m │ │ ├── HPKPageHandler.m │ │ ├── HPKPageManager.m │ │ ├── HPKScrollProcessor.h │ │ ├── HPKScrollProcessor.m │ │ ├── HPKWebView.m │ │ ├── HPKWebViewExtensionDelegate.h │ │ ├── HPKWebViewExtensionDelegate.m │ │ ├── HPKWebViewPool.h │ │ ├── HPKWebViewPool.m │ │ ├── WKWebView + HPKDelegateExtension.h │ │ ├── WKWebView + HPKDelegateExtension.m │ │ ├── WKWebView + HPKExtension.h │ │ ├── WKWebView + HPKExtension.m │ │ ├── WKWebView + HPKReusable.h │ │ ├── WKWebView + HPKReusable.m │ │ ├── _HPKAspects.h │ │ ├── _HPKAspects.m │ │ ├── _HPKUtils.h │ │ └── _HPKUtils.m │ └── HybridPageKitTests │ ├── HPKSafeKVOTests.m │ ├── HPKWebViewDelegateTests.m │ ├── HPKWebViewReuseTests.m │ ├── HPKWebViewTests.m │ └── Info.plist ├── LICENSE ├── README-CN.md ├── README-IMAGE ├── Banner.gif ├── Folded.gif ├── Hybrid.gif └── Short.gif └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/xcode,macos,objective-c 3 | 4 | ### macOS ### 5 | *.DS_Store 6 | .AppleDouble 7 | .LSOverride 8 | 9 | # Icon must end with two \r 10 | Icon 11 | 12 | # Thumbnails 13 | ._* 14 | 15 | # Files that might appear in the root of a volume 16 | .DocumentRevisions-V100 17 | .fseventsd 18 | .Spotlight-V100 19 | .TemporaryItems 20 | .Trashes 21 | .VolumeIcon.icns 22 | .com.apple.timemachine.donotpresent 23 | 24 | # Directories potentially created on remote AFP share 25 | .AppleDB 26 | .AppleDesktop 27 | Network Trash Folder 28 | Temporary Items 29 | .apdisk 30 | 31 | ### Objective-C ### 32 | # Xcode 33 | # 34 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 35 | 36 | ## Build generated 37 | build/ 38 | DerivedData/ 39 | 40 | ## Various settings 41 | *.pbxuser 42 | !default.pbxuser 43 | *.mode1v3 44 | !default.mode1v3 45 | *.mode2v3 46 | !default.mode2v3 47 | *.perspectivev3 48 | !default.perspectivev3 49 | xcuserdata/ 50 | 51 | ## Other 52 | *.moved-aside 53 | *.xccheckout 54 | *.xcscmblueprint 55 | 56 | ## Obj-C/Swift specific 57 | *.hmap 58 | *.ipa 59 | *.dSYM.zip 60 | *.dSYM 61 | 62 | # CocoaPods - Refactored to standalone file 63 | 64 | 65 | # Carthage - Refactored to standalone file 66 | 67 | # fastlane 68 | # 69 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 70 | # screenshots whenever they are needed. 71 | # For more information about the recommended setup visit: 72 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 73 | 74 | fastlane/report.xml 75 | fastlane/Preview.html 76 | fastlane/screenshots 77 | fastlane/test_output 78 | 79 | # Code Injection 80 | # 81 | # After new code Injection tools there's a generated folder /iOSInjectionProject 82 | # https://github.com/johnno1962/injectionforxcode 83 | 84 | iOSInjectionProject/ 85 | 86 | ### Objective-C Patch ### 87 | 88 | ### Xcode ### 89 | # Xcode 90 | # 91 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 92 | 93 | ## Build generated 94 | 95 | ## Various settings 96 | 97 | ## Other 98 | 99 | ### Xcode Patch ### 100 | *.xcodeproj/* 101 | !*.xcodeproj/project.pbxproj 102 | !*.xcodeproj/xcshareddata/ 103 | !*.xcworkspace/contents.xcworkspacedata 104 | /*.gcno 105 | 106 | 107 | # End of https://www.gitignore.io/api/xcode,macos,objective-c -------------------------------------------------------------------------------- /HybridPageKit.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "HybridPageKit" 3 | s.version = "1.4" 4 | s.summary = "A high-performance、high-extensibility、easy integration framework for Hybrid content page. Support most content page types of News App." 5 | s.homepage = "https://github.com/dequan1331/HybridPageKit" 6 | s.license = "MIT" 7 | s.author = "dequanzhu" 8 | s.platform = :ios, "8.0" 9 | s.requires_arc = true 10 | s.source = { :git => "https://github.com/dequan1331/HybridPageKit.git", :tag => s.version.to_s } 11 | s.source_files = "HybridPageKit/HybridPageKit/HybridPageKit/**/*.{h,m}" 12 | s.public_header_files = "HybridPageKit/HybridPageKit/HybridPageKit/*.h" 13 | 14 | s.test_spec 'HybridPageKitTests' do |test_spec| 15 | test_spec.source_files = "HybridPageKit/HybridPageKit/HybridPageKitTests/*.{h,m}" 16 | end 17 | end -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // HybridPageKit-Demo 4 | // 5 | // Created by deqzhu on 2019/3/3. 6 | // Copyright © 2019 dequanzhu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // HybridPageKit-Demo 4 | // 5 | // Created by deqzhu on 2019/3/3. 6 | // Copyright © 2019 dequanzhu. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "ListViewController.h" 11 | 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | 19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 20 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 21 | UINavigationController *navigationcontroller = [[UINavigationController alloc] initWithRootViewController:[[ListViewController alloc]init]]; 22 | self.window.rootViewController = navigationcontroller; 23 | [self.window makeKeyAndVisible]; 24 | return YES; 25 | } 26 | 27 | 28 | - (void)applicationWillResignActive:(UIApplication *)application { 29 | } 30 | 31 | 32 | - (void)applicationDidEnterBackground:(UIApplication *)application { 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | } 38 | 39 | 40 | - (void)applicationDidBecomeActive:(UIApplication *)application { 41 | } 42 | 43 | 44 | - (void)applicationWillTerminate:(UIApplication *)application { 45 | } 46 | 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-40@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-60@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-58@2x.png", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-87@3x.png", 25 | "scale" : "3x" 26 | }, 27 | { 28 | "size" : "40x40", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-80@2x.png", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-120@3x.png", 37 | "scale" : "3x" 38 | }, 39 | { 40 | "size" : "60x60", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-120@2x.png", 43 | "scale" : "2x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-180@3x.png", 49 | "scale" : "3x" 50 | }, 51 | { 52 | "size" : "1024x1024", 53 | "idiom" : "ios-marketing", 54 | "filename" : "icon-1024.png", 55 | "scale" : "1x" 56 | } 57 | ], 58 | "info" : { 59 | "version" : 1, 60 | "author" : "xcode" 61 | } 62 | } -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/AppIcon.appiconset/Icon-120@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dequan1331/HybridPageKit/3500feb2cb3cbd2efbf54c309ea7c9baf7b03e31/HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/AppIcon.appiconset/Icon-120@2x.png -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/AppIcon.appiconset/Icon-120@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dequan1331/HybridPageKit/3500feb2cb3cbd2efbf54c309ea7c9baf7b03e31/HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/AppIcon.appiconset/Icon-120@3x.png -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/AppIcon.appiconset/Icon-180@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dequan1331/HybridPageKit/3500feb2cb3cbd2efbf54c309ea7c9baf7b03e31/HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/AppIcon.appiconset/Icon-180@3x.png -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/AppIcon.appiconset/Icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dequan1331/HybridPageKit/3500feb2cb3cbd2efbf54c309ea7c9baf7b03e31/HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/AppIcon.appiconset/Icon-40@2x.png -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/AppIcon.appiconset/Icon-58@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dequan1331/HybridPageKit/3500feb2cb3cbd2efbf54c309ea7c9baf7b03e31/HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/AppIcon.appiconset/Icon-58@2x.png -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dequan1331/HybridPageKit/3500feb2cb3cbd2efbf54c309ea7c9baf7b03e31/HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/AppIcon.appiconset/Icon-80@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dequan1331/HybridPageKit/3500feb2cb3cbd2efbf54c309ea7c9baf7b03e31/HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/AppIcon.appiconset/Icon-80@2x.png -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/AppIcon.appiconset/Icon-87@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dequan1331/HybridPageKit/3500feb2cb3cbd2efbf54c309ea7c9baf7b03e31/HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/AppIcon.appiconset/Icon-87@3x.png -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/AppIcon.appiconset/icon-1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dequan1331/HybridPageKit/3500feb2cb3cbd2efbf54c309ea7c9baf7b03e31/HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/AppIcon.appiconset/icon-1024.png -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/LaunchImage.launchimage/320x480pt@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dequan1331/HybridPageKit/3500feb2cb3cbd2efbf54c309ea7c9baf7b03e31/HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/LaunchImage.launchimage/320x480pt@2x.png -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/LaunchImage.launchimage/320x568pt@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dequan1331/HybridPageKit/3500feb2cb3cbd2efbf54c309ea7c9baf7b03e31/HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/LaunchImage.launchimage/320x568pt@2x.png -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/LaunchImage.launchimage/375x667pt@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dequan1331/HybridPageKit/3500feb2cb3cbd2efbf54c309ea7c9baf7b03e31/HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/LaunchImage.launchimage/375x667pt@2x.png -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/LaunchImage.launchimage/375x812pt@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dequan1331/HybridPageKit/3500feb2cb3cbd2efbf54c309ea7c9baf7b03e31/HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/LaunchImage.launchimage/375x812pt@3x.png -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/LaunchImage.launchimage/414x736pt@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dequan1331/HybridPageKit/3500feb2cb3cbd2efbf54c309ea7c9baf7b03e31/HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/LaunchImage.launchimage/414x736pt@3x.png -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Assets.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "extent" : "full-screen", 5 | "idiom" : "iphone", 6 | "subtype" : "2436h", 7 | "filename" : "375x812pt@3x.png", 8 | "minimum-system-version" : "11.0", 9 | "orientation" : "portrait", 10 | "scale" : "3x" 11 | }, 12 | { 13 | "extent" : "full-screen", 14 | "idiom" : "iphone", 15 | "subtype" : "736h", 16 | "filename" : "414x736pt@3x.png", 17 | "minimum-system-version" : "8.0", 18 | "orientation" : "portrait", 19 | "scale" : "3x" 20 | }, 21 | { 22 | "extent" : "full-screen", 23 | "idiom" : "iphone", 24 | "subtype" : "667h", 25 | "filename" : "375x667pt@2x.png", 26 | "minimum-system-version" : "8.0", 27 | "orientation" : "portrait", 28 | "scale" : "2x" 29 | }, 30 | { 31 | "orientation" : "portrait", 32 | "idiom" : "iphone", 33 | "filename" : "320x480pt@2x.png", 34 | "extent" : "full-screen", 35 | "minimum-system-version" : "7.0", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "extent" : "full-screen", 40 | "idiom" : "iphone", 41 | "subtype" : "retina4", 42 | "filename" : "320x568pt@2x.png", 43 | "minimum-system-version" : "7.0", 44 | "orientation" : "portrait", 45 | "scale" : "2x" 46 | } 47 | ], 48 | "info" : { 49 | "version" : 1, 50 | "author" : "xcode" 51 | } 52 | } -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Controller/ListViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ListViewController.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | @interface ListViewController : UIViewController 26 | @end 27 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Controller/NativeComponentController.h: -------------------------------------------------------------------------------- 1 | // 2 | // NativeComponentController.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | @interface NativeComponentController : UIViewController 26 | @property (nonatomic, strong, readwrite) HPKPageHandler *componentHandler; 27 | @end 28 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Controller/NativeComponentController.m: -------------------------------------------------------------------------------- 1 | // 2 | // NativeComponentController.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import "NativeComponentController.h" 26 | #import "ArticleModel.h" 27 | 28 | @interface NativeComponentController () 29 | @property (nonatomic, strong, readwrite) ArticleModel *articleModel; 30 | 31 | @property (nonatomic, strong, readwrite) UIScrollView *containerScrollView; 32 | 33 | @end 34 | 35 | @implementation NativeComponentController 36 | - (instancetype)init { 37 | self = [super init]; 38 | if (self) { 39 | _componentHandler = [[HPKPageHandler alloc] init]; 40 | [_componentHandler configWithViewController:self componentsControllers:@[[[TitleController alloc]initWithController:self], 41 | [[AdController alloc]initWithController:self], 42 | [[MediaController alloc]initWithController:self], 43 | [[RelateNewsController alloc]initWithController:self], 44 | [[HotCommentController alloc]initWithController:self], 45 | [[BlockNewsController alloc]initWithController:self]]]; 46 | } 47 | return self; 48 | } 49 | 50 | - (void)dealloc { 51 | } 52 | 53 | - (void)viewDidLoad { 54 | [super viewDidLoad]; 55 | 56 | [self _getRemoteDataAndLoad]; 57 | 58 | [self.view addSubview:({ 59 | _containerScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - CGRectGetMaxY(self.navigationController.navigationBar.frame))]; 60 | _containerScrollView.backgroundColor = [UIColor whiteColor]; 61 | _containerScrollView.delegate = self; 62 | _containerScrollView; 63 | })]; 64 | 65 | [_componentHandler handleSingleScrollView:_containerScrollView]; 66 | } 67 | 68 | #pragma mark - 69 | 70 | - (void)_getRemoteDataAndLoad { 71 | __weak typeof(self)wself = self; 72 | _articleModel = [[ArticleModel alloc] init]; 73 | [_articleModel loadArticleContentWithFinishBlock:^{ 74 | __strong __typeof(wself) strongSelf = wself; 75 | [strongSelf.componentHandler triggerBroadcastSelector:@selector(didReceiveArticleContent:) para1:strongSelf.articleModel para2:nil]; 76 | [strongSelf.componentHandler layoutWithComponentModels:strongSelf.articleModel.extensionComponents]; 77 | }]; 78 | } 79 | 80 | #pragma mark - 81 | 82 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView{ 83 | [_componentHandler triggerBroadcastSelector:@selector(containerScrollViewDidScroll:) para1:scrollView para2:nil]; 84 | } 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Controller/NestingBannerController.h: -------------------------------------------------------------------------------- 1 | // 2 | // NestingBannerController.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | @interface NestingBannerController : UIViewController 26 | @property (nonatomic, strong, readwrite) HPKPageHandler *componentHandler; 27 | @end 28 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Controller/NestingWebViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // NestingWebViewController.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | @interface NestingWebViewController : UIViewController 26 | @property (nonatomic, strong, readwrite) HPKPageHandler *componentHandler; 27 | - (instancetype)initWithUseCustomComparator:(BOOL)useCustomComparator; 28 | @end 29 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Controller/SingleWebViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // SingleWebViewController.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | @interface SingleWebViewController : UIViewController 27 | @end 28 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Controller/SingleWebViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // SingleWebViewController.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import "SingleWebViewController.h" 26 | 27 | @interface SingleWebView : HPKWebView 28 | @end 29 | @implementation SingleWebView 30 | @end 31 | 32 | @interface SingleWebViewController () 33 | @property (nonatomic, strong, readwrite) SingleWebView *webView; 34 | @end 35 | 36 | @implementation SingleWebViewController 37 | 38 | - (void)dealloc { 39 | [[HPKPageManager sharedInstance] enqueueWebView:self.webView]; 40 | } 41 | 42 | - (void)viewDidLoad { 43 | [super viewDidLoad]; 44 | [self.view addSubview:({ 45 | _webView = [[HPKPageManager sharedInstance] dequeueWebViewWithClass:[SingleWebView class] webViewHolder:self]; 46 | _webView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - CGRectGetMaxY(self.navigationController.navigationBar.frame));; 47 | [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.qq.com"]]]; 48 | _webView; 49 | })]; 50 | } 51 | 52 | #pragma mark - 53 | - (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation { 54 | // custom webviewe delegate 55 | } 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Controller/WebComponentController.h: -------------------------------------------------------------------------------- 1 | // 2 | // WebComponentController.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | @interface WebComponentController : UIViewController 27 | @property (nonatomic, strong, readwrite) HPKPageHandler *webComponentHandler; 28 | @end 29 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Controller/WebComponentController.m: -------------------------------------------------------------------------------- 1 | // 2 | // WebComponentController.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "WebComponentController.h" 27 | #import "ArticleModel.h" 28 | 29 | @interface WebComponentController () 30 | 31 | @property (nonatomic, strong, readwrite) HPKWebView *webView; 32 | 33 | @property (nonatomic, strong, readwrite) ArticleModel *articleModel; 34 | @end 35 | 36 | @implementation WebComponentController 37 | 38 | - (instancetype)init { 39 | self = [super init]; 40 | if (self) { 41 | _webComponentHandler = [[HPKPageHandler alloc] init]; 42 | [_webComponentHandler configWithViewController:self componentsControllers:@[[[VideoController alloc]initWithController:self], 43 | [[GifController alloc]initWithController:self], 44 | [[ImageController alloc]initWithController:self]]]; 45 | } 46 | return self; 47 | } 48 | 49 | - (void)dealloc { 50 | [[HPKPageManager sharedInstance] enqueueWebView:self.webView]; 51 | } 52 | 53 | - (void)viewDidLoad { 54 | [super viewDidLoad]; 55 | 56 | [self _getRemoteDataAndLoad]; 57 | 58 | [self.view addSubview:({ 59 | _webView = [[HPKPageManager sharedInstance] dequeueWebViewWithClass:[HPKWebView class] webViewHolder:self]; 60 | _webView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - CGRectGetMaxY(self.navigationController.navigationBar.frame)); 61 | _webView.navigationDelegate = self; 62 | _webView; 63 | })]; 64 | 65 | [_webComponentHandler handleSingleWebView:_webView webComponentDomClass:@"web-component" webComponentIndexKey:@"component-index"]; 66 | } 67 | 68 | #pragma mark - 69 | 70 | - (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation { 71 | [_webComponentHandler layoutWithWebComponentModels:self.articleModel.webViewComponents]; 72 | } 73 | 74 | #pragma mark - 75 | 76 | - (void)_getRemoteDataAndLoad { 77 | __weak typeof(self)wself = self; 78 | _articleModel = [[ArticleModel alloc] init]; 79 | [_articleModel loadArticleContentWithFinishBlock:^{ 80 | __strong __typeof(wself) strongSelf = wself; 81 | [strongSelf.webView loadHTMLString:strongSelf.articleModel.contentTemplateString baseURL:nil]; 82 | }]; 83 | } 84 | 85 | @end 86 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Data/ArticleModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // ArticleModel.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | @class HotCommentModel; 26 | 27 | typedef void (^ArticleModelLoadFinishBlock)(void); 28 | 29 | @interface ArticleModel : NSObject 30 | 31 | @property (nonatomic, copy, readonly) NSString *articleIdStr; 32 | 33 | //template 34 | @property (nonatomic, copy, readonly) NSString *contentTemplateString; 35 | 36 | //component 37 | @property (nonatomic, strong, readonly) NSArray *webViewComponents; 38 | @property (nonatomic, strong, readwrite) NSArray *extensionComponents; 39 | 40 | @property (nonatomic, strong, readwrite) HotCommentModel *hotCommentModel; 41 | 42 | - (void)loadArticleContentWithFinishBlock:(ArticleModelLoadFinishBlock)finishBlock; 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Data/articleContent.txt: -------------------------------------------------------------------------------- 1 | { 2 | "ret": "0", 3 | "articleContent": "HybridPageKit

正文内容开始

替换Web中图片为ImageView展示 \n


替换Web中视频为ImageView展示


替换Web中图片为ImageView展示 \n


替换Web中图片为ImageView展示 \n


替换Web中Gif为ImageView展示 \n


替换Web中图片为ImageView展示 \n


替换Web中Gif为ImageView展示 \n


替换Web中Gif为ImageView展示 \n


替换Web中图片为ImageView展示 \n


正文结束

", 4 | "components": { 5 | "IMG_0": { 6 | "desc": "HybridPageKit-TestImage-0", 7 | "url": "http://127.0.0.1:8080?type=3", 8 | "width": "340", 9 | "height": "200" 10 | }, 11 | "IMG_1": { 12 | "desc": "HybridPageKit-TestImage-1", 13 | "url": "http://127.0.0.1:8080?type=3", 14 | "width": "340", 15 | "height": "200" 16 | }, 17 | "IMG_2": { 18 | "desc": "HybridPageKit-TestImage-2", 19 | "url": "http://127.0.0.1:8080?type=3", 20 | "width": "340", 21 | "height": "200" 22 | }, 23 | "IMG_3": { 24 | "desc": "HybridPageKit-TestImage-3", 25 | "url": "http://127.0.0.1:8080?type=3", 26 | "width": "340", 27 | "height": "200" 28 | }, 29 | "IMG_4": { 30 | "desc": "HybridPageKit-TestImage-4", 31 | "url": "http://127.0.0.1:8080?type=3", 32 | "width": "340", 33 | "height": "200" 34 | }, 35 | "GIF_0": { 36 | "desc": "HybridPageKit-TestImage-0", 37 | "url": "http://127.0.0.1:8080?type=3", 38 | "width": "340", 39 | "height": "200" 40 | }, 41 | "GIF_1": { 42 | "desc": "HybridPageKit-TestImage-1", 43 | "url": "http://127.0.0.1:8080?type=3", 44 | "width": "340", 45 | "height": "200" 46 | }, 47 | "GIF_2": { 48 | "desc": "HybridPageKit-TestImage-2", 49 | "url": "http://127.0.0.1:8080?type=3", 50 | "width": "340", 51 | "height": "200" 52 | }, 53 | "VIDEO_0": { 54 | "desc": "HybridPageKit-VIDEO-0", 55 | "url": "http://127.0.0.1:8080?type=3", 56 | "width": "340", 57 | "height": "200" 58 | }, 59 | }, 60 | "articleTitle": { 61 | "title" : "文章标题", 62 | }, 63 | "articleAd":{ 64 | "ret": "0", 65 | "id": "123456789", 66 | "title" : "HybridPageKit", 67 | "subTitle" : "一个异步拉取数据、动态更新的组件", 68 | "image" : "", 69 | }, 70 | "articleMedia": { 71 | "mediaName" : "HybridPageKit", 72 | "mediaDescribe": "普通业务组件", 73 | "mediaIcon": "", 74 | }, 75 | "articleRelateNews": { 76 | "newsArray" : [ 77 | "相关文章 - 普通TableViewCell - 1", 78 | "相关文章 - 普通TableViewCell - 2", 79 | "相关文章 - 普通TableViewCell - 3", 80 | "相关文章 - 普通TableViewCell - 4", 81 | ], 82 | }, 83 | "articleHotComment": { 84 | "commentArray" : [ 85 | "底部评论 - 支持上拉加载 - ", 86 | "底部评论 - 支持上拉加载 - ", 87 | "底部评论 - 支持上拉加载 - ", 88 | "底部评论 - 支持上拉加载 - ", 89 | "底部评论 - 支持上拉加载 - ", 90 | "底部评论 - 支持上拉加载 - ", 91 | "底部评论 - 支持上拉加载 - ", 92 | "底部评论 - 支持上拉加载 - ", 93 | "底部评论 - 支持上拉加载 - ", 94 | "底部评论 - 支持上拉加载 - ", 95 | ], 96 | }, 97 | } 98 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Data/gif1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dequan1331/HybridPageKit/3500feb2cb3cbd2efbf54c309ea7c9baf7b03e31/HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Data/gif1.jpeg -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Data/gif2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dequan1331/HybridPageKit/3500feb2cb3cbd2efbf54c309ea7c9baf7b03e31/HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Data/gif2.jpeg -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Data/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dequan1331/HybridPageKit/3500feb2cb3cbd2efbf54c309ea7c9baf7b03e31/HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Data/icon.png -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Data/play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dequan1331/HybridPageKit/3500feb2cb3cbd2efbf54c309ea7c9baf7b03e31/HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Data/play.png -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/AD/AdController.h: -------------------------------------------------------------------------------- 1 | // 2 | // AdController.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import "ComponentBaseController.h" 26 | @interface AdController : ComponentBaseController 27 | @end 28 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/AD/AdController.m: -------------------------------------------------------------------------------- 1 | // 2 | // AdController.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import "AdController.h" 26 | #import "ArticleModel.h" 27 | #import "AdModel.h" 28 | #import "AdView.h" 29 | 30 | @interface AdController () 31 | @property (nonatomic, strong, readwrite) AdModel *adModel; 32 | @end 33 | 34 | @implementation AdController 35 | 36 | - (nullable NSArray *)supportComponentModelClass { 37 | return @[[AdModel class]]; 38 | } 39 | 40 | - (nullable Class)reusableComponentViewClassWithModel:(HPKModel *)componentModel { 41 | return [AdView class]; 42 | } 43 | 44 | - (void)didReceiveArticleContent:(ArticleModel *)articleModel { 45 | _adModel = [[AdModel alloc] init]; 46 | 47 | __weak typeof(self)wself = self; 48 | [_adModel getAsyncDataWithCompletionBlock:^{ 49 | __strong __typeof(wself) strongSelf = wself; 50 | [strongSelf.pageHandler layoutWithAddComponentModel:strongSelf.adModel]; 51 | }]; 52 | } 53 | 54 | - (void)scrollViewWillPrepareComponentView:(HPKView *)componentView 55 | componentModel:(HPKModel *)componentModel { 56 | [((AdView *)componentView) layoutWithData:(AdModel *)componentModel]; 57 | 58 | [((AdModel *)componentModel) setComponentFrame:CGRectMake(0, 0, componentView.frame.size.width, componentView.frame.size.height)]; 59 | [self.pageHandler relayoutWithComponentChange]; 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/AD/AdModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // AdModel.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | typedef void (^AdModelLoadCompletionBlock)(void); 27 | 28 | @interface AdModel : NSObject 29 | 30 | @property (nonatomic, copy, readonly) NSString *imageUrl; 31 | @property (nonatomic, copy, readonly) NSString *title; 32 | @property (nonatomic, copy, readonly) NSString *desc; 33 | 34 | - (void)getAsyncDataWithCompletionBlock:(AdModelLoadCompletionBlock)completionBlock; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/AD/AdModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // AdModel.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import "AdModel.h" 26 | #import "AdView.h" 27 | #import "AdController.h" 28 | 29 | @interface AdModel () 30 | @property (nonatomic, copy, readwrite) NSString *imageUrl; 31 | @property (nonatomic, copy, readwrite) NSString *title; 32 | @property (nonatomic, copy, readwrite) NSString *desc; 33 | @property (nonatomic, copy, readwrite) AdModelLoadCompletionBlock completionBlock; 34 | @end 35 | 36 | @implementation AdModel 37 | 38 | IMP_HPKModelProtocol(@(kHPKDemoComponentIndexAd).stringValue); 39 | 40 | - (void)dealloc { 41 | _completionBlock = nil; 42 | } 43 | 44 | - (void)getAsyncDataWithCompletionBlock:(AdModelLoadCompletionBlock)completionBlock { 45 | if (!completionBlock) { 46 | return; 47 | } 48 | 49 | _completionBlock = [completionBlock copy]; 50 | 51 | NSDictionary *responseDic = nil; 52 | NSData *contentData = [[NSFileManager defaultManager] contentsAtPath:[[NSBundle mainBundle] pathForResource:@"articleContent" ofType:@"txt"]]; 53 | id obj = [NSJSONSerialization JSONObjectWithData:contentData options:kNilOptions error:nil]; 54 | if (obj && [obj isKindOfClass:[NSDictionary class]]) { 55 | responseDic = [(NSDictionary *)obj objectForKey:@"articleAd"]; 56 | } 57 | 58 | self.title = [responseDic objectForKey:@"title"]; 59 | self.desc = [responseDic objectForKey:@"subTitle"]; 60 | 61 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ 62 | if (completionBlock) { 63 | completionBlock(); 64 | } 65 | }); 66 | } 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/AD/AdView.h: -------------------------------------------------------------------------------- 1 | // 2 | // AdView.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import "AdModel.h" 26 | 27 | @interface AdView : UIView 28 | 29 | - (void)layoutWithData:(AdModel *)adModel; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/AD/AdView.m: -------------------------------------------------------------------------------- 1 | // 2 | // AdView.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import "AdView.h" 26 | 27 | @interface AdView () 28 | @property(nonatomic,strong,readwrite)UIImageView * adIcon; 29 | @property(nonatomic,strong,readwrite)UILabel * adName; 30 | @property(nonatomic,strong,readwrite)UILabel * adDes; 31 | @property (nonatomic, strong, readwrite) CALayer *topLine; 32 | @end 33 | 34 | @implementation AdView 35 | 36 | IMP_HPKViewProtocol() 37 | 38 | -(instancetype)initWithFrame:(CGRect)frame{ 39 | self = [super initWithFrame:frame]; 40 | if (self) { 41 | self.backgroundColor = [UIColor whiteColor]; 42 | self.clipsToBounds = YES; 43 | 44 | [self.layer addSublayer:({ 45 | _topLine = [[CALayer alloc]init]; 46 | _topLine.backgroundColor = [UIColor colorWithRed:234.f / 255.f green:234.f / 255.f blue:234.f / 255.f alpha:1.f].CGColor; 47 | _topLine; 48 | })]; 49 | 50 | [self addSubview:({ 51 | _adIcon = [[UIImageView alloc]initWithFrame:CGRectMake(8, 20, 60, 60)]; 52 | _adIcon.layer.masksToBounds = YES; 53 | _adIcon.layer.cornerRadius = 30.f; 54 | _adIcon; 55 | })]; 56 | [self addSubview:({ 57 | _adName = [[UILabel alloc]init]; 58 | _adName.textColor = [UIColor blackColor]; 59 | _adName.font = [UIFont systemFontOfSize:18.f]; 60 | _adName; 61 | })]; 62 | 63 | [self addSubview:({ 64 | _adDes = [[UILabel alloc]init]; 65 | _adDes.textColor = [UIColor grayColor]; 66 | _adDes.font = [UIFont systemFontOfSize:14.f]; 67 | _adDes; 68 | })]; 69 | } 70 | return self; 71 | } 72 | 73 | -(void)layoutWithData:(AdModel *)adModel{ 74 | 75 | _topLine.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 5); 76 | 77 | [_adIcon setImage:[UIImage imageNamed:@"icon.png"]]; 78 | 79 | [_adName setText:adModel.title]; 80 | [_adName sizeToFit]; 81 | _adName.frame = CGRectMake( _adIcon.frame.origin.x + _adIcon.frame.size.width + 10, _adIcon.frame.origin.y +7, _adName.frame.size.width, _adName.frame.size.height); 82 | 83 | [_adDes setText:adModel.desc]; 84 | [_adDes sizeToFit]; 85 | _adDes.frame = CGRectMake(_adName.frame.origin.x, _adName.frame.origin.y + _adName.frame.size.height + 10, _adDes.frame.size.width, _adDes.frame.size.height); 86 | 87 | self.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, CGRectGetMaxY(_adDes.frame) + 20); 88 | } 89 | 90 | @end 91 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/ArticleFeatureDef.h: -------------------------------------------------------------------------------- 1 | // 2 | // ArticleFeatureDef.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import "TitleView.h" 26 | #import "TitleModel.h" 27 | #import "TitleController.h" 28 | 29 | #import "BlockNewsView.h" 30 | #import "BlockNewsModel.h" 31 | #import "BlockNewsController.h" 32 | 33 | #import "RelateNewsView.h" 34 | #import "RelateNewsModel.h" 35 | #import "RelateNewsController.h" 36 | 37 | #import "HotCommentView.h" 38 | #import "HotCommentModel.h" 39 | #import "HotCommentController.h" 40 | 41 | #import "MediaView.h" 42 | #import "MediaModel.h" 43 | #import "MediaController.h" 44 | 45 | #import "AdView.h" 46 | #import "AdModel.h" 47 | #import "AdController.h" 48 | 49 | #import "VideoView.h" 50 | #import "VideoModel.h" 51 | #import "VideoController.h" 52 | 53 | #import "GifView.h" 54 | #import "GifModel.h" 55 | #import "GifController.h" 56 | 57 | #import "ImageView.h" 58 | #import "ImageModel.h" 59 | #import "ImageController.h" 60 | 61 | typedef NS_ENUM(NSInteger, HPKDemoComponentIndex){ 62 | kHPKDemoComponentIndexTitle, 63 | kHPKDemoComponentIndexWebView, 64 | kHPKDemoComponentIndexBlockNews, 65 | kHPKDemoComponentIndexAd, 66 | kHPKDemoComponentIndexRelate, 67 | kHPKDemoComponentIndexMedia, 68 | kHPKDemoComponentIndexComment, 69 | }; 70 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/BlockNews/BlockNewsController.h: -------------------------------------------------------------------------------- 1 | // 2 | // BlockNewsController.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "ComponentBaseController.h" 27 | 28 | @interface BlockNewsController : ComponentBaseController 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/BlockNews/BlockNewsController.m: -------------------------------------------------------------------------------- 1 | // 2 | // BlockNewsController.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "BlockNewsController.h" 27 | 28 | @implementation BlockNewsController 29 | 30 | - (nullable NSArray *)supportComponentModelClass { 31 | return @[[BlockNewsModel class]]; 32 | } 33 | 34 | - (nullable Class)reusableComponentViewClassWithModel:(HPKModel *)componentModel { 35 | return [BlockNewsView class]; 36 | } 37 | 38 | - (void)didReceiveArticleContent:(ArticleModel *)articleModel{ 39 | BlockNewsModel *blockModel = [[BlockNewsModel alloc] init]; 40 | [blockModel setComponentFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 350.f)]; 41 | NSMutableArray *models = articleModel.extensionComponents.mutableCopy ; 42 | [models addObject:blockModel]; 43 | articleModel.extensionComponents = models.copy; 44 | } 45 | 46 | - (void)scrollViewWillPrepareComponentView:(HPKView *)componentView 47 | componentModel:(HPKModel *)componentModel { 48 | [((BlockNewsView *)componentView) layoutWithTitle:@"component container"]; 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/BlockNews/BlockNewsModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // BlockNewsModel.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import 27 | 28 | @interface BlockNewsModel : NSObject 29 | 30 | @end 31 | 32 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/BlockNews/BlockNewsModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // BlockNewsModel.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "BlockNewsModel.h" 27 | 28 | @implementation BlockNewsModel 29 | 30 | IMP_HPKModelProtocol(@(kHPKDemoComponentIndexBlockNews).stringValue); 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/BlockNews/BlockNewsView.h: -------------------------------------------------------------------------------- 1 | // 2 | // BlockNewsView.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | @interface BlockNewsView : UIView 27 | 28 | - (void)layoutWithTitle:(NSString *)title; 29 | 30 | @end 31 | 32 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/BlockNews/BlockNewsView.m: -------------------------------------------------------------------------------- 1 | // 2 | // BlockNewsView.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "BlockNewsView.h" 27 | 28 | @interface BlockNewsView () 29 | @property (nonatomic, strong, readwrite) UILabel *titleLabel; 30 | @property (nonatomic, strong, readwrite) CALayer *topLine; 31 | 32 | @end 33 | 34 | @implementation BlockNewsView 35 | 36 | IMP_HPKViewProtocol() 37 | 38 | - (instancetype)initWithFrame:(CGRect)frame { 39 | self = [super initWithFrame:frame]; 40 | if (self) { 41 | self.backgroundColor = [UIColor whiteColor]; 42 | 43 | [self.layer addSublayer:({ 44 | _topLine = [[CALayer alloc]init]; 45 | _topLine.backgroundColor = [UIColor colorWithRed:234.f / 255.f green:234.f / 255.f blue:234.f / 255.f alpha:1.f].CGColor; 46 | _topLine.frame = CGRectMake(0, 0, frame.size.width, 5); 47 | _topLine; 48 | })]; 49 | 50 | [self addSubview:({ 51 | _titleLabel = [[UILabel alloc]init]; 52 | _titleLabel.textColor = [UIColor blackColor]; 53 | _titleLabel.font = [UIFont systemFontOfSize:20.f]; 54 | _titleLabel; 55 | })]; 56 | } 57 | return self; 58 | } 59 | 60 | - (void)layoutWithTitle:(NSString *)title { 61 | [_titleLabel setText:title]; 62 | [_titleLabel sizeToFit]; 63 | _titleLabel.center = CGPointMake(self.frame.size.width / 2, self.frame.size.height / 2); 64 | _topLine.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 5); 65 | } 66 | 67 | #pragma mark - 68 | 69 | - (CGFloat)componentHeight{ 70 | return self.frame.size.height; 71 | } 72 | 73 | @end 74 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Comment/HotCommentController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HotCommentController.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import "ComponentBaseController.h" 26 | @interface HotCommentController : ComponentBaseController 27 | @end 28 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Comment/HotCommentModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // HotCommentModel.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | typedef void (^HotCommentModelLoadCompletionBlock)(void); 27 | 28 | @interface HotCommentModel : NSObject 29 | 30 | @property (nonatomic, copy, readonly) NSArray *hotCommentArray; 31 | @property (nonatomic, assign, readonly) BOOL hasMore; 32 | 33 | - (instancetype)initWithDic:(NSDictionary *)dic; 34 | 35 | - (void)loadMoreHotCommentsWithCompletionBlock:(HotCommentModelLoadCompletionBlock)completionBlock; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Comment/HotCommentModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // HotCommentModel.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "HotCommentModel.h" 27 | #import "HotCommentView.h" 28 | #import "HotCommentController.h" 29 | 30 | @interface HotCommentModel () 31 | @property (nonatomic, copy, readwrite) NSArray *hotCommentArray; 32 | @property (nonatomic, copy, readwrite) HotCommentModelLoadCompletionBlock completionBlock; 33 | @property (nonatomic, assign, readwrite) BOOL hasMore; 34 | 35 | @end 36 | @implementation HotCommentModel 37 | 38 | IMP_HPKModelProtocol(@(kHPKDemoComponentIndexComment).stringValue); 39 | 40 | - (instancetype)initWithDic:(NSDictionary *)dic { 41 | self = [super init]; 42 | if (self) { 43 | _hasMore = YES; 44 | [self setHotComments:[dic objectForKey:@"commentArray"]]; 45 | } 46 | return self; 47 | } 48 | 49 | - (void)dealloc { 50 | _completionBlock = nil; 51 | } 52 | 53 | - (void)loadMoreHotCommentsWithCompletionBlock:(HotCommentModelLoadCompletionBlock)completionBlock { 54 | if (!completionBlock) { 55 | return; 56 | } 57 | 58 | _completionBlock = [completionBlock copy]; 59 | 60 | NSDictionary *responseDic = nil; 61 | NSData *contentData = [[NSFileManager defaultManager] contentsAtPath:[[NSBundle mainBundle] pathForResource:@"articleContent" ofType:@"txt"]]; 62 | id obj = [NSJSONSerialization JSONObjectWithData:contentData options:kNilOptions error:nil]; 63 | if (obj && [obj isKindOfClass:[NSDictionary class]]) { 64 | responseDic = (NSDictionary *)obj; 65 | } 66 | 67 | self.hotCommentArray = [self.hotCommentArray arrayByAddingObjectsFromArray:[[responseDic objectForKey:@"articleHotComment"] objectForKey:@"commentArray"]]; 68 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ 69 | if (completionBlock) { 70 | completionBlock(); 71 | } 72 | }); 73 | } 74 | 75 | #pragma mark - 76 | 77 | - (void)setHotComments:(NSArray *)hotComments { 78 | _hotCommentArray = hotComments; 79 | } 80 | 81 | @end 82 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Comment/HotCommentView.h: -------------------------------------------------------------------------------- 1 | // 2 | // HotCommentView.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import "HotCommentModel.h" 26 | 27 | @interface HotCommentView : UITableView 28 | 29 | - (void)layoutWithData:(HotCommentModel *)hotCommentModel; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Comment/HotCommentView.m: -------------------------------------------------------------------------------- 1 | // 2 | // HotCommentView.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import "HotCommentView.h" 26 | 27 | @interface HotCommentView () 28 | @property (nonatomic, copy, readwrite) NSArray *hotCommentData; 29 | @end 30 | 31 | @implementation HotCommentView 32 | 33 | IMP_HPKViewProtocol() 34 | 35 | - (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style{ 36 | self = [super initWithFrame:frame style:style]; 37 | if (self) { 38 | self.scrollEnabled = NO; 39 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 40 | if (@available(iOS 11.0, *)) { 41 | self.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; 42 | } 43 | #endif 44 | self.estimatedRowHeight = 0; 45 | self.estimatedSectionHeaderHeight = 0; 46 | self.estimatedSectionFooterHeight = 0; 47 | } 48 | return self; 49 | } 50 | 51 | - (void)layoutWithData:(HotCommentModel *)hotCommentModel { 52 | if (hotCommentModel == nil || hotCommentModel.hotCommentArray == nil) { 53 | return; 54 | } 55 | _hotCommentData = [hotCommentModel.hotCommentArray copy]; 56 | [self reloadData]; 57 | } 58 | 59 | - (CGFloat)componentHeight{ 60 | return self.contentSize.height; 61 | } 62 | 63 | - (nullable UIScrollView *)componentInnerScrollView { 64 | return self; 65 | } 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/ComponentBaseController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ComponentBaseController.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import 27 | #import "ArticleModel.h" 28 | 29 | @protocol ComponentControllerProtocol 30 | @optional 31 | - (void)didReceiveArticleContent:(ArticleModel *)articleModel; 32 | - (void)containerScrollViewDidScroll:(UIScrollView *)containerScrollView; 33 | @end 34 | 35 | @interface ComponentBaseController : NSObject 36 | 37 | - (HPKPageHandler *)pageHandler; 38 | 39 | - (instancetype)initWithController:(UIViewController *)controller; 40 | 41 | @end 42 | 43 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/ComponentBaseController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ComponentBaseController.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "ComponentBaseController.h" 27 | #import "WebComponentController.h" 28 | #import "NativeComponentController.h" 29 | #import "NestingWebViewController.h" 30 | #import "NestingBannerController.h" 31 | 32 | @interface ComponentBaseController () 33 | 34 | @property (nonatomic, weak, readwrite) UIViewController *viewController; 35 | 36 | @end 37 | 38 | @implementation ComponentBaseController 39 | 40 | - (instancetype)initWithController:(UIViewController *)controller { 41 | self = [super init]; 42 | if (self) { 43 | _viewController = controller; 44 | } 45 | return self; 46 | } 47 | 48 | - (HPKPageHandler *)pageHandler { 49 | if ([_viewController isKindOfClass:[WebComponentController class]]) { 50 | return ((WebComponentController *)_viewController).webComponentHandler; 51 | } else if ([_viewController isKindOfClass:[NativeComponentController class]]) { 52 | return ((NativeComponentController *)_viewController).componentHandler; 53 | } else if ([_viewController isKindOfClass:[NestingWebViewController class]]) { 54 | return ((NestingWebViewController *)_viewController).componentHandler; 55 | } else if ([_viewController isKindOfClass:[NestingBannerController class]]) { 56 | return ((NestingBannerController *)_viewController).componentHandler; 57 | } 58 | return nil; 59 | } 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Gif/GifController.h: -------------------------------------------------------------------------------- 1 | // 2 | // GifController.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import "ComponentBaseController.h" 26 | @interface GifController : ComponentBaseController 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Gif/GifController.m: -------------------------------------------------------------------------------- 1 | // 2 | // GifController.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import "GifController.h" 26 | #import "GifView.h" 27 | #import "GifModel.h" 28 | 29 | @implementation GifController 30 | 31 | - (nullable NSArray *)supportComponentModelClass { 32 | return @[[GifModel class]]; 33 | } 34 | 35 | - (nullable Class)reusableComponentViewClassWithModel:(HPKModel *)componentModel { 36 | return [GifView class]; 37 | } 38 | 39 | - (void)scrollViewWillDisplayComponentView:(HPKView *)componentView 40 | componentModel:(HPKModel *)componentModel { 41 | [((GifView *)componentView) startPlay]; 42 | } 43 | 44 | - (void)scrollViewEndDisplayComponentView:(HPKView *)componentView 45 | componentModel:(HPKModel *)componentModel { 46 | [((GifView *)componentView) stopPlay]; 47 | } 48 | 49 | - (void)scrollViewWillPrepareComponentView:(HPKView *)componentView 50 | componentModel:(HPKModel *)componentModel { 51 | [((GifView *)componentView) layoutWithData:(GifModel *)componentModel]; 52 | } 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Gif/GifModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // GifModel.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | @interface GifModel : NSObject 27 | 28 | @property (nonatomic, copy, readonly) NSString *imageUrl; 29 | @property (nonatomic, copy, readonly) NSString *desc; 30 | 31 | - (instancetype)initWithValueDic:(NSDictionary *)valueDic; 32 | @end 33 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Gif/GifModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // GifModel.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "GifModel.h" 27 | #import "GifView.h" 28 | #import "GifController.h" 29 | 30 | @interface GifModel () 31 | @property (nonatomic, copy, readwrite) NSString *index; 32 | @property (nonatomic, copy, readwrite) NSString *imageUrl; 33 | @property (nonatomic, copy, readwrite) NSString *desc; 34 | @end 35 | 36 | @implementation GifModel 37 | 38 | IMP_HPKModelProtocol(@""); 39 | 40 | - (instancetype)initWithValueDic:(NSDictionary *)valueDic { 41 | self = [super init]; 42 | if (self) { 43 | _imageUrl = [valueDic objectForKey:@"url"]; 44 | _desc = [valueDic objectForKey:@"desc"]; 45 | } 46 | return self; 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Gif/GifView.h: -------------------------------------------------------------------------------- 1 | // 2 | // GifView.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import "GifModel.h" 26 | 27 | @interface GifView : UIImageView 28 | 29 | -(void)layoutWithData:(GifModel *)gifModel; 30 | -(void)startPlay; 31 | -(void)stopPlay; 32 | @end 33 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Gif/GifView.m: -------------------------------------------------------------------------------- 1 | // 2 | // GifView.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "GifView.h" 27 | 28 | @implementation GifView 29 | 30 | IMP_HPKViewProtocol() 31 | 32 | - (instancetype)initWithFrame:(CGRect)frame { 33 | self = [super initWithFrame:frame]; 34 | if (self) { 35 | self.backgroundColor = [UIColor colorWithRed:234.f / 255.f green:234.f / 255.f blue:234.f / 255.f alpha:1.f]; 36 | self.contentMode = UIViewContentModeScaleToFill; 37 | } 38 | return self; 39 | } 40 | 41 | - (void)layoutWithData:(GifModel *)gifModel { 42 | self.animationImages = @[[UIImage imageNamed:@"gif1.jpeg"], [UIImage imageNamed:@"gif2.jpeg"]]; 43 | self.animationDuration = 0.5; 44 | } 45 | 46 | - (void)startPlay { 47 | [self startAnimating]; 48 | } 49 | 50 | - (void)stopPlay { 51 | [self stopAnimating]; 52 | } 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Image/ImageController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ImageController.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import "ComponentBaseController.h" 26 | @interface ImageController : ComponentBaseController 27 | @end 28 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Image/ImageController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ImageController.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import "ImageController.h" 26 | #import "ImageView.h" 27 | #import "ImageModel.h" 28 | 29 | @implementation ImageController 30 | 31 | - (nullable NSArray *)supportComponentModelClass { 32 | return @[[ImageModel class]]; 33 | } 34 | 35 | - (nullable Class)reusableComponentViewClassWithModel:(HPKModel *)componentModel { 36 | return [ImageView class]; 37 | } 38 | 39 | - (void)scrollViewWillPrepareComponentView:(HPKView *)componentView 40 | componentModel:(HPKModel *)componentModel { 41 | [((ImageView *)componentView) layoutWithData:(ImageModel *)componentModel]; 42 | } 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Image/ImageModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // ImageModel.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | @interface ImageModel : NSObject 27 | 28 | @property (nonatomic, copy, readonly) NSString *imageUrl; 29 | @property (nonatomic, copy, readonly) NSString *desc; 30 | 31 | - (instancetype)initWithValueDic:(NSDictionary *)valueDic; 32 | @end 33 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Image/ImageModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // ImageModel.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "ImageModel.h" 27 | #import "ImageView.h" 28 | #import "ImageController.h" 29 | 30 | @interface ImageModel () 31 | @property (nonatomic, copy, readwrite) NSString *imageUrl; 32 | @property (nonatomic, copy, readwrite) NSString *desc; 33 | @end 34 | 35 | @implementation ImageModel 36 | 37 | IMP_HPKModelProtocol(@"") 38 | 39 | - (instancetype)initWithValueDic:(NSDictionary *)valueDic; { 40 | self = [super init]; 41 | if (self) { 42 | _imageUrl = [valueDic objectForKey:@"url"]; 43 | _desc = [valueDic objectForKey:@"desc"]; 44 | } 45 | return self; 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Image/ImageView.h: -------------------------------------------------------------------------------- 1 | // 2 | // ImageView.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | @class ImageModel; 26 | 27 | @interface ImageView : UIImageView 28 | 29 | - (void)layoutWithData:(ImageModel *)imageModel; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Image/ImageView.m: -------------------------------------------------------------------------------- 1 | // 2 | // ImageView.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "ImageView.h" 27 | #import "ImageModel.h" 28 | 29 | @implementation ImageView 30 | 31 | IMP_HPKViewProtocol() 32 | 33 | - (instancetype)initWithFrame:(CGRect)frame { 34 | self = [super initWithFrame:frame]; 35 | if (self) { 36 | self.backgroundColor = [UIColor colorWithRed:234.f / 255.f green:234.f / 255.f blue:234.f / 255.f alpha:1.f]; 37 | self.contentMode = UIViewContentModeScaleToFill; 38 | } 39 | return self; 40 | } 41 | 42 | - (void)layoutWithData:(ImageModel *)imageModel { 43 | [self setImage:[UIImage imageNamed:@"gif1.jpeg"]]; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/MediaInfo/MediaController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MediaController.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import "ComponentBaseController.h" 26 | @interface MediaController : ComponentBaseController 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/MediaInfo/MediaController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MediaController.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import "MediaController.h" 26 | #import "MediaModel.h" 27 | #import "MediaView.h" 28 | 29 | @interface MediaController () 30 | @property(nonatomic, strong, readwrite)MediaView *mediaView; 31 | @end 32 | 33 | @implementation MediaController 34 | 35 | - (nullable NSArray *)supportComponentModelClass { 36 | return @[[MediaModel class]]; 37 | } 38 | 39 | - (nullable HPKView *)unReusableComponentViewWithModel:(HPKModel *)componentModel{ 40 | if (!_mediaView) { 41 | _mediaView = [[MediaView alloc]initWithFrame:CGRectZero]; 42 | } 43 | return _mediaView; 44 | } 45 | 46 | - (void)scrollViewWillPrepareComponentView:(HPKView *)componentView 47 | componentModel:(HPKModel *)componentModel{ 48 | [_mediaView layoutWithData:(MediaModel *)componentModel]; 49 | [self.pageHandler relayoutWithComponentChange]; 50 | } 51 | @end 52 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/MediaInfo/MediaModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // MediaModel.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | @interface MediaModel : NSObject 27 | @property (nonatomic, copy, readonly) NSString *mediaId; 28 | @property (nonatomic, copy, readonly) NSString *mediaIcon; 29 | @property (nonatomic, copy, readonly) NSString *mediaName; 30 | @property (nonatomic, copy, readonly) NSString *mediaDes; 31 | 32 | - (instancetype)initWithDic:(NSDictionary *)dic; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/MediaInfo/MediaModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // MediaModel.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "MediaModel.h" 27 | #import "MediaView.h" 28 | #import "MediaController.h" 29 | 30 | @interface MediaModel () 31 | @property (nonatomic, copy, readwrite) NSString *mediaId; 32 | @property (nonatomic, copy, readwrite) NSString *mediaIcon; 33 | @property (nonatomic, copy, readwrite) NSString *mediaName; 34 | @property (nonatomic, copy, readwrite) NSString *mediaDes; 35 | @end 36 | @implementation MediaModel 37 | 38 | IMP_HPKModelProtocol(@(kHPKDemoComponentIndexMedia).stringValue); 39 | 40 | - (instancetype)initWithDic:(NSDictionary *)dic { 41 | self = [super init]; 42 | if (self) { 43 | _mediaId = [dic objectForKey:@"mediaId"]; 44 | _mediaIcon = [dic objectForKey:@"mediaIcon"]; 45 | _mediaName = [dic objectForKey:@"mediaName"]; 46 | _mediaDes = [dic objectForKey:@"mediaDescribe"]; 47 | } 48 | return self; 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/MediaInfo/MediaView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MediaView.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "MediaModel.h" 27 | 28 | @interface MediaView : UIView 29 | 30 | - (void)layoutWithData:(MediaModel *)mediaModel; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/MediaInfo/MediaView.m: -------------------------------------------------------------------------------- 1 | // 2 | // MediaView.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "MediaView.h" 27 | @interface MediaView () 28 | @property (nonatomic, strong, readwrite) CALayer *topLine; 29 | @property (nonatomic, strong, readwrite) UIImageView *mediaIcon; 30 | @property (nonatomic, strong, readwrite) UILabel *mediaName; 31 | @property (nonatomic, strong, readwrite) UILabel *mediaDes; 32 | @end 33 | @implementation MediaView 34 | 35 | IMP_HPKViewProtocol() 36 | 37 | - (instancetype)initWithFrame:(CGRect)frame { 38 | self = [super initWithFrame:frame]; 39 | if (self) { 40 | self.backgroundColor = [UIColor whiteColor]; 41 | [self.layer addSublayer:({ 42 | _topLine = [[CALayer alloc]init]; 43 | _topLine.backgroundColor = [UIColor colorWithRed:234.f / 255.f green:234.f / 255.f blue:234.f / 255.f alpha:1.f].CGColor; 44 | _topLine.frame = CGRectMake(0, 0, frame.size.width, 5); 45 | _topLine; 46 | })]; 47 | [self.layer addSublayer:({ 48 | _topLine = [[CALayer alloc]init]; 49 | _topLine.backgroundColor = [UIColor colorWithRed:234.f / 255.f green:234.f / 255.f blue:234.f / 255.f alpha:1.f].CGColor; 50 | _topLine.frame = CGRectMake(0, 0, frame.size.width, 5); 51 | _topLine; 52 | })]; 53 | [self addSubview:({ 54 | _mediaIcon = [[UIImageView alloc]initWithFrame:CGRectMake(8, 20, 60, 60)]; 55 | _mediaIcon.layer.masksToBounds = YES; 56 | _mediaIcon.layer.cornerRadius = 30.f; 57 | _mediaIcon; 58 | })]; 59 | [self addSubview:({ 60 | _mediaName = [[UILabel alloc]init]; 61 | _mediaName.textColor = [UIColor blackColor]; 62 | _mediaName.font = [UIFont systemFontOfSize:18.f]; 63 | _mediaName; 64 | })]; 65 | 66 | [self addSubview:({ 67 | _mediaDes = [[UILabel alloc]init]; 68 | _mediaDes.textColor = [UIColor grayColor]; 69 | _mediaDes.font = [UIFont systemFontOfSize:14.f]; 70 | _mediaDes; 71 | })]; 72 | } 73 | return self; 74 | } 75 | 76 | - (void)layoutWithData:(MediaModel *)mediaModel { 77 | _topLine.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 5); 78 | 79 | [_mediaIcon setImage:[UIImage imageNamed:@"icon.png"]]; 80 | 81 | [_mediaName setText:mediaModel.mediaName]; 82 | [_mediaName sizeToFit]; 83 | _mediaName.frame = CGRectMake(_mediaIcon.frame.origin.x + _mediaIcon.frame.size.width + 10, _mediaIcon.frame.origin.y + 7, _mediaName.frame.size.width, _mediaName.frame.size.height); 84 | 85 | [_mediaDes setText:mediaModel.mediaDes]; 86 | [_mediaDes sizeToFit]; 87 | _mediaDes.frame = CGRectMake(_mediaName.frame.origin.x, _mediaName.frame.origin.y + _mediaName.frame.size.height + 10, _mediaDes.frame.size.width, _mediaDes.frame.size.height); 88 | 89 | self.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, CGRectGetMaxY(_mediaDes.frame) + 20); 90 | } 91 | 92 | - (CGFloat)componentHeight{ 93 | return self.frame.size.height; 94 | } 95 | 96 | @end 97 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/RelateNews/RelateNewsController.h: -------------------------------------------------------------------------------- 1 | // 2 | // RelateNewsController.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import "ComponentBaseController.h" 26 | @interface RelateNewsController : ComponentBaseController 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/RelateNews/RelateNewsController.m: -------------------------------------------------------------------------------- 1 | // 2 | // RelateNewsController.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import "RelateNewsController.h" 26 | #import "RelateNewsModel.h" 27 | #import "RelateNewsView.h" 28 | 29 | @interface RelateNewsController () 30 | 31 | @property (nonatomic, strong, readwrite) RelateNewsView *relateView; 32 | 33 | @end 34 | 35 | @implementation RelateNewsController 36 | 37 | - (nullable NSArray *)supportComponentModelClass { 38 | return @[[RelateNewsModel class]]; 39 | } 40 | 41 | - (nullable HPKView *)unReusableComponentViewWithModel:(HPKModel *)componentModel { 42 | if (!_relateView) { 43 | _relateView = [[RelateNewsView alloc]initWithFrame:CGRectZero]; 44 | } 45 | return _relateView; 46 | } 47 | 48 | - (void)scrollViewWillPrepareComponentView:(__kindof UIView *)componentView 49 | componentModel:(HPKModel *)componentModel { 50 | [_relateView layoutWithData:(RelateNewsModel *)componentModel]; 51 | [self.pageHandler relayoutWithComponentChange]; 52 | } 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/RelateNews/RelateNewsModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // RelateNewsModel.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | @interface RelateNewsModel : NSObject 26 | 27 | @property (nonatomic, copy, readonly) NSArray *relateNewsArray; 28 | 29 | - (instancetype)initWithDic:(NSDictionary *)dic; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/RelateNews/RelateNewsModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // RelateNewsModel.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "RelateNewsModel.h" 27 | #import "RelateNewsView.h" 28 | #import "RelateNewsController.h" 29 | 30 | @interface RelateNewsModel () 31 | @property (nonatomic, copy, readwrite) NSArray *relateNewsArray; 32 | @end 33 | @implementation RelateNewsModel 34 | 35 | IMP_HPKModelProtocol(@(kHPKDemoComponentIndexRelate).stringValue); 36 | 37 | - (instancetype)initWithDic:(NSDictionary *)dic { 38 | self = [super init]; 39 | if (self) { 40 | _relateNewsArray = [dic objectForKey:@"newsArray"]; 41 | } 42 | return self; 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/RelateNews/RelateNewsView.h: -------------------------------------------------------------------------------- 1 | // 2 | // RelateNewsView.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "RelateNewsModel.h" 27 | 28 | @interface RelateNewsView : UIView 29 | -(void)layoutWithData:(RelateNewsModel *)relateNewsModel; 30 | @end 31 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Title/TitleController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TitleController.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import "ComponentBaseController.h" 26 | 27 | @interface TitleController : ComponentBaseController 28 | @end 29 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Title/TitleController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TitleController.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "TitleController.h" 27 | #import "TitleView.h" 28 | #import "TitleModel.h" 29 | 30 | @interface TitleController () 31 | @property(nonatomic, strong, readwrite)TitleView *titleView; 32 | @end 33 | 34 | @implementation TitleController 35 | 36 | - (nullable NSArray *)supportComponentModelClass { 37 | return @[[TitleModel class]]; 38 | } 39 | 40 | - (nullable HPKView *)unReusableComponentViewWithModel:(HPKModel *)componentModel{ 41 | if (!_titleView) { 42 | _titleView = [[TitleView alloc]initWithFrame:CGRectZero]; 43 | } 44 | return _titleView; 45 | } 46 | 47 | - (void)scrollViewWillPrepareComponentView:(HPKView *)componentView 48 | componentModel:(HPKModel *)componentModel { 49 | [_titleView layoutWithData:(TitleModel *)componentModel]; 50 | [self.pageHandler relayoutWithComponentChange]; 51 | } 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Title/TitleModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // TitleModel.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import 26 | 27 | @interface TitleModel : NSObject 28 | 29 | @property (nonatomic, copy, readonly) NSString *title; 30 | 31 | - (instancetype)initWithDic:(NSDictionary *)dic; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Title/TitleModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // TitleModel.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import "TitleModel.h" 26 | #import "TitleView.h" 27 | #import "TitleController.h" 28 | 29 | @interface TitleModel () 30 | @property (nonatomic, copy, readwrite) NSString *title; 31 | @property (nonatomic, copy, readwrite) NSString *index; 32 | @end 33 | @implementation TitleModel 34 | 35 | IMP_HPKModelProtocol(@(kHPKDemoComponentIndexTitle).stringValue) 36 | 37 | - (instancetype)initWithDic:(NSDictionary *)dic { 38 | self = [super init]; 39 | if (self) { 40 | _title = [dic objectForKey:@"title"]; 41 | _index = [dic objectForKey:@"index"]; 42 | } 43 | return self; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Title/TitleView.h: -------------------------------------------------------------------------------- 1 | // 2 | // TitleView.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import 26 | 27 | @class TitleModel; 28 | 29 | @interface TitleView : UIView 30 | 31 | - (void)layoutWithData:(TitleModel *)titleModel; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Title/TitleView.m: -------------------------------------------------------------------------------- 1 | // 2 | // TitleView.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "TitleView.h" 27 | 28 | @interface TitleView () 29 | @property (nonatomic, strong, readwrite) UILabel *titleLabel; 30 | @property (nonatomic, strong, readwrite) UILabel *timeLabel; 31 | @end 32 | 33 | @implementation TitleView 34 | 35 | IMP_HPKViewProtocol() 36 | 37 | - (instancetype)initWithFrame:(CGRect)frame { 38 | self = [super initWithFrame:frame]; 39 | if (self) { 40 | [self addSubview:({ 41 | _titleLabel = [[UILabel alloc]init]; 42 | _titleLabel.textColor = [UIColor blackColor]; 43 | _titleLabel.font = [UIFont systemFontOfSize:36.f]; 44 | _titleLabel.numberOfLines = 0; 45 | _titleLabel; 46 | })]; 47 | 48 | [self addSubview:({ 49 | _timeLabel = [[UILabel alloc]init]; 50 | _timeLabel.textColor = [UIColor grayColor]; 51 | _timeLabel.font = [UIFont systemFontOfSize:14.f]; 52 | _timeLabel; 53 | })]; 54 | } 55 | return self; 56 | } 57 | 58 | - (void)layoutWithData:(TitleModel *)titleModel { 59 | [_titleLabel setText:titleModel.title]; 60 | _titleLabel.frame = CGRectMake(8, 20, [UIScreen mainScreen].bounds.size.width - (8 << 1), _titleLabel.frame.size.height); 61 | [_titleLabel sizeToFit]; 62 | 63 | [_timeLabel setText:[NSString stringWithFormat:@"%@", [NSDate date]]]; 64 | [_timeLabel sizeToFit]; 65 | _timeLabel.frame = CGRectMake(8, _titleLabel.frame.size.height + 30, _timeLabel.frame.size.width, _timeLabel.frame.size.height); 66 | 67 | self.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, CGRectGetMaxY(_timeLabel.frame) + 10); 68 | } 69 | 70 | - (CGFloat)componentHeight { 71 | return self.frame.size.height; 72 | } 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Video/VideoController.h: -------------------------------------------------------------------------------- 1 | // 2 | // VideoController.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import "ComponentBaseController.h" 26 | @interface VideoController : ComponentBaseController 27 | @end 28 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Video/VideoController.m: -------------------------------------------------------------------------------- 1 | // 2 | // VideoController.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "VideoController.h" 27 | #import "VideoModel.h" 28 | #import "VideoView.h" 29 | 30 | @implementation VideoController 31 | 32 | - (nullable NSArray *)supportComponentModelClass { 33 | return @[[VideoModel class]]; 34 | } 35 | 36 | - (nullable Class)reusableComponentViewClassWithModel:(HPKModel *)componentModel { 37 | return [VideoView class]; 38 | } 39 | 40 | - (void)controllerViewDidAppear { 41 | // 进入当前页面 42 | // 视频相关可以从悬浮逻辑,重新attach到页面位置上 43 | } 44 | 45 | - (void)controllerViewDidDisappear { 46 | // 离开当前页面 47 | // 视频相关可以变成悬浮窗口悬浮 48 | } 49 | 50 | //component scroll 51 | - (void)scrollViewWillDisplayComponentView:(HPKView *)componentView 52 | componentModel:(HPKModel *)componentModel { 53 | [((VideoView *)componentView) layoutWithData:(VideoModel *)componentModel]; 54 | 55 | //播放逻辑 56 | } 57 | 58 | - (void)scrollViewEndDisplayComponentView:(HPKView *)componentView 59 | componentModel:(HPKModel *)componentModel { 60 | // 自动播放的可以停止播放,暂停 61 | // 也可以变成悬浮窗口悬浮 62 | } 63 | 64 | - (void)scrollViewWillPrepareComponentView:(HPKView *)componentView 65 | componentModel:(HPKModel *)componentModel { 66 | // 视频相关的预加载及预处理 67 | // 提高视频加载速度,减少loading时间 68 | } 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Video/VideoModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // VideoModel.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | @interface VideoModel : NSObject 27 | @property (nonatomic, copy, readonly) NSString *imageUrl; 28 | @property (nonatomic, copy, readonly) NSString *desc; 29 | 30 | - (instancetype)initWithValueDic:(NSDictionary *)valueDic; 31 | @end 32 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Video/VideoModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // VideoModel.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import "VideoModel.h" 26 | #import "VideoView.h" 27 | #import "VideoController.h" 28 | 29 | @interface VideoModel () 30 | @property (nonatomic, copy, readwrite) NSString *imageUrl; 31 | @property (nonatomic, copy, readwrite) NSString *desc; 32 | @end 33 | 34 | @implementation VideoModel 35 | 36 | IMP_HPKModelProtocol(@""); 37 | 38 | - (instancetype)initWithValueDic:(NSDictionary *)valueDic { 39 | self = [super init]; 40 | if (self) { 41 | _imageUrl = [valueDic objectForKey:@"url"]; 42 | _desc = [valueDic objectForKey:@"desc"]; 43 | } 44 | return self; 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Video/VideoView.h: -------------------------------------------------------------------------------- 1 | // 2 | // VideoView.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "VideoModel.h" 27 | 28 | @interface VideoView : UIImageView 29 | 30 | - (void)layoutWithData:(VideoModel *)videoModel; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Feature/Video/VideoView.m: -------------------------------------------------------------------------------- 1 | // 2 | // VideoView.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "VideoView.h" 27 | 28 | @interface VideoView() 29 | @property(nonatomic,strong,readwrite)UIImageView *playButton; 30 | @end 31 | 32 | @implementation VideoView 33 | 34 | IMP_HPKViewProtocol() 35 | 36 | -(instancetype)initWithFrame:(CGRect)frame{ 37 | self = [super initWithFrame:frame]; 38 | if (self) { 39 | self.contentMode = UIViewContentModeScaleToFill; 40 | self.backgroundColor = [UIColor colorWithRed:234.f / 255.f green:234.f / 255.f blue:234.f / 255.f alpha:1.f]; 41 | 42 | [self addSubview:({ 43 | UIImage *playButton = [UIImage imageNamed:@"play.png"]; 44 | _playButton = [[UIImageView alloc]initWithImage:playButton]; 45 | _playButton.frame = CGRectMake(0, 0, playButton.size.width/2, playButton.size.height/2); 46 | _playButton.center = CGPointMake(frame.size.width/2, frame.size.height/2); 47 | _playButton; 48 | })]; 49 | } 50 | return self; 51 | } 52 | 53 | -(void)setFrame:(CGRect)frame{ 54 | [super setFrame:frame]; 55 | _playButton.center = CGPointMake(self.frame.size.width/2, self.frame.size.height/2); 56 | } 57 | 58 | -(void)layoutWithData:(VideoModel *)videoModel{ 59 | [self setImage:[UIImage imageNamed:@"gif1.jpeg"]]; 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIRequiredDeviceCapabilities 24 | 25 | armv7 26 | 27 | UISupportedInterfaceOrientations 28 | 29 | UIInterfaceOrientationPortrait 30 | 31 | UISupportedInterfaceOrientations~ipad 32 | 33 | UIInterfaceOrientationPortrait 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/PrefixHeader.pch: -------------------------------------------------------------------------------- 1 | // 2 | // PrefixHeader.pch 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | 27 | #ifndef PrefixHeader_pch 28 | #define PrefixHeader_pch 29 | 30 | #import 31 | #import 32 | #import "ArticleFeatureDef.h" 33 | 34 | #import 35 | #import 36 | 37 | #endif /* PrefixHeader_pch */ 38 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit-Demo/HybridPageKit-Demo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // HybridPageKit-Demo 4 | // 5 | // Created by deqzhu on 2019/3/3. 6 | // Copyright © 2019 dequanzhu. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit/HybridPageKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit/HybridPageKit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit/HybridPageKit/HPKModelProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // HPKModelProtocol.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #ifndef HPKModelProtocol_h 27 | #define HPKModelProtocol_h 28 | 29 | #import 30 | #import 31 | #import 32 | 33 | typedef NS_ENUM (NSInteger, HPKState) { kHPKStateNone, kHPKStatePrepare, kHPKStateVisible }; 34 | 35 | NS_ASSUME_NONNULL_BEGIN 36 | 37 | #define HPKModel NSObject 38 | 39 | #define ISHPKModel(value) ([value conformsToProtocol:@protocol(HPKModelProtocol)]) 40 | 41 | #define IMP_HPKModelProtocol(INDEX) \ 42 | - (void)setComponentIndex: (NSString *)componentIndex { objc_setAssociatedObject(self, @selector(setComponentIndex:), componentIndex, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } \ 43 | - (NSString *)componentIndex { NSString *index = objc_getAssociatedObject(self, @selector(setComponentIndex:)); return index ? : INDEX; } \ 44 | - (CGRect)componentFrame { NSValue *rectValue = objc_getAssociatedObject(self, @selector(setComponentFrame:)); return [rectValue CGRectValue]; } \ 45 | - (void)setComponentFrame:(CGRect)frame { NSValue *rectValue = [NSValue valueWithCGRect:frame]; objc_setAssociatedObject(self, @selector(setComponentFrame:), rectValue, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } \ 46 | - (HPKState)componentNewState { NSNumber *newStateNum = objc_getAssociatedObject(self, @selector(setComponentNewState:)); HPKState newState = (HPKState)newStateNum.integerValue; return newState; } \ 47 | - (void)setComponentNewState:(HPKState)componentNewState { objc_setAssociatedObject(self, @selector(setComponentNewState:), @(componentNewState), OBJC_ASSOCIATION_RETAIN_NONATOMIC); } \ 48 | - (HPKState)componentOldState { NSNumber *oldStateNum = objc_getAssociatedObject(self, @selector(setComponentOldState:)); HPKState oldState = (HPKState)oldStateNum.integerValue; return oldState; } \ 49 | - (void)setComponentOldState:(HPKState)componentOldState { objc_setAssociatedObject(self, @selector(setComponentOldState:), @(componentOldState), OBJC_ASSOCIATION_RETAIN_NONATOMIC); } \ 50 | - (void)resetComponentState { [self setComponentNewState:kHPKStateNone]; [self setComponentOldState:kHPKStateNone]; } 51 | 52 | /** 53 | * 底层页Component组件Model protocol 54 | * ComponentModel需要实现 `IMP_HPKModelProtocol(INDEX)` INDEX为默认component index 55 | */ 56 | @protocol HPKModelProtocol 57 | 58 | @optional 59 | 60 | /** 61 | @return 返回component model的index 62 | */ 63 | - (NSString *)componentIndex; 64 | 65 | /** 66 | @param componentIndex 设置component model的index 67 | */ 68 | - (void)setComponentIndex:(NSString *)componentIndex; 69 | 70 | /** 71 | @return 返回component在container中的frame 72 | */ 73 | - (CGRect)componentFrame; 74 | 75 | /** 76 | @param frame 设置component在container中的frame 77 | */ 78 | - (void)setComponentFrame:(CGRect)frame; 79 | 80 | /** 81 | 清除在container中滚动复用的component状态 82 | */ 83 | - (void)resetComponentState; 84 | 85 | /** 86 | 以下使用 `IMP_HPKModelProtocol()` 替代 87 | */ 88 | @required 89 | - (HPKState)componentNewState; 90 | - (void)setComponentNewState:(HPKState)componentNewState; 91 | - (HPKState)componentOldState; 92 | - (void)setComponentOldState:(HPKState)componentOldState; 93 | @end 94 | 95 | NS_ASSUME_NONNULL_END 96 | 97 | #endif /* HPKModelProtocol_h */ 98 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit/HybridPageKit/HPKViewProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // HPKViewProtocol.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #ifndef HPKViewProtocol_h 27 | #define HPKViewProtocol_h 28 | 29 | #import 30 | #import 31 | #import 32 | 33 | NS_ASSUME_NONNULL_BEGIN 34 | 35 | #define HPKView UIView 36 | 37 | #define ISHPKView(value) ([value conformsToProtocol:@protocol(HPKViewProtocol)]) 38 | 39 | #define IMP_HPKViewProtocol() \ 40 | - (void)setComponentViewId: (NSString *)componentViewId { objc_setAssociatedObject(self, @selector(setComponentViewId:), componentViewId, OBJC_ASSOCIATION_COPY_NONATOMIC); } \ 41 | - (NSString *)componentViewId { return objc_getAssociatedObject(self, @selector(setComponentViewId:)); } 42 | 43 | /** 44 | * 底层页Component组件View的protocol 45 | * ComponentView需要实现 `IMP_HPKViewProtocol()` 46 | */ 47 | @protocol HPKViewProtocol 48 | 49 | @optional 50 | /** 51 | component在content container中占的高度 52 | 53 | @return view返回自定义高度或view的height,自身或者包含scrollView的返回contentSize 54 | */ 55 | - (CGFloat)componentHeight; 56 | 57 | /** 58 | @return component自身或者包含的scrollView 59 | */ 60 | - (nullable UIScrollView *)componentInnerScrollView; 61 | 62 | /** 63 | componentView 即将离开回收池,初始化layout展示 64 | */ 65 | - (void)componentViewWillLeavePool; 66 | 67 | /** 68 | componentView 即将进入回收池,清理布局状态等 69 | */ 70 | - (void)componentViewWillEnterPool; 71 | 72 | /** 73 | 以下使用 `IMP_HPKViewProtocol()` 替代 74 | */ 75 | @required 76 | - (void)setComponentViewId:(NSString *)detailComponentId; 77 | - (NSString *)componentViewId; 78 | @end 79 | 80 | NS_ASSUME_NONNULL_END 81 | 82 | #endif /* HPKViewProtocol_h */ 83 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit/HybridPageKit/HPKWebView.h: -------------------------------------------------------------------------------- 1 | // 2 | // HPKWebView.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import 26 | #import "HPKViewProtocol.h" 27 | 28 | @interface HPKWebView : WKWebView 29 | 30 | /** 31 | 标志当前webview禁止重用,直接销毁 32 | */ 33 | @property (nonatomic, assign, readwrite) BOOL invalidForReuse; 34 | 35 | /** 36 | webView 即将离开回收池,初始化设置 37 | */ 38 | - (void)componentViewWillLeavePool __attribute__((objc_requires_super)); 39 | 40 | /** 41 | webView 即将进入回收池,清除自定义属性状态等 42 | */ 43 | - (void)componentViewWillEnterPool __attribute__((objc_requires_super)); 44 | 45 | /** 46 | 清理webview的BackForwardList,防止重用时展示上次页面 47 | */ 48 | - (void)clearBackForwardList; 49 | 50 | @end 51 | 52 | //_______________________________________________________________________________________________________________ 53 | //_______________________________________________________________________________________________________________ 54 | 55 | typedef void (^HPKWebViewJSCompletionBlock)(NSObject *result); 56 | 57 | @interface HPKWebView (extension) 58 | 59 | /** 60 | 执行js,retain self 防止crash 61 | */ 62 | - (void)safeAsyncEvaluateJavaScriptString:(NSString *)script; 63 | 64 | /** 65 | 执行js,retain self 防止crash 66 | 明确result类型,null -> string, 返回NSObject类型 67 | */ 68 | - (void)safeAsyncEvaluateJavaScriptString:(NSString *)script completionBlock:(HPKWebViewJSCompletionBlock)block; 69 | 70 | /** 71 | 手动设置cookies 72 | */ 73 | - (void)setCookieWithName:(NSString *)name 74 | value:(NSString *)value 75 | domain:(NSString *)domain 76 | path:(NSString *)path 77 | expiresDate:(NSDate *)expiresDate 78 | completionBlock:(HPKWebViewJSCompletionBlock)completionBlock; 79 | 80 | /** 81 | 删除相应name的cookie 82 | */ 83 | - (void)deleteCookiesWithName:(NSString *)name completionBlock:(HPKWebViewJSCompletionBlock)completionBlock; 84 | 85 | /** 86 | 获取全部通过setCookieWithName注入的cookieName 87 | */ 88 | - (NSSet *)getAllCustomCookiesName; 89 | 90 | /** 91 | 删除所有通过setCookieWithName注入的cookie 92 | */ 93 | - (void)deleteAllCustomCookies; 94 | 95 | @end 96 | 97 | //_______________________________________________________________________________________________________________ 98 | //_______________________________________________________________________________________________________________ 99 | 100 | @interface HPKWebView (secondaryDelegate) 101 | 102 | /** 103 | 使用main & secondary delegate 104 | @param useDefaultUIDelegate 是否自动处理UIDelegate 105 | */ 106 | - (void)useExternalNavigationDelegateAndWithDefaultUIDelegate:(BOOL)useDefaultUIDelegate; 107 | 108 | /** 109 | 设置main navigation delegate,webView只有唯一一个 110 | */ 111 | - (void)setMainNavigationDelegate:(NSObject *)mainDelegate; 112 | 113 | /** 114 | 设置secondary navigation delegate,可以有任意多个 115 | */ 116 | - (void)addSecondaryNavigationDelegate:(NSObject *)delegate; 117 | 118 | /** 119 | 删除某个secondary navigation delegate 120 | */ 121 | - (void)removeSecondaryNavigationDelegate:(NSObject *)delegate; 122 | 123 | /** 124 | 删除全部secondary navigation delegate 125 | */ 126 | - (void)removeAllSecondaryNavigationDelegates; 127 | 128 | @end 129 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit/HybridPageKit/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | 22 | 23 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit/HybridPageKit/Source/HPKCommonViewPool.h: -------------------------------------------------------------------------------- 1 | // 2 | // HPKCommonViewPool.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "HPKViewProtocol.h" 27 | /** 28 | * 底层页Components复用回收池 29 | */ 30 | @interface HPKCommonViewPool : NSObject 31 | 32 | + (HPKCommonViewPool *)sharedInstance; 33 | 34 | /** 35 | 从回收池中根据class取View 36 | */ 37 | - (HPKView *)dequeueComponentViewWithClass:(Class)viewClass; 38 | 39 | /** 40 | 回收相应view 41 | */ 42 | - (void)enqueueComponentView:(HPKView *)componentView; 43 | 44 | /** 45 | 回收某个view上的全部components View 46 | */ 47 | - (void)enqueueAllComponentViewsOfSuperView:(__kindof UIView *)superView; 48 | 49 | /** 50 | 重置View状态 51 | */ 52 | - (void)resetVisibleComponentViewState:(HPKView *)componentView; 53 | 54 | /** 55 | 清理全部复用View 56 | */ 57 | - (void)clearAllReusableComponentViews; 58 | @end 59 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit/HybridPageKit/Source/HPKDefaultWebViewControl.h: -------------------------------------------------------------------------------- 1 | // 2 | // HPKDefaultWebViewControl.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "HPKWebView.h" 27 | #import "HPKControllerProtocol.h" 28 | 29 | @class HPKPageHandler; 30 | 31 | @interface HPKDefaultWebViewControl : NSObject 32 | /** 33 | 默认内置的webview 34 | */ 35 | @property (nonatomic, strong, readonly) __kindof HPKWebView *defaultWebView; 36 | 37 | /** 38 | 默认内置webview对应的model 39 | */ 40 | @property (nonatomic, strong, readonly) HPKModel *defaultWebViewModel; 41 | 42 | /** 43 | 生成默认的webview,webviewModel以及navigation delegate扩展 44 | 45 | @param detailHandler HPKPageHandler 46 | @param webViewClass webview的class,应该是HPKWebView的子类 47 | @param defaultWebViewIndex webview在container中的index 48 | */ 49 | - (instancetype)initWithDetailHandler:(HPKPageHandler *)detailHandler 50 | defaultWebViewClass:(Class)webViewClass 51 | defaultWebViewIndex:(NSInteger)defaultWebViewIndex; 52 | 53 | /** 54 | 重置defaultWebview,生成新的webview,并清理复用回收池 55 | */ 56 | - (void)resetWebView; 57 | 58 | /** 59 | webView contentSize变化回调 60 | */ 61 | - (void)webviewContentSizeChange:(__kindof HPKWebView *)webView 62 | newSize:(CGSize)newSize 63 | oldSize:(CGSize)oldSize; 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit/HybridPageKit/Source/HPKPageManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // HPKPageManager.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "HPKPageManager.h" 27 | #import "HPKWebViewPool.h" 28 | #import "WKWebView + HPKExtension.h" 29 | 30 | @implementation HPKPageManager 31 | 32 | + (HPKPageManager *)sharedInstance { 33 | static dispatch_once_t once; 34 | static HPKPageManager *singleton; 35 | dispatch_once(&once, 36 | ^{ 37 | singleton = [[HPKPageManager alloc] init]; 38 | }); 39 | return singleton; 40 | } 41 | 42 | - (instancetype)init { 43 | self = [super init]; 44 | if (self) { 45 | self.showWebViewWithAnimation = YES; 46 | self.componentsPrepareWorkRange = [UIScreen mainScreen].bounds.size.height / 2; 47 | self.componentsMaxReuseCount = 10; 48 | self.webViewShowMaxRetryTimes = 50; 49 | self.webViewMaxReuseTimes = NSIntegerMax; 50 | self.webViewReuseLoadUrlStr = @""; 51 | } 52 | return self; 53 | } 54 | 55 | #pragma mark - HPKReusableWebView 56 | 57 | - (__kindof HPKWebView *)dequeueWebViewWithClass:(Class)webViewClass webViewHolder:(NSObject *)webViewHolder { 58 | return [[HPKWebViewPool sharedInstance] dequeueWebViewWithClass:webViewClass webViewHolder:webViewHolder]; 59 | } 60 | 61 | - (void)enqueueWebView:(__kindof HPKWebView *)webView { 62 | [[HPKWebViewPool sharedInstance] enqueueWebView:webView]; 63 | } 64 | 65 | - (void)removeReusableWebView:(__kindof HPKWebView *)webView { 66 | [[HPKWebViewPool sharedInstance] removeReusableWebView:webView]; 67 | } 68 | 69 | - (void)clearAllReusableWebViews { 70 | [[HPKWebViewPool sharedInstance] clearAllReusableWebViews]; 71 | } 72 | 73 | - (void)clearAllReusableWebViewsWithClass:(Class)webViewClass { 74 | [[HPKWebViewPool sharedInstance] clearAllReusableWebViewsWithClass:webViewClass]; 75 | } 76 | 77 | - (void)reloadAllReusableWebViews { 78 | [[HPKWebViewPool sharedInstance] reloadAllReusableWebViews]; 79 | } 80 | 81 | #pragma mark - HPKWebView 82 | 83 | + (void)configCustomUAWithType:(HPKWebViewUAConfigType)type 84 | UAString:(NSString *)customString { 85 | [WKWebView configCustomUAWithType:((type == kHPKWebViewUAConfigTypeReplace) ? kConfigUATypeReplace : kConfigUATypeAppend) 86 | UAString:customString]; 87 | } 88 | 89 | + (void)safeClearAllCacheIncludeiOS8:(BOOL)includeiOS8 { 90 | [WKWebView safeClearAllCacheIncludeiOS8:includeiOS8]; 91 | } 92 | 93 | + (void)fixWKWebViewMenuItems { 94 | [WKWebView fixWKWebViewMenuItems]; 95 | } 96 | 97 | + (void)disableWebViewDoubleClick{ 98 | [WKWebView disableWebViewDoubleClick]; 99 | } 100 | 101 | @end 102 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit/HybridPageKit/Source/HPKScrollProcessor.h: -------------------------------------------------------------------------------- 1 | // 2 | // HPKScrollProcessor.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "HPKPageManager.h" 27 | #import "HPKViewProtocol.h" 28 | #import "HPKModelProtocol.h" 29 | #import "HPKControllerProtocol.h" 30 | 31 | typedef NSObject* (^HPKScrollProcessorDelegateBlock)(HPKModel *model , BOOL isGetViewEvent); 32 | 33 | typedef NS_ENUM (NSInteger, HPKLayoutType) { 34 | kHPKLayoutTypeAutoCalculateFrame, //根据ComponentIndex及相应的protocol自动计算 35 | kHPKLayoutTypeManualCalculateFrame, //根据ComponentModel中的Frame布局 36 | }; 37 | /** 38 | * 底层页components滚动管理 39 | */ 40 | @interface HPKScrollProcessor : NSObject 41 | 42 | #pragma mark - 43 | 44 | - (instancetype)initWithScrollView:(__kindof UIScrollView *)scrollView 45 | layoutType:(HPKLayoutType)layoutType 46 | scrollDelegateBlock:(HPKScrollProcessorDelegateBlock)scrollDelegateBlock; 47 | 48 | #pragma mark - layout 49 | 50 | - (void)relayoutWithComponentFrameChange; 51 | - (void)addComponentModelAndRelayout:(HPKModel *)componentModel; 52 | - (void)removeComponentModelAndRelayout:(HPKModel *)componentModel; 53 | - (void)layoutWithComponentModels:(NSArray *)componentModels; 54 | 55 | - (void)setCustomComponentModelsComparator:(NSComparator)customComparator; 56 | 57 | #pragma mark - scroll 58 | 59 | - (void)scrollToContentOffset:(CGPoint)toContentOffset animated:(BOOL)animated; 60 | - (void)scrollToComponentView:(HPKView *)componentView atOffset:(CGFloat)offsetY animated:(BOOL)animated; 61 | - (void)scrollToComponentModel:(HPKModel *)componentModel atOffset:(CGFloat)offsetY animated:(BOOL)animated; 62 | 63 | #pragma mark - get View or Model 64 | 65 | - (NSArray *)getAllComponentModels; 66 | - (NSArray *)getVisibleComponentModels; 67 | - (NSArray *)getVisibleComponentViews; 68 | 69 | //get model 70 | - (HPKModel *)getComponentModelByComponentView:(HPKView *)componentView; 71 | - (HPKModel *)getComponentModelByIndex:(NSString *)componentIndex; 72 | 73 | //get view 74 | - (HPKView *)getComponentViewByComponentModel:(HPKModel *)componentModel; 75 | - (HPKView *)getComponentViewByIndex:(NSString *)componentIndex; 76 | 77 | @end 78 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit/HybridPageKit/Source/HPKWebView.m: -------------------------------------------------------------------------------- 1 | // 2 | // HPKWebView.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "HPKWebView.h" 27 | #import "WKWebView + HPKExtension.h" 28 | #import "WKWebView + HPKReusable.h" 29 | #import "WKWebView + HPKDelegateExtension.h" 30 | #import "_HPKUtils.h" 31 | 32 | @implementation HPKWebView 33 | 34 | IMP_HPKViewProtocol() 35 | 36 | - (void)dealloc { 37 | [super setNavigationDelegate:nil]; 38 | [super setUIDelegate:nil]; 39 | self.scrollView.delegate = nil; 40 | [self stopLoading]; 41 | [self removeAllSecondaryNavigationDelegates]; 42 | [self setMainNavigationDelegate:nil]; 43 | } 44 | 45 | - (void)setInvalidForReuse:(BOOL)invalidForReuse { 46 | [super setInvalid:invalidForReuse]; 47 | } 48 | 49 | - (BOOL)invalidForReuse { 50 | return [super invalid]; 51 | } 52 | 53 | - (void)componentViewWillLeavePool { 54 | [super componentViewWillLeavePool]; 55 | } 56 | 57 | - (void)componentViewWillEnterPool { 58 | [super componentViewWillEnterPool]; 59 | [self setMainNavigationDelegate:nil]; 60 | [self removeAllSecondaryNavigationDelegates]; 61 | [self.scrollView safeRemoveAllObserver]; 62 | } 63 | 64 | - (void)clearBackForwardList { 65 | [super _clearBackForwardList]; 66 | } 67 | 68 | - (void)safeAsyncEvaluateJavaScriptString:(NSString *)script { 69 | [super _safeAsyncEvaluateJavaScriptString:script]; 70 | } 71 | 72 | - (void)safeAsyncEvaluateJavaScriptString:(NSString *)script completionBlock:(HPKWebViewJSCompletionBlock)block { 73 | [super _safeAsyncEvaluateJavaScriptString:script completionBlock:block]; 74 | } 75 | 76 | - (void)setCookieWithName:(NSString *)name 77 | value:(NSString *)value 78 | domain:(NSString *)domain 79 | path:(NSString *)path 80 | expiresDate:(NSDate *)expiresDate 81 | completionBlock:(HPKWebViewJSCompletionBlock)completionBlock { 82 | [super _setCookieWithName:name value:value domain:domain path:path expiresDate:expiresDate completionBlock:completionBlock]; 83 | } 84 | 85 | - (void)deleteCookiesWithName:(NSString *)name completionBlock:(HPKWebViewJSCompletionBlock)completionBlock { 86 | [super _deleteCookiesWithName:name completionBlock:completionBlock]; 87 | } 88 | 89 | - (NSSet *)getAllCustomCookiesName { 90 | return [super _getAllCustomCookiesName]; 91 | } 92 | 93 | - (void)deleteAllCustomCookies { 94 | [super _deleteAllCustomCookies]; 95 | } 96 | 97 | - (void)useExternalNavigationDelegateAndWithDefaultUIDelegate:(BOOL)useDefaultUIDelegate { 98 | [super _useExternalNavigationDelegateAndWithDefaultUIDelegate:useDefaultUIDelegate]; 99 | } 100 | 101 | - (void)setMainNavigationDelegate:(NSObject *)mainDelegate { 102 | [super _setMainNavigationDelegate:mainDelegate]; 103 | } 104 | 105 | - (void)addSecondaryNavigationDelegate:(NSObject *)delegate { 106 | [super _addSecondaryNavigationDelegate:delegate]; 107 | } 108 | 109 | - (void)removeSecondaryNavigationDelegate:(NSObject *)delegate { 110 | [super _removeSecondaryNavigationDelegate:delegate]; 111 | } 112 | 113 | - (void)removeAllSecondaryNavigationDelegates { 114 | [super _removeAllSecondaryNavigationDelegates]; 115 | } 116 | 117 | - (CGFloat)componentHeight { 118 | return self.scrollView.contentSize.height; 119 | } 120 | 121 | - (UIScrollView *)componentInnerScrollView { 122 | return self.scrollView; 123 | } 124 | 125 | @end 126 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit/HybridPageKit/Source/HPKWebViewExtensionDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // HPKWebViewExtensionDelegate.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import 27 | #import "HPKControllerProtocol.h" 28 | 29 | typedef void (^HPKWebViewMainNavDelegateScrollBlock)(CGPoint offset); 30 | typedef void (^HPKWebViewMainNavDelegateContentSizeChangeBlock)(NSValue *newValue, NSValue *oldValue); 31 | 32 | @interface HPKWebViewExtensionDelegate : NSObject 33 | 34 | /** 35 | 使用webview navigation delegate扩展,优化展示逻辑 36 | 37 | @param originalDelegate webview原navigation delegate,之后作为main delegate 38 | @param navigationDelegates 广播webview响应事件的接收对象 39 | */ 40 | - (instancetype)initWithOriginalDelegate:(NSObject *)originalDelegate 41 | navigationDelegates:(NSArray *> *)navigationDelegates; 42 | 43 | /** 44 | 设置对应的webview,承接webview的navigation delegate 45 | 46 | @param contentSizeChangeBlock 监听webview contentSize 变化时的回调 47 | */ 48 | - (void)configWebView:(__kindof WKWebView *)webView contentSizeChangeBlock:(HPKWebViewMainNavDelegateContentSizeChangeBlock)contentSizeChangeBlock; 49 | 50 | /** 51 | 优化展示上次阅读位置 52 | 53 | @param lastReadPositionY 上次阅读位置 offset Y 54 | @param scrollBlock 滚动到响应offset block,多scrollView嵌套时处理 55 | */ 56 | - (void)configWebViewLastReadPositionY:(CGFloat)lastReadPositionY 57 | scrollBlock:(HPKWebViewMainNavDelegateScrollBlock)scrollBlock; 58 | 59 | /** 60 | 广播webview布局web component 61 | */ 62 | - (void)triggerRelayoutWebComponentEvent; 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit/HybridPageKit/Source/HPKWebViewPool.h: -------------------------------------------------------------------------------- 1 | // 2 | // HPKWebViewPool.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "HPKWebView.h" 27 | 28 | /** 29 | * 底层页WebView复用回收池 30 | */ 31 | @interface HPKWebViewPool : NSObject 32 | 33 | + (HPKWebViewPool *)sharedInstance; 34 | 35 | /** 36 | 获取可复用的WKWebView 37 | 38 | @param webViewClass 可复用的WKWebView Class 39 | @param webViewHolder webView的持有者,用于自动回收WebView 40 | @return 可复用的WKWebView 41 | */ 42 | - (__kindof HPKWebView *)dequeueWebViewWithClass:(Class)webViewClass webViewHolder:(NSObject *)webViewHolder; 43 | 44 | /** 45 | 回收可复用的WKWebView 46 | 47 | @param webView 可复用的webView 48 | */ 49 | - (void)enqueueWebView:(__kindof HPKWebView *)webView; 50 | 51 | /** 52 | 回收并销毁WKWebView,并且将之从回收池里删除 53 | 54 | @param webView 可复用的webView 55 | */ 56 | - (void)removeReusableWebView:(__kindof HPKWebView *)webView; 57 | 58 | /** 59 | 销毁全部在回收池中的WebView 60 | */ 61 | - (void)clearAllReusableWebViews; 62 | 63 | /** 64 | 销毁在回收池中特定Class的WebView 65 | 66 | @param webViewClass 可复用的webView的类型 67 | */ 68 | - (void)clearAllReusableWebViewsWithClass:(Class)webViewClass; 69 | 70 | /** 71 | 重新刷新在回收池中的WebView 72 | */ 73 | - (void)reloadAllReusableWebViews; 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit/HybridPageKit/Source/WKWebView + HPKDelegateExtension.h: -------------------------------------------------------------------------------- 1 | // 2 | // WKWebView + HPKDelegateExtension.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import 27 | 28 | @interface WKWebView (HPKDelegateExtension) 29 | 30 | - (void)_useExternalNavigationDelegateAndWithDefaultUIDelegate:(BOOL)useDefaultUIDelegate; 31 | - (void)_setNavigationDelegate:(id)delegate __attribute__((unavailable)); 32 | - (void)_setMainNavigationDelegate:(NSObject *)mainDelegate; 33 | - (void)_addSecondaryNavigationDelegate:(NSObject *)delegate; 34 | - (void)_removeSecondaryNavigationDelegate:(NSObject *)delegate; 35 | - (void)_removeAllSecondaryNavigationDelegates; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit/HybridPageKit/Source/WKWebView + HPKExtension.h: -------------------------------------------------------------------------------- 1 | // 2 | // WKWebView + HPKExtension.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import 27 | 28 | typedef void (^_HPKWebViewJSCompletionBlock)(NSObject *result); 29 | 30 | typedef NS_ENUM (NSInteger, ConfigUAType) { 31 | kConfigUATypeReplace, //replace all UA string 32 | kConfigUATypeAppend, //append to original UA string 33 | }; 34 | 35 | @interface WKWebView (HPKExtension) 36 | 37 | #pragma mark - safe evaluate js 38 | 39 | - (void)_safeAsyncEvaluateJavaScriptString:(NSString *)script; 40 | 41 | - (void)_safeAsyncEvaluateJavaScriptString:(NSString *)script completionBlock:(_HPKWebViewJSCompletionBlock)block; 42 | 43 | #pragma mark - Cookies 44 | 45 | - (void)_setCookieWithName:(NSString *)name 46 | value:(NSString *)value 47 | domain:(NSString *)domain 48 | path:(NSString *)path 49 | expiresDate:(NSDate *)expiresDate 50 | completionBlock:(_HPKWebViewJSCompletionBlock)completionBlock; 51 | 52 | - (void)_deleteCookiesWithName:(NSString *)name completionBlock:(_HPKWebViewJSCompletionBlock)completionBlock; 53 | 54 | - (NSSet *)_getAllCustomCookiesName; 55 | - (void)_deleteAllCustomCookies; 56 | 57 | #pragma mark - UA 58 | 59 | + (void)configCustomUAWithType:(ConfigUAType)type 60 | UAString:(NSString *)customString API_AVAILABLE(ios(9.0)); 61 | 62 | #pragma mark - clear webview cache 63 | 64 | + (void)safeClearAllCacheIncludeiOS8:(BOOL)includeiOS8; 65 | 66 | #pragma mark - fix menu items 67 | 68 | + (void)fixWKWebViewMenuItems; 69 | 70 | #pragma mark - disable double click 71 | 72 | + (void)disableWebViewDoubleClick; 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit/HybridPageKit/Source/WKWebView + HPKReusable.h: -------------------------------------------------------------------------------- 1 | // 2 | // WKWebView + HPKReusable.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import 27 | 28 | @protocol HPKReusableWebViewProtocol 29 | @optional 30 | - (void)componentViewWillLeavePool; //即将离开回收池 31 | - (void)componentViewWillEnterPool; //即将进入回收池 32 | @end 33 | 34 | @interface WKWebView (HPKReusable) 35 | 36 | @property (nonatomic, weak, readwrite) NSObject *holderObject; 37 | @property (nonatomic, assign, readwrite) NSInteger reusedTimes; 38 | @property (nonatomic, assign, readwrite) BOOL invalid; 39 | 40 | - (void)componentViewWillLeavePool __attribute__((objc_requires_super)); //即将离开回收池 41 | - (void)componentViewWillEnterPool __attribute__((objc_requires_super)); //即将进入回收池 42 | 43 | #pragma mark - clear backForwardList 44 | 45 | - (void)_clearBackForwardList; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit/HybridPageKit/Source/WKWebView + HPKReusable.m: -------------------------------------------------------------------------------- 1 | // 2 | // WKWebView + HPKReusable.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #import "WKWebView + HPKReusable.h" 27 | #import "HPKPageManager.h" 28 | #import 29 | 30 | @interface HPKWeakWrapper : NSObject 31 | @property(nonatomic, weak, readwrite)NSObject *weakObj; 32 | @end 33 | @implementation HPKWeakWrapper 34 | @end 35 | 36 | @implementation WKWebView (HPKReusable) 37 | 38 | #pragma mark - 39 | 40 | - (void)setHolderObject:(NSObject *)holderObject { 41 | HPKWeakWrapper *wrapObj = objc_getAssociatedObject(self, @selector(setHolderObject:)); 42 | if (wrapObj) { 43 | wrapObj.weakObj = holderObject; 44 | }else{ 45 | wrapObj = [[HPKWeakWrapper alloc] init]; 46 | wrapObj.weakObj = holderObject; 47 | objc_setAssociatedObject(self, @selector(setHolderObject:), wrapObj, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 48 | } 49 | } 50 | 51 | - (NSObject *)holderObject { 52 | HPKWeakWrapper *wrapObj = objc_getAssociatedObject(self, @selector(setHolderObject:)); 53 | return wrapObj.weakObj; 54 | } 55 | 56 | - (void)setReusedTimes:(NSInteger)reusedTimes { 57 | NSNumber *reusedTimesNum = @(reusedTimes); 58 | objc_setAssociatedObject(self, @selector(setReusedTimes:), reusedTimesNum, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 59 | } 60 | 61 | - (NSInteger)reusedTimes { 62 | NSNumber *reusedTimesNum = objc_getAssociatedObject(self, @selector(setReusedTimes:)); 63 | return [reusedTimesNum integerValue]; 64 | } 65 | 66 | - (void)setInvalid:(BOOL)invalid { 67 | objc_setAssociatedObject(self, @selector(setInvalid:), @(invalid), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 68 | } 69 | 70 | - (BOOL)invalid { 71 | NSNumber *invalidNum = objc_getAssociatedObject(self, @selector(setInvalid:)); 72 | return invalidNum.boolValue; 73 | } 74 | 75 | #pragma mark - 76 | 77 | - (void)componentViewWillLeavePool { 78 | self.reusedTimes += 1; 79 | [self _clearBackForwardList]; 80 | } 81 | 82 | - (void)componentViewWillEnterPool { 83 | self.holderObject = nil; 84 | self.scrollView.delegate = nil; 85 | self.scrollView.scrollEnabled = YES; 86 | [self stopLoading]; 87 | [NSObject cancelPreviousPerformRequestsWithTarget:self]; 88 | NSString *reuseLoadUrl = [[HPKPageManager sharedInstance] webViewReuseLoadUrlStr]; 89 | if (reuseLoadUrl && reuseLoadUrl.length > 0) { 90 | [self loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:reuseLoadUrl]]]; 91 | } else { 92 | [self loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@""]]]; 93 | } 94 | } 95 | 96 | #pragma mark - clear backForwardList 97 | 98 | - (void)_clearBackForwardList { 99 | #pragma clang diagnostic push 100 | #pragma clang diagnostic ignored "-Warc-performSelector-leaks" 101 | SEL sel = NSSelectorFromString([NSString stringWithFormat:@"%@%@%@%@", @"_re", @"moveA", @"llIte", @"ms"]); 102 | if ([self.backForwardList respondsToSelector:sel]) { 103 | [self.backForwardList performSelector:sel]; 104 | } 105 | #pragma clang diagnostic pop 106 | } 107 | 108 | @end 109 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit/HybridPageKit/Source/_HPKAspects.h: -------------------------------------------------------------------------------- 1 | // 2 | // Aspects.h 3 | // Aspects - A delightful, simple library for aspect oriented programming. 4 | // 5 | // Copyright (c) 2014 Peter Steinberger. Licensed under the MIT license. 6 | // 7 | 8 | #import 9 | 10 | typedef NS_OPTIONS(NSUInteger, HPK_AspectOptions) { 11 | AspectPositionAfter = 0, /// Called after the original implementation (default) 12 | AspectPositionInstead = 1, /// Will replace the original implementation. 13 | AspectPositionBefore = 2, /// Called before the original implementation. 14 | 15 | AspectOptionAutomaticRemoval = 1 << 3 /// Will remove the hook after the first execution. 16 | }; 17 | 18 | /// Opaque Aspect Token that allows to deregister the hook. 19 | @protocol HPK_AspectToken 20 | 21 | /// Deregisters an aspect. 22 | /// @return YES if deregistration is successful, otherwise NO. 23 | - (BOOL)remove; 24 | 25 | @end 26 | 27 | /// The AspectInfo protocol is the first parameter of our block syntax. 28 | @protocol HPK_AspectInfo 29 | 30 | /// The instance that is currently hooked. 31 | - (id)instance; 32 | 33 | /// The original invocation of the hooked method. 34 | - (NSInvocation *)originalInvocation; 35 | 36 | /// All method arguments, boxed. This is lazily evaluated. 37 | - (NSArray *)arguments; 38 | 39 | @end 40 | 41 | /** 42 | Aspects uses Objective-C message forwarding to hook into messages. This will create some overhead. Don't add aspects to methods that are called a lot. Aspects is meant for view/controller code that is not called a 1000 times per second. 43 | 44 | Adding aspects returns an opaque token which can be used to deregister again. All calls are thread safe. 45 | */ 46 | @interface NSObject (HPK_Aspects) 47 | 48 | /// Adds a block of code before/instead/after the current `selector` for a specific class. 49 | /// 50 | /// @param block Aspects replicates the type signature of the method being hooked. 51 | /// The first parameter will be `id`, followed by all parameters of the method. 52 | /// These parameters are optional and will be filled to match the block signature. 53 | /// You can even use an empty block, or one that simple gets `id`. 54 | /// 55 | /// @note Hooking static methods is not supported. 56 | /// @return A token which allows to later deregister the aspect. 57 | + (id)HPK_aspect_hookSelector:(SEL)selector 58 | withOptions:(HPK_AspectOptions)options 59 | usingBlock:(id)block 60 | error:(NSError **)error; 61 | 62 | /// Adds a block of code before/instead/after the current `selector` for a specific instance. 63 | - (id)HPK_aspect_hookSelector:(SEL)selector 64 | withOptions:(HPK_AspectOptions)options 65 | usingBlock:(id)block 66 | error:(NSError **)error; 67 | 68 | @end 69 | 70 | 71 | typedef NS_ENUM(NSUInteger, HPK_AspectErrorCode) { 72 | AspectErrorSelectorBlacklisted, /// Selectors like release, retain, autorelease are blacklisted. 73 | AspectErrorDoesNotRespondToSelector, /// Selector could not be found. 74 | AspectErrorSelectorDeallocPosition, /// When hooking dealloc, only AspectPositionBefore is allowed. 75 | AspectErrorSelectorAlreadyHookedInClassHierarchy, /// Statically hooking the same method in subclasses is not allowed. 76 | AspectErrorFailedToAllocateClassPair, /// The runtime failed creating a class pair. 77 | AspectErrorMissingBlockSignature, /// The block misses compile time signature info and can't be called. 78 | AspectErrorIncompatibleBlockSignature, /// The block signature does not match the method or is too large. 79 | 80 | AspectErrorRemoveObjectAlreadyDeallocated = 100 /// (for removing) The object hooked is already deallocated. 81 | }; 82 | 83 | extern NSString *const HPK_AspectErrorDomain; 84 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit/HybridPageKit/Source/_HPKUtils.h: -------------------------------------------------------------------------------- 1 | // 2 | // _HPKUtils.h 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | 26 | #ifndef _HPKUtils_h 27 | #define _HPKUtils_h 28 | 29 | #import "HPKPageManager.h" 30 | 31 | #define HPKInfoLog(logformat, ...) \ 32 | [[HPKPageManager sharedInstance] logWithErrorLevel:kHPKLogLevelInfo logFormat:(logformat), ## __VA_ARGS__]; 33 | 34 | #define HPKErrorLog(logformat, ...) \ 35 | [[HPKPageManager sharedInstance] logWithErrorLevel:kHPKLogLevelError logFormat:(logformat), ## __VA_ARGS__]; 36 | 37 | #define HPKFatalLog(logformat, ...) \ 38 | [[HPKPageManager sharedInstance] logWithErrorLevel:kHPKLogLevelFatal logFormat:(logformat), ## __VA_ARGS__]; 39 | 40 | @interface HPKPageManager (_utils) 41 | - (void)logWithErrorLevel:(HPKLogLevel)errorLevel logFormat:(NSString *)logFormat, ... NS_FORMAT_FUNCTION(2, 3); 42 | @end 43 | 44 | typedef void (^HPKKVOCallback)(NSObject *oldValue, NSObject *newValue); 45 | @interface NSObject (HPKKVO) 46 | 47 | - (void)safeAddObserver:(id)observer keyPath:(NSString *)keyPath callback:(HPKKVOCallback)callback; 48 | - (void)safeRemoveObserver:(id)observer keyPath:(NSString *)keyPath; 49 | - (void)safeRemoveAllObserver; 50 | @end 51 | 52 | #pragma mark - 53 | 54 | #define isiOS13Beta1 \ 55 | ([@"13.0" isEqualToString:[[UIDevice currentDevice] systemVersion]]) 56 | 57 | #endif /* _HPKUtils_h */ 58 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit/HybridPageKitTests/HPKSafeKVOTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // HPKWebViewDelegateTests.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import 26 | #import 27 | #import 28 | #import "_HPKUtils.h" 29 | 30 | @interface Test_NSObject_KVO : XCTestCase 31 | @end 32 | 33 | @implementation Test_NSObject_KVO 34 | 35 | - (void)testBasics { 36 | 37 | UIView *view = [[UIView alloc] init]; 38 | view.backgroundColor = [UIColor redColor]; 39 | NSObject *tmpObserver = [[NSObject alloc] init]; 40 | int __block callbackCount = 0; 41 | 42 | [view safeAddObserver:tmpObserver 43 | keyPath:@"backgroundColor" 44 | callback:^(NSObject *oldValue, NSObject *newValue) { 45 | callbackCount++; 46 | XCTAssert(oldValue == [UIColor redColor]); 47 | XCTAssert(newValue == [UIColor blackColor]); 48 | }]; 49 | 50 | [view safeAddObserver:tmpObserver 51 | keyPath:@"frame" 52 | callback:^(NSObject *oldValue, NSObject *newValue) { 53 | callbackCount++; 54 | XCTAssert([newValue isKindOfClass:[NSValue class]]); 55 | XCTAssert([oldValue isKindOfClass:[NSValue class]]); 56 | }]; 57 | 58 | view.backgroundColor = [UIColor blackColor]; 59 | XCTAssert(callbackCount == 1); 60 | 61 | view.frame = CGRectMake(0, 0, 100, 100); 62 | XCTAssert(callbackCount == 2); 63 | 64 | [view safeRemoveObserver:tmpObserver keyPath:@"backgroundColor"]; 65 | view.backgroundColor = [UIColor blackColor]; 66 | XCTAssert(callbackCount == 2); 67 | } 68 | 69 | - (void)testObservedObjectDealloc { 70 | NSObject *tmpObserver = [[NSObject alloc] init]; 71 | @autoreleasepool { 72 | UIView *view = [[UIView alloc] init]; 73 | int __block callbackCount = 0; 74 | [view safeAddObserver:tmpObserver 75 | keyPath:@"backgroundColor" 76 | callback:^(NSObject *oldValue, NSObject *newValue) { 77 | callbackCount++; 78 | }]; 79 | 80 | view.backgroundColor = [UIColor blackColor]; 81 | XCTAssert(callbackCount == 1); 82 | } 83 | } 84 | 85 | - (void)testObserverDealloc { 86 | @autoreleasepool { 87 | UIView *view = [[UIView alloc] init]; 88 | int __block callbackCount = 0; 89 | @autoreleasepool { 90 | NSObject *tmpObserver = [[NSObject alloc] init]; 91 | 92 | [view safeAddObserver:tmpObserver 93 | keyPath:@"backgroundColor" 94 | callback:^(NSObject *oldValue, NSObject *newValue) { 95 | callbackCount++; 96 | }]; 97 | 98 | view.backgroundColor = [UIColor blackColor]; 99 | 100 | XCTAssert(callbackCount == 1); 101 | } 102 | view.backgroundColor = [UIColor redColor]; // trigger to unbind KVO 103 | XCTAssert(callbackCount == 1); 104 | } 105 | } 106 | @end 107 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit/HybridPageKitTests/HPKWebViewDelegateTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // HPKWebViewDelegateTests.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import 26 | #import "HPKWebView.h" 27 | 28 | typedef WKNavigationActionPolicy (^HPKWebViewDelegateDecidePolicyBlock)(void); 29 | typedef void (^HPKWebViewDelegateFinishNavigationBlock)(WKNavigation *navigation); 30 | typedef void (^HPKWebViewDelegateFailNavigationBlock)(NSError *error); 31 | 32 | @interface HPKWebViewDelegate : NSObject 33 | @property (nonatomic, copy, readwrite) HPKWebViewDelegateDecidePolicyBlock decidePolicyBlock; 34 | @property (nonatomic, copy, readwrite) HPKWebViewDelegateFinishNavigationBlock finishNavigationBlock; 35 | @property (nonatomic, copy, readwrite) HPKWebViewDelegateFailNavigationBlock failNavigationBlock; 36 | @end 37 | @implementation HPKWebViewDelegate 38 | - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { 39 | if (_decidePolicyBlock) { 40 | decisionHandler(_decidePolicyBlock()); 41 | } else { 42 | decisionHandler(WKNavigationActionPolicyCancel); 43 | } 44 | } 45 | 46 | - (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation { 47 | if (_finishNavigationBlock) { 48 | _finishNavigationBlock(navigation); 49 | } 50 | } 51 | 52 | - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error { 53 | if (_failNavigationBlock) { 54 | _failNavigationBlock(error); 55 | } 56 | } 57 | 58 | - (void)webView:(WKWebView *)webView didFailNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error { 59 | if (_failNavigationBlock) { 60 | _failNavigationBlock(error); 61 | } 62 | } 63 | 64 | @end 65 | 66 | @interface HPKWebViewDelegateTests : XCTestCase 67 | 68 | @property (nonatomic, strong, readwrite) HPKWebView *webView; 69 | @property (nonatomic, strong, readwrite) HPKWebViewDelegate *mainDelegate; 70 | @property (nonatomic, strong, readwrite) HPKWebViewDelegate *secondaryDelegate; 71 | @end 72 | 73 | @implementation HPKWebViewDelegateTests 74 | 75 | - (void)setUp { 76 | _webView = [[HPKWebView alloc]initWithFrame:CGRectZero]; 77 | _mainDelegate = [[HPKWebViewDelegate alloc] init]; 78 | _secondaryDelegate = [[HPKWebViewDelegate alloc] init]; 79 | } 80 | 81 | - (void)tearDown { 82 | } 83 | 84 | - (void)testWebViewDelegate { 85 | [_webView useExternalNavigationDelegateAndWithDefaultUIDelegate:YES]; 86 | [_webView setMainNavigationDelegate:_mainDelegate]; 87 | XCTAssertNotEqualObjects(_mainDelegate, _webView.navigationDelegate); 88 | [_webView addSecondaryNavigationDelegate:_secondaryDelegate]; 89 | XCTAssertNotEqualObjects(_secondaryDelegate, _webView.navigationDelegate); 90 | 91 | XCTestExpectation *expectation = [self expectationWithDescription:@(__LINE__).stringValue]; 92 | [_mainDelegate setDecidePolicyBlock:^WKNavigationActionPolicy { 93 | return WKNavigationActionPolicyAllow; 94 | }]; 95 | [_secondaryDelegate setDecidePolicyBlock:^WKNavigationActionPolicy { 96 | return WKNavigationActionPolicyCancel; 97 | }]; 98 | [_secondaryDelegate setFinishNavigationBlock:^(WKNavigation *navigation) { 99 | [expectation fulfill]; 100 | }]; 101 | 102 | [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://httpbin.org/"]]]; 103 | [self waitForExpectationsWithTimeout:10 * 60 handler:nil]; 104 | } 105 | 106 | @end 107 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit/HybridPageKitTests/HPKWebViewReuseTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // HPKWebViewReuseTests.m 3 | // 4 | // Copyright (c) 2019 dequanzhu 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // 24 | 25 | #import 26 | #import "HPKPageManager.h" 27 | #import "WKWebView + HPKReusable.h" 28 | 29 | @interface TestWebView : HPKWebView 30 | @end 31 | @implementation TestWebView 32 | @end 33 | 34 | @interface HPKWebViewReuseTests : XCTestCase 35 | 36 | @property (nonatomic, weak, readwrite) HPKWebView *webView1; 37 | @property (nonatomic, weak, readwrite) HPKWebView *webView2; 38 | @property (nonatomic, weak, readwrite) HPKWebView *webView3; 39 | 40 | @end 41 | 42 | @implementation HPKWebViewReuseTests 43 | 44 | - (void)testReusableWebView { 45 | //常规取 46 | _webView1 = [[HPKPageManager sharedInstance] dequeueWebViewWithClass:[TestWebView class] webViewHolder:self]; 47 | XCTAssertNotNil(_webView1); 48 | XCTAssertTrue([_webView1 isMemberOfClass:[TestWebView class]]); 49 | 50 | _webView2 = [[HPKPageManager sharedInstance] dequeueWebViewWithClass:[HPKWebView class] webViewHolder:self]; 51 | XCTAssertNotNil(_webView2); 52 | XCTAssertTrue([_webView2 isMemberOfClass:[HPKWebView class]]); 53 | XCTAssertNotEqualObjects(_webView1, _webView2); 54 | 55 | //回收 56 | [[HPKPageManager sharedInstance] enqueueWebView:_webView1]; 57 | _webView3 = [[HPKPageManager sharedInstance] dequeueWebViewWithClass:[TestWebView class] webViewHolder:self]; 58 | XCTAssertEqual(_webView3.reusedTimes, 2); 59 | XCTAssertEqualObjects(_webView1, _webView3); 60 | 61 | //回收 62 | [[HPKPageManager sharedInstance] enqueueWebView:_webView1]; 63 | _webView3 = [[HPKPageManager sharedInstance] dequeueWebViewWithClass:[HPKWebView class] webViewHolder:self]; 64 | XCTAssertNotEqualObjects(_webView1, _webView3); 65 | 66 | //删除 67 | [[HPKPageManager sharedInstance] removeReusableWebView:_webView1]; 68 | _webView3 = [[HPKPageManager sharedInstance] dequeueWebViewWithClass:[TestWebView class] webViewHolder:self]; 69 | XCTAssertNotEqualObjects(_webView1, _webView3); 70 | 71 | //invalid 72 | _webView3.invalid = YES; 73 | [[HPKPageManager sharedInstance] enqueueWebView:_webView3]; 74 | _webView1 = [[HPKPageManager sharedInstance] dequeueWebViewWithClass:[TestWebView class] webViewHolder:self]; 75 | XCTAssertNotEqualObjects(_webView1, _webView3); 76 | 77 | //auto recyle 78 | NSObject *temHolder = [[NSObject alloc] init]; 79 | _webView1 = [[HPKPageManager sharedInstance] dequeueWebViewWithClass:[TestWebView class] webViewHolder:temHolder]; 80 | temHolder = nil; 81 | _webView2 = [[HPKPageManager sharedInstance] dequeueWebViewWithClass:[TestWebView class] webViewHolder:self]; 82 | XCTAssertEqualObjects(_webView1, _webView2); 83 | } 84 | 85 | @end 86 | -------------------------------------------------------------------------------- /HybridPageKit/HybridPageKit/HybridPageKitTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 dequanzhu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README-IMAGE/Banner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dequan1331/HybridPageKit/3500feb2cb3cbd2efbf54c309ea7c9baf7b03e31/README-IMAGE/Banner.gif -------------------------------------------------------------------------------- /README-IMAGE/Folded.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dequan1331/HybridPageKit/3500feb2cb3cbd2efbf54c309ea7c9baf7b03e31/README-IMAGE/Folded.gif -------------------------------------------------------------------------------- /README-IMAGE/Hybrid.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dequan1331/HybridPageKit/3500feb2cb3cbd2efbf54c309ea7c9baf7b03e31/README-IMAGE/Hybrid.gif -------------------------------------------------------------------------------- /README-IMAGE/Short.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dequan1331/HybridPageKit/3500feb2cb3cbd2efbf54c309ea7c9baf7b03e31/README-IMAGE/Short.gif --------------------------------------------------------------------------------