Skip to content
Merged
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
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* [*] Add "File Size" to Site Media Details [#24947]
* [*] Add "Email to Subscribers" row to "Publishing" sheet [#24946]
* [*] Add permalink preview in the slug editor and make other improvements [#24949]
* [*] Update "Categories" picker to indicate multiple selection [#24952]

26.4
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ import WordPressUI
switch selectionMode {
case .post:
navigationItem.rightBarButtonItem = rightBarButtonItem
title = NSLocalizedString("Post Categories", comment: "Title for selecting categories for a post")
title = Strings.postCategoriesTitle
case .parent:
navigationItem.rightBarButtonItem = rightBarButtonItem
title = NSLocalizedString("Parent Category", comment: "Title for selecting parent category of a category")
title = Strings.parentCategoryTitle
case .blogDefault:
title = NSLocalizedString("Default Category", comment: "Title for selecting a default category for a post")
title = Strings.defaultCategoryTitle
}
}

Expand Down Expand Up @@ -170,7 +170,7 @@ import WordPressUI
private func configureNoCategoryRow(cell: WPTableViewCell) {
WPStyleGuide.configureTableViewDestructiveActionCell(cell)
cell.textLabel?.textAlignment = .natural
cell.textLabel?.text = NSLocalizedString("No Category", comment: "Text shown (to select no-category) in the parent-category-selection screen when creating a new category.")
cell.textLabel?.text = Strings.noCategoryText
if selectedCategories.isEmpty {
cell.accessoryType = selectedCategories.isEmpty ? .checkmark : .none
} else {
Expand All @@ -184,11 +184,14 @@ import WordPressUI
cell.indentationWidth = Constants.categoryCellIndentation
cell.textLabel?.text = category.categoryName.stringByDecodingXMLCharacters()
WPStyleGuide.configureTableViewCell(cell)
if selectedCategories.contains(category) {
cell.accessoryType = .checkmark
} else {
cell.accessoryType = .none
}
cell.accessoryView = makeAccessoryView(isSelected: selectedCategories.contains(category))
}

private func makeAccessoryView(isSelected: Bool) -> UIView {
let image = UIImage(systemName: isSelected ? "checkmark.circle.fill" : "circle")
let view = UIImageView(image: image)
view.tintColor = isSelected ? UIAppColor.primary : .opaqueSeparator
return view
}

//tableView
Expand Down Expand Up @@ -255,10 +258,10 @@ import WordPressUI
if selectedCategories.contains(category),
let index = selectedCategories.firstIndex(of: category) {
selectedCategories.remove(at: index)
tableView.cellForRow(at: indexPath)?.accessoryType = .none
tableView.cellForRow(at: indexPath)?.accessoryView = makeAccessoryView(isSelected: false)
} else {
selectedCategories.append(category)
tableView.cellForRow(at: indexPath)?.accessoryType = .checkmark
tableView.cellForRow(at: indexPath)?.accessoryView = makeAccessoryView(isSelected: true)
}

delegate?.postCategoriesViewController?(self, didUpdateSelectedCategories: NSSet(array: selectedCategories))
Expand All @@ -284,4 +287,30 @@ private extension PostCategoriesViewController {
static let categoryCellIdentifier = "CategoryCellIdentifier"
static let categoryCellIndentation = CGFloat(16.0)
}

enum Strings {
static let postCategoriesTitle = NSLocalizedString(
"postCategories.title",
value: "Categories",
comment: "Title for selecting categories for a post or a page"
)

static let parentCategoryTitle = NSLocalizedString(
"parentCategory.title",
value: "Parent Category",
comment: "Title for selecting parent category of a category"
)

static let defaultCategoryTitle = NSLocalizedString(
"defaultCategory.title",
value: "Default Category",
comment: "Title for selecting a default category for a post"
)

static let noCategoryText = NSLocalizedString(
"parentCategory.noCategory",
value: "No Category",
comment: "Text shown (to select no-category) in the parent-category-selection screen when creating a new category."
)
}
}