Skip to content

Commit

Permalink
new features
Browse files Browse the repository at this point in the history
  • Loading branch information
caonongyun authored and caonongyun committed Jun 7, 2017
1 parent 876a9ee commit 5c59095
Show file tree
Hide file tree
Showing 78 changed files with 4,360 additions and 547 deletions.
Binary file modified .DS_Store
Binary file not shown.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

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

<<<<<<< HEAD
**20170607:本次功能变更:增加书架删除,缓存,修复一些缺陷**
----
=======
>>>>>>> 876a9ee6afa162f4fb71eff5fa02f2e0dbe52ae2
**仅供学习交流,请勿用于商业用途**

## Requirements
Expand All @@ -24,7 +29,16 @@ 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

## Contact
Expand Down
Binary file added qs_bookshelf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions zhuishushenqi.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

22 changes: 21 additions & 1 deletion zhuishushenqi/Base/Controllers/SideViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ class SideViewController: UIViewController,UIGestureRecognizerDelegate {
/// 是否左侧边栏处于关闭状态
var isCloseLeftSide:Bool = true

/// 全屏手势密码开启
var fullScreenPanGestureEnable:Bool = false
var panGestureToleranceX:CGFloat = 10


var leftViewController:UIViewController?
var rightViewController:UIViewController?
Expand All @@ -57,6 +61,8 @@ class SideViewController: UIViewController,UIGestureRecognizerDelegate {
fileprivate var bounchesX:CGFloat = 20
/// 最小open宽度
fileprivate var minimumSwipeX:CGFloat = 20

fileprivate var showSideMenu:Bool = true

fileprivate lazy var panGes:UIPanGestureRecognizer = {
let pan:UIPanGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(self.panAction(_:)))
Expand Down Expand Up @@ -98,8 +104,18 @@ class SideViewController: UIViewController,UIGestureRecognizerDelegate {
@objc fileprivate func panAction(_ pan:UIPanGestureRecognizer){
let translation:CGPoint = pan.translation(in: self.contentView)
let velocity:CGPoint = pan.velocity(in: self.contentView)

let location = pan.location(in: self.contentView)

if pan.state == UIGestureRecognizerState.began {
// 是否开启全屏手势识别,默认关闭
if !fullScreenPanGestureEnable {
if location.x > panGestureToleranceX && location.x < (ScreenWidth - panGestureToleranceX) {
showSideMenu = false
}else {
showSideMenu = true
}
}

if velocity.x > 0 && isCloseLeftSide{
horizonalXSide = .left
}else if velocity.x < 0 && isCloseRightSide {
Expand All @@ -114,6 +130,10 @@ class SideViewController: UIViewController,UIGestureRecognizerDelegate {
updateContentViewShadow()
}

if !showSideMenu {
return
}

if pan.state == UIGestureRecognizerState.ended {
//停止时的手势速度方向为哪边则显示哪边
//这里设置了最小 open 宽度,小于它则不会显示侧边栏
Expand Down
3 changes: 3 additions & 0 deletions zhuishushenqi/Extension/Date+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ extension Date{
case 2:
days = isLeapYear() ? 29:28
break
case 4,6,9,11:
days = 30
break
default: break
}
return days
Expand Down
13 changes: 9 additions & 4 deletions zhuishushenqi/Extension/DateIntervalFormatter+formatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,33 @@ extension DateIntervalFormatter{
return String(format: "%.0f小时前",retTime)
}else if abs(year) == 0 && abs(month) <= 1 || abs(year) == 1 && to.month() == 1 && from.month() == 12{
// 第一个条件是同年,且相隔时间在一个月内
// 第二个条件是隔年,对于隔年,只能是去年12月与今年1月这种情况
// 第二个条件是隔年,且相隔时间在一个月内,对于隔年,只能是去年12月与今年1月这种情况
var retDay = 0
if year == 0 {//同年
if month == 0 {//同月
retDay = day
}
}
//跨月
if retDay <= 0{
// 获取发布日期中,该月有多少天
let totalDays = from.days(month: from.month())
// 当前天数 + (发布日期月中的总天数-发布日期月中发布日,即等于距离今天的天数)
retDay = to.day() + totalDays - from.day()

}
return String(format: "%d天前",abs(retDay))
}else {
}else {//间隔时间大于一个月
if abs(year) <= 1 {
if year == 0 {//同年
return String(format: "%d个月前",
(month))
} else {//跨年计算月份
return String(format: "%d个月前",12 - from.month() + to.month())
//跨年可能月份大于12个月,按一年来算
let monthCount = 12 - from.month() + to.month()
if monthCount > 12 {
return String(format: "%d年前",monthCount/12)
}
return String(format: "%d个月前",monthCount)
}
}
if month < 0 { //未满一年不计算
Expand Down
15 changes: 15 additions & 0 deletions zhuishushenqi/Extension/NSString+Encode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// NSString+Encode.h
// zhuishushenqi
//
// Created by caonongyun on 2017/4/26.
// Copyright © 2017年 QS. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface NSString (Encode)

- (NSString*)urlEncode;

@end
23 changes: 23 additions & 0 deletions zhuishushenqi/Extension/NSString+Encode.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// NSString+Encode.m
// zhuishushenqi
//
// Created by caonongyun on 2017/4/26.
// Copyright © 2017年 QS. All rights reserved.
//

#import "NSString+Encode.h"

@implementation NSString (Encode)


- (NSString*)urlEncode{
//different library use slightly different escaped and unescaped set.
//below is copied from AFNetworking but still escaped [] as AF leave them for Rails array parameter which we don't use.
//https://github.com/AFNetworking/AFNetworking/pull/555
NSString *result = (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef)self, CFSTR("."), CFSTR(":/?#[]@!$&'()*+,;="), kCFStringEncodingUTF8));

return result;
}

@end
Loading

0 comments on commit 5c59095

Please sign in to comment.