From 36ea471339fb7634ae0f5c9815bea5bef4cb9e44 Mon Sep 17 00:00:00 2001 From: Rakuyo Date: Wed, 22 Sep 2021 13:58:36 +0800 Subject: [PATCH 1/4] update README --- README.md | 44 +++++++++++++++++++------------------------- README_CN.md | 43 +++++++++++++++++++------------------------ 2 files changed, 38 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 635032c..2e827ce 100644 --- a/README.md +++ b/README.md @@ -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`. @@ -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) @@ -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 diff --git a/README_CN.md b/README_CN.md index 601e120..6a2795e 100644 --- a/README_CN.md +++ b/README_CN.md @@ -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` 提供**折叠**与**展开**功能。 @@ -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) @@ -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。 -- [ ] 更完善的复制操作。 ## 致谢 From 20e88e97eb83dca49d25126ff74833824924ec77 Mon Sep 17 00:00:00 2001 From: Rakuyo Date: Thu, 23 Sep 2021 09:44:00 +0800 Subject: [PATCH 2/4] update --- JSONPreview/JSONPreview/Core/JSONDecorator.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JSONPreview/JSONPreview/Core/JSONDecorator.swift b/JSONPreview/JSONPreview/Core/JSONDecorator.swift index 25763e1..e5c9cc3 100644 --- a/JSONPreview/JSONPreview/Core/JSONDecorator.swift +++ b/JSONPreview/JSONPreview/Core/JSONDecorator.swift @@ -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) From b68a5108f10e02f81d44ffc0fffb69795290e2f9 Mon Sep 17 00:00:00 2001 From: Rakuyo Date: Thu, 23 Sep 2021 10:25:08 +0800 Subject: [PATCH 3/4] Fix the height calculation problem --- JSONPreview/JSONPreview/Core/JSONPreview.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/JSONPreview/JSONPreview/Core/JSONPreview.swift b/JSONPreview/JSONPreview/Core/JSONPreview.swift index fc6ebb7..24b1f38 100644 --- a/JSONPreview/JSONPreview/Core/JSONPreview.swift +++ b/JSONPreview/JSONPreview/Core/JSONPreview.swift @@ -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 From e8dbc9c712b73e15bffb5b753a11d09a87ac3e50 Mon Sep 17 00:00:00 2001 From: Rakuyo Date: Thu, 23 Sep 2021 10:31:57 +0800 Subject: [PATCH 4/4] [Release Script] Version updated to 1.3.1 202109221340 --- JSONPreview/JSONPreview.podspec | 2 +- JSONPreview/JSONPreview.xcodeproj/project.pbxproj | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/JSONPreview/JSONPreview.podspec b/JSONPreview/JSONPreview.podspec index a79e2fc..81cfa44 100755 --- a/JSONPreview/JSONPreview.podspec +++ b/JSONPreview/JSONPreview.podspec @@ -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.' diff --git a/JSONPreview/JSONPreview.xcodeproj/project.pbxproj b/JSONPreview/JSONPreview.xcodeproj/project.pbxproj index 95335c8..fdcf1a5 100644 --- a/JSONPreview/JSONPreview.xcodeproj/project.pbxproj +++ b/JSONPreview/JSONPreview.xcodeproj/project.pbxproj @@ -509,7 +509,7 @@ 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; @@ -517,7 +517,7 @@ "$(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; @@ -530,7 +530,7 @@ 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; @@ -538,7 +538,7 @@ "$(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;