Skip to content

Commit 09137bb

Browse files
committed
Support for custom text
1 parent 5136d33 commit 09137bb

File tree

6 files changed

+65
-17
lines changed

6 files changed

+65
-17
lines changed

Example/Example/ViewController.swift

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ class ViewController: UIViewController {
3939
override func viewDidLoad() {
4040
super.viewDidLoad()
4141

42-
self.setupUI()
42+
setupUI()
43+
configImageEditor()
4344
}
4445

4546
func setupUI() {
@@ -208,6 +209,24 @@ class ViewController: UIViewController {
208209
}
209210
}
210211

212+
func configImageEditor() {
213+
// ZLImageEditorUIConfiguration.default()
214+
// .languageType(.english)
215+
// .customLanguageConfig(
216+
// [
217+
// .cancel: "×",
218+
// .editFinish: "👌"
219+
// ]
220+
// )
221+
222+
ZLImageEditorConfiguration.default()
223+
// Provide a image sticker container view
224+
.imageStickerContainerView(ImageStickerContainerView())
225+
.fontChooserContainerView(FontChooserContainerView())
226+
// Custom filter
227+
// .filters = [.normal]
228+
}
229+
211230
@objc func pickImage() {
212231
let picker = UIImagePickerController()
213232
picker.delegate = self
@@ -280,13 +299,6 @@ class ViewController: UIViewController {
280299
}
281300

282301
func editImage(_ image: UIImage, editModel: ZLEditImageModel?) {
283-
ZLImageEditorConfiguration.default()
284-
// Provide a image sticker container view
285-
.imageStickerContainerView(ImageStickerContainerView())
286-
.fontChooserContainerView(FontChooserContainerView())
287-
// Custom filter
288-
// .filters = [.normal]
289-
290302
ZLEditImageViewController.showEditImageVC(parentVC: self, image: image, editModel: editModel) { [weak self] (resImage, editModel) in
291303
self?.resultImageView.image = resImage
292304
self?.resultImageEditModel = editModel

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ ZLEditImageViewController.showEditImageVC(parentVC: self, image: image, editMode
6363
```
6464

6565
### <a id="Languages"></a>Languages
66-
🇨🇳 Chinese, 🇺🇸 English, 🇯🇵 Japanese, 🇫🇷 French, 🇩🇪 German, 🇷🇺 Russian, 🇻🇳 Vietnamese, 🇰🇷 Korean, 🇲🇾 Malay, 🇮🇹 Italian, 🇮🇩Indonesian.
66+
🇨🇳 Chinese, 🇺🇸 English, 🇯🇵 Japanese, 🇫🇷 French, 🇩🇪 German, 🇷🇺 Russian, 🇻🇳 Vietnamese, 🇰🇷 Korean, 🇲🇾 Malay, 🇮🇹 Italian, 🇮🇩 Indonesian, 🇪🇸 Spanish, 🇵🇹 Portuguese, 🇹🇷 Turkey.
6767

6868
### <a id="Installation"></a>Installation
6969
There are four ways to use ZLImageEditor in your project:

Sources/General/ZLImageEditorConfiguration.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,6 @@ public extension ZLImageEditorConfiguration {
236236
}
237237
}
238238

239-
// MARK: Image source deploy
240-
241-
enum ZLCustomImageDeploy {
242-
static var imageNames: [String] = []
243-
244-
static var imageForKey: [String: UIImage] = [:]
245-
}
246-
247239
// MARK: Clip ratio.
248240

249241
public class ZLImageClipRatio: NSObject {

Sources/General/ZLImageEditorLanguageDefine.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,9 @@ public struct ZLLocalLanguageKey: Hashable {
8181
}
8282

8383
func localLanguageTextValue(_ key: ZLLocalLanguageKey) -> String {
84+
if let value = ZLImageEditorUIConfiguration.default().customLanguageConfig[key] {
85+
return value
86+
}
87+
8488
return Bundle.zlLocalizedString(key.rawValue)
8589
}

Sources/General/ZLImageEditorUIConfiguration+Chaining.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ public extension ZLImageEditorUIConfiguration {
3939
return self
4040
}
4141

42+
@discardableResult
43+
func customLanguageConfig(_ config: [ZLLocalLanguageKey: String]) -> ZLImageEditorUIConfiguration {
44+
customLanguageConfig = config
45+
return self
46+
}
47+
4248
@discardableResult
4349
func customImageNames(_ names: [String]) -> ZLImageEditorUIConfiguration {
4450
customImageNames = names

Sources/General/ZLImageEditorUIConfiguration.swift

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,37 @@ public class ZLImageEditorUIConfiguration: NSObject {
4040
/// HUD style. Defaults to dark.
4141
@objc public var hudStyle: ZLProgressHUD.HUDStyle = .dark
4242

43+
// MARK: Language properties
44+
4345
/// Language for framework.
4446
@objc public var languageType: ZLImageEditorLanguageType = .system {
4547
didSet {
4648
Bundle.resetLanguage()
4749
}
4850
}
4951

52+
/// Developers can customize languages.
53+
/// - example: If you needs to replace
54+
/// key: .hudLoading, value: "loading, waiting please" language,
55+
/// The dictionary that needs to be passed in is [.hudLoading: "text to be replaced"].
56+
/// - warning: Please pay attention to the placeholders contained in languages when changing, such as %ld, %@.
57+
public var customLanguageConfig: [ZLLocalLanguageKey: String] = [:]
58+
59+
/// Developers can customize languages (This property is only for objc).
60+
/// - example: If you needs to replace
61+
/// key: @"loading", value: @"loading, waiting please" language,
62+
/// The dictionary that needs to be passed in is @[@"hudLoading": @"text to be replaced"].
63+
/// - warning: Please pay attention to the placeholders contained in languages when changing, such as %ld, %@.
64+
@objc public var customLanguageConfig_objc: [String: String] = [:] {
65+
didSet {
66+
var swiftParams: [ZLLocalLanguageKey: String] = [:]
67+
customLanguageConfig_objc.forEach { key, value in
68+
swiftParams[ZLLocalLanguageKey(rawValue: key)] = value
69+
}
70+
customLanguageConfig = swiftParams
71+
}
72+
}
73+
5074
/// Developers can customize images, but the name of the custom image resource must be consistent with the image name in the replaced bundle.
5175
/// - example: Developers need to replace the selected and unselected image resources, and the array that needs to be passed in is
5276
/// ["zl_btn_selected", "zl_btn_unselected"].
@@ -74,6 +98,8 @@ public class ZLImageEditorUIConfiguration: NSObject {
7498
}
7599
}
76100

101+
// MARK: Color properties
102+
77103
/// The normal color of adjust slider.
78104
@objc public var adjustSliderNormalColor = UIColor.white
79105

@@ -98,3 +124,11 @@ public class ZLImageEditorUIConfiguration: NSObject {
98124
/// The tint color of the title below the various tools in the image editor.
99125
@objc public var toolTitleTintColor = UIColor.white
100126
}
127+
128+
// MARK: Image source deploy
129+
130+
enum ZLCustomImageDeploy {
131+
static var imageNames: [String] = []
132+
133+
static var imageForKey: [String: UIImage] = [:]
134+
}

0 commit comments

Comments
 (0)