├── .gitignore ├── Podfile ├── Podfile.lock ├── README.md ├── Solidot.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── WorkspaceSettings.xcsettings ├── Solidot.xcworkspace └── contents.xcworkspacedata └── Sources ├── AppDelegate.swift ├── Controller.swift ├── Extension.swift ├── Manager.swift ├── Model.swift ├── Service.swift ├── Support Files ├── Assets.xcassets │ ├── 702-share.imageset │ │ ├── 702-share.png │ │ ├── 702-share@2x.png │ │ └── Contents.json │ ├── 715-globe.imageset │ │ ├── 715-globe.png │ │ ├── 715-globe@2x.png │ │ └── Contents.json │ ├── 937-wifi-signal.imageset │ │ ├── 937-wifi-signal.png │ │ ├── 937-wifi-signal@2x.png │ │ ├── 937-wifi-signal@3x.png │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── Icon-1024.png │ │ ├── Icon-120.png │ │ ├── Icon-121.png │ │ ├── Icon-152.png │ │ ├── Icon-167.png │ │ ├── Icon-180.png │ │ ├── Icon-20.png │ │ ├── Icon-29.png │ │ ├── Icon-40.png │ │ ├── Icon-41.png │ │ ├── Icon-42.png │ │ ├── Icon-58.png │ │ ├── Icon-59.png │ │ ├── Icon-60.png │ │ ├── Icon-76.png │ │ ├── Icon-80.png │ │ ├── Icon-81.png │ │ └── Icon-87.png │ ├── Contents.json │ ├── Icon-Back.imageset │ │ ├── Contents.json │ │ ├── Icon-Back.png │ │ ├── Icon-Back@2x.png │ │ └── Icon-Back@3x.png │ ├── Icon-Close.imageset │ │ ├── Contents.json │ │ ├── Icon-Cross.png │ │ ├── Icon-Cross@2x.png │ │ └── Icon-Cross@3x.png │ ├── logo_2015.imageset │ │ ├── Contents.json │ │ └── logo_2015.png │ └── safari.imageset │ │ ├── Contents.json │ │ ├── safari.png │ │ ├── safari@2x.png │ │ ├── safari@3x.png │ │ ├── safari~iPad.png │ │ └── safari~iPad@2x.png ├── Info.plist ├── en.lproj │ ├── InfoPlist.strings │ └── Localizable.strings └── zh-Hans.lproj │ ├── InfoPlist.strings │ └── Localizable.strings ├── View.swift └── XIB ├── Detail Header View.xib ├── Detail View.xib ├── Story Cell View.xib ├── en.lproj └── Launch Screen.strings └── zh-Hans.lproj └── Launch Screen.storyboard /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | # Package.resolved 41 | .build/ 42 | 43 | # CocoaPods 44 | # 45 | # We recommend against adding the Pods directory to your .gitignore. However 46 | # you should judge for yourself, the pros and cons are mentioned at: 47 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 48 | # 49 | 50 | Pods/ 51 | 52 | # Carthage 53 | # 54 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 55 | # Carthage/Checkouts 56 | 57 | Carthage/Build 58 | 59 | # fastlane 60 | # 61 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 62 | # screenshots whenever they are needed. 63 | # For more information about the recommended setup visit: 64 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 65 | 66 | fastlane/report.xml 67 | fastlane/Preview.html 68 | fastlane/screenshots 69 | fastlane/test_output 70 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '8.0' 2 | 3 | target 'Solidot' do 4 | use_frameworks! 5 | 6 | pod 'Alamofire', '~> 4.5' 7 | 8 | pod 'Kanna', :git => 'https://github.com/tid-kijyun/Kanna.git', :branch => 'feature/v4.0.0' 9 | 10 | pod 'SwiftyJSON' 11 | 12 | pod 'SnapKit', '~> 4.0.0' 13 | 14 | pod 'Reachability' 15 | 16 | pod 'SDWebImage', '~> 3.8', :subspecs => [ 17 | 'WebP' 18 | ] 19 | end 20 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Alamofire (4.6.0) 3 | - Kanna (4.0.0) 4 | - libwebp (0.6.0): 5 | - libwebp/core (= 0.6.0) 6 | - libwebp/dec (= 0.6.0) 7 | - libwebp/demux (= 0.6.0) 8 | - libwebp/dsp (= 0.6.0) 9 | - libwebp/enc (= 0.6.0) 10 | - libwebp/mux (= 0.6.0) 11 | - libwebp/utils (= 0.6.0) 12 | - libwebp/webp (= 0.6.0) 13 | - libwebp/core (0.6.0): 14 | - libwebp/webp 15 | - libwebp/dec (0.6.0): 16 | - libwebp/core 17 | - libwebp/demux (0.6.0): 18 | - libwebp/core 19 | - libwebp/dsp (0.6.0): 20 | - libwebp/core 21 | - libwebp/enc (0.6.0): 22 | - libwebp/core 23 | - libwebp/mux (0.6.0): 24 | - libwebp/core 25 | - libwebp/utils (0.6.0): 26 | - libwebp/core 27 | - libwebp/webp (0.6.0) 28 | - Reachability (3.2) 29 | - SDWebImage/Core (3.8.2) 30 | - SDWebImage/WebP (3.8.2): 31 | - libwebp 32 | - SDWebImage/Core 33 | - SnapKit (4.0.0) 34 | - SwiftyJSON (4.0.0) 35 | 36 | DEPENDENCIES: 37 | - Alamofire (~> 4.5) 38 | - Kanna (from `https://github.com/tid-kijyun/Kanna.git`, branch `feature/v4.0.0`) 39 | - Reachability 40 | - SDWebImage/WebP (~> 3.8) 41 | - SnapKit (~> 4.0.0) 42 | - SwiftyJSON 43 | 44 | EXTERNAL SOURCES: 45 | Kanna: 46 | :branch: feature/v4.0.0 47 | :git: https://github.com/tid-kijyun/Kanna.git 48 | 49 | CHECKOUT OPTIONS: 50 | Kanna: 51 | :commit: 58e3513d20cd16fe8b9ff16b5a2b481fcd643499 52 | :git: https://github.com/tid-kijyun/Kanna.git 53 | 54 | SPEC CHECKSUMS: 55 | Alamofire: f41a599bd63041760b26d393ec1069d9d7b917f4 56 | Kanna: d5ae2a26472f7e7a474e7f36a9cd8aa2c8c63ad3 57 | libwebp: 1d5a07c2eb97f9c31bd5f154bb82efc0ea67c6a2 58 | Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96 59 | SDWebImage: 098e97e6176540799c27e804c96653ee0833d13c 60 | SnapKit: a42d492c16e80209130a3379f73596c3454b7694 61 | SwiftyJSON: 070dabdcb1beb81b247c65ffa3a79dbbfb3b48aa 62 | 63 | PODFILE CHECKSUM: 49056acd9fc2ff677e8ec371d714742ac1023039 64 | 65 | COCOAPODS: 1.3.1 66 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Unofficial Solidot iOS App 2 | ### 非官方的Solidot iOS App 3 | 4 | Good day, Nerds. 5 | 这是一个非官方的Solidot iOS客户端,因为不知为何不符合苹果商店的审核标准。 6 | 故开源出来给大家交流学习,目前仅实现了基本的阅读功能。 7 | 如果有什么问题,请反馈至 Issues 里。 8 | 本人会不定期维护代码。 9 | 10 | ## MIT License 11 | 12 | Copyright 2018 Joe Wang 13 | 14 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /Solidot.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 5915F4161FFF5266000BEA0A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5915F4151FFF5266000BEA0A /* AppDelegate.swift */; }; 11 | 5915F4181FFF5266000BEA0A /* Controller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5915F4171FFF5266000BEA0A /* Controller.swift */; }; 12 | 5947D3A52000D6A1006FD22E /* Detail Header View.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5947D3A42000D6A1006FD22E /* Detail Header View.xib */; }; 13 | 5947D3A72000EF1E006FD22E /* Manager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5947D3A62000EF1E006FD22E /* Manager.swift */; }; 14 | 5947D3A92000F22C006FD22E /* Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5947D3A82000F22C006FD22E /* Model.swift */; }; 15 | 5947D3AB2000F367006FD22E /* Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5947D3AA2000F367006FD22E /* Extension.swift */; }; 16 | 5947D3AD2000F382006FD22E /* View.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5947D3AC2000F382006FD22E /* View.swift */; }; 17 | 597B895D2001FDD0009C4BD6 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 597B895F2001FDD0009C4BD6 /* InfoPlist.strings */; }; 18 | 597B89642002001F009C4BD6 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 597B89662002001F009C4BD6 /* Localizable.strings */; }; 19 | 597B896820020660009C4BD6 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 597B896A20020660009C4BD6 /* Launch Screen.storyboard */; }; 20 | 59CFD56D2059305000151D1C /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 59CFD56C2059305000151D1C /* README.md */; }; 21 | 59D11AF91FFF54620004689C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 59D11AF71FFF54620004689C /* Assets.xcassets */; }; 22 | 59D11AFE1FFF656F0004689C /* Service.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59D11AFD1FFF656F0004689C /* Service.swift */; }; 23 | 59D11B011FFF90590004689C /* Story Cell View.xib in Resources */ = {isa = PBXBuildFile; fileRef = 59D11B001FFF90590004689C /* Story Cell View.xib */; }; 24 | 59D9E1151FFFCA0B003EAEA4 /* Detail View.xib in Resources */ = {isa = PBXBuildFile; fileRef = 59D9E1141FFFCA0B003EAEA4 /* Detail View.xib */; }; 25 | 867D41F56A5A378D5C6D947C /* Pods_Solidot.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ACFC4A779389863BA2C6327F /* Pods_Solidot.framework */; }; 26 | /* End PBXBuildFile section */ 27 | 28 | /* Begin PBXFileReference section */ 29 | 4A76BF42E55B66393C6542A3 /* Pods-Solidot.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Solidot.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Solidot/Pods-Solidot.debug.xcconfig"; sourceTree = ""; }; 30 | 5915F4121FFF5266000BEA0A /* Solidot.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Solidot.app; sourceTree = BUILT_PRODUCTS_DIR; }; 31 | 5915F4151FFF5266000BEA0A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 32 | 5915F4171FFF5266000BEA0A /* Controller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Controller.swift; sourceTree = ""; }; 33 | 5947D3A42000D6A1006FD22E /* Detail Header View.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = "Detail Header View.xib"; sourceTree = ""; }; 34 | 5947D3A62000EF1E006FD22E /* Manager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Manager.swift; sourceTree = ""; }; 35 | 5947D3A82000F22C006FD22E /* Model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Model.swift; sourceTree = ""; }; 36 | 5947D3AA2000F367006FD22E /* Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extension.swift; sourceTree = ""; }; 37 | 5947D3AC2000F382006FD22E /* View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = View.swift; sourceTree = ""; }; 38 | 597B895E2001FDD0009C4BD6 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 39 | 597B89612001FEA2009C4BD6 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/InfoPlist.strings"; sourceTree = ""; }; 40 | 597B89652002001F009C4BD6 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = ""; }; 41 | 597B89672002002B009C4BD6 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; 42 | 597B896920020660009C4BD6 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = "zh-Hans"; path = "zh-Hans.lproj/Launch Screen.storyboard"; sourceTree = ""; }; 43 | 597B896C20020665009C4BD6 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = "en.lproj/Launch Screen.strings"; sourceTree = ""; }; 44 | 59CFD56C2059305000151D1C /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; 45 | 59D11AF71FFF54620004689C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 46 | 59D11AF81FFF54620004689C /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 47 | 59D11AFB1FFF5BBD0004689C /* Podfile */ = {isa = PBXFileReference; lastKnownFileType = text; path = Podfile; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; 48 | 59D11AFD1FFF656F0004689C /* Service.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Service.swift; sourceTree = ""; }; 49 | 59D11B001FFF90590004689C /* Story Cell View.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = "Story Cell View.xib"; sourceTree = ""; }; 50 | 59D9E1141FFFCA0B003EAEA4 /* Detail View.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = "Detail View.xib"; sourceTree = ""; }; 51 | 8F203D26E5689F5C3F3FD206 /* Pods-NerdsFeeder.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NerdsFeeder.debug.xcconfig"; path = "Pods/Target Support Files/Pods-NerdsFeeder/Pods-NerdsFeeder.debug.xcconfig"; sourceTree = ""; }; 52 | A0FA67BBE3239F55F5CA0769 /* Pods-Solidot.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Solidot.release.xcconfig"; path = "Pods/Target Support Files/Pods-Solidot/Pods-Solidot.release.xcconfig"; sourceTree = ""; }; 53 | ACFC4A779389863BA2C6327F /* Pods_Solidot.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Solidot.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 54 | F14F1428260DE72251873537 /* Pods-NerdsFeeder.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NerdsFeeder.release.xcconfig"; path = "Pods/Target Support Files/Pods-NerdsFeeder/Pods-NerdsFeeder.release.xcconfig"; sourceTree = ""; }; 55 | FA1CCAEC983E948A0DB9EAA3 /* Pods_NerdsFeeder.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_NerdsFeeder.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 56 | /* End PBXFileReference section */ 57 | 58 | /* Begin PBXFrameworksBuildPhase section */ 59 | 5915F40F1FFF5266000BEA0A /* Frameworks */ = { 60 | isa = PBXFrameworksBuildPhase; 61 | buildActionMask = 2147483647; 62 | files = ( 63 | 867D41F56A5A378D5C6D947C /* Pods_Solidot.framework in Frameworks */, 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | /* End PBXFrameworksBuildPhase section */ 68 | 69 | /* Begin PBXGroup section */ 70 | 5915F4091FFF5266000BEA0A = { 71 | isa = PBXGroup; 72 | children = ( 73 | 59CFD56C2059305000151D1C /* README.md */, 74 | 59D11AFB1FFF5BBD0004689C /* Podfile */, 75 | 5915F4141FFF5266000BEA0A /* Sources */, 76 | 5915F4131FFF5266000BEA0A /* Products */, 77 | 9F3E09B3563AD31D2694D025 /* Pods */, 78 | F22AA4765305D474B2886751 /* Frameworks */, 79 | ); 80 | sourceTree = ""; 81 | }; 82 | 5915F4131FFF5266000BEA0A /* Products */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | 5915F4121FFF5266000BEA0A /* Solidot.app */, 86 | ); 87 | name = Products; 88 | sourceTree = ""; 89 | }; 90 | 5915F4141FFF5266000BEA0A /* Sources */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | 5915F4151FFF5266000BEA0A /* AppDelegate.swift */, 94 | 5915F4171FFF5266000BEA0A /* Controller.swift */, 95 | 5947D3AA2000F367006FD22E /* Extension.swift */, 96 | 5947D3A62000EF1E006FD22E /* Manager.swift */, 97 | 5947D3A82000F22C006FD22E /* Model.swift */, 98 | 59D11AFD1FFF656F0004689C /* Service.swift */, 99 | 5947D3AC2000F382006FD22E /* View.swift */, 100 | 59D11AF61FFF54620004689C /* Support Files */, 101 | 59D11AFF1FFF90400004689C /* XIB */, 102 | ); 103 | path = Sources; 104 | sourceTree = ""; 105 | }; 106 | 59D11AF61FFF54620004689C /* Support Files */ = { 107 | isa = PBXGroup; 108 | children = ( 109 | 59D11AF71FFF54620004689C /* Assets.xcassets */, 110 | 59D11AF81FFF54620004689C /* Info.plist */, 111 | 597B895F2001FDD0009C4BD6 /* InfoPlist.strings */, 112 | 597B89662002001F009C4BD6 /* Localizable.strings */, 113 | ); 114 | path = "Support Files"; 115 | sourceTree = ""; 116 | }; 117 | 59D11AFF1FFF90400004689C /* XIB */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | 59D9E1141FFFCA0B003EAEA4 /* Detail View.xib */, 121 | 5947D3A42000D6A1006FD22E /* Detail Header View.xib */, 122 | 597B896A20020660009C4BD6 /* Launch Screen.storyboard */, 123 | 59D11B001FFF90590004689C /* Story Cell View.xib */, 124 | ); 125 | path = XIB; 126 | sourceTree = ""; 127 | }; 128 | 9F3E09B3563AD31D2694D025 /* Pods */ = { 129 | isa = PBXGroup; 130 | children = ( 131 | 8F203D26E5689F5C3F3FD206 /* Pods-NerdsFeeder.debug.xcconfig */, 132 | F14F1428260DE72251873537 /* Pods-NerdsFeeder.release.xcconfig */, 133 | 4A76BF42E55B66393C6542A3 /* Pods-Solidot.debug.xcconfig */, 134 | A0FA67BBE3239F55F5CA0769 /* Pods-Solidot.release.xcconfig */, 135 | ); 136 | name = Pods; 137 | sourceTree = ""; 138 | }; 139 | F22AA4765305D474B2886751 /* Frameworks */ = { 140 | isa = PBXGroup; 141 | children = ( 142 | FA1CCAEC983E948A0DB9EAA3 /* Pods_NerdsFeeder.framework */, 143 | ACFC4A779389863BA2C6327F /* Pods_Solidot.framework */, 144 | ); 145 | name = Frameworks; 146 | sourceTree = ""; 147 | }; 148 | /* End PBXGroup section */ 149 | 150 | /* Begin PBXNativeTarget section */ 151 | 5915F4111FFF5266000BEA0A /* Solidot */ = { 152 | isa = PBXNativeTarget; 153 | buildConfigurationList = 5915F4241FFF5266000BEA0A /* Build configuration list for PBXNativeTarget "Solidot" */; 154 | buildPhases = ( 155 | BFE852954CDD4C9A4656E86B /* [CP] Check Pods Manifest.lock */, 156 | 5915F40E1FFF5266000BEA0A /* Sources */, 157 | 5915F40F1FFF5266000BEA0A /* Frameworks */, 158 | 5915F4101FFF5266000BEA0A /* Resources */, 159 | DC029EA417FDCF4D56A9C639 /* [CP] Embed Pods Frameworks */, 160 | C964C23076C53541D4252835 /* [CP] Copy Pods Resources */, 161 | ); 162 | buildRules = ( 163 | ); 164 | dependencies = ( 165 | ); 166 | name = Solidot; 167 | productName = NerdsFeeder; 168 | productReference = 5915F4121FFF5266000BEA0A /* Solidot.app */; 169 | productType = "com.apple.product-type.application"; 170 | }; 171 | /* End PBXNativeTarget section */ 172 | 173 | /* Begin PBXProject section */ 174 | 5915F40A1FFF5266000BEA0A /* Project object */ = { 175 | isa = PBXProject; 176 | attributes = { 177 | LastSwiftUpdateCheck = 0920; 178 | LastUpgradeCheck = 0920; 179 | ORGANIZATIONNAME = "Joe Wang"; 180 | TargetAttributes = { 181 | 5915F4111FFF5266000BEA0A = { 182 | CreatedOnToolsVersion = 9.2; 183 | ProvisioningStyle = Automatic; 184 | }; 185 | }; 186 | }; 187 | buildConfigurationList = 5915F40D1FFF5266000BEA0A /* Build configuration list for PBXProject "Solidot" */; 188 | compatibilityVersion = "Xcode 8.0"; 189 | developmentRegion = en; 190 | hasScannedForEncodings = 0; 191 | knownRegions = ( 192 | en, 193 | Base, 194 | "zh-Hans", 195 | ); 196 | mainGroup = 5915F4091FFF5266000BEA0A; 197 | productRefGroup = 5915F4131FFF5266000BEA0A /* Products */; 198 | projectDirPath = ""; 199 | projectRoot = ""; 200 | targets = ( 201 | 5915F4111FFF5266000BEA0A /* Solidot */, 202 | ); 203 | }; 204 | /* End PBXProject section */ 205 | 206 | /* Begin PBXResourcesBuildPhase section */ 207 | 5915F4101FFF5266000BEA0A /* Resources */ = { 208 | isa = PBXResourcesBuildPhase; 209 | buildActionMask = 2147483647; 210 | files = ( 211 | 597B896820020660009C4BD6 /* Launch Screen.storyboard in Resources */, 212 | 597B895D2001FDD0009C4BD6 /* InfoPlist.strings in Resources */, 213 | 59D11B011FFF90590004689C /* Story Cell View.xib in Resources */, 214 | 597B89642002001F009C4BD6 /* Localizable.strings in Resources */, 215 | 59D9E1151FFFCA0B003EAEA4 /* Detail View.xib in Resources */, 216 | 59D11AF91FFF54620004689C /* Assets.xcassets in Resources */, 217 | 59CFD56D2059305000151D1C /* README.md in Resources */, 218 | 5947D3A52000D6A1006FD22E /* Detail Header View.xib in Resources */, 219 | ); 220 | runOnlyForDeploymentPostprocessing = 0; 221 | }; 222 | /* End PBXResourcesBuildPhase section */ 223 | 224 | /* Begin PBXShellScriptBuildPhase section */ 225 | BFE852954CDD4C9A4656E86B /* [CP] Check Pods Manifest.lock */ = { 226 | isa = PBXShellScriptBuildPhase; 227 | buildActionMask = 2147483647; 228 | files = ( 229 | ); 230 | inputPaths = ( 231 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 232 | "${PODS_ROOT}/Manifest.lock", 233 | ); 234 | name = "[CP] Check Pods Manifest.lock"; 235 | outputPaths = ( 236 | "$(DERIVED_FILE_DIR)/Pods-Solidot-checkManifestLockResult.txt", 237 | ); 238 | runOnlyForDeploymentPostprocessing = 0; 239 | shellPath = /bin/sh; 240 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 241 | showEnvVarsInLog = 0; 242 | }; 243 | C964C23076C53541D4252835 /* [CP] Copy Pods Resources */ = { 244 | isa = PBXShellScriptBuildPhase; 245 | buildActionMask = 2147483647; 246 | files = ( 247 | ); 248 | inputPaths = ( 249 | ); 250 | name = "[CP] Copy Pods Resources"; 251 | outputPaths = ( 252 | ); 253 | runOnlyForDeploymentPostprocessing = 0; 254 | shellPath = /bin/sh; 255 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Solidot/Pods-Solidot-resources.sh\"\n"; 256 | showEnvVarsInLog = 0; 257 | }; 258 | DC029EA417FDCF4D56A9C639 /* [CP] Embed Pods Frameworks */ = { 259 | isa = PBXShellScriptBuildPhase; 260 | buildActionMask = 2147483647; 261 | files = ( 262 | ); 263 | inputPaths = ( 264 | "${SRCROOT}/Pods/Target Support Files/Pods-Solidot/Pods-Solidot-frameworks.sh", 265 | "${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework", 266 | "${BUILT_PRODUCTS_DIR}/Kanna/Kanna.framework", 267 | "${BUILT_PRODUCTS_DIR}/Reachability/Reachability.framework", 268 | "${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework", 269 | "${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework", 270 | "${BUILT_PRODUCTS_DIR}/SwiftyJSON/SwiftyJSON.framework", 271 | "${BUILT_PRODUCTS_DIR}/libwebp/libwebp.framework", 272 | ); 273 | name = "[CP] Embed Pods Frameworks"; 274 | outputPaths = ( 275 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Alamofire.framework", 276 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Kanna.framework", 277 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Reachability.framework", 278 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework", 279 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SnapKit.framework", 280 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftyJSON.framework", 281 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libwebp.framework", 282 | ); 283 | runOnlyForDeploymentPostprocessing = 0; 284 | shellPath = /bin/sh; 285 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Solidot/Pods-Solidot-frameworks.sh\"\n"; 286 | showEnvVarsInLog = 0; 287 | }; 288 | /* End PBXShellScriptBuildPhase section */ 289 | 290 | /* Begin PBXSourcesBuildPhase section */ 291 | 5915F40E1FFF5266000BEA0A /* Sources */ = { 292 | isa = PBXSourcesBuildPhase; 293 | buildActionMask = 2147483647; 294 | files = ( 295 | 5947D3A92000F22C006FD22E /* Model.swift in Sources */, 296 | 5915F4181FFF5266000BEA0A /* Controller.swift in Sources */, 297 | 5915F4161FFF5266000BEA0A /* AppDelegate.swift in Sources */, 298 | 5947D3AB2000F367006FD22E /* Extension.swift in Sources */, 299 | 59D11AFE1FFF656F0004689C /* Service.swift in Sources */, 300 | 5947D3AD2000F382006FD22E /* View.swift in Sources */, 301 | 5947D3A72000EF1E006FD22E /* Manager.swift in Sources */, 302 | ); 303 | runOnlyForDeploymentPostprocessing = 0; 304 | }; 305 | /* End PBXSourcesBuildPhase section */ 306 | 307 | /* Begin PBXVariantGroup section */ 308 | 597B895F2001FDD0009C4BD6 /* InfoPlist.strings */ = { 309 | isa = PBXVariantGroup; 310 | children = ( 311 | 597B895E2001FDD0009C4BD6 /* en */, 312 | 597B89612001FEA2009C4BD6 /* zh-Hans */, 313 | ); 314 | name = InfoPlist.strings; 315 | sourceTree = ""; 316 | }; 317 | 597B89662002001F009C4BD6 /* Localizable.strings */ = { 318 | isa = PBXVariantGroup; 319 | children = ( 320 | 597B89652002001F009C4BD6 /* zh-Hans */, 321 | 597B89672002002B009C4BD6 /* en */, 322 | ); 323 | name = Localizable.strings; 324 | sourceTree = ""; 325 | }; 326 | 597B896A20020660009C4BD6 /* Launch Screen.storyboard */ = { 327 | isa = PBXVariantGroup; 328 | children = ( 329 | 597B896920020660009C4BD6 /* zh-Hans */, 330 | 597B896C20020665009C4BD6 /* en */, 331 | ); 332 | name = "Launch Screen.storyboard"; 333 | sourceTree = ""; 334 | }; 335 | /* End PBXVariantGroup section */ 336 | 337 | /* Begin XCBuildConfiguration section */ 338 | 5915F4221FFF5266000BEA0A /* Debug */ = { 339 | isa = XCBuildConfiguration; 340 | buildSettings = { 341 | ALWAYS_SEARCH_USER_PATHS = NO; 342 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 343 | CLANG_ANALYZER_NONNULL = YES; 344 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 345 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 346 | CLANG_CXX_LIBRARY = "libc++"; 347 | CLANG_ENABLE_MODULES = YES; 348 | CLANG_ENABLE_OBJC_ARC = YES; 349 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 350 | CLANG_WARN_BOOL_CONVERSION = YES; 351 | CLANG_WARN_COMMA = YES; 352 | CLANG_WARN_CONSTANT_CONVERSION = YES; 353 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 354 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 355 | CLANG_WARN_EMPTY_BODY = YES; 356 | CLANG_WARN_ENUM_CONVERSION = YES; 357 | CLANG_WARN_INFINITE_RECURSION = YES; 358 | CLANG_WARN_INT_CONVERSION = YES; 359 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 360 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 361 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 362 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 363 | CLANG_WARN_STRICT_PROTOTYPES = YES; 364 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 365 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 366 | CLANG_WARN_UNREACHABLE_CODE = YES; 367 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 368 | CODE_SIGN_IDENTITY = "iPhone Developer"; 369 | COPY_PHASE_STRIP = NO; 370 | DEBUG_INFORMATION_FORMAT = dwarf; 371 | ENABLE_STRICT_OBJC_MSGSEND = YES; 372 | ENABLE_TESTABILITY = YES; 373 | GCC_C_LANGUAGE_STANDARD = gnu11; 374 | GCC_DYNAMIC_NO_PIC = NO; 375 | GCC_NO_COMMON_BLOCKS = YES; 376 | GCC_OPTIMIZATION_LEVEL = 0; 377 | GCC_PREPROCESSOR_DEFINITIONS = ( 378 | "DEBUG=1", 379 | "$(inherited)", 380 | ); 381 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 382 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 383 | GCC_WARN_UNDECLARED_SELECTOR = YES; 384 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 385 | GCC_WARN_UNUSED_FUNCTION = YES; 386 | GCC_WARN_UNUSED_VARIABLE = YES; 387 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 388 | MTL_ENABLE_DEBUG_INFO = YES; 389 | ONLY_ACTIVE_ARCH = YES; 390 | SDKROOT = iphoneos; 391 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 392 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 393 | }; 394 | name = Debug; 395 | }; 396 | 5915F4231FFF5266000BEA0A /* Release */ = { 397 | isa = XCBuildConfiguration; 398 | buildSettings = { 399 | ALWAYS_SEARCH_USER_PATHS = NO; 400 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 401 | CLANG_ANALYZER_NONNULL = YES; 402 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 403 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 404 | CLANG_CXX_LIBRARY = "libc++"; 405 | CLANG_ENABLE_MODULES = YES; 406 | CLANG_ENABLE_OBJC_ARC = YES; 407 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 408 | CLANG_WARN_BOOL_CONVERSION = YES; 409 | CLANG_WARN_COMMA = YES; 410 | CLANG_WARN_CONSTANT_CONVERSION = YES; 411 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 412 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 413 | CLANG_WARN_EMPTY_BODY = YES; 414 | CLANG_WARN_ENUM_CONVERSION = YES; 415 | CLANG_WARN_INFINITE_RECURSION = YES; 416 | CLANG_WARN_INT_CONVERSION = YES; 417 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 418 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 419 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 420 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 421 | CLANG_WARN_STRICT_PROTOTYPES = YES; 422 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 423 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 424 | CLANG_WARN_UNREACHABLE_CODE = YES; 425 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 426 | CODE_SIGN_IDENTITY = "iPhone Developer"; 427 | COPY_PHASE_STRIP = NO; 428 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 429 | ENABLE_NS_ASSERTIONS = NO; 430 | ENABLE_STRICT_OBJC_MSGSEND = YES; 431 | GCC_C_LANGUAGE_STANDARD = gnu11; 432 | GCC_NO_COMMON_BLOCKS = YES; 433 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 434 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 435 | GCC_WARN_UNDECLARED_SELECTOR = YES; 436 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 437 | GCC_WARN_UNUSED_FUNCTION = YES; 438 | GCC_WARN_UNUSED_VARIABLE = YES; 439 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 440 | MTL_ENABLE_DEBUG_INFO = NO; 441 | SDKROOT = iphoneos; 442 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 443 | VALIDATE_PRODUCT = YES; 444 | }; 445 | name = Release; 446 | }; 447 | 5915F4251FFF5266000BEA0A /* Debug */ = { 448 | isa = XCBuildConfiguration; 449 | baseConfigurationReference = 4A76BF42E55B66393C6542A3 /* Pods-Solidot.debug.xcconfig */; 450 | buildSettings = { 451 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 452 | CODE_SIGN_STYLE = Automatic; 453 | DEVELOPMENT_TEAM = 39UHD3D274; 454 | INFOPLIST_FILE = "$(SRCROOT)/Sources/Support Files/Info.plist"; 455 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 456 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 457 | PRODUCT_BUNDLE_IDENTIFIER = net.moe48.app.Solidot; 458 | PRODUCT_NAME = "$(TARGET_NAME)"; 459 | SWIFT_VERSION = 4.0; 460 | TARGETED_DEVICE_FAMILY = "1,2"; 461 | }; 462 | name = Debug; 463 | }; 464 | 5915F4261FFF5266000BEA0A /* Release */ = { 465 | isa = XCBuildConfiguration; 466 | baseConfigurationReference = A0FA67BBE3239F55F5CA0769 /* Pods-Solidot.release.xcconfig */; 467 | buildSettings = { 468 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 469 | CODE_SIGN_STYLE = Automatic; 470 | DEVELOPMENT_TEAM = 39UHD3D274; 471 | INFOPLIST_FILE = "$(SRCROOT)/Sources/Support Files/Info.plist"; 472 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 473 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 474 | PRODUCT_BUNDLE_IDENTIFIER = net.moe48.app.Solidot; 475 | PRODUCT_NAME = "$(TARGET_NAME)"; 476 | SWIFT_VERSION = 4.0; 477 | TARGETED_DEVICE_FAMILY = "1,2"; 478 | }; 479 | name = Release; 480 | }; 481 | /* End XCBuildConfiguration section */ 482 | 483 | /* Begin XCConfigurationList section */ 484 | 5915F40D1FFF5266000BEA0A /* Build configuration list for PBXProject "Solidot" */ = { 485 | isa = XCConfigurationList; 486 | buildConfigurations = ( 487 | 5915F4221FFF5266000BEA0A /* Debug */, 488 | 5915F4231FFF5266000BEA0A /* Release */, 489 | ); 490 | defaultConfigurationIsVisible = 0; 491 | defaultConfigurationName = Release; 492 | }; 493 | 5915F4241FFF5266000BEA0A /* Build configuration list for PBXNativeTarget "Solidot" */ = { 494 | isa = XCConfigurationList; 495 | buildConfigurations = ( 496 | 5915F4251FFF5266000BEA0A /* Debug */, 497 | 5915F4261FFF5266000BEA0A /* Release */, 498 | ); 499 | defaultConfigurationIsVisible = 0; 500 | defaultConfigurationName = Release; 501 | }; 502 | /* End XCConfigurationList section */ 503 | }; 504 | rootObject = 5915F40A1FFF5266000BEA0A /* Project object */; 505 | } 506 | -------------------------------------------------------------------------------- /Solidot.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Solidot.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Solidot.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Sources/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Solidot 4 | // 5 | // Created by octopus on 05/01/2018. 6 | // Copyright © 2018 Joe Wang. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | var master = MasterController() 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | 20 | let documentsPath = NSURL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]) 21 | let dataPath = documentsPath.appendingPathComponent("Data") 22 | 23 | do { 24 | try FileManager.default.createDirectory(atPath: dataPath!.path, withIntermediateDirectories: true, attributes: nil) 25 | } catch let error as NSError { 26 | print(error.localizedDescription) 27 | } 28 | 29 | window = UIWindow(frame: screenBounds()) 30 | window?.backgroundColor = UIColor.white 31 | window?.rootViewController = NavigationController(rootViewController: master) 32 | window?.makeKeyAndVisible() 33 | 34 | return true 35 | } 36 | 37 | func screenBounds() -> CGRect { 38 | var rect:CGRect = UIScreen.main.bounds 39 | if UIDeviceOrientationIsLandscape(UIDevice.current.orientation) { 40 | var width:CGFloat 41 | width = rect.size.width 42 | rect.size.width = rect.size.height 43 | rect.size.height = width 44 | } 45 | 46 | return rect 47 | } 48 | 49 | func applicationWillResignActive(_ application: UIApplication) { 50 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 51 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 52 | SolidotStoryManager.shared.cacheList() 53 | } 54 | 55 | func applicationDidEnterBackground(_ application: UIApplication) { 56 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 57 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 58 | SolidotStoryManager.shared.cacheList() 59 | } 60 | 61 | func applicationWillEnterForeground(_ application: UIApplication) { 62 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 63 | } 64 | 65 | func applicationDidBecomeActive(_ application: UIApplication) { 66 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 67 | } 68 | 69 | func applicationWillTerminate(_ application: UIApplication) { 70 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 71 | SolidotStoryManager.shared.cacheList() 72 | } 73 | 74 | 75 | } 76 | 77 | -------------------------------------------------------------------------------- /Sources/Controller.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MasterController.swift 3 | // Solidot 4 | // 5 | // Created by octopus on 05/01/2018. 6 | // Copyright © 2018 Joe Wang. All rights reserved. 7 | // 8 | 9 | import Kanna 10 | import UIKit 11 | import SnapKit 12 | import SDWebImage 13 | import Alamofire 14 | import Reachability 15 | 16 | class NavigationController: UINavigationController { 17 | 18 | override func viewDidLoad() { 19 | super.viewDidLoad() 20 | navigationBar.shadowImage = UIImage() 21 | navigationBar.isTranslucent = false 22 | navigationBar.setBackgroundImage(UIImage(), for: .default) 23 | navigationBar.barTintColor = #colorLiteral(red: 0.003921568627, green: 0.3254901961, blue: 0.3176470588, alpha: 1) 24 | navigationBar.tintColor = .white 25 | } 26 | 27 | } 28 | 29 | class MasterController: UITableViewController, UIViewControllerPreviewingDelegate { 30 | 31 | var reachability = Reachability() 32 | var lastSelected:IndexPath? 33 | var manager = SolidotStoryManager.shared 34 | var storyListObservation:NSKeyValueObservation? 35 | var loadingObservation:NSKeyValueObservation? 36 | var endedObservation:NSKeyValueObservation? 37 | var refreshObservation:NSKeyValueObservation? 38 | var detail:DetailController? 39 | let footerView = UIView() 40 | let indicator = UIActivityIndicatorView() 41 | var errorView = UIView() 42 | private var _title:String = "" 43 | var titleView = UIImageView(image: #imageLiteral(resourceName: "logo_2015")) 44 | 45 | override func viewDidLoad() { 46 | super.viewDidLoad() 47 | 48 | refreshControl = UIRefreshControl() 49 | refreshControl?.layer.zPosition = -1 50 | refreshControl?.addTarget(self, action: #selector(refresh), for: .valueChanged) 51 | 52 | indicator.activityIndicatorViewStyle = .whiteLarge 53 | indicator.tintColor = .gray 54 | indicator.color = .gray 55 | indicator.hidesWhenStopped = true 56 | indicator.frame = CGRect(x: (UIScreen.main.bounds.width - 44) / 2, y: 8, width: 44, height: 44) 57 | 58 | footerView.frame = CGRect(origin: .zero, size: CGSize(width: UIScreen.main.bounds.width, height: 60)) 59 | footerView.addSubview(indicator) 60 | 61 | tableView.register(StoryCell.self, forCellReuseIdentifier: "cell") 62 | tableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0) 63 | tableView.separatorColor = #colorLiteral(red: 0.8039215803, green: 0.8039215803, blue: 0.8039215803, alpha: 1) 64 | tableView.rowHeight = UITableViewAutomaticDimension 65 | tableView.allowsMultipleSelection = false 66 | tableView.backgroundColor = #colorLiteral(red: 0.9098039216, green: 0.9098039216, blue: 0.9098039216, alpha: 1) 67 | tableView.tableHeaderView = UIView() 68 | tableView.tableFooterView = UIView() 69 | tableView.estimatedRowHeight = 100 70 | tableView.tableFooterView = footerView 71 | if #available(iOS 9.0, *) { 72 | tableView.cellLayoutMarginsFollowReadableWidth = false 73 | } 74 | 75 | storyListObservation = manager.observe(\.storyList) { object, change in 76 | if Thread.isMainThread { 77 | self.update() 78 | self.tableView.reloadData() 79 | } else { 80 | DispatchQueue.main.async { 81 | self.update() 82 | self.tableView.reloadData() 83 | } 84 | } 85 | } 86 | 87 | refreshObservation = manager.observe(\.refresh) { object, change in 88 | if Thread.isMainThread { 89 | self.update() 90 | } else { 91 | DispatchQueue.main.async { 92 | self.update() 93 | } 94 | } 95 | } 96 | 97 | loadingObservation = manager.observe(\.loading) { object, change in 98 | if object.refresh { 99 | return 100 | } 101 | 102 | if Thread.isMainThread { 103 | self.update() 104 | } else { 105 | DispatchQueue.main.async { 106 | self.update() 107 | } 108 | } 109 | } 110 | 111 | setupTitleView() 112 | manager.restoreList() 113 | setupError() 114 | refresh() 115 | } 116 | 117 | override func viewWillDisappear(_ animated: Bool) { 118 | super.viewWillDisappear(animated) 119 | } 120 | 121 | func update() { 122 | errorView.isHidden = (manager.storyList.count != 0) 123 | updateRefresh() 124 | updateLoader() 125 | } 126 | 127 | func setupError() { 128 | let icon = UIImageView(image: #imageLiteral(resourceName: "937-wifi-signal")) 129 | let label = UILabel() 130 | label.text = "no_data_drag_to_refresh".localized() 131 | label.textAlignment = .center 132 | icon.contentMode = .scaleAspectFit 133 | errorView.addSubview(icon) 134 | errorView.addSubview(label) 135 | icon.snp.makeConstraints { make in 136 | make.width.height.equalTo(44) 137 | make.centerX.equalToSuperview() 138 | make.centerY.equalToSuperview().offset(-44) 139 | } 140 | label.snp.makeConstraints { make in 141 | make.top.equalTo(icon.snp.bottom).offset(10) 142 | make.width.equalToSuperview() 143 | make.height.equalTo(30) 144 | } 145 | view.addSubview(errorView) 146 | errorView.snp.makeConstraints { make in 147 | make.center.width.height.equalToSuperview() 148 | } 149 | errorView.backgroundColor = #colorLiteral(red: 0.9098039216, green: 0.9098039216, blue: 0.9098039216, alpha: 1) 150 | errorView.isHidden = true 151 | errorView.layer.zPosition = 999 152 | errorView.isUserInteractionEnabled = true 153 | } 154 | 155 | func updateLoader() { 156 | if manager.loading { 157 | indicator.startAnimating() 158 | } else { 159 | indicator.stopAnimating() 160 | } 161 | } 162 | 163 | func updateRefresh() { 164 | if manager.refresh { 165 | refreshControl?.beginRefreshing() 166 | } else { 167 | refreshControl?.endRefreshing() 168 | } 169 | } 170 | 171 | @objc func refresh() { 172 | manager.fetchStories() 173 | } 174 | 175 | override open func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { 176 | if indexPath.row == manager.storyList.count - 1 { 177 | if !manager.loading { 178 | DispatchQueue.global(qos: .userInitiated).async { 179 | self.manager.yesterdayIssue() 180 | } 181 | } 182 | } 183 | } 184 | 185 | func previewingContext(_ previewingContext: UIViewControllerPreviewing, commit viewControllerToCommit: UIViewController) { 186 | show(viewControllerToCommit, sender: self) 187 | } 188 | 189 | func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? { 190 | if #available(iOS 9.0, *) { 191 | if let cell = previewingContext.sourceView as? StoryCell { 192 | if let indexPath = tableView.indexPath(for: cell) { 193 | detail = DetailController() 194 | detail?.story = manager.storyList[indexPath.row] 195 | detail?.storyIndex = indexPath.row 196 | } 197 | } 198 | } 199 | return detail 200 | } 201 | 202 | override func viewWillAppear(_ animated: Bool) { 203 | super.viewWillAppear(animated) 204 | UIApplication.shared.setStatusBarStyle(.lightContent, animated: animated) 205 | 206 | self.update() 207 | 208 | if detail != nil { 209 | let offsetIndexPath = IndexPath(row: detail!.storyIndex, section: 0) 210 | if lastSelected != nil { 211 | tableView.deselectRow(at: lastSelected!, animated: false) 212 | } 213 | if offsetIndexPath.row != lastSelected?.row { 214 | tableView.scrollToRow(at: offsetIndexPath, at: .middle, animated: false) 215 | lastSelected = offsetIndexPath 216 | } 217 | tableView.selectRow(at: lastSelected, animated: false, scrollPosition: .middle) 218 | } 219 | } 220 | 221 | override func viewDidAppear(_ animated: Bool) { 222 | super.viewDidAppear(animated) 223 | 224 | if lastSelected != nil { 225 | tableView.deselectRow(at: lastSelected!, animated: animated) 226 | } 227 | } 228 | 229 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 230 | let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as? StoryCell ?? StoryCell() 231 | let story = manager.storyList[indexPath.row] 232 | 233 | cell.storyTitleLabel.text = story.title 234 | 235 | var attrString:NSMutableAttributedString! 236 | if #available(iOS 8.2, *) { 237 | attrString = NSMutableAttributedString(string: story.detail, attributes: [ 238 | NSAttributedStringKey.font: UIFont.systemFont(ofSize: 15, weight: .light), 239 | NSAttributedStringKey.foregroundColor: #colorLiteral(red: 0.1930259168, green: 0.1930313706, blue: 0.19302845, alpha: 1) 240 | ]) 241 | } else { 242 | attrString = NSMutableAttributedString(string: story.detail, attributes: [ 243 | NSAttributedStringKey.font: UIFont.systemFont(ofSize: 15), 244 | NSAttributedStringKey.foregroundColor: #colorLiteral(red: 0.1930259168, green: 0.1930313706, blue: 0.19302845, alpha: 1) 245 | ]) 246 | } 247 | 248 | if #available(iOS 9.0, *) { 249 | if( traitCollection.forceTouchCapability == .available){ 250 | registerForPreviewing(with: self, sourceView: cell) 251 | } 252 | } 253 | 254 | let style = NSMutableParagraphStyle() 255 | style.lineBreakMode = .byCharWrapping 256 | style.lineSpacing = 4.5 257 | style.paragraphSpacing = 1.2 258 | style.lineBreakMode = .byTruncatingTail 259 | attrString.addAttribute(NSAttributedStringKey.paragraphStyle, value: style, range: NSRange(location: 0, length: story.detail.count)) 260 | 261 | cell.topicImageView.sd_setImage(with: story.topicImage) 262 | 263 | if story.topicImage != nil { 264 | cell.imageConstraint.constant = 12 265 | } else { 266 | cell.imageConstraint.constant = -48 267 | } 268 | cell.storyDescLabel.text = String(format:"%@_dept".localized(), story.dept) 269 | cell.storyDetailLabel.attributedText = attrString 270 | return cell 271 | } 272 | 273 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 274 | lastSelected = indexPath 275 | 276 | detail = DetailController() 277 | detail?.story = manager.storyList[indexPath.row] 278 | detail?.storyIndex = indexPath.row 279 | navigationController?.pushViewController(detail!, animated: true) 280 | } 281 | 282 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 283 | return manager.storyList.count 284 | } 285 | 286 | override func didReceiveMemoryWarning() { 287 | super.didReceiveMemoryWarning() 288 | } 289 | 290 | func setupTitleView() { 291 | titleView.frame = CGRect(x: 0, y: 0, width: 164, height: 30) 292 | titleView.contentMode = .scaleAspectFit 293 | navigationItem.titleView = UIView() 294 | navigationItem.titleView?.addSubview(titleView) 295 | titleView.snp.makeConstraints { make in 296 | make.width.equalTo(164) 297 | make.height.equalTo(30) 298 | make.center.equalToSuperview() 299 | } 300 | } 301 | } 302 | 303 | class DetailController: UITableViewController, UIGestureRecognizerDelegate { 304 | 305 | var story:StoryModel! 306 | var storyIndex:Int = 0 307 | var manager = SolidotStoryManager.shared 308 | 309 | private var _title:String = "" 310 | public var titleView:UILabel? 311 | public var navigationTitle:String? { 312 | get { 313 | return _title 314 | } 315 | set { 316 | _title = newValue ?? "" 317 | titleView?.text = _title 318 | titleView?.sizeToFit() 319 | } 320 | } 321 | var storyListObservation:NSKeyValueObservation? 322 | var loadingObservation:NSKeyValueObservation? 323 | 324 | override func viewDidLoad() { 325 | super.viewDidLoad() 326 | 327 | tableView.register(DetailHeaderCell.self, forCellReuseIdentifier: "headerCell") 328 | tableView.register(DetailCell.self, forCellReuseIdentifier: "detailCell") 329 | tableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0) 330 | tableView.separatorColor = #colorLiteral(red: 0.8039215803, green: 0.8039215803, blue: 0.8039215803, alpha: 1) 331 | tableView.rowHeight = UITableViewAutomaticDimension 332 | tableView.allowsMultipleSelection = false 333 | tableView.backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1) 334 | tableView.tableHeaderView = UIView() 335 | tableView.tableFooterView = UIView() 336 | tableView.estimatedRowHeight = 100 337 | if #available(iOS 9.0, *) { 338 | tableView.cellLayoutMarginsFollowReadableWidth = false 339 | } 340 | 341 | let backBarItem:UIBarButtonItem = UIBarButtonItem(image: #imageLiteral(resourceName: "Icon-Back"), style: .plain, target: self, action: #selector(self.backToPrevious)) 342 | 343 | navigationItem.leftBarButtonItems = [backBarItem] 344 | 345 | let frame = CGRect(x: 0, y: 0, width: 18, height: 24) 346 | let shareBtn = UIBarButtonItem(customView: imageBtn(image: #imageLiteral(resourceName: "702-share"), rect: frame, target: self, action: #selector(share))) 347 | navigationItem.rightBarButtonItem = shareBtn 348 | navigationItem.rightBarButtonItem?.tintColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1) 349 | 350 | if let navigationController = navigationController { 351 | if navigationController.viewControllers.count > 2 { 352 | let closeBarItem:UIBarButtonItem = UIBarButtonItem(image: #imageLiteral(resourceName: "Icon-Close"), style: .plain, target: self, action: #selector(self.popToRoot)) 353 | navigationItem.leftBarButtonItems = [backBarItem, closeBarItem] 354 | } 355 | } 356 | 357 | storyListObservation = manager.observe(\.storyList) { object, change in 358 | if self.tableView.numberOfRows(inSection: 0) < 2 { 359 | return 360 | } 361 | 362 | if Thread.isMainThread { 363 | self.tableView.reloadRows(at: [IndexPath(row: 2, section: 0)], with: .automatic) 364 | } else { 365 | DispatchQueue.main.async { 366 | self.tableView.reloadRows(at: [IndexPath(row: 2, section: 0)], with: .automatic) 367 | } 368 | } 369 | } 370 | 371 | setupTitleView() 372 | navigationTitle = String(format:"published_in_%@".localized(), timeAgoStringFromDate(date: story.published) ?? "") 373 | } 374 | 375 | @objc func share() { 376 | if story.url != nil { 377 | let safari = SafariActivity() 378 | let activity = UIActivityViewController(activityItems: [story.url!], applicationActivities: [safari]) 379 | activity.excludedActivityTypes = [.print] 380 | self.present(activity, animated: true, completion: nil) 381 | } 382 | } 383 | 384 | override func viewWillDisappear(_ animated: Bool) { 385 | super.viewWillDisappear(animated) 386 | storyListObservation?.invalidate() 387 | } 388 | 389 | func reloadData() { 390 | DispatchQueue.main.async { 391 | self.navigationTitle = String(format:"published_in_%@".localized(), self.timeAgoStringFromDate(date: self.story.published) ?? "") 392 | self.tableView.reloadSections([0], with: .automatic) 393 | self.tableView.scrollToRow(at: IndexPath(row: 0, section: 0), at: .top, animated: true) 394 | } 395 | } 396 | 397 | override func viewWillAppear(_ animated: Bool) { 398 | super.viewWillAppear(animated) 399 | navigationController?.interactivePopGestureRecognizer?.delegate = self 400 | tableView.reloadSections([0], with: .automatic) 401 | } 402 | 403 | func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { 404 | if gestureRecognizer == navigationController?.interactivePopGestureRecognizer { 405 | return navigationController!.viewControllers.count > 1 406 | } 407 | return true 408 | } 409 | 410 | @objc func popToRoot() { 411 | navigationController?.popToRootViewController(animated: true) 412 | } 413 | 414 | @objc func backToPrevious(){ 415 | navigationController?.popViewController(animated: true) 416 | } 417 | 418 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 419 | tableView.deselectRow(at: indexPath, animated: false) 420 | if indexPath.row < 2 { 421 | 422 | } else if indexPath.row == 2 { 423 | if let previous = manager.previous(index: storyIndex) { 424 | self.story = previous 425 | self.storyIndex += 1 426 | if #available(iOS 10.0, *) { 427 | let generator = UIImpactFeedbackGenerator(style: .light) 428 | generator.impactOccurred() 429 | } 430 | reloadData() 431 | } 432 | } else { 433 | if let next = manager.next(index: storyIndex) { 434 | self.story = next 435 | self.storyIndex -= 1 436 | if #available(iOS 10.0, *) { 437 | let generator = UIImpactFeedbackGenerator(style: .light) 438 | generator.impactOccurred() 439 | } 440 | reloadData() 441 | } 442 | } 443 | 444 | } 445 | 446 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 447 | 448 | if indexPath.row == 0 { 449 | return retireCell(story, "", UIFont.systemFont(ofSize: 22)) 450 | } else if indexPath.row == 1 { 451 | let cell = tableView.dequeueReusableCell(withIdentifier: "detailCell") as? DetailCell ?? DetailCell() 452 | 453 | if let _ = navigationController { 454 | cell.detailTextHTML = story.detailHTML 455 | } else { 456 | cell.detailText = story.detail 457 | } 458 | 459 | return cell 460 | } else if indexPath.row == 2 { 461 | if let previous = manager.previous(index: storyIndex) { 462 | return retireCell(previous, "prev_story_".localized(), UIFont.boldSystemFont(ofSize: 16)) 463 | } else { 464 | let model = StoryModel() 465 | model.title = "loading".localized() 466 | model.dept = "from_the_robot_dept".localized() 467 | 468 | if !manager.loading { 469 | DispatchQueue.global(qos: .userInitiated).async { 470 | self.manager.yesterdayIssue() 471 | } 472 | } 473 | 474 | return retireCell(model, "", UIFont.systemFont(ofSize: 18)) 475 | } 476 | } else { 477 | if let next = manager.next(index: storyIndex) { 478 | return retireCell(next, "next_story_".localized(), UIFont.boldSystemFont(ofSize: 16)) 479 | } 480 | } 481 | 482 | return UITableViewCell() 483 | } 484 | 485 | func retireCell(_ story:StoryModel, _ titlePrefix:String = "", _ font:UIFont? = nil) -> UITableViewCell { 486 | let cell = tableView.dequeueReusableCell(withIdentifier: "headerCell") as? DetailHeaderCell ?? DetailHeaderCell() 487 | 488 | if story.topicImage != nil { 489 | cell.imageConstraint.constant = 12 490 | } else { 491 | cell.imageConstraint.constant = -48 492 | } 493 | cell.storyTitleLabel.text = "\(titlePrefix)\(story.title)" 494 | cell.storyTitleLabel.font = font 495 | cell.topicImageView.sd_setImage(with: story.topicImage) 496 | cell.storyDescLabel.text = String(format:"%@_dept".localized(), story.dept) 497 | 498 | return cell 499 | } 500 | 501 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 502 | var rows = 3 503 | if let _ = SolidotStoryManager.shared.next(index: storyIndex) { 504 | rows += 1 505 | } 506 | return rows 507 | } 508 | 509 | func setupTitleView() { 510 | titleView = UILabel() 511 | titleView?.text = _title 512 | titleView?.textAlignment = NSTextAlignment.center 513 | titleView?.font = UIFont.boldSystemFont(ofSize: 17.0) 514 | titleView?.textColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1) 515 | titleView?.sizeToFit() 516 | navigationItem.titleView = titleView 517 | } 518 | 519 | func timeAgoStringFromDate(date: Date) -> String? { 520 | let formatter = DateComponentsFormatter() 521 | formatter.unitsStyle = .full 522 | 523 | let now = Date() 524 | 525 | let calendar = NSCalendar.current 526 | let components1: Set = [.year, .month, .weekOfMonth, .day, .hour, .minute, .second] 527 | let components = calendar.dateComponents(components1, from: date, to: now) 528 | 529 | if components.year ?? 0 > 0 { 530 | formatter.allowedUnits = .year 531 | } else if components.month ?? 0 > 0 { 532 | formatter.allowedUnits = .month 533 | } else if components.weekOfMonth ?? 0 > 0 { 534 | formatter.allowedUnits = .weekOfMonth 535 | } else if components.day ?? 0 > 0 { 536 | formatter.allowedUnits = .day 537 | } else if components.hour ?? 0 > 0 { 538 | formatter.allowedUnits = [.hour] 539 | } else if components.minute ?? 0 > 0 { 540 | formatter.allowedUnits = .minute 541 | } else { 542 | formatter.allowedUnits = .second 543 | } 544 | 545 | let formatString = NSLocalizedString("%@_ago", comment: "Used to say how much time has passed. e.g. '2 hours ago'") 546 | 547 | guard let timeString = formatter.string(for: components) else { 548 | return nil 549 | } 550 | return String(format: formatString, timeString) 551 | } 552 | 553 | func imageBtn(image:UIImage, rect:CGRect, target: Any?, action: Selector?) -> UIImageView { 554 | let 🖼 = UIImageView(image: image.withRenderingMode(UIImageRenderingMode.alwaysTemplate)) 555 | let 👆 = UITapGestureRecognizer(target: target, action: action) 556 | 👆.numberOfTapsRequired = 1 557 | 🖼.isUserInteractionEnabled = true 558 | 🖼.frame = rect 559 | 🖼.addGestureRecognizer(👆) 560 | return 🖼 561 | } 562 | } 563 | 564 | -------------------------------------------------------------------------------- /Sources/Extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Extension.swift 3 | // Solidot 4 | // 5 | // Created by octopus on 06/01/2018. 6 | // Copyright © 2018 Joe Wang. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Foundation 11 | 12 | extension UINavigationBar { 13 | 14 | func setGradientBackground(colors: [UIColor]) { 15 | 16 | var updatedFrame = bounds 17 | updatedFrame.size.height += 20 18 | let gradientLayer = CAGradientLayer(frame: updatedFrame, colors: colors) 19 | 20 | barTintColor = UIColor(patternImage: gradientLayer.creatGradientImage() ?? UIImage()) 21 | } 22 | } 23 | 24 | extension String { 25 | 26 | var htmlToAttributedString: NSAttributedString { 27 | guard let data = data(using: .utf8) else { return NSAttributedString() } 28 | do { 29 | return try NSAttributedString(data: data, options: [ 30 | NSAttributedString.DocumentReadingOptionKey.documentType: NSAttributedString.DocumentType.html, 31 | NSAttributedString.DocumentReadingOptionKey.characterEncoding: String.Encoding.utf8.rawValue 32 | ], documentAttributes: nil) 33 | } catch let error as NSError { 34 | print(error.localizedDescription) 35 | return NSAttributedString() 36 | } 37 | } 38 | 39 | var html2String: String { 40 | return htmlToAttributedString.string 41 | } 42 | 43 | func condenseWhitespace() -> String { 44 | let components = self.components(separatedBy: .whitespacesAndNewlines) 45 | return components.filter { !$0.isEmpty }.joined(separator: " ") 46 | } 47 | 48 | func matches(for regex: String) -> [String] { 49 | do { 50 | let regex = try NSRegularExpression(pattern: regex) 51 | let nsString = self as NSString 52 | let results = regex.matches(in: self, range: NSRange(location: 0, length: nsString.length)) 53 | return results.map { nsString.substring(with: $0.range)} 54 | } catch { 55 | return [] 56 | } 57 | } 58 | 59 | func localized(bundle: Bundle = .main, tableName: String = "Localizable") -> String { 60 | return NSLocalizedString(self, tableName: tableName, value: "**\(self)**", comment: "") 61 | } 62 | } 63 | 64 | extension Date { 65 | var yesterday: Date { 66 | return Calendar.current.date(byAdding: .day, value: -1, to: noon)! 67 | } 68 | var tomorrow: Date { 69 | return Calendar.current.date(byAdding: .day, value: 1, to: noon)! 70 | } 71 | var noon: Date { 72 | return Calendar.current.date(bySettingHour: 12, minute: 0, second: 0, of: self)! 73 | } 74 | var month: Int { 75 | return Calendar.current.component(.month, from: self) 76 | } 77 | var isLastDayOfMonth: Bool { 78 | return tomorrow.month != month 79 | } 80 | } 81 | 82 | extension CAGradientLayer { 83 | 84 | convenience init(frame: CGRect, colors: [UIColor]) { 85 | self.init() 86 | self.frame = frame 87 | self.colors = [] 88 | for color in colors { 89 | self.colors?.append(color.cgColor) 90 | } 91 | startPoint = CGPoint(x: 0, y: 0) 92 | endPoint = CGPoint(x: 0, y: 1) 93 | } 94 | 95 | func creatGradientImage() -> UIImage? { 96 | 97 | var image: UIImage? = nil 98 | UIGraphicsBeginImageContext(bounds.size) 99 | if let context = UIGraphicsGetCurrentContext() { 100 | render(in: context) 101 | image = UIGraphicsGetImageFromCurrentImageContext() 102 | } 103 | UIGraphicsEndImageContext() 104 | return image 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /Sources/Manager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Manager.swift 3 | // Solidot 4 | // 5 | // Created by octopus on 06/01/2018. 6 | // Copyright © 2018 Joe Wang. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class SolidotStoryManager:NSObject { 12 | 13 | static let shared = SolidotStoryManager() 14 | @objc dynamic var storyList:[StoryModel] = [] 15 | @objc dynamic var loading = false 16 | @objc dynamic var ended = false 17 | @objc dynamic var refresh = false 18 | public var issueDate:Date? 19 | 20 | private var listFilePath:String { 21 | get { 22 | let manager = FileManager.default 23 | let url = manager.urls(for: .documentDirectory, in: .userDomainMask).first 24 | return url!.appendingPathComponent("Data/CachedStoryList.v1.data").path 25 | } 26 | } 27 | 28 | override private init() { 29 | super.init() 30 | } 31 | 32 | func fetchStories( _ date:Date? = nil ) { 33 | if refresh { 34 | return 35 | } 36 | 37 | if loading { 38 | return 39 | } 40 | 41 | var issueDate:String? 42 | if let date = date { 43 | let formatter = DateFormatter() 44 | formatter.dateFormat = "yyyyMMdd" 45 | issueDate = formatter.string(from: date) 46 | } else { 47 | refresh = true 48 | } 49 | 50 | loading = true 51 | 52 | // Retire issues list 53 | SolidotService.shared.list(issueDate, { result in 54 | self.loading = false 55 | self.ended = (result.count == 0) 56 | if self.refresh { 57 | self.storyList = [] 58 | self.refresh = false 59 | } 60 | self.updateList(list: result) 61 | }, errorHandler) 62 | } 63 | 64 | func yesterdayIssue() { 65 | if issueDate == nil { 66 | issueDate = Date() 67 | } else { 68 | issueDate = issueDate?.yesterday 69 | } 70 | fetchStories(issueDate) 71 | } 72 | 73 | func updateList(list:[StoryModel]) { 74 | for story in list { 75 | let confilicts = storyList.filter { model -> Bool in 76 | return model.sid == story.sid 77 | } 78 | if confilicts.count == 0 { 79 | storyList.append(story) 80 | } 81 | } 82 | 83 | storyList.sort { a, b -> Bool in 84 | return a.sid > b.sid 85 | } 86 | } 87 | 88 | func cacheList() { 89 | if self.storyList.count == 0 { 90 | return 91 | } 92 | DispatchQueue.global(qos: .userInitiated).async { 93 | let max = (self.storyList.count >= 99) ? 99 : self.storyList.count - 1 94 | let cachedList = Array(self.storyList[.. StoryModel? { 122 | if storyList.count <= index { 123 | return nil 124 | } 125 | return (index + 1) < storyList.count ? storyList[index + 1] : nil 126 | } 127 | 128 | func next(index:Int) -> StoryModel? { 129 | if storyList.count <= index { 130 | return nil 131 | } 132 | return (index > 0) ? storyList[index - 1] : nil 133 | } 134 | 135 | } 136 | -------------------------------------------------------------------------------- /Sources/Model.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Model.swift 3 | // Solidot 4 | // 5 | // Created by octopus on 06/01/2018. 6 | // Copyright © 2018 Joe Wang. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | enum StorySourceType:String { 12 | case solidot 13 | } 14 | 15 | class StoryModel: NSObject, NSCoding { 16 | var sid:Int = 0 17 | var title:String = "" 18 | var detail:String = "" 19 | var detailHTML:String = "" 20 | var url:URL? 21 | var image:URL? 22 | var topicImage:URL? 23 | var desc:String = "" 24 | var dept:String = "" 25 | var author:String = "" 26 | var published:Date = Date() 27 | var source:StorySourceType = .solidot 28 | var readed:Bool = false 29 | 30 | override init() { 31 | super.init() 32 | } 33 | 34 | required init?(coder aDecoder: NSCoder) { 35 | sid = aDecoder.decodeInteger(forKey: "sid") 36 | title = aDecoder.decodeObject(forKey: "title") as? String ?? "" 37 | detail = aDecoder.decodeObject(forKey: "detail") as? String ?? "" 38 | detailHTML = aDecoder.decodeObject(forKey: "detailHTML") as? String ?? "" 39 | url = aDecoder.decodeObject(forKey: "url") as? URL 40 | image = aDecoder.decodeObject(forKey: "image") as? URL 41 | topicImage = aDecoder.decodeObject(forKey: "topicImage") as? URL 42 | desc = aDecoder.decodeObject(forKey: "desc") as? String ?? "" 43 | dept = aDecoder.decodeObject(forKey: "dept") as? String ?? "" 44 | author = aDecoder.decodeObject(forKey: "author") as? String ?? "" 45 | published = aDecoder.decodeObject(forKey: "published") as? Date ?? Date() 46 | readed = aDecoder.decodeBool(forKey: "readed") 47 | let sourceStr = aDecoder.decodeObject(forKey: "dept") as? String 48 | if sourceStr != nil { 49 | source = StorySourceType.init(rawValue: sourceStr!) ?? .solidot 50 | } else { 51 | source = .solidot 52 | } 53 | } 54 | 55 | func encode(with aCoder: NSCoder) { 56 | aCoder.encode(sid, forKey: "sid") 57 | aCoder.encode(title, forKey: "title") 58 | aCoder.encode(detail, forKey: "detail") 59 | aCoder.encode(detailHTML, forKey: "detailHTML") 60 | aCoder.encode(url, forKey: "url") 61 | aCoder.encode(image, forKey: "image") 62 | aCoder.encode(topicImage, forKey: "topicImage") 63 | aCoder.encode(desc, forKey: "desc") 64 | aCoder.encode(dept, forKey: "dept") 65 | aCoder.encode(author, forKey: "author") 66 | aCoder.encode(published, forKey: "published") 67 | aCoder.encode(source.rawValue, forKey: "source") 68 | aCoder.encode(readed, forKey: "readed") 69 | } 70 | 71 | override var description: String { 72 | get { 73 | return "\(sid) - \(published):\(title)" 74 | } 75 | } 76 | } 77 | 78 | 79 | class StoryModels: NSObject, NSCoding { 80 | var sid:Int = 0 81 | var title:String = "" 82 | var detail:String = "" 83 | var detailHTML:String = "" 84 | var url:URL? 85 | var image:URL? 86 | var topicImage:URL? 87 | var desc:String = "" 88 | var dept:String = "" 89 | var author:String = "" 90 | var published:Date = Date() 91 | var source:StorySourceType = .solidot 92 | var readed:Bool = false 93 | 94 | override init() { 95 | super.init() 96 | } 97 | 98 | required init?(coder aDecoder: NSCoder) { 99 | sid = aDecoder.decodeInteger(forKey: "sid") 100 | title = aDecoder.decodeObject(forKey: "title") as? String ?? "" 101 | detail = aDecoder.decodeObject(forKey: "detail") as? String ?? "" 102 | detailHTML = aDecoder.decodeObject(forKey: "detailHTML") as? String ?? "" 103 | url = aDecoder.decodeObject(forKey: "url") as? URL 104 | image = aDecoder.decodeObject(forKey: "image") as? URL 105 | topicImage = aDecoder.decodeObject(forKey: "topicImage") as? URL 106 | desc = aDecoder.decodeObject(forKey: "desc") as? String ?? "" 107 | dept = aDecoder.decodeObject(forKey: "dept") as? String ?? "" 108 | author = aDecoder.decodeObject(forKey: "author") as? String ?? "" 109 | published = aDecoder.decodeObject(forKey: "published") as? Date ?? Date() 110 | readed = aDecoder.decodeBool(forKey: "readed") 111 | let sourceStr = aDecoder.decodeObject(forKey: "dept") as? String 112 | if sourceStr != nil { 113 | source = StorySourceType.init(rawValue: sourceStr!) ?? .solidot 114 | } else { 115 | source = .solidot 116 | } 117 | } 118 | 119 | func encode(with aCoder: NSCoder) { 120 | aCoder.encode(sid, forKey: "sid") 121 | aCoder.encode(title, forKey: "title") 122 | aCoder.encode(detail, forKey: "detail") 123 | aCoder.encode(detailHTML, forKey: "detailHTML") 124 | aCoder.encode(url, forKey: "url") 125 | aCoder.encode(image, forKey: "image") 126 | aCoder.encode(topicImage, forKey: "topicImage") 127 | aCoder.encode(desc, forKey: "desc") 128 | aCoder.encode(dept, forKey: "dept") 129 | aCoder.encode(author, forKey: "author") 130 | aCoder.encode(published, forKey: "published") 131 | aCoder.encode(source.rawValue, forKey: "source") 132 | aCoder.encode(readed, forKey: "readed") 133 | } 134 | 135 | override var description: String { 136 | get { 137 | return "\(sid) - \(published):\(title)" 138 | } 139 | } 140 | } 141 | 142 | -------------------------------------------------------------------------------- /Sources/Service.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Service.swift 3 | // Solidot 4 | // 5 | // Created by octopus on 05/01/2018. 6 | // Copyright © 2018 Joe Wang. All rights reserved. 7 | // 8 | 9 | import Kanna 10 | import SwiftyJSON 11 | import Foundation 12 | import Alamofire 13 | 14 | class BaseService { 15 | 16 | internal init() {} 17 | 18 | func requestString( 19 | _ url: URLConvertible, 20 | method: HTTPMethod = .post, 21 | params: Parameters = [:], 22 | headers: HTTPHeaders = [:], 23 | completion: @escaping (String) -> Void, 24 | errorHandler: @escaping (Error) -> Void) 25 | -> DataRequest 26 | { 27 | if Thread.isMainThread { 28 | UIApplication.shared.isNetworkActivityIndicatorVisible = true 29 | } else { 30 | DispatchQueue.main.async { 31 | UIApplication.shared.isNetworkActivityIndicatorVisible = true 32 | } 33 | } 34 | 35 | let request = Alamofire.request( 36 | url, method: method, 37 | parameters: params, 38 | encoding: URLEncoding.default, 39 | headers: headers) 40 | 41 | request.validate().responseString { response in 42 | if Thread.isMainThread { 43 | UIApplication.shared.isNetworkActivityIndicatorVisible = false 44 | } else { 45 | DispatchQueue.main.async { 46 | UIApplication.shared.isNetworkActivityIndicatorVisible = false 47 | } 48 | } 49 | switch response.result { 50 | case .success: 51 | completion(response.result.value ?? "") 52 | case .failure(let error): 53 | errorHandler(error) 54 | } 55 | } 56 | 57 | return request 58 | } 59 | } 60 | 61 | class SolidotService: BaseService { 62 | 63 | let urlBase = "https://www.solidot.org" 64 | var request:Request? 65 | 66 | static let shared = SolidotService() 67 | 68 | override private init() {} 69 | 70 | func list(_ date:String?, 71 | _ completionHandler: @escaping (_ data:[StoryModel]) -> Void, 72 | _ errorHandler: @escaping (_ error:Error) -> Void) { 73 | 74 | var params:Parameters = [:] 75 | 76 | if let date = date { 77 | params = ["issue": date] 78 | } 79 | 80 | if request != nil { 81 | request?.cancel() 82 | request = nil 83 | } 84 | 85 | request = requestString("\(urlBase)", method: .get, params: params, headers: [:], completion: { result in 86 | 87 | self.request = nil 88 | 89 | do { 90 | let doc = try Kanna.HTML(html: result, encoding: String.Encoding.utf8) 91 | var list:[StoryModel] = [] 92 | 93 | for newsBlock in doc.css(".block_m") { 94 | let model = StoryModel() 95 | 96 | let titles = newsBlock.css(".ct_tittle h2 a") 97 | var urlString = "" 98 | if titles.count > 1 { 99 | urlString = titles[1]["href"] ?? "" 100 | model.title = (titles[1].text ?? "").trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) 101 | } else if titles.count > 0 { 102 | urlString = titles[0]["href"] ?? "" 103 | model.title = (titles[0].text ?? "").trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) 104 | } 105 | 106 | if urlString.range(of: "http") == nil { 107 | urlString = "http://www.solidot.org\(urlString)" 108 | } 109 | let matches = urlString.matches(for: "/story\\?sid=[0-9]+") 110 | if matches.count > 0 { 111 | let number = matches[0].replacingOccurrences(of: "/story?sid=", with: "") 112 | model.sid = Int(number) ?? -1 113 | } 114 | model.url = URL(string: urlString) 115 | 116 | if let img = newsBlock.at_css(".p_content .limg") { 117 | model.image = URL(string: img["src"] ?? "") 118 | } 119 | 120 | if let desc = newsBlock.at_css(".talk_time") { 121 | let cleanString = desc.text?.condenseWhitespace() 122 | model.desc = cleanString ?? "" 123 | } 124 | 125 | if let dept = newsBlock.at_css(".talk_time b") { 126 | let cleanString = dept.text?.condenseWhitespace() 127 | model.dept = cleanString ?? "" 128 | } 129 | 130 | if let topicImage = newsBlock.at_css(".talk_time .icon_float img") { 131 | model.topicImage = URL(string: "http:" + (topicImage["src"] ?? "")) 132 | } 133 | 134 | if let time = newsBlock.at_css(".talk_time") { 135 | let cleanString = time.text?.condenseWhitespace() 136 | if let matches = cleanString?.matches(for: "[0-9]+年[0-9]+月[0-9]+日 [0-9]+时[0-9]+分") { 137 | if matches.count > 0 { 138 | let dateFormatter = DateFormatter() 139 | dateFormatter.dateFormat = "yyyy年MM月dd日 HH时mm分" 140 | model.published = dateFormatter.date(from: matches[0]) ?? Date() 141 | } 142 | } 143 | } 144 | 145 | if let detail = newsBlock.at_css(".p_content .p_mainnew") { 146 | model.detail = (detail.text ?? "").trimmingCharacters(in: .whitespacesAndNewlines) 147 | model.detailHTML = (detail.innerHTML ?? "").trimmingCharacters(in: .whitespacesAndNewlines) 148 | } 149 | 150 | model.source = .solidot 151 | 152 | list.append(model) 153 | } 154 | 155 | completionHandler(list) 156 | } catch { 157 | errorHandler(error) 158 | } 159 | }) { error in 160 | self.request = nil 161 | errorHandler(error) 162 | } 163 | } 164 | 165 | } 166 | -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/702-share.imageset/702-share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/702-share.imageset/702-share.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/702-share.imageset/702-share@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/702-share.imageset/702-share@2x.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/702-share.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "702-share.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "702-share@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/715-globe.imageset/715-globe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/715-globe.imageset/715-globe.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/715-globe.imageset/715-globe@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/715-globe.imageset/715-globe@2x.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/715-globe.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "715-globe.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "715-globe@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/937-wifi-signal.imageset/937-wifi-signal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/937-wifi-signal.imageset/937-wifi-signal.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/937-wifi-signal.imageset/937-wifi-signal@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/937-wifi-signal.imageset/937-wifi-signal@2x.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/937-wifi-signal.imageset/937-wifi-signal@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/937-wifi-signal.imageset/937-wifi-signal@3x.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/937-wifi-signal.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "937-wifi-signal.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "937-wifi-signal@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "937-wifi-signal@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-42.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-60.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-58.png", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-87.png", 25 | "scale" : "3x" 26 | }, 27 | { 28 | "size" : "40x40", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-80.png", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-121.png", 37 | "scale" : "3x" 38 | }, 39 | { 40 | "size" : "60x60", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-120.png", 43 | "scale" : "2x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-180.png", 49 | "scale" : "3x" 50 | }, 51 | { 52 | "size" : "20x20", 53 | "idiom" : "ipad", 54 | "filename" : "Icon-20.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-41.png", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "size" : "29x29", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-29.png", 67 | "scale" : "1x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-59.png", 73 | "scale" : "2x" 74 | }, 75 | { 76 | "size" : "40x40", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-40.png", 79 | "scale" : "1x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-81.png", 85 | "scale" : "2x" 86 | }, 87 | { 88 | "size" : "76x76", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-76.png", 91 | "scale" : "1x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-152.png", 97 | "scale" : "2x" 98 | }, 99 | { 100 | "size" : "83.5x83.5", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-167.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "1024x1024", 107 | "idiom" : "ios-marketing", 108 | "filename" : "Icon-1024.png", 109 | "scale" : "1x" 110 | } 111 | ], 112 | "info" : { 113 | "version" : 1, 114 | "author" : "xcode" 115 | } 116 | } -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-1024.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-120.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-121.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-121.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-152.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-167.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-167.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-180.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-20.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-29.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-40.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-41.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-41.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-42.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-42.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-58.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-58.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-59.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-59.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-60.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-76.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-80.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-81.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-81.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-87.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/AppIcon.appiconset/Icon-87.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/Icon-Back.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "Icon-Back.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "Icon-Back@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "Icon-Back@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/Icon-Back.imageset/Icon-Back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/Icon-Back.imageset/Icon-Back.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/Icon-Back.imageset/Icon-Back@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/Icon-Back.imageset/Icon-Back@2x.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/Icon-Back.imageset/Icon-Back@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/Icon-Back.imageset/Icon-Back@3x.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/Icon-Close.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "Icon-Cross.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "Icon-Cross@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "Icon-Cross@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/Icon-Close.imageset/Icon-Cross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/Icon-Close.imageset/Icon-Cross.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/Icon-Close.imageset/Icon-Cross@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/Icon-Close.imageset/Icon-Cross@2x.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/Icon-Close.imageset/Icon-Cross@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/Icon-Close.imageset/Icon-Cross@3x.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/logo_2015.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "logo_2015.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/logo_2015.imageset/logo_2015.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/logo_2015.imageset/logo_2015.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/safari.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "safari.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "safari@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "safari@3x.png", 16 | "scale" : "3x" 17 | }, 18 | { 19 | "idiom" : "ipad", 20 | "filename" : "safari~iPad.png", 21 | "scale" : "1x" 22 | }, 23 | { 24 | "idiom" : "ipad", 25 | "filename" : "safari~iPad@2x.png", 26 | "scale" : "2x" 27 | } 28 | ], 29 | "info" : { 30 | "version" : 1, 31 | "author" : "xcode" 32 | } 33 | } -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/safari.imageset/safari.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/safari.imageset/safari.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/safari.imageset/safari@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/safari.imageset/safari@2x.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/safari.imageset/safari@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/safari.imageset/safari@3x.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/safari.imageset/safari~iPad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/safari.imageset/safari~iPad.png -------------------------------------------------------------------------------- /Sources/Support Files/Assets.xcassets/safari.imageset/safari~iPad@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shar0/iOS-Solidot/8e24e36ca86ec80cf77f5b4422814ea72a2335fd/Sources/Support Files/Assets.xcassets/safari.imageset/safari~iPad@2x.png -------------------------------------------------------------------------------- /Sources/Support Files/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Solidot 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 0.1 21 | CFBundleVersion 22 | 2 23 | LSHasLocalizedDisplayName 24 | 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSAllowsArbitraryLoads 30 | 31 | NSExceptionDomains 32 | 33 | www.solidot.org 34 | 35 | NSExceptionAllowsInsecureHTTPLoads 36 | 37 | NSExceptionMinimumTLSVersion 38 | TLSv1.2 39 | NSExceptionRequiresForwardSecrecy 40 | 41 | NSIncludesSubdomains 42 | 43 | NSRequiresCertificateTransparency 44 | 45 | NSThirdPartyExceptionAllowsInsecureHTTPLoads 46 | 47 | NSThirdPartyExceptionMinimumTLSVersion 48 | TLSv1.2 49 | NSThirdPartyExceptionRequiresForwardSecrecy 50 | 51 | 52 | 53 | 54 | UILaunchStoryboardName 55 | Launch Screen 56 | UIRequiredDeviceCapabilities 57 | 58 | armv7 59 | 60 | UIRequiresFullScreen 61 | 62 | UIStatusBarStyle 63 | UIStatusBarStyleLightContent 64 | UISupportedInterfaceOrientations 65 | 66 | UIInterfaceOrientationPortrait 67 | UIInterfaceOrientationLandscapeRight 68 | UIInterfaceOrientationLandscapeLeft 69 | 70 | UISupportedInterfaceOrientations~ipad 71 | 72 | UIInterfaceOrientationPortrait 73 | UIInterfaceOrientationPortraitUpsideDown 74 | UIInterfaceOrientationLandscapeLeft 75 | UIInterfaceOrientationLandscapeRight 76 | 77 | UIViewControllerBasedStatusBarAppearance 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /Sources/Support Files/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* 2 | InfoPlist.strings 3 | Solidot 4 | 5 | Created by octopus on 07/01/2018. 6 | Copyright © 2018 Joe Wang. All rights reserved. 7 | */ 8 | 9 | "CFBundleDisplayName" = "Solidot"; 10 | "CFBundleName" = "Solidot"; 11 | -------------------------------------------------------------------------------- /Sources/Support Files/en.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* 2 | Localizable.strings 3 | Solidot 4 | 5 | Created by octopus on 07/01/2018. 6 | Copyright © 2018 Joe Wang. All rights reserved. 7 | */ 8 | 9 | "solidot" = "Solidot"; 10 | "no_data_drag_to_refresh" = "No Data, Drag to Refresh"; 11 | "refreshing" = "Refreshing"; 12 | "%@_dept" = "%@ dept."; 13 | "published_in_%@" = "Published in %@"; 14 | "%@_ago" = "%@ ago"; 15 | "prev_story_" = "Prev "; 16 | "next_story_" = "Next "; 17 | "from_the_robot_dept" = "from the robot"; 18 | "loading" = "loading..."; 19 | "open_in_safari" = "Open in Safari"; 20 | -------------------------------------------------------------------------------- /Sources/Support Files/zh-Hans.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* 2 | InfoPlist.strings 3 | Solidot 4 | 5 | Created by octopus on 07/01/2018. 6 | Copyright © 2018 Joe Wang. All rights reserved. 7 | */ 8 | 9 | "CFBundleDisplayName" = "奇客故事"; 10 | "CFBundleName" = "奇客故事"; 11 | -------------------------------------------------------------------------------- /Sources/Support Files/zh-Hans.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* 2 | Localizable.strings 3 | Solidot 4 | 5 | Created by octopus on 07/01/2018. 6 | Copyright © 2018 Joe Wang. All rights reserved. 7 | */ 8 | 9 | "solidot" = "奇客故事"; 10 | "no_data_drag_to_refresh" = "暂无数据,下拉后刷新"; 11 | "refreshing" = "正在刷新"; 12 | "%@_dept" = "%@"; 13 | "published_in_%@" = "发布于%@"; 14 | "%@_ago" = "%@前"; 15 | "prev_story_" = "上一篇 "; 16 | "next_story_" = "下一篇 "; 17 | "from_the_robot_dept" = "来自机器人"; 18 | "loading" = "加载中..."; 19 | "open_in_safari" = "在 Safari 中打开"; 20 | -------------------------------------------------------------------------------- /Sources/View.swift: -------------------------------------------------------------------------------- 1 | // 2 | // View.swift 3 | // Solidot 4 | // 5 | // Created by octopus on 06/01/2018. 6 | // Copyright © 2018 Joe Wang. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Foundation 11 | 12 | class DetailCell: UITableViewCell, UITextViewDelegate { 13 | 14 | @IBOutlet var detailView:UIView! 15 | @IBOutlet var textView:UITextView! 16 | 17 | private var _detailTextHTML = "" 18 | var detailTextHTML:String { 19 | get { 20 | return _detailTextHTML 21 | } 22 | set { 23 | _detailTextHTML = newValue 24 | textView.attributedText = htmlToAttributedString(_detailTextHTML) 25 | } 26 | } 27 | 28 | private var _detailText = "" 29 | var detailText:String { 30 | get { 31 | return _detailText 32 | } 33 | set { 34 | _detailText = newValue 35 | textView.text = _detailText 36 | } 37 | } 38 | 39 | required init(coder aDecoder: NSCoder) { 40 | super.init(coder: aDecoder)! 41 | setup() 42 | } 43 | 44 | override init(style: UITableViewCellStyle, reuseIdentifier: String?) { 45 | super.init(style: style, reuseIdentifier: reuseIdentifier) 46 | setup() 47 | } 48 | 49 | func setup() { 50 | Bundle.main.loadNibNamed("Detail View", owner: self, options: nil) 51 | addSubview(detailView) 52 | textView.delegate = self 53 | detailView.snp.makeConstraints { make in 54 | make.top.equalToSuperview().offset(0) 55 | make.left.equalToSuperview().offset(0) 56 | make.right.equalToSuperview().offset(0) 57 | make.bottom.equalToSuperview().offset(0) 58 | } 59 | } 60 | 61 | @available(iOS 10.0, *) 62 | func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool { 63 | UIApplication.shared.open(URL, options: [:]) 64 | return true 65 | } 66 | 67 | func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange) -> Bool { 68 | UIApplication.shared.openURL(URL) 69 | return true 70 | } 71 | 72 | func htmlToAttributedString(_ string: String) -> NSAttributedString { 73 | guard let data = string.data(using: .utf8) else { return NSAttributedString() } 74 | do { 75 | let attr = try NSMutableAttributedString(data: data, options: [ 76 | NSAttributedString.DocumentReadingOptionKey.documentType: NSAttributedString.DocumentType.html, 77 | NSAttributedString.DocumentReadingOptionKey.characterEncoding: String.Encoding.utf8.rawValue, 78 | ], documentAttributes: nil) 79 | 80 | let style = NSMutableParagraphStyle() 81 | style.lineSpacing = 8 82 | style.paragraphSpacing = 1.4 83 | let fontSize:CGFloat = (UIDevice.current.userInterfaceIdiom == .pad) ? 22 : 18 84 | 85 | if #available(iOS 8.2, *), UIDevice.current.userInterfaceIdiom == .pad { 86 | attr.addAttributes([ 87 | NSAttributedStringKey.font: UIFont.systemFont(ofSize: fontSize, weight: .light), 88 | NSAttributedStringKey.foregroundColor: #colorLiteral(red: 0.1930259168, green: 0.1930313706, blue: 0.19302845, alpha: 1), 89 | NSAttributedStringKey.paragraphStyle: style 90 | ], range: NSRange(location: 0, length: attr.string.count)) 91 | } else { 92 | attr.addAttributes([ 93 | NSAttributedStringKey.font: UIFont.systemFont(ofSize: fontSize), 94 | NSAttributedStringKey.foregroundColor: #colorLiteral(red: 0.1930259168, green: 0.1930313706, blue: 0.19302845, alpha: 1), 95 | NSAttributedStringKey.paragraphStyle: style 96 | ], range: NSRange(location: 0, length: attr.string.count)) 97 | } 98 | 99 | return attr 100 | } catch let error as NSError { 101 | print(error.localizedDescription) 102 | return NSAttributedString() 103 | } 104 | } 105 | 106 | } 107 | 108 | 109 | class DetailHeaderCell: UITableViewCell { 110 | 111 | @IBOutlet weak var imageConstraint: NSLayoutConstraint! 112 | @IBOutlet var topicImageView:UIImageView! 113 | @IBOutlet var storyDescLabel:UILabel! 114 | @IBOutlet var storyContent:UIView! 115 | @IBOutlet var storyTitleLabel:UILabel! 116 | 117 | required init(coder aDecoder: NSCoder) { 118 | super.init(coder: aDecoder)! 119 | setup() 120 | } 121 | 122 | override init(style: UITableViewCellStyle, reuseIdentifier: String?) { 123 | super.init(style: style, reuseIdentifier: reuseIdentifier) 124 | setup() 125 | } 126 | 127 | func setup() { 128 | Bundle.main.loadNibNamed("Detail Header View", owner: self, options: nil) 129 | addSubview(storyContent) 130 | storyContent.snp.makeConstraints { make in 131 | make.top.equalToSuperview().offset(0) 132 | make.left.equalToSuperview().offset(0) 133 | make.right.equalToSuperview().offset(0) 134 | make.bottom.equalToSuperview().offset(0) 135 | } 136 | } 137 | 138 | override func layoutSubviews() { 139 | super.layoutSubviews() 140 | relocate() 141 | } 142 | 143 | func relocate() { 144 | 145 | } 146 | 147 | } 148 | 149 | class StoryCell: UITableViewCell { 150 | 151 | @IBOutlet weak var imageConstraint: NSLayoutConstraint! 152 | @IBOutlet var topicImageView:UIImageView! 153 | @IBOutlet var storyDescLabel:UILabel! 154 | @IBOutlet var storyContent:UIView! 155 | @IBOutlet var storyTitleLabel:UILabel! 156 | @IBOutlet var storyDetailLabel:UILabel! 157 | 158 | required init(coder aDecoder: NSCoder) { 159 | super.init(coder: aDecoder)! 160 | setup() 161 | } 162 | 163 | override init(style: UITableViewCellStyle, reuseIdentifier: String?) { 164 | super.init(style: style, reuseIdentifier: reuseIdentifier) 165 | setup() 166 | } 167 | 168 | func setup() { 169 | 170 | /** 171 | * @TODO Lag on too much cell views 172 | */ 173 | 174 | Bundle.main.loadNibNamed("Story Cell View", owner: self, options: nil) 175 | addSubview(storyContent) 176 | storyContent.snp.makeConstraints { make in 177 | make.top.equalToSuperview().offset(0) 178 | make.left.equalToSuperview().offset(0) 179 | make.right.equalToSuperview().offset(0) 180 | make.bottom.equalToSuperview().offset(0) 181 | } 182 | } 183 | 184 | override func layoutSubviews() { 185 | super.layoutSubviews() 186 | relocate() 187 | } 188 | 189 | func relocate() { 190 | 191 | } 192 | 193 | } 194 | 195 | public class SafariActivity: UIActivity { 196 | public var URL: URL? 197 | 198 | public override var activityType: UIActivityType? { 199 | return UIActivityType(rawValue: "SafariActivity") 200 | } 201 | 202 | public override var activityTitle: String? { 203 | // load value from main bundle to enable overwriting title 204 | let frameworkBundle = Bundle(for: type(of: self)) 205 | let mainBundle = Bundle.main 206 | let defaultString = frameworkBundle.localizedString(forKey: "open_in_safari", value: "open_in_safari", table: nil) 207 | return mainBundle.localizedString(forKey: "open_in_safari", value: defaultString, table: nil) 208 | } 209 | 210 | public override var activityImage: UIImage? { 211 | return #imageLiteral(resourceName: "safari") 212 | } 213 | 214 | public override func canPerform(withActivityItems activityItems: [Any]) -> Bool { 215 | var canPerform = false 216 | 217 | for activityItem in activityItems { 218 | if let URL = activityItem as? URL { 219 | if UIApplication.shared.canOpenURL(URL) { 220 | canPerform = true 221 | break 222 | } 223 | } 224 | } 225 | 226 | return canPerform 227 | } 228 | 229 | public override func prepare(withActivityItems activityItems: [Any]) { 230 | for activityItem in activityItems { 231 | if let URL = activityItem as? URL { 232 | self.URL = URL 233 | break 234 | } 235 | } 236 | } 237 | 238 | public override func perform() { 239 | var completed = false 240 | 241 | if let URL = URL { 242 | completed = UIApplication.shared.openURL(URL) 243 | } 244 | 245 | activityDidFinish(completed) 246 | } 247 | } 248 | 249 | -------------------------------------------------------------------------------- /Sources/XIB/Detail Header View.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 32 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /Sources/XIB/Detail View.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /Sources/XIB/Story Cell View.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 33 | 39 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /Sources/XIB/en.lproj/Launch Screen.strings: -------------------------------------------------------------------------------- 1 | 2 | /* Class = "UILabel"; text = "Solidot"; ObjectID = "GJd-Yh-RWb"; */ 3 | "GJd-Yh-RWb.text" = "Solidot"; 4 | 5 | /* Class = "UILabel"; text = "www.solidot.org"; ObjectID = "obG-Y5-kRd"; */ 6 | "obG-Y5-kRd.text" = "www.solidot.org"; 7 | -------------------------------------------------------------------------------- /Sources/XIB/zh-Hans.lproj/Launch Screen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | --------------------------------------------------------------------------------