Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
caonongyun authored and caonongyun committed Jun 8, 2017
1 parent e29cfd0 commit c1fe4a4
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 7 deletions.
Binary file modified .DS_Store
Binary file not shown.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@

**采用Swift语言,仿追书神器做的,主要是练习阅读器的一些技术,包括仿真阅读等。不断更新中......**

<<<<<<< HEAD
**20170607:本次功能变更:增加书架删除,缓存,修复一些缺陷**
----
=======
>>>>>>> 876a9ee6afa162f4fb71eff5fa02f2e0dbe52ae2

**仅供学习交流,请勿用于商业用途**

## Requirements
Expand All @@ -29,16 +27,18 @@ Main development of TXTReader olny support Swift 3.0+.

###效果图如下:

<<<<<<< HEAD

![zhuishushenqi](zhuishushenqi.png)
![zhuishenqiing](qs_bookshelf.png)
![zhuishenqiimg](qs_reader.png)
![zhuishenqiimg](qs_readerMain.png)
![zhuishenqiimg](qs_changeSource.png)

=======
<img src="qs_reader.png" width="20%" height="20%" /><img src="qs_readerMain.png" width="20%" height="20%" /><img src="qs_changeSource.png" width="20%" height="20%" />
>>>>>>> 876a9ee6afa162f4fb71eff5fa02f2e0dbe52ae2

<img src="qs_reader.png" width="20%" height="20%" />
<img src="qs_readerMain.png" width="20%" height="20%" />
<img src="qs_changeSource.png" width="20%" height="20%" />
<img src="qs_bookshelf.png" width="20%" height="20%" />


## Contact
Expand Down
12 changes: 12 additions & 0 deletions zhuishushenqi.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
B22182CD1DA4058E002458D2 /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = B22182CC1DA4058E002458D2 /* libsqlite3.tbd */; };
B22182CF1DA40594002458D2 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = B22182CE1DA40594002458D2 /* libz.tbd */; };
B22204901EE859E9008E1902 /* BookCommentViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = B222048F1EE859E9008E1902 /* BookCommentViewCell.xib */; };
B22204A21EE9284F008E1902 /* QSSplashScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = B22204A11EE9284F008E1902 /* QSSplashScreen.swift */; };
B22269D61EA0C70A008FD314 /* QSBook.swift in Sources */ = {isa = PBXBuildFile; fileRef = B22269D31EA0C70A008FD314 /* QSBook.swift */; };
B22269D71EA0C70A008FD314 /* QSChapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = B22269D41EA0C70A008FD314 /* QSChapter.swift */; };
B22269D81EA0C70A008FD314 /* QSPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = B22269D51EA0C70A008FD314 /* QSPage.swift */; };
Expand Down Expand Up @@ -509,6 +510,7 @@
B22182CC1DA4058E002458D2 /* libsqlite3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = usr/lib/libsqlite3.tbd; sourceTree = SDKROOT; };
B22182CE1DA40594002458D2 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
B222048F1EE859E9008E1902 /* BookCommentViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = BookCommentViewCell.xib; sourceTree = "<group>"; };
B22204A11EE9284F008E1902 /* QSSplashScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QSSplashScreen.swift; sourceTree = "<group>"; };
B22269D31EA0C70A008FD314 /* QSBook.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QSBook.swift; sourceTree = "<group>"; };
B22269D41EA0C70A008FD314 /* QSChapter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QSChapter.swift; sourceTree = "<group>"; };
B22269D51EA0C70A008FD314 /* QSPage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QSPage.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1043,6 +1045,14 @@
path = BookDetail;
sourceTree = "<group>";
};
B22204961EE8FC45008E1902 /* Splash */ = {
isa = PBXGroup;
children = (
B22204A11EE9284F008E1902 /* QSSplashScreen.swift */,
);
path = Splash;
sourceTree = "<group>";
};
B22A8D2B1EAD948B00C7E978 /* Community */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1171,6 +1181,7 @@
B2B4BA131E7EA4A8000CC201 /* Extension */,
B2B4BA221E7EA4A8000CC201 /* RightSide */,
B2B4BA571E7EA4A8000CC201 /* Root */,
B22204961EE8FC45008E1902 /* Splash */,
B2B4BA651E7EA4A8000CC201 /* TXTReader */,
B2B4BA8E1E7EA4A8000CC201 /* Vender */,
B2F778A31EAEEDD4004B4362 /* M80AttributedLabel */,
Expand Down Expand Up @@ -2647,6 +2658,7 @@
B2B02E571EA9A9F000A6880A /* QSCatalogViewController.swift in Sources */,
B2F778AF1EAEEDD4004B4362 /* M80AttributedLabelURL.m in Sources */,
B258BB0B1EA45B4C006E5802 /* CategoryButton.swift in Sources */,
B22204A21EE9284F008E1902 /* QSSplashScreen.swift in Sources */,
B2F778F21EAF36D1004B4362 /* ConstraintMakerPriortizable.swift in Sources */,
B2B4BCDF1E7EA4AB000CC201 /* YYAnimatedImageView.m in Sources */,
B2B4BC391E7EA4AB000CC201 /* PageInfo.swift in Sources */,
Expand Down
Binary file modified zhuishushenqi/.DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions zhuishushenqi/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// let navbarTitleTextAttributes = [NSForegroundColorAttributeName:UIColor ( red: 0.7235, green: 0.0, blue: 0.1146, alpha: 1.0 )]
// UINavigationBar.appearance().titleTextAttributes = navbarTitleTextAttributes
UIApplication.shared.statusBarStyle = .lightContent

