Skip to content

Commit 5246643

Browse files
committed
优化内部Action执行流程
1 parent 4fd2f3e commit 5246643

File tree

7 files changed

+34
-37
lines changed

7 files changed

+34
-37
lines changed

AttributedString.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = "AttributedString"
4-
s.version = "3.3.0"
4+
s.version = "3.3.1"
55
s.summary = "基于Swift字符串插值快速构建你想要的富文本, 支持点击按住等事件获取, 支持多种类型过滤"
66

77
s.homepage = "https://github.com/lixiang1994/AttributedString"

Demo-Watch/Demo-Watch.xcodeproj/xcshareddata/xcschemes/Demo-Watch WatchKit App.xcscheme

+19-6
Original file line numberDiff line numberDiff line change
@@ -54,33 +54,46 @@
5454
debugDocumentVersioning = "YES"
5555
debugServiceExtension = "internal"
5656
allowLocationSimulation = "YES">
57-
<BuildableProductRunnable
58-
runnableDebuggingMode = "0">
57+
<RemoteRunnable
58+
runnableDebuggingMode = "2"
59+
BundleIdentifier = "com.apple.Carousel"
60+
RemotePath = "/Demo-Watch WatchKit App">
5961
<BuildableReference
6062
BuildableIdentifier = "primary"
6163
BlueprintIdentifier = "9B267B4D24405CFA002F571E"
6264
BuildableName = "Demo-Watch WatchKit App.app"
6365
BlueprintName = "Demo-Watch WatchKit App"
6466
ReferencedContainer = "container:Demo-Watch.xcodeproj">
6567
</BuildableReference>
66-
</BuildableProductRunnable>
68+
</RemoteRunnable>
6769
</LaunchAction>
6870
<ProfileAction
6971
buildConfiguration = "Release"
7072
shouldUseLaunchSchemeArgsEnv = "YES"
7173
savedToolIdentifier = ""
7274
useCustomWorkingDirectory = "NO"
7375
debugDocumentVersioning = "YES">
74-
<BuildableProductRunnable
75-
runnableDebuggingMode = "0">
76+
<RemoteRunnable
77+
runnableDebuggingMode = "2"
78+
BundleIdentifier = "com.apple.Carousel"
79+
RemotePath = "/Demo-Watch WatchKit App">
7680
<BuildableReference
7781
BuildableIdentifier = "primary"
7882
BlueprintIdentifier = "9B267B4D24405CFA002F571E"
7983
BuildableName = "Demo-Watch WatchKit App.app"
8084
BlueprintName = "Demo-Watch WatchKit App"
8185
ReferencedContainer = "container:Demo-Watch.xcodeproj">
8286
</BuildableReference>
83-
</BuildableProductRunnable>
87+
</RemoteRunnable>
88+
<MacroExpansion>
89+
<BuildableReference
90+
BuildableIdentifier = "primary"
91+
BlueprintIdentifier = "9B267B4D24405CFA002F571E"
92+
BuildableName = "Demo-Watch WatchKit App.app"
93+
BlueprintName = "Demo-Watch WatchKit App"
94+
ReferencedContainer = "container:Demo-Watch.xcodeproj">
95+
</BuildableReference>
96+
</MacroExpansion>
8497
</ProfileAction>
8598
<AnalyzeAction
8699
buildConfiguration = "Debug">

Demo/Demo.xcodeproj/project.pbxproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@
441441
buildSettings = {
442442
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
443443
CODE_SIGN_STYLE = Automatic;
444-
DEVELOPMENT_TEAM = B9D8DJR5J5;
444+
DEVELOPMENT_TEAM = 8G74YECJ4Z;
445445
INFOPLIST_FILE = Demo/Info.plist;
446446
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
447447
LD_RUNPATH_SEARCH_PATHS = (

Demo/Demo/Details/ActionViewController.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class ActionViewController: UIViewController {
5858
5959
This is \("Long Press", .font(.systemFont(ofSize: 30)), .action(.press, pressed))
6060
61-
Please \("custom", .font(.systemFont(ofSize: 30)), .action(custom)).
61+
Please \("custom highlight style", .font(.systemFont(ofSize: 30)), .action(custom)).
6262
6363
Please custom -> \(.image(#imageLiteral(resourceName: "swift-icon"), .original(.center)), action: custom).
6464
@@ -71,9 +71,9 @@ class ActionViewController: UIViewController {
7171
7272
This is \("Long Press", .font(.systemFont(ofSize: 30)), .action(.press, pressed))
7373
74-
Please \("custom", .font(.systemFont(ofSize: 30)), .action(custom)).
74+
Please \("custom highlight style", .font(.systemFont(ofSize: 30)), .action(custom)).
7575
76-
Please custom -> \(.image(#imageLiteral(resourceName: "swift-icon"), .original(.center)), action: custom).
76+
Please custom highlight style -> \(.image(#imageLiteral(resourceName: "swift-icon"), .original(.center)), action: custom).
7777
7878
"""
7979
}

Sources/Extension/UIKit/ActionQueue.swift

+8-24
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,21 @@ class ActionQueue {
1717

1818
private var action: Handle?
1919

20-
private var lock: Int = 0
21-
22-
func next(_ lock: Int) {
23-
self.lock = lock
24-
switch lock {
25-
case 1:
26-
guard let handle = action else { return }
27-
handle()
28-
next(0)
29-
30-
default:
31-
action = nil
32-
}
33-
}
34-
3520
func began(_ handle: Handle) {
3621
handle()
37-
next(1)
3822
}
3923

4024
func action(_ handle: @escaping Handle) {
41-
if lock == 1 {
42-
handle()
43-
44-
} else {
45-
action = handle
46-
}
25+
action = handle
26+
}
27+
28+
func ended(_ handle: @escaping Handle) {
29+
action?()
30+
handle()
4731
}
4832

49-
func ended(_ handle: Handle) {
33+
func cancelled(_ handle: @escaping Handle) {
34+
action = nil
5035
handle()
51-
next(0)
5236
}
5337
}

Sources/Extension/UIKit/UILabel/UILabelExtension.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ extension UILabel {
300300
return
301301
}
302302
// 保证 touchesBegan -> Action -> touchesEnded 的调用顺序
303-
ActionQueue.main.ended {
303+
ActionQueue.main.cancelled {
304304
self.touched = nil
305305
self.attributedText = touched.0.value
306306
}

Sources/Extension/UIKit/UITextViewExtension.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ extension UITextView {
342342
return
343343
}
344344
// 保证 touchesBegan -> Action -> touchesEnded 的调用顺序
345-
ActionQueue.main.ended {
345+
ActionQueue.main.cancelled {
346346
self.touched = nil
347347
self.attributedText = touched.0.value
348348
self.layout()

0 commit comments

Comments
 (0)