Skip to content

Commit

Permalink
Merge branch 'release/1.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
rakuyoMo committed Sep 23, 2021
2 parents 77a86df + e8dbc9c commit 4642ab6
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 56 deletions.
2 changes: 1 addition & 1 deletion JSONPreview/JSONPreview.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Pod::Spec.new do |s|

s.name = 'JSONPreview'

s.version = '1.3.0'
s.version = '1.3.1'

s.summary = '🎨 A view that can be highlighted after formatting JSON.'

Expand Down
8 changes: 4 additions & 4 deletions JSONPreview/JSONPreview.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -509,15 +509,15 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 202109221340;
CURRENT_PROJECT_VERSION = 202109231031;
DEVELOPMENT_TEAM = 5C9JW4S9DE;
INFOPLIST_FILE = "$(SRCROOT)/JSONPreview/Other/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.3.0;
MARKETING_VERSION = 1.3.1;
PRODUCT_BUNDLE_IDENTIFIER = com.rakuyo.JSONPreview;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -530,15 +530,15 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 202109221340;
CURRENT_PROJECT_VERSION = 202109231031;
DEVELOPMENT_TEAM = 5C9JW4S9DE;
INFOPLIST_FILE = "$(SRCROOT)/JSONPreview/Other/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.3.0;
MARKETING_VERSION = 1.3.1;
PRODUCT_BUNDLE_IDENTIFIER = com.rakuyo.JSONPreview;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
2 changes: 1 addition & 1 deletion JSONPreview/JSONPreview/Core/JSONDecorator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ private extension JSONDecorator {
break
}

