Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compute NavigationRightButton text #758

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Source/Configuration/YPWordings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
2 changes: 1 addition & 1 deletion Source/Filters/Photo/YPPhotoFiltersVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion Source/Filters/Video/YPVideoFiltersVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion Source/SelectionsGallery/YPSelectionsGalleryVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 2 additions & 1 deletion Source/YPPickerVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down