@cometchat/chat-uikit-react-native 5.2.11 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +3 -0
- package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +4 -1
- package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +909 -10
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorPackage.kt +24 -0
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +5382 -0
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorViewManager.kt +452 -0
- package/ios/FileManager.m +430 -3
- package/ios/RichTextEditorView.swift +5504 -0
- package/ios/RichTextEditorViewManager.m +66 -0
- package/ios/RichTextEditorViewManager.swift +291 -0
- package/ios/ToolbarIcons.swift +736 -0
- package/package.json +1 -1
- package/react-native-cometchat-ui-kit.podspec +1 -1
- package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +4557 -0
- package/src/CometChatCompactMessageComposer/SingleLineTextComposerConfiguration.tsx +568 -0
- package/src/CometChatCompactMessageComposer/heightUtils.ts +204 -0
- package/src/CometChatCompactMessageComposer/index.ts +56 -0
- package/src/CometChatCompactMessageComposer/resources/index.ts +5 -0
- package/src/CometChatCompactMessageComposer/styles.ts +291 -0
- package/src/CometChatConversations/CometChatConversations.tsx +139 -10
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +1 -20
- package/src/CometChatMessageComposer/styles.tsx +0 -1
- package/src/CometChatMessageList/CometChatMessageList.tsx +6 -1
- package/src/CometChatRichTextEditor/RichTextEditorViewNativeComponent.ts +105 -0
- package/src/CometChatRichTextEditor/index.tsx +385 -0
- package/src/CometChatRichTextEditor/types.ts +162 -0
- package/src/CometChatSearch/CometChatSearch.tsx +8 -3
- package/src/index.ts +48 -1
- package/src/shared/constants/UIKitConstants.ts +12 -1
- package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +5 -5
- package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +768 -0
- package/src/shared/formatters/index.ts +3 -0
- package/src/shared/framework/MessageDataSource.tsx +93 -2
- package/src/shared/helper/composerHelpers.ts +553 -0
- package/src/shared/helper/useKeyboard.tsx +7 -17
- package/src/shared/icons/components/code-blocks.tsx +13 -0
- package/src/shared/icons/components/code.tsx +11 -0
- package/src/shared/icons/components/format-bold.tsx +11 -0
- package/src/shared/icons/components/format-italic.tsx +11 -0
- package/src/shared/icons/components/format-list-bulleted.tsx +11 -0
- package/src/shared/icons/components/format-list-numbered.tsx +11 -0
- package/src/shared/icons/components/format-quote.tsx +13 -0
- package/src/shared/icons/components/format-strikethrough.tsx +13 -0
- package/src/shared/icons/components/format-underlined.tsx +11 -0
- package/src/shared/icons/components/smileys-&-people.tsx +1 -1
- package/src/shared/icons/icon-mapping.tsx +18 -0
- package/src/shared/index.ts +54 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +37 -32
- package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +5 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +17 -12
- package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +505 -500
- package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +18 -13
- package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +17 -12
- package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +504 -499
- package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +504 -499
- package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +504 -499
- package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +18 -13
- package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +17 -12
- package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +505 -500
- package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +17 -12
- package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +17 -12
- package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +18 -13
- package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +505 -500
- package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +17 -12
- package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +18 -13
- package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +132 -11
- package/src/shared/utils/CometChatMessagePreview/style.ts +1 -3
- package/src/shared/utils/MarkdownUtils.ts +143 -0
- package/src/shared/utils/MentionUtils.ts +37 -0
- package/src/shared/utils/index.ts +5 -0
- package/src/shared/views/CometChatInlineAudioRecorder/AudioWaveformVisualizer.tsx +417 -0
- package/src/shared/views/CometChatInlineAudioRecorder/CometChatInlineAudioRecorder.tsx +537 -0
- package/src/shared/views/CometChatInlineAudioRecorder/index.ts +34 -0
- package/src/shared/views/CometChatInlineAudioRecorder/style.ts +155 -0
- package/src/shared/views/CometChatInlineAudioRecorder/types.ts +303 -0
- package/src/shared/views/CometChatInlineAudioRecorder/useAudioRecorder.ts +1336 -0
- package/src/shared/views/CometChatLinkConfirmPopup/CometChatLinkConfirmPopup.tsx +183 -0
- package/src/shared/views/CometChatLinkConfirmPopup/index.ts +13 -0
- package/src/shared/views/CometChatLinkConfirmPopup/style.ts +128 -0
- package/src/shared/views/CometChatSendButtonView/CometChatSendButtonView.tsx +32 -29
- package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +64 -16
- package/src/shared/views/index.ts +39 -0
|
@@ -0,0 +1,736 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
|
|
3
|
+
/// Provides vector icons for the rich text editor toolbar
|
|
4
|
+
/// Icons match the Android VectorDrawable implementations for cross-platform consistency
|
|
5
|
+
class ToolbarIcons {
|
|
6
|
+
|
|
7
|
+
static func getIcon(for option: String, color: UIColor, size: CGSize = CGSize(width: 24, height: 24)) -> UIImage? {
|
|
8
|
+
switch option {
|
|
9
|
+
case "bold": return drawBoldIcon(color: color, size: size)
|
|
10
|
+
case "italic": return drawItalicIcon(color: color, size: size)
|
|
11
|
+
case "underline": return drawUnderlineIcon(color: color, size: size)
|
|
12
|
+
case "strikethrough": return drawStrikethroughIcon(color: color, size: size)
|
|
13
|
+
case "code": return drawCodeIcon(color: color, size: size)
|
|
14
|
+
case "highlight": return drawHighlightIcon(color: color, size: size)
|
|
15
|
+
case "heading": return drawHeadingIcon(color: color, size: size)
|
|
16
|
+
case "bullet": return drawBulletListIcon(color: color, size: size)
|
|
17
|
+
case "numbered": return drawNumberedListIcon(color: color, size: size)
|
|
18
|
+
case "quote": return drawQuoteIcon(color: color, size: size)
|
|
19
|
+
case "checklist": return drawChecklistIcon(color: color, size: size)
|
|
20
|
+
case "link": return drawLinkIcon(color: color, size: size)
|
|
21
|
+
case "undo": return drawUndoIcon(color: color, size: size)
|
|
22
|
+
case "redo": return drawRedoIcon(color: color, size: size)
|
|
23
|
+
case "clearFormatting": return drawClearFormattingIcon(color: color, size: size)
|
|
24
|
+
case "indent": return drawIndentIcon(color: color, size: size)
|
|
25
|
+
case "outdent": return drawOutdentIcon(color: color, size: size)
|
|
26
|
+
case "alignLeft": return drawAlignLeftIcon(color: color, size: size)
|
|
27
|
+
case "alignCenter": return drawAlignCenterIcon(color: color, size: size)
|
|
28
|
+
case "alignRight": return drawAlignRightIcon(color: color, size: size)
|
|
29
|
+
default: return nil
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// MARK: - Icon Drawing Methods
|
|
34
|
+
|
|
35
|
+
private static func drawBoldIcon(color: UIColor, size: CGSize) -> UIImage {
|
|
36
|
+
return drawIcon(size: size, color: color) { ctx, scale in
|
|
37
|
+
let path = UIBezierPath()
|
|
38
|
+
path.move(to: CGPoint(x: 15.6 * scale, y: 10.79 * scale))
|
|
39
|
+
path.addCurve(to: CGPoint(x: 17.25 * scale, y: 8 * scale),
|
|
40
|
+
controlPoint1: CGPoint(x: 16.57 * scale, y: 10.12 * scale),
|
|
41
|
+
controlPoint2: CGPoint(x: 17.25 * scale, y: 9.02 * scale))
|
|
42
|
+
path.addCurve(to: CGPoint(x: 13.25 * scale, y: 4 * scale),
|
|
43
|
+
controlPoint1: CGPoint(x: 17.25 * scale, y: 5.74 * scale),
|
|
44
|
+
controlPoint2: CGPoint(x: 15.5 * scale, y: 4 * scale))
|
|
45
|
+
path.addLine(to: CGPoint(x: 7 * scale, y: 4 * scale))
|
|
46
|
+
path.addLine(to: CGPoint(x: 7 * scale, y: 18 * scale))
|
|
47
|
+
path.addLine(to: CGPoint(x: 14.04 * scale, y: 18 * scale))
|
|
48
|
+
path.addCurve(to: CGPoint(x: 17.75 * scale, y: 14.21 * scale),
|
|
49
|
+
controlPoint1: CGPoint(x: 16.13 * scale, y: 18 * scale),
|
|
50
|
+
controlPoint2: CGPoint(x: 17.75 * scale, y: 16.51 * scale))
|
|
51
|
+
path.addCurve(to: CGPoint(x: 15.6 * scale, y: 10.79 * scale),
|
|
52
|
+
controlPoint1: CGPoint(x: 17.75 * scale, y: 12.69 * scale),
|
|
53
|
+
controlPoint2: CGPoint(x: 16.89 * scale, y: 11.39 * scale))
|
|
54
|
+
path.close()
|
|
55
|
+
|
|
56
|
+
path.move(to: CGPoint(x: 10 * scale, y: 6.5 * scale))
|
|
57
|
+
path.addLine(to: CGPoint(x: 13 * scale, y: 6.5 * scale))
|
|
58
|
+
path.addCurve(to: CGPoint(x: 14.5 * scale, y: 8 * scale),
|
|
59
|
+
controlPoint1: CGPoint(x: 13.83 * scale, y: 6.5 * scale),
|
|
60
|
+
controlPoint2: CGPoint(x: 14.5 * scale, y: 7.17 * scale))
|
|
61
|
+
path.addCurve(to: CGPoint(x: 13 * scale, y: 9.5 * scale),
|
|
62
|
+
controlPoint1: CGPoint(x: 14.5 * scale, y: 8.83 * scale),
|
|
63
|
+
controlPoint2: CGPoint(x: 13.83 * scale, y: 9.5 * scale))
|
|
64
|
+
path.addLine(to: CGPoint(x: 10 * scale, y: 9.5 * scale))
|
|
65
|
+
path.addLine(to: CGPoint(x: 10 * scale, y: 6.5 * scale))
|
|
66
|
+
path.close()
|
|
67
|
+
|
|
68
|
+
path.move(to: CGPoint(x: 13.5 * scale, y: 15.5 * scale))
|
|
69
|
+
path.addLine(to: CGPoint(x: 10 * scale, y: 15.5 * scale))
|
|
70
|
+
path.addLine(to: CGPoint(x: 10 * scale, y: 12.5 * scale))
|
|
71
|
+
path.addLine(to: CGPoint(x: 13.5 * scale, y: 12.5 * scale))
|
|
72
|
+
path.addCurve(to: CGPoint(x: 15 * scale, y: 14 * scale),
|
|
73
|
+
controlPoint1: CGPoint(x: 14.33 * scale, y: 12.5 * scale),
|
|
74
|
+
controlPoint2: CGPoint(x: 15 * scale, y: 13.17 * scale))
|
|
75
|
+
path.addCurve(to: CGPoint(x: 13.5 * scale, y: 15.5 * scale),
|
|
76
|
+
controlPoint1: CGPoint(x: 15 * scale, y: 14.83 * scale),
|
|
77
|
+
controlPoint2: CGPoint(x: 14.33 * scale, y: 15.5 * scale))
|
|
78
|
+
path.close()
|
|
79
|
+
|
|
80
|
+
path.fill()
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private static func drawItalicIcon(color: UIColor, size: CGSize) -> UIImage {
|
|
85
|
+
return drawIcon(size: size, color: color) { ctx, scale in
|
|
86
|
+
let path = UIBezierPath()
|
|
87
|
+
path.move(to: CGPoint(x: 10 * scale, y: 4 * scale))
|
|
88
|
+
path.addLine(to: CGPoint(x: 10 * scale, y: 7 * scale))
|
|
89
|
+
path.addLine(to: CGPoint(x: 12.21 * scale, y: 7 * scale))
|
|
90
|
+
path.addLine(to: CGPoint(x: 8.79 * scale, y: 15 * scale))
|
|
91
|
+
path.addLine(to: CGPoint(x: 6 * scale, y: 15 * scale))
|
|
92
|
+
path.addLine(to: CGPoint(x: 6 * scale, y: 18 * scale))
|
|
93
|
+
path.addLine(to: CGPoint(x: 14 * scale, y: 18 * scale))
|
|
94
|
+
path.addLine(to: CGPoint(x: 14 * scale, y: 15 * scale))
|
|
95
|
+
path.addLine(to: CGPoint(x: 11.79 * scale, y: 15 * scale))
|
|
96
|
+
path.addLine(to: CGPoint(x: 15.21 * scale, y: 7 * scale))
|
|
97
|
+
path.addLine(to: CGPoint(x: 18 * scale, y: 7 * scale))
|
|
98
|
+
path.addLine(to: CGPoint(x: 18 * scale, y: 4 * scale))
|
|
99
|
+
path.close()
|
|
100
|
+
path.fill()
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
private static func drawUnderlineIcon(color: UIColor, size: CGSize) -> UIImage {
|
|
105
|
+
return drawIcon(size: size, color: color) { ctx, scale in
|
|
106
|
+
let path = UIBezierPath()
|
|
107
|
+
// U shape
|
|
108
|
+
path.move(to: CGPoint(x: 12 * scale, y: 17 * scale))
|
|
109
|
+
path.addCurve(to: CGPoint(x: 18 * scale, y: 11 * scale),
|
|
110
|
+
controlPoint1: CGPoint(x: 15.31 * scale, y: 17 * scale),
|
|
111
|
+
controlPoint2: CGPoint(x: 18 * scale, y: 14.31 * scale))
|
|
112
|
+
path.addLine(to: CGPoint(x: 18 * scale, y: 3 * scale))
|
|
113
|
+
path.addLine(to: CGPoint(x: 15.5 * scale, y: 3 * scale))
|
|
114
|
+
path.addLine(to: CGPoint(x: 15.5 * scale, y: 11 * scale))
|
|
115
|
+
path.addCurve(to: CGPoint(x: 12 * scale, y: 14.5 * scale),
|
|
116
|
+
controlPoint1: CGPoint(x: 15.5 * scale, y: 12.93 * scale),
|
|
117
|
+
controlPoint2: CGPoint(x: 13.93 * scale, y: 14.5 * scale))
|
|
118
|
+
path.addCurve(to: CGPoint(x: 8.5 * scale, y: 11 * scale),
|
|
119
|
+
controlPoint1: CGPoint(x: 10.07 * scale, y: 14.5 * scale),
|
|
120
|
+
controlPoint2: CGPoint(x: 8.5 * scale, y: 12.93 * scale))
|
|
121
|
+
path.addLine(to: CGPoint(x: 8.5 * scale, y: 3 * scale))
|
|
122
|
+
path.addLine(to: CGPoint(x: 6 * scale, y: 3 * scale))
|
|
123
|
+
path.addLine(to: CGPoint(x: 6 * scale, y: 11 * scale))
|
|
124
|
+
path.addCurve(to: CGPoint(x: 12 * scale, y: 17 * scale),
|
|
125
|
+
controlPoint1: CGPoint(x: 6 * scale, y: 14.31 * scale),
|
|
126
|
+
controlPoint2: CGPoint(x: 8.69 * scale, y: 17 * scale))
|
|
127
|
+
path.close()
|
|
128
|
+
|
|
129
|
+
// Underline
|
|
130
|
+
path.move(to: CGPoint(x: 5 * scale, y: 19 * scale))
|
|
131
|
+
path.addLine(to: CGPoint(x: 5 * scale, y: 21 * scale))
|
|
132
|
+
path.addLine(to: CGPoint(x: 19 * scale, y: 21 * scale))
|
|
133
|
+
path.addLine(to: CGPoint(x: 19 * scale, y: 19 * scale))
|
|
134
|
+
path.close()
|
|
135
|
+
|
|
136
|
+
path.fill()
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
private static func drawStrikethroughIcon(color: UIColor, size: CGSize) -> UIImage {
|
|
141
|
+
return drawIcon(size: size, color: color) { ctx, scale in
|
|
142
|
+
let path = UIBezierPath()
|
|
143
|
+
// Top part
|
|
144
|
+
path.move(to: CGPoint(x: 10 * scale, y: 19 * scale))
|
|
145
|
+
path.addLine(to: CGPoint(x: 14 * scale, y: 19 * scale))
|
|
146
|
+
path.addLine(to: CGPoint(x: 14 * scale, y: 16 * scale))
|
|
147
|
+
path.addLine(to: CGPoint(x: 10 * scale, y: 16 * scale))
|
|
148
|
+
path.close()
|
|
149
|
+
|
|
150
|
+
// S shape top
|
|
151
|
+
path.move(to: CGPoint(x: 5 * scale, y: 4 * scale))
|
|
152
|
+
path.addLine(to: CGPoint(x: 5 * scale, y: 7 * scale))
|
|
153
|
+
path.addLine(to: CGPoint(x: 10 * scale, y: 7 * scale))
|
|
154
|
+
path.addLine(to: CGPoint(x: 10 * scale, y: 10 * scale))
|
|
155
|
+
path.addLine(to: CGPoint(x: 14 * scale, y: 10 * scale))
|
|
156
|
+
path.addLine(to: CGPoint(x: 14 * scale, y: 7 * scale))
|
|
157
|
+
path.addLine(to: CGPoint(x: 19 * scale, y: 7 * scale))
|
|
158
|
+
path.addLine(to: CGPoint(x: 19 * scale, y: 4 * scale))
|
|
159
|
+
path.close()
|
|
160
|
+
|
|
161
|
+
// Strike line
|
|
162
|
+
path.move(to: CGPoint(x: 3 * scale, y: 14 * scale))
|
|
163
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 14 * scale))
|
|
164
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 12 * scale))
|
|
165
|
+
path.addLine(to: CGPoint(x: 3 * scale, y: 12 * scale))
|
|
166
|
+
path.close()
|
|
167
|
+
|
|
168
|
+
path.fill()
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
private static func drawCodeIcon(color: UIColor, size: CGSize) -> UIImage {
|
|
173
|
+
return drawIcon(size: size, color: color) { ctx, scale in
|
|
174
|
+
let path = UIBezierPath()
|
|
175
|
+
// Left bracket <
|
|
176
|
+
path.move(to: CGPoint(x: 9.4 * scale, y: 16.6 * scale))
|
|
177
|
+
path.addLine(to: CGPoint(x: 4.8 * scale, y: 12 * scale))
|
|
178
|
+
path.addLine(to: CGPoint(x: 9.4 * scale, y: 7.4 * scale))
|
|
179
|
+
path.addLine(to: CGPoint(x: 8 * scale, y: 6 * scale))
|
|
180
|
+
path.addLine(to: CGPoint(x: 2 * scale, y: 12 * scale))
|
|
181
|
+
path.addLine(to: CGPoint(x: 8 * scale, y: 18 * scale))
|
|
182
|
+
path.close()
|
|
183
|
+
|
|
184
|
+
// Right bracket >
|
|
185
|
+
path.move(to: CGPoint(x: 14.6 * scale, y: 16.6 * scale))
|
|
186
|
+
path.addLine(to: CGPoint(x: 19.2 * scale, y: 12 * scale))
|
|
187
|
+
path.addLine(to: CGPoint(x: 14.6 * scale, y: 7.4 * scale))
|
|
188
|
+
path.addLine(to: CGPoint(x: 16 * scale, y: 6 * scale))
|
|
189
|
+
path.addLine(to: CGPoint(x: 22 * scale, y: 12 * scale))
|
|
190
|
+
path.addLine(to: CGPoint(x: 16 * scale, y: 18 * scale))
|
|
191
|
+
path.close()
|
|
192
|
+
|
|
193
|
+
path.fill()
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
private static func drawHighlightIcon(color: UIColor, size: CGSize) -> UIImage {
|
|
198
|
+
return drawIcon(size: size, color: color) { ctx, scale in
|
|
199
|
+
let path = UIBezierPath()
|
|
200
|
+
// Marker body
|
|
201
|
+
path.move(to: CGPoint(x: 6 * scale, y: 14 * scale))
|
|
202
|
+
path.addLine(to: CGPoint(x: 9 * scale, y: 17 * scale))
|
|
203
|
+
path.addLine(to: CGPoint(x: 9 * scale, y: 22 * scale))
|
|
204
|
+
path.addLine(to: CGPoint(x: 15 * scale, y: 22 * scale))
|
|
205
|
+
path.addLine(to: CGPoint(x: 15 * scale, y: 17 * scale))
|
|
206
|
+
path.addLine(to: CGPoint(x: 18 * scale, y: 14 * scale))
|
|
207
|
+
path.addLine(to: CGPoint(x: 18 * scale, y: 9 * scale))
|
|
208
|
+
path.addLine(to: CGPoint(x: 6 * scale, y: 9 * scale))
|
|
209
|
+
path.close()
|
|
210
|
+
|
|
211
|
+
// Top line
|
|
212
|
+
path.move(to: CGPoint(x: 11 * scale, y: 2 * scale))
|
|
213
|
+
path.addLine(to: CGPoint(x: 13 * scale, y: 2 * scale))
|
|
214
|
+
path.addLine(to: CGPoint(x: 13 * scale, y: 5 * scale))
|
|
215
|
+
path.addLine(to: CGPoint(x: 11 * scale, y: 5 * scale))
|
|
216
|
+
path.close()
|
|
217
|
+
|
|
218
|
+
// Left ray
|
|
219
|
+
path.move(to: CGPoint(x: 3.5 * scale, y: 5.88 * scale))
|
|
220
|
+
path.addLine(to: CGPoint(x: 4.91 * scale, y: 4.47 * scale))
|
|
221
|
+
path.addLine(to: CGPoint(x: 7.03 * scale, y: 6.59 * scale))
|
|
222
|
+
path.addLine(to: CGPoint(x: 5.62 * scale, y: 8 * scale))
|
|
223
|
+
path.close()
|
|
224
|
+
|
|
225
|
+
// Right ray
|
|
226
|
+
path.move(to: CGPoint(x: 16.96 * scale, y: 6.59 * scale))
|
|
227
|
+
path.addLine(to: CGPoint(x: 19.08 * scale, y: 4.47 * scale))
|
|
228
|
+
path.addLine(to: CGPoint(x: 20.49 * scale, y: 5.88 * scale))
|
|
229
|
+
path.addLine(to: CGPoint(x: 18.37 * scale, y: 8 * scale))
|
|
230
|
+
path.close()
|
|
231
|
+
|
|
232
|
+
path.fill()
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
private static func drawHeadingIcon(color: UIColor, size: CGSize) -> UIImage {
|
|
237
|
+
return drawIcon(size: size, color: color) { ctx, scale in
|
|
238
|
+
let path = UIBezierPath()
|
|
239
|
+
path.move(to: CGPoint(x: 5 * scale, y: 4 * scale))
|
|
240
|
+
path.addLine(to: CGPoint(x: 5 * scale, y: 7 * scale))
|
|
241
|
+
path.addLine(to: CGPoint(x: 10.5 * scale, y: 7 * scale))
|
|
242
|
+
path.addLine(to: CGPoint(x: 10.5 * scale, y: 19 * scale))
|
|
243
|
+
path.addLine(to: CGPoint(x: 13.5 * scale, y: 19 * scale))
|
|
244
|
+
path.addLine(to: CGPoint(x: 13.5 * scale, y: 7 * scale))
|
|
245
|
+
path.addLine(to: CGPoint(x: 19 * scale, y: 7 * scale))
|
|
246
|
+
path.addLine(to: CGPoint(x: 19 * scale, y: 4 * scale))
|
|
247
|
+
path.close()
|
|
248
|
+
path.fill()
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
private static func drawBulletListIcon(color: UIColor, size: CGSize) -> UIImage {
|
|
253
|
+
return drawIcon(size: size, color: color) { ctx, scale in
|
|
254
|
+
let path = UIBezierPath()
|
|
255
|
+
// Bullets
|
|
256
|
+
path.append(UIBezierPath(ovalIn: CGRect(x: 2.5 * scale, y: 10.5 * scale, width: 3 * scale, height: 3 * scale)))
|
|
257
|
+
path.append(UIBezierPath(ovalIn: CGRect(x: 2.5 * scale, y: 4.5 * scale, width: 3 * scale, height: 3 * scale)))
|
|
258
|
+
path.append(UIBezierPath(ovalIn: CGRect(x: 2.5 * scale, y: 16.5 * scale, width: 3 * scale, height: 3 * scale)))
|
|
259
|
+
|
|
260
|
+
// Lines
|
|
261
|
+
path.move(to: CGPoint(x: 7 * scale, y: 19 * scale))
|
|
262
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 19 * scale))
|
|
263
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 17 * scale))
|
|
264
|
+
path.addLine(to: CGPoint(x: 7 * scale, y: 17 * scale))
|
|
265
|
+
path.close()
|
|
266
|
+
|
|
267
|
+
path.move(to: CGPoint(x: 7 * scale, y: 13 * scale))
|
|
268
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 13 * scale))
|
|
269
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 11 * scale))
|
|
270
|
+
path.addLine(to: CGPoint(x: 7 * scale, y: 11 * scale))
|
|
271
|
+
path.close()
|
|
272
|
+
|
|
273
|
+
path.move(to: CGPoint(x: 7 * scale, y: 5 * scale))
|
|
274
|
+
path.addLine(to: CGPoint(x: 7 * scale, y: 7 * scale))
|
|
275
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 7 * scale))
|
|
276
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 5 * scale))
|
|
277
|
+
path.close()
|
|
278
|
+
|
|
279
|
+
path.fill()
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
private static func drawNumberedListIcon(color: UIColor, size: CGSize) -> UIImage {
|
|
284
|
+
return drawIcon(size: size, color: color) { ctx, scale in
|
|
285
|
+
// Draw numbers using text
|
|
286
|
+
let paragraphStyle = NSMutableParagraphStyle()
|
|
287
|
+
paragraphStyle.alignment = .left
|
|
288
|
+
let attrs: [NSAttributedString.Key: Any] = [
|
|
289
|
+
.font: UIFont.systemFont(ofSize: 8 * scale, weight: .medium),
|
|
290
|
+
.foregroundColor: color
|
|
291
|
+
]
|
|
292
|
+
|
|
293
|
+
"1".draw(at: CGPoint(x: 3 * scale, y: 4 * scale), withAttributes: attrs)
|
|
294
|
+
"2".draw(at: CGPoint(x: 3 * scale, y: 10 * scale), withAttributes: attrs)
|
|
295
|
+
"3".draw(at: CGPoint(x: 3 * scale, y: 16 * scale), withAttributes: attrs)
|
|
296
|
+
|
|
297
|
+
// Lines
|
|
298
|
+
let path = UIBezierPath()
|
|
299
|
+
path.move(to: CGPoint(x: 7 * scale, y: 5 * scale))
|
|
300
|
+
path.addLine(to: CGPoint(x: 7 * scale, y: 7 * scale))
|
|
301
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 7 * scale))
|
|
302
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 5 * scale))
|
|
303
|
+
path.close()
|
|
304
|
+
|
|
305
|
+
path.move(to: CGPoint(x: 7 * scale, y: 13 * scale))
|
|
306
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 13 * scale))
|
|
307
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 11 * scale))
|
|
308
|
+
path.addLine(to: CGPoint(x: 7 * scale, y: 11 * scale))
|
|
309
|
+
path.close()
|
|
310
|
+
|
|
311
|
+
path.move(to: CGPoint(x: 7 * scale, y: 19 * scale))
|
|
312
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 19 * scale))
|
|
313
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 17 * scale))
|
|
314
|
+
path.addLine(to: CGPoint(x: 7 * scale, y: 17 * scale))
|
|
315
|
+
path.close()
|
|
316
|
+
|
|
317
|
+
path.fill()
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
private static func drawQuoteIcon(color: UIColor, size: CGSize) -> UIImage {
|
|
322
|
+
return drawIcon(size: size, color: color) { ctx, scale in
|
|
323
|
+
let path = UIBezierPath()
|
|
324
|
+
// Left quote
|
|
325
|
+
path.move(to: CGPoint(x: 6 * scale, y: 17 * scale))
|
|
326
|
+
path.addLine(to: CGPoint(x: 9 * scale, y: 17 * scale))
|
|
327
|
+
path.addLine(to: CGPoint(x: 11 * scale, y: 13 * scale))
|
|
328
|
+
path.addLine(to: CGPoint(x: 11 * scale, y: 7 * scale))
|
|
329
|
+
path.addLine(to: CGPoint(x: 5 * scale, y: 7 * scale))
|
|
330
|
+
path.addLine(to: CGPoint(x: 5 * scale, y: 13 * scale))
|
|
331
|
+
path.addLine(to: CGPoint(x: 8 * scale, y: 13 * scale))
|
|
332
|
+
path.close()
|
|
333
|
+
|
|
334
|
+
// Right quote
|
|
335
|
+
path.move(to: CGPoint(x: 14 * scale, y: 17 * scale))
|
|
336
|
+
path.addLine(to: CGPoint(x: 17 * scale, y: 17 * scale))
|
|
337
|
+
path.addLine(to: CGPoint(x: 19 * scale, y: 13 * scale))
|
|
338
|
+
path.addLine(to: CGPoint(x: 19 * scale, y: 7 * scale))
|
|
339
|
+
path.addLine(to: CGPoint(x: 13 * scale, y: 7 * scale))
|
|
340
|
+
path.addLine(to: CGPoint(x: 13 * scale, y: 13 * scale))
|
|
341
|
+
path.addLine(to: CGPoint(x: 16 * scale, y: 13 * scale))
|
|
342
|
+
path.close()
|
|
343
|
+
|
|
344
|
+
path.fill()
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
private static func drawChecklistIcon(color: UIColor, size: CGSize) -> UIImage {
|
|
349
|
+
return drawIcon(size: size, color: color) { ctx, scale in
|
|
350
|
+
let path = UIBezierPath()
|
|
351
|
+
// Lines
|
|
352
|
+
path.move(to: CGPoint(x: 22 * scale, y: 7 * scale))
|
|
353
|
+
path.addLine(to: CGPoint(x: 13 * scale, y: 7 * scale))
|
|
354
|
+
path.addLine(to: CGPoint(x: 13 * scale, y: 9 * scale))
|
|
355
|
+
path.addLine(to: CGPoint(x: 22 * scale, y: 9 * scale))
|
|
356
|
+
path.close()
|
|
357
|
+
|
|
358
|
+
path.move(to: CGPoint(x: 22 * scale, y: 15 * scale))
|
|
359
|
+
path.addLine(to: CGPoint(x: 13 * scale, y: 15 * scale))
|
|
360
|
+
path.addLine(to: CGPoint(x: 13 * scale, y: 17 * scale))
|
|
361
|
+
path.addLine(to: CGPoint(x: 22 * scale, y: 17 * scale))
|
|
362
|
+
path.close()
|
|
363
|
+
|
|
364
|
+
// Checkmarks
|
|
365
|
+
path.move(to: CGPoint(x: 5.54 * scale, y: 11 * scale))
|
|
366
|
+
path.addLine(to: CGPoint(x: 2 * scale, y: 7.46 * scale))
|
|
367
|
+
path.addLine(to: CGPoint(x: 3.41 * scale, y: 6.05 * scale))
|
|
368
|
+
path.addLine(to: CGPoint(x: 5.53 * scale, y: 8.17 * scale))
|
|
369
|
+
path.addLine(to: CGPoint(x: 9.77 * scale, y: 3.93 * scale))
|
|
370
|
+
path.addLine(to: CGPoint(x: 11.18 * scale, y: 5.34 * scale))
|
|
371
|
+
path.close()
|
|
372
|
+
|
|
373
|
+
path.move(to: CGPoint(x: 5.54 * scale, y: 19 * scale))
|
|
374
|
+
path.addLine(to: CGPoint(x: 2 * scale, y: 15.46 * scale))
|
|
375
|
+
path.addLine(to: CGPoint(x: 3.41 * scale, y: 14.05 * scale))
|
|
376
|
+
path.addLine(to: CGPoint(x: 5.53 * scale, y: 16.17 * scale))
|
|
377
|
+
path.addLine(to: CGPoint(x: 9.77 * scale, y: 11.93 * scale))
|
|
378
|
+
path.addLine(to: CGPoint(x: 11.18 * scale, y: 13.34 * scale))
|
|
379
|
+
path.close()
|
|
380
|
+
|
|
381
|
+
path.fill()
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
private static func drawLinkIcon(color: UIColor, size: CGSize) -> UIImage {
|
|
386
|
+
return drawIcon(size: size, color: color) { ctx, scale in
|
|
387
|
+
let path = UIBezierPath()
|
|
388
|
+
// Left chain
|
|
389
|
+
path.move(to: CGPoint(x: 3.9 * scale, y: 12 * scale))
|
|
390
|
+
path.addCurve(to: CGPoint(x: 7 * scale, y: 8.9 * scale),
|
|
391
|
+
controlPoint1: CGPoint(x: 3.9 * scale, y: 10.29 * scale),
|
|
392
|
+
controlPoint2: CGPoint(x: 5.29 * scale, y: 8.9 * scale))
|
|
393
|
+
path.addLine(to: CGPoint(x: 11 * scale, y: 8.9 * scale))
|
|
394
|
+
path.addLine(to: CGPoint(x: 11 * scale, y: 7 * scale))
|
|
395
|
+
path.addLine(to: CGPoint(x: 7 * scale, y: 7 * scale))
|
|
396
|
+
path.addCurve(to: CGPoint(x: 2 * scale, y: 12 * scale),
|
|
397
|
+
controlPoint1: CGPoint(x: 4.24 * scale, y: 7 * scale),
|
|
398
|
+
controlPoint2: CGPoint(x: 2 * scale, y: 9.24 * scale))
|
|
399
|
+
path.addCurve(to: CGPoint(x: 7 * scale, y: 17 * scale),
|
|
400
|
+
controlPoint1: CGPoint(x: 2 * scale, y: 14.76 * scale),
|
|
401
|
+
controlPoint2: CGPoint(x: 4.24 * scale, y: 17 * scale))
|
|
402
|
+
path.addLine(to: CGPoint(x: 11 * scale, y: 17 * scale))
|
|
403
|
+
path.addLine(to: CGPoint(x: 11 * scale, y: 15.1 * scale))
|
|
404
|
+
path.addLine(to: CGPoint(x: 7 * scale, y: 15.1 * scale))
|
|
405
|
+
path.addCurve(to: CGPoint(x: 3.9 * scale, y: 12 * scale),
|
|
406
|
+
controlPoint1: CGPoint(x: 5.29 * scale, y: 15.1 * scale),
|
|
407
|
+
controlPoint2: CGPoint(x: 3.9 * scale, y: 13.71 * scale))
|
|
408
|
+
path.close()
|
|
409
|
+
|
|
410
|
+
// Middle bar
|
|
411
|
+
path.move(to: CGPoint(x: 8 * scale, y: 13 * scale))
|
|
412
|
+
path.addLine(to: CGPoint(x: 16 * scale, y: 13 * scale))
|
|
413
|
+
path.addLine(to: CGPoint(x: 16 * scale, y: 11 * scale))
|
|
414
|
+
path.addLine(to: CGPoint(x: 8 * scale, y: 11 * scale))
|
|
415
|
+
path.close()
|
|
416
|
+
|
|
417
|
+
// Right chain
|
|
418
|
+
path.move(to: CGPoint(x: 17 * scale, y: 7 * scale))
|
|
419
|
+
path.addLine(to: CGPoint(x: 13 * scale, y: 7 * scale))
|
|
420
|
+
path.addLine(to: CGPoint(x: 13 * scale, y: 8.9 * scale))
|
|
421
|
+
path.addLine(to: CGPoint(x: 17 * scale, y: 8.9 * scale))
|
|
422
|
+
path.addCurve(to: CGPoint(x: 20.1 * scale, y: 12 * scale),
|
|
423
|
+
controlPoint1: CGPoint(x: 18.71 * scale, y: 8.9 * scale),
|
|
424
|
+
controlPoint2: CGPoint(x: 20.1 * scale, y: 10.29 * scale))
|
|
425
|
+
path.addCurve(to: CGPoint(x: 17 * scale, y: 15.1 * scale),
|
|
426
|
+
controlPoint1: CGPoint(x: 20.1 * scale, y: 13.71 * scale),
|
|
427
|
+
controlPoint2: CGPoint(x: 18.71 * scale, y: 15.1 * scale))
|
|
428
|
+
path.addLine(to: CGPoint(x: 13 * scale, y: 15.1 * scale))
|
|
429
|
+
path.addLine(to: CGPoint(x: 13 * scale, y: 17 * scale))
|
|
430
|
+
path.addLine(to: CGPoint(x: 17 * scale, y: 17 * scale))
|
|
431
|
+
path.addCurve(to: CGPoint(x: 22 * scale, y: 12 * scale),
|
|
432
|
+
controlPoint1: CGPoint(x: 19.76 * scale, y: 17 * scale),
|
|
433
|
+
controlPoint2: CGPoint(x: 22 * scale, y: 14.76 * scale))
|
|
434
|
+
path.addCurve(to: CGPoint(x: 17 * scale, y: 7 * scale),
|
|
435
|
+
controlPoint1: CGPoint(x: 22 * scale, y: 9.24 * scale),
|
|
436
|
+
controlPoint2: CGPoint(x: 19.76 * scale, y: 7 * scale))
|
|
437
|
+
path.close()
|
|
438
|
+
|
|
439
|
+
path.fill()
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
private static func drawUndoIcon(color: UIColor, size: CGSize) -> UIImage {
|
|
444
|
+
return drawIcon(size: size, color: color) { ctx, scale in
|
|
445
|
+
let path = UIBezierPath()
|
|
446
|
+
path.move(to: CGPoint(x: 12.5 * scale, y: 8 * scale))
|
|
447
|
+
path.addCurve(to: CGPoint(x: 5.67 * scale, y: 10.73 * scale),
|
|
448
|
+
controlPoint1: CGPoint(x: 9.85 * scale, y: 8 * scale),
|
|
449
|
+
controlPoint2: CGPoint(x: 7.45 * scale, y: 9.04 * scale))
|
|
450
|
+
path.addLine(to: CGPoint(x: 3 * scale, y: 8 * scale))
|
|
451
|
+
path.addLine(to: CGPoint(x: 3 * scale, y: 17 * scale))
|
|
452
|
+
path.addLine(to: CGPoint(x: 12 * scale, y: 17 * scale))
|
|
453
|
+
path.addLine(to: CGPoint(x: 9.19 * scale, y: 14.19 * scale))
|
|
454
|
+
path.addCurve(to: CGPoint(x: 14.25 * scale, y: 12.25 * scale),
|
|
455
|
+
controlPoint1: CGPoint(x: 10.55 * scale, y: 12.98 * scale),
|
|
456
|
+
controlPoint2: CGPoint(x: 12.33 * scale, y: 12.25 * scale))
|
|
457
|
+
path.addCurve(to: CGPoint(x: 21.14 * scale, y: 18.25 * scale),
|
|
458
|
+
controlPoint1: CGPoint(x: 17.77 * scale, y: 12.25 * scale),
|
|
459
|
+
controlPoint2: CGPoint(x: 20.69 * scale, y: 14.86 * scale))
|
|
460
|
+
path.addLine(to: CGPoint(x: 23 * scale, y: 18.25 * scale))
|
|
461
|
+
path.addCurve(to: CGPoint(x: 14.25 * scale, y: 10.25 * scale),
|
|
462
|
+
controlPoint1: CGPoint(x: 22.54 * scale, y: 13.74 * scale),
|
|
463
|
+
controlPoint2: CGPoint(x: 18.9 * scale, y: 10.25 * scale))
|
|
464
|
+
path.addCurve(to: CGPoint(x: 12.5 * scale, y: 8 * scale),
|
|
465
|
+
controlPoint1: CGPoint(x: 13.66 * scale, y: 9.35 * scale),
|
|
466
|
+
controlPoint2: CGPoint(x: 13.05 * scale, y: 8.55 * scale))
|
|
467
|
+
path.close()
|
|
468
|
+
path.fill()
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
private static func drawRedoIcon(color: UIColor, size: CGSize) -> UIImage {
|
|
473
|
+
return drawIcon(size: size, color: color) { ctx, scale in
|
|
474
|
+
let path = UIBezierPath()
|
|
475
|
+
path.move(to: CGPoint(x: 18.4 * scale, y: 10.6 * scale))
|
|
476
|
+
path.addCurve(to: CGPoint(x: 11.5 * scale, y: 8 * scale),
|
|
477
|
+
controlPoint1: CGPoint(x: 16.55 * scale, y: 8.99 * scale),
|
|
478
|
+
controlPoint2: CGPoint(x: 14.15 * scale, y: 8 * scale))
|
|
479
|
+
path.addCurve(to: CGPoint(x: 1.54 * scale, y: 15.22 * scale),
|
|
480
|
+
controlPoint1: CGPoint(x: 6.85 * scale, y: 8 * scale),
|
|
481
|
+
controlPoint2: CGPoint(x: 2.92 * scale, y: 11.03 * scale))
|
|
482
|
+
path.addLine(to: CGPoint(x: 3.9 * scale, y: 16 * scale))
|
|
483
|
+
path.addCurve(to: CGPoint(x: 11.5 * scale, y: 10.5 * scale),
|
|
484
|
+
controlPoint1: CGPoint(x: 4.95 * scale, y: 12.81 * scale),
|
|
485
|
+
controlPoint2: CGPoint(x: 7.95 * scale, y: 10.5 * scale))
|
|
486
|
+
path.addCurve(to: CGPoint(x: 16.62 * scale, y: 12.38 * scale),
|
|
487
|
+
controlPoint1: CGPoint(x: 13.45 * scale, y: 10.5 * scale),
|
|
488
|
+
controlPoint2: CGPoint(x: 15.23 * scale, y: 11.22 * scale))
|
|
489
|
+
path.addLine(to: CGPoint(x: 13 * scale, y: 16 * scale))
|
|
490
|
+
path.addLine(to: CGPoint(x: 22 * scale, y: 16 * scale))
|
|
491
|
+
path.addLine(to: CGPoint(x: 22 * scale, y: 7 * scale))
|
|
492
|
+
path.close()
|
|
493
|
+
path.fill()
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
private static func drawClearFormattingIcon(color: UIColor, size: CGSize) -> UIImage {
|
|
498
|
+
return drawIcon(size: size, color: color) { ctx, scale in
|
|
499
|
+
let path = UIBezierPath()
|
|
500
|
+
// Diagonal line
|
|
501
|
+
path.move(to: CGPoint(x: 3.27 * scale, y: 5 * scale))
|
|
502
|
+
path.addLine(to: CGPoint(x: 2 * scale, y: 6.27 * scale))
|
|
503
|
+
path.addLine(to: CGPoint(x: 8.97 * scale, y: 13.24 * scale))
|
|
504
|
+
path.addLine(to: CGPoint(x: 6.5 * scale, y: 19 * scale))
|
|
505
|
+
path.addLine(to: CGPoint(x: 9.5 * scale, y: 19 * scale))
|
|
506
|
+
path.addLine(to: CGPoint(x: 11.07 * scale, y: 15.34 * scale))
|
|
507
|
+
path.addLine(to: CGPoint(x: 16.73 * scale, y: 21 * scale))
|
|
508
|
+
path.addLine(to: CGPoint(x: 18 * scale, y: 19.73 * scale))
|
|
509
|
+
path.addLine(to: CGPoint(x: 3.55 * scale, y: 5.27 * scale))
|
|
510
|
+
path.close()
|
|
511
|
+
|
|
512
|
+
// T shape
|
|
513
|
+
path.move(to: CGPoint(x: 6 * scale, y: 5 * scale))
|
|
514
|
+
path.addLine(to: CGPoint(x: 6 * scale, y: 5.18 * scale))
|
|
515
|
+
path.addLine(to: CGPoint(x: 8.82 * scale, y: 8 * scale))
|
|
516
|
+
path.addLine(to: CGPoint(x: 11.22 * scale, y: 8 * scale))
|
|
517
|
+
path.addLine(to: CGPoint(x: 10.5 * scale, y: 9.68 * scale))
|
|
518
|
+
path.addLine(to: CGPoint(x: 12.6 * scale, y: 11.78 * scale))
|
|
519
|
+
path.addLine(to: CGPoint(x: 14.21 * scale, y: 8 * scale))
|
|
520
|
+
path.addLine(to: CGPoint(x: 20 * scale, y: 8 * scale))
|
|
521
|
+
path.addLine(to: CGPoint(x: 20 * scale, y: 5 * scale))
|
|
522
|
+
path.close()
|
|
523
|
+
|
|
524
|
+
path.fill()
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
private static func drawIndentIcon(color: UIColor, size: CGSize) -> UIImage {
|
|
529
|
+
return drawIcon(size: size, color: color) { ctx, scale in
|
|
530
|
+
let path = UIBezierPath()
|
|
531
|
+
// Lines
|
|
532
|
+
path.move(to: CGPoint(x: 3 * scale, y: 21 * scale))
|
|
533
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 21 * scale))
|
|
534
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 19 * scale))
|
|
535
|
+
path.addLine(to: CGPoint(x: 3 * scale, y: 19 * scale))
|
|
536
|
+
path.close()
|
|
537
|
+
|
|
538
|
+
// Arrow
|
|
539
|
+
path.move(to: CGPoint(x: 3 * scale, y: 8 * scale))
|
|
540
|
+
path.addLine(to: CGPoint(x: 3 * scale, y: 16 * scale))
|
|
541
|
+
path.addLine(to: CGPoint(x: 7 * scale, y: 12 * scale))
|
|
542
|
+
path.close()
|
|
543
|
+
|
|
544
|
+
path.move(to: CGPoint(x: 11 * scale, y: 17 * scale))
|
|
545
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 17 * scale))
|
|
546
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 15 * scale))
|
|
547
|
+
path.addLine(to: CGPoint(x: 11 * scale, y: 15 * scale))
|
|
548
|
+
path.close()
|
|
549
|
+
|
|
550
|
+
path.move(to: CGPoint(x: 3 * scale, y: 3 * scale))
|
|
551
|
+
path.addLine(to: CGPoint(x: 3 * scale, y: 5 * scale))
|
|
552
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 5 * scale))
|
|
553
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 3 * scale))
|
|
554
|
+
path.close()
|
|
555
|
+
|
|
556
|
+
path.move(to: CGPoint(x: 11 * scale, y: 9 * scale))
|
|
557
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 9 * scale))
|
|
558
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 7 * scale))
|
|
559
|
+
path.addLine(to: CGPoint(x: 11 * scale, y: 7 * scale))
|
|
560
|
+
path.close()
|
|
561
|
+
|
|
562
|
+
path.move(to: CGPoint(x: 11 * scale, y: 13 * scale))
|
|
563
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 13 * scale))
|
|
564
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 11 * scale))
|
|
565
|
+
path.addLine(to: CGPoint(x: 11 * scale, y: 11 * scale))
|
|
566
|
+
path.close()
|
|
567
|
+
|
|
568
|
+
path.fill()
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
private static func drawOutdentIcon(color: UIColor, size: CGSize) -> UIImage {
|
|
573
|
+
return drawIcon(size: size, color: color) { ctx, scale in
|
|
574
|
+
let path = UIBezierPath()
|
|
575
|
+
path.move(to: CGPoint(x: 11 * scale, y: 17 * scale))
|
|
576
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 17 * scale))
|
|
577
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 15 * scale))
|
|
578
|
+
path.addLine(to: CGPoint(x: 11 * scale, y: 15 * scale))
|
|
579
|
+
path.close()
|
|
580
|
+
|
|
581
|
+
// Arrow pointing left
|
|
582
|
+
path.move(to: CGPoint(x: 3 * scale, y: 12 * scale))
|
|
583
|
+
path.addLine(to: CGPoint(x: 7 * scale, y: 16 * scale))
|
|
584
|
+
path.addLine(to: CGPoint(x: 7 * scale, y: 8 * scale))
|
|
585
|
+
path.close()
|
|
586
|
+
|
|
587
|
+
path.move(to: CGPoint(x: 3 * scale, y: 21 * scale))
|
|
588
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 21 * scale))
|
|
589
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 19 * scale))
|
|
590
|
+
path.addLine(to: CGPoint(x: 3 * scale, y: 19 * scale))
|
|
591
|
+
path.close()
|
|
592
|
+
|
|
593
|
+
path.move(to: CGPoint(x: 3 * scale, y: 3 * scale))
|
|
594
|
+
path.addLine(to: CGPoint(x: 3 * scale, y: 5 * scale))
|
|
595
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 5 * scale))
|
|
596
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 3 * scale))
|
|
597
|
+
path.close()
|
|
598
|
+
|
|
599
|
+
path.move(to: CGPoint(x: 11 * scale, y: 9 * scale))
|
|
600
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 9 * scale))
|
|
601
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 7 * scale))
|
|
602
|
+
path.addLine(to: CGPoint(x: 11 * scale, y: 7 * scale))
|
|
603
|
+
path.close()
|
|
604
|
+
|
|
605
|
+
path.move(to: CGPoint(x: 11 * scale, y: 13 * scale))
|
|
606
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 13 * scale))
|
|
607
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 11 * scale))
|
|
608
|
+
path.addLine(to: CGPoint(x: 11 * scale, y: 11 * scale))
|
|
609
|
+
path.close()
|
|
610
|
+
|
|
611
|
+
path.fill()
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
private static func drawAlignLeftIcon(color: UIColor, size: CGSize) -> UIImage {
|
|
616
|
+
return drawIcon(size: size, color: color) { ctx, scale in
|
|
617
|
+
let path = UIBezierPath()
|
|
618
|
+
path.move(to: CGPoint(x: 15 * scale, y: 15 * scale))
|
|
619
|
+
path.addLine(to: CGPoint(x: 3 * scale, y: 15 * scale))
|
|
620
|
+
path.addLine(to: CGPoint(x: 3 * scale, y: 17 * scale))
|
|
621
|
+
path.addLine(to: CGPoint(x: 15 * scale, y: 17 * scale))
|
|
622
|
+
path.close()
|
|
623
|
+
|
|
624
|
+
path.move(to: CGPoint(x: 15 * scale, y: 7 * scale))
|
|
625
|
+
path.addLine(to: CGPoint(x: 3 * scale, y: 7 * scale))
|
|
626
|
+
path.addLine(to: CGPoint(x: 3 * scale, y: 9 * scale))
|
|
627
|
+
path.addLine(to: CGPoint(x: 15 * scale, y: 9 * scale))
|
|
628
|
+
path.close()
|
|
629
|
+
|
|
630
|
+
path.move(to: CGPoint(x: 3 * scale, y: 13 * scale))
|
|
631
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 13 * scale))
|
|
632
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 11 * scale))
|
|
633
|
+
path.addLine(to: CGPoint(x: 3 * scale, y: 11 * scale))
|
|
634
|
+
path.close()
|
|
635
|
+
|
|
636
|
+
path.move(to: CGPoint(x: 3 * scale, y: 21 * scale))
|
|
637
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 21 * scale))
|
|
638
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 19 * scale))
|
|
639
|
+
path.addLine(to: CGPoint(x: 3 * scale, y: 19 * scale))
|
|
640
|
+
path.close()
|
|
641
|
+
|
|
642
|
+
path.move(to: CGPoint(x: 3 * scale, y: 3 * scale))
|
|
643
|
+
path.addLine(to: CGPoint(x: 3 * scale, y: 5 * scale))
|
|
644
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 5 * scale))
|
|
645
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 3 * scale))
|
|
646
|
+
path.close()
|
|
647
|
+
|
|
648
|
+
path.fill()
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
private static func drawAlignCenterIcon(color: UIColor, size: CGSize) -> UIImage {
|
|
653
|
+
return drawIcon(size: size, color: color) { ctx, scale in
|
|
654
|
+
let path = UIBezierPath()
|
|
655
|
+
path.move(to: CGPoint(x: 7 * scale, y: 15 * scale))
|
|
656
|
+
path.addLine(to: CGPoint(x: 7 * scale, y: 17 * scale))
|
|
657
|
+
path.addLine(to: CGPoint(x: 17 * scale, y: 17 * scale))
|
|
658
|
+
path.addLine(to: CGPoint(x: 17 * scale, y: 15 * scale))
|
|
659
|
+
path.close()
|
|
660
|
+
|
|
661
|
+
path.move(to: CGPoint(x: 3 * scale, y: 21 * scale))
|
|
662
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 21 * scale))
|
|
663
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 19 * scale))
|
|
664
|
+
path.addLine(to: CGPoint(x: 3 * scale, y: 19 * scale))
|
|
665
|
+
path.close()
|
|
666
|
+
|
|
667
|
+
path.move(to: CGPoint(x: 3 * scale, y: 13 * scale))
|
|
668
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 13 * scale))
|
|
669
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 11 * scale))
|
|
670
|
+
path.addLine(to: CGPoint(x: 3 * scale, y: 11 * scale))
|
|
671
|
+
path.close()
|
|
672
|
+
|
|
673
|
+
path.move(to: CGPoint(x: 7 * scale, y: 7 * scale))
|
|
674
|
+
path.addLine(to: CGPoint(x: 7 * scale, y: 9 * scale))
|
|
675
|
+
path.addLine(to: CGPoint(x: 17 * scale, y: 9 * scale))
|
|
676
|
+
path.addLine(to: CGPoint(x: 17 * scale, y: 7 * scale))
|
|
677
|
+
path.close()
|
|
678
|
+
|
|
679
|
+
path.move(to: CGPoint(x: 3 * scale, y: 3 * scale))
|
|
680
|
+
path.addLine(to: CGPoint(x: 3 * scale, y: 5 * scale))
|
|
681
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 5 * scale))
|
|
682
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 3 * scale))
|
|
683
|
+
path.close()
|
|
684
|
+
|
|
685
|
+
path.fill()
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
private static func drawAlignRightIcon(color: UIColor, size: CGSize) -> UIImage {
|
|
690
|
+
return drawIcon(size: size, color: color) { ctx, scale in
|
|
691
|
+
let path = UIBezierPath()
|
|
692
|
+
path.move(to: CGPoint(x: 3 * scale, y: 21 * scale))
|
|
693
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 21 * scale))
|
|
694
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 19 * scale))
|
|
695
|
+
path.addLine(to: CGPoint(x: 3 * scale, y: 19 * scale))
|
|
696
|
+
path.close()
|
|
697
|
+
|
|
698
|
+
path.move(to: CGPoint(x: 9 * scale, y: 17 * scale))
|
|
699
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 17 * scale))
|
|
700
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 15 * scale))
|
|
701
|
+
path.addLine(to: CGPoint(x: 9 * scale, y: 15 * scale))
|
|
702
|
+
path.close()
|
|
703
|
+
|
|
704
|
+
path.move(to: CGPoint(x: 3 * scale, y: 13 * scale))
|
|
705
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 13 * scale))
|
|
706
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 11 * scale))
|
|
707
|
+
path.addLine(to: CGPoint(x: 3 * scale, y: 11 * scale))
|
|
708
|
+
path.close()
|
|
709
|
+
|
|
710
|
+
path.move(to: CGPoint(x: 9 * scale, y: 9 * scale))
|
|
711
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 9 * scale))
|
|
712
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 7 * scale))
|
|
713
|
+
path.addLine(to: CGPoint(x: 9 * scale, y: 7 * scale))
|
|
714
|
+
path.close()
|
|
715
|
+
|
|
716
|
+
path.move(to: CGPoint(x: 3 * scale, y: 3 * scale))
|
|
717
|
+
path.addLine(to: CGPoint(x: 3 * scale, y: 5 * scale))
|
|
718
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 5 * scale))
|
|
719
|
+
path.addLine(to: CGPoint(x: 21 * scale, y: 3 * scale))
|
|
720
|
+
path.close()
|
|
721
|
+
|
|
722
|
+
path.fill()
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
// MARK: - Helper
|
|
727
|
+
|
|
728
|
+
private static func drawIcon(size: CGSize, color: UIColor, draw: (CGContext, CGFloat) -> Void) -> UIImage {
|
|
729
|
+
let renderer = UIGraphicsImageRenderer(size: size)
|
|
730
|
+
return renderer.image { context in
|
|
731
|
+
color.setFill()
|
|
732
|
+
let scale = size.width / 24.0
|
|
733
|
+
draw(context.cgContext, scale)
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
}
|