// MARK: - Link
// MARK: Link
case .link(let value):
let addExtraLinkStyle: (NSMutableAttributedString, Int) -> Void = {
let range = NSRange(location: $1, length: value.count)
Expand Down
4 changes: 3 additions & 1 deletion JSONPreview/JSONPreview/Core/JSONPreview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ private extension JSONPreview {
return height
}

let height = calculateLineHeight(at: line - 1, width: jsonTextView.frame.width)
let width = jsonTextView.frame.width - { $0.left + $0.right }(jsonTextView.textContainerInset)
let height = calculateLineHeight(at: line - 1, width: width)

lineHeights[lastOrientation]![line] = height

return height
Expand Down
44 changes: 19 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ pod 'JSONPreview'

## Features

> In version `1.3.0`, we removed the diagonal swipe feature. Now if a JSON row is not displayed open, it will be displayed folded instead of going beyond the screen. If you wish to use this feature, please use version [1.2.3](https://github.com/rakuyoMo/JSONPreview/releases/tag/1.2.3)
- [x] Supports **formatting** to display JSON data.
- [x] Supports **highlighting** JSON data, with multiple color and font configuration options.
- [x] Provides **fold** and **expand** features for `Array` and `Object`.
Expand Down Expand Up @@ -71,27 +73,27 @@ previewView.preview(json)
```swift
let highlightColor = HighlightColor(
keyWord: <#T##ConvertibleToColor#>,
key: <#T##ConvertibleToColor#>,
link: <#T##ConvertibleToColor#>,
string: <#T##ConvertibleToColor#>,
number: <#T##ConvertibleToColor#>,
boolean: <#T##ConvertibleToColor#>,
null: <#T##ConvertibleToColor#>,
unknownText: <#T##ConvertibleToColor#>,
unknownBackground: <#T##ConvertibleToColor#>,
jsonBackground: <#T##ConvertibleToColor#>,
lineBackground: <#T##ConvertibleToColor#>,
lineText: <#T##ConvertibleToColor#>
keyWord: ConvertibleToColor,
key: ConvertibleToColor,
link: ConvertibleToColor,
string: ConvertibleToColor,
number: ConvertibleToColor,
boolean: ConvertibleToColor,
null: ConvertibleToColor,
unknownText: ConvertibleToColor,
unknownBackground: ConvertibleToColor,
jsonBackground: ConvertibleToColor,
lineBackground: ConvertibleToColor,
lineText: ConvertibleToColor
)

let style = HighlightStyle(
expandIcon: <#T##UIImage?#>,
foldIcon: <#T##UIImage?#>,
expandIcon: UIImage?,
foldIcon: UIImage?,
color: highlightColor,
lineFont: <#T##UIFont?#>,
jsonFont: <#T##UIFont?#>,
lineHeight: <#T##CGFloat#>
lineFont: UIFont?,
jsonFont: UIFont?,
lineHeight: CGFloat
)

previewView.preview(json, style: style)
Expand Down Expand Up @@ -132,18 +134,10 @@ The following de-escaping operations are supported in different versions.

![image](https://github.com/rakuyoMo/JSONPreview/blob/master/Images/DFD.png)

## Known issues

1. After the first display, slide to a non-terminal position, rotate the screen, and the subviews will be misaligned. The subview will be misaligned. This problem does not occur when screen rotation is disabled.
2. When collapsing/expanding nodes, there is a possibility of JSON flickering.
3. On some systems (a more comprehensive test has not been performed yet), when the JSON is very complex, there will be flickering problems, and the console will output `CoreAnimation: failed to allocate xxx bytes`. (The problem may be an iOS system problem)

## TODO

- [ ] Fix known issues.
- [ ] Add new integration methods, such as `Carthage` and `Swift Package Manager`.
- [ ] Support for macOS.
- [ ] Better copy operation.

## Thanks

Expand Down
43 changes: 19 additions & 24 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ pod 'JSONPreview'

## 功能

> `1.3.0` 版本中,我们删除了斜向滑动的功能。现在如果JSON一行展示不开,那么它将折行展示,而不是超出屏幕。如果您希望使用该功能,请使用 [1.2.3](https://github.com/rakuyoMo/JSONPreview/releases/tag/1.2.3) 版本
- [x] 支持**格式化**显示 JSON 数据。
- [x] 支持**高亮** JSON 数据,提供多种颜色与字体配置选项。
- [x] 针对 `Array``Object` 提供**折叠****展开**功能。
Expand Down Expand Up @@ -69,27 +71,27 @@ previewView.preview(json)
```swift
let highlightColor = HighlightColor(
keyWord: <#T##ConvertibleToColor#>,
key: <#T##ConvertibleToColor#>,
link: <#T##ConvertibleToColor#>,
string: <#T##ConvertibleToColor#>,
number: <#T##ConvertibleToColor#>,
boolean: <#T##ConvertibleToColor#>,
null: <#T##ConvertibleToColor#>,
unknownText: <#T##ConvertibleToColor#>,
unknownBackground: <#T##ConvertibleToColor#>,
jsonBackground: <#T##ConvertibleToColor#>,
lineBackground: <#T##ConvertibleToColor#>,
lineText: <#T##ConvertibleToColor#>
keyWord: ConvertibleToColor,
key: ConvertibleToColor,
link: ConvertibleToColor,
string: ConvertibleToColor,
number: ConvertibleToColor,
boolean: ConvertibleToColor,
null: ConvertibleToColor,
unknownText: ConvertibleToColor,
unknownBackground: ConvertibleToColor,
jsonBackground: ConvertibleToColor,
lineBackground: ConvertibleToColor,
lineText: ConvertibleToColor
)

let style = HighlightStyle(
expandIcon: <#T##UIImage?#>,
foldIcon: <#T##UIImage?#>,
expandIcon: UIImage?,
foldIcon: UIImage?,
color: highlightColor,
lineFont: <#T##UIFont?#>,
jsonFont: <#T##UIFont?#>,
lineHeight: <#T##CGFloat#>
lineFont: UIFont?,
jsonFont: UIFont?,
lineHeight: CGFloat
)

previewView.preview(json, style: style)
Expand Down Expand Up @@ -130,18 +132,11 @@ previewView.preview(json, style: style)

![image](https://github.com/rakuyoMo/JSONPreview/blob/master/Images/DFD.png)

## 已知问题

1. 首次显示后,滑动到非结尾位置,旋转屏幕,子视图将出现错位问题。产生滑动后恢复正常。禁止屏幕转转时该问题不会发生。
2. 折叠/展开节点时,有概率发生 JSON 闪烁的问题。
3. 在某些系统上(暂未进行更全面的测试),当 JSON 非常复杂时,会出现闪烁问题,此时控制台将输出 `CoreAnimation: failed to allocate xxx bytes`。(该问题可能是 iOS 系统问题)

## TODO

- [ ] 修复已知问题。
- [ ] 增加新的集成方式,例如 `Carthage``Swift Package Manager`
- [ ] 支持 macOS。
- [ ] 更完善的复制操作。

## 致谢

Expand Down

0 comments on commit 4642ab6

Please sign in to comment.