From 52d40851efe375ea4027f8f3f72bd03d1b6cdc63 Mon Sep 17 00:00:00 2001 From: d-nakajima Date: Fri, 2 Sep 2022 16:17:14 +0900 Subject: [PATCH] compute NavigationRightButton text --- Source/Configuration/YPWordings.swift | 28 +++++++++++++++++++ Source/Filters/Photo/YPPhotoFiltersVC.swift | 2 +- Source/Filters/Video/YPVideoFiltersVC.swift | 2 +- .../YPSelectionsGalleryVC.swift | 3 +- Source/YPPickerVC.swift | 3 +- 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/Source/Configuration/YPWordings.swift b/Source/Configuration/YPWordings.swift index 2a4288961..e668dbcba 100644 --- a/Source/Configuration/YPWordings.swift +++ b/Source/Configuration/YPWordings.swift @@ -42,3 +42,31 @@ public struct YPWordings { public var crop = ypLocalized("YPImagePickerCrop") public var warningMaxItemsLimit = ypLocalized("YPImagePickerWarningItemsLimit") } + +public enum YPImagePickerStep { + case pick + case multipleGallary + case filter + case crop +} + +extension YPWordings { + public func computeNavigationRightButtonText(step: YPImagePickerStep) -> String { + let config = YPConfig + let wordings = config.wordings + switch step { + case .pick: + if (config.showsPhotoFilters) { return wordings.next } + if case .none = config.showsCrop { return wordings.done } + else { return wordings.next } + case .multipleGallary: + if case .none = config.showsCrop { return wordings.done } + else { return wordings.next } + case .filter: + if case .none = config.showsCrop { return wordings.done } + else { return wordings.next } + case .crop: + return wordings.done + } + } +} diff --git a/Source/Filters/Photo/YPPhotoFiltersVC.swift b/Source/Filters/Photo/YPPhotoFiltersVC.swift index e8917121c..826d384b2 100644 --- a/Source/Filters/Photo/YPPhotoFiltersVC.swift +++ b/Source/Filters/Photo/YPPhotoFiltersVC.swift @@ -102,7 +102,7 @@ open class YPPhotoFiltersVC: UIViewController, IsMediaFilterVC, UIGestureRecogni // MARK: Setup - ⚙️ fileprivate func setupRightBarButton() { - let rightBarButtonTitle = isFromSelectionVC ? YPConfig.wordings.done : YPConfig.wordings.next + let rightBarButtonTitle = isFromSelectionVC ? YPConfig.wordings.done : YPWordings().computeNavigationRightButtonText(step: .filter) navigationItem.rightBarButtonItem = UIBarButtonItem(title: rightBarButtonTitle, style: .done, target: self, diff --git a/Source/Filters/Video/YPVideoFiltersVC.swift b/Source/Filters/Video/YPVideoFiltersVC.swift index 2e2c8e3a9..c026891f1 100644 --- a/Source/Filters/Video/YPVideoFiltersVC.swift +++ b/Source/Filters/Video/YPVideoFiltersVC.swift @@ -137,7 +137,7 @@ public final class YPVideoFiltersVC: UIViewController, IsMediaFilterVC { } private func setupRightBarButtonItem() { - let rightBarButtonTitle = isFromSelectionVC ? YPConfig.wordings.done : YPConfig.wordings.next + let rightBarButtonTitle = isFromSelectionVC ? YPConfig.wordings.done : YPWordings().computeNavigationRightButtonText(step: .filter) navigationItem.rightBarButtonItem = UIBarButtonItem(title: rightBarButtonTitle, style: .done, target: self, diff --git a/Source/SelectionsGallery/YPSelectionsGalleryVC.swift b/Source/SelectionsGallery/YPSelectionsGalleryVC.swift index 85dede0ee..3466c5c44 100644 --- a/Source/SelectionsGallery/YPSelectionsGalleryVC.swift +++ b/Source/SelectionsGallery/YPSelectionsGalleryVC.swift @@ -40,7 +40,8 @@ public class YPSelectionsGalleryVC: UIViewController, YPSelectionsGalleryCellDel v.collectionView.delegate = self // Setup navigation bar - navigationItem.rightBarButtonItem = UIBarButtonItem(title: YPConfig.wordings.next, + let title = YPWordings().computeNavigationRightButtonText(step: .multipleGallary) + navigationItem.rightBarButtonItem = UIBarButtonItem(title: title, style: .done, target: self, action: #selector(done)) diff --git a/Source/YPPickerVC.swift b/Source/YPPickerVC.swift index 64f361ff9..0774efbff 100644 --- a/Source/YPPickerVC.swift +++ b/Source/YPPickerVC.swift @@ -280,7 +280,8 @@ open class YPPickerVC: YPBottomPager, YPBottomPagerDelegate { switch mode { case .library: setTitleViewWithTitle(aTitle: libraryVC?.title ?? "") - navigationItem.rightBarButtonItem = UIBarButtonItem(title: YPConfig.wordings.next, + let title = YPWordings().computeNavigationRightButtonText(step: .pick) + navigationItem.rightBarButtonItem = UIBarButtonItem(title: title, style: .done, target: self, action: #selector(done))