let splash = QSSplashScreen()
splash.show()

return true
}
Expand Down
142 changes: 142 additions & 0 deletions zhuishushenqi/Splash/QSSplashScreen.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
//
// QSSplashScreen.swift
// zhuishushenqi
//
// Created by caonongyun on 2017/6/8.
// Copyright © 2017年 QS. All rights reserved.
//

import UIKit
import QSNetwork

typealias SplashCallback = ()->Void

class QSSplashScreen: NSObject {

var splashInfo:NSDictionary?
private var splashRootVC:QSSplashViewController?

private let splashURL = "http://api.zhuishushenqi.com/splashes/ios"

func show(){
detachRootViewController()
let splashWindoww = UIWindow(frame: UIScreen.main.bounds)
splashWindoww.backgroundColor = UIColor.black
splashRootVC = QSSplashViewController()
splashRootVC?.finishCallback = {
self.hide()
}
splashRootVC?.view.backgroundColor = UIColor.clear
splashWindoww.rootViewController = splashRootVC
splashWindow = splashWindoww
splashWindow?.makeKeyAndVisible()
getSplashInfo()
}

func getSplashInfo(){
// first

// request splash image
QSNetwork.request(splashURL) { (response) in
let splash = response.json?["splash"] as? [NSDictionary]
if let splashInfo = splash?[0] {
// save splash info,download image and save it
self.splashInfo = splashInfo
self.downloadSplashImage()
// USER_DEFAULTS.set(splashInfo, forKey: "splashInfo")

}
}
}

func downloadSplashImage(){
let urlString = getSplashURLString()
QSNetwork.request(urlString) { (response) in
QSLog(response.data)
if let imageData = response.data {
let image = UIImage(data: imageData)
if let splashImage = image{
self.splashInfo?.setValue(splashImage.base64(), forKey: "imageData")
self.splashRootVC?.setSplashImage(image: splashImage)
}
}
}
}

func getSplashURLString()->String {
//according to screen dimension
let imageString = self.splashInfo?.object(forKey: "img") as? String ?? ""
return imageString
}

func hide(){
attachRootViewController()
let mainWindow:UIWindow? = (UIApplication.shared.delegate?.window)!
mainWindow?.makeKeyAndVisible()
}

}

var originalRootViewController:UIViewController?
var splashWindow:UIWindow?

extension QSSplashScreen {
func detachRootViewController(){
if originalRootViewController == nil {
let mainWindow:UIWindow? = (UIApplication.shared.delegate?.window)!
originalRootViewController = mainWindow?.rootViewController
}
}

func attachRootViewController(){
if originalRootViewController != nil {
let mainWindow:UIWindow? = (UIApplication.shared.delegate?.window)!
mainWindow?.rootViewController = originalRootViewController
}
}
}

class QSSplashViewController: UIViewController {
private var bgView:UIImageView!
private var splashIcon:UIImageView!
private var skipBtn:UIButton!
var finishCallback:SplashCallback?

override func viewDidLoad() {
super.viewDidLoad()
setupSubviews()
}

private func setupSubviews(){
bgView = UIImageView(frame: UIScreen.main.bounds)
bgView.image = UIImage(named: "LaunchImage")
view.addSubview(bgView)

splashIcon = UIImageView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width
, height: UIScreen.main.bounds.height - 100))
splashIcon.backgroundColor = UIColor.clear
view.addSubview(splashIcon)

skipBtn = UIButton(type: .custom)
skipBtn.frame = CGRect(x: UIScreen.main.bounds.width - 120, y: 35, width: 60, height: 30)

skipBtn.setTitle("跳过", for: .normal)
skipBtn.setTitleColor(UIColor.gray, for: .normal)
skipBtn.backgroundColor = UIColor(white: 1.0, alpha: 0.6)
skipBtn.isHidden = true
skipBtn.addTarget(self, action: #selector(skipAction(btn:)), for: .touchUpInside)
skipBtn.layer.cornerRadius = 5
view.addSubview(skipBtn)
}

@objc private func skipAction(btn:UIButton){
if let callback = finishCallback {
callback()
}
}

func setSplashImage(image:UIImage){
splashIcon.image = image
skipBtn.isHidden = false
}
}

0 comments on commit c1fe4a4

Please sign in to comment.