修复收集箱有内容时无法进入
This commit is contained in:
+15
-13
@@ -15,15 +15,16 @@ class ViewController: UIViewController {
|
|||||||
let icon: String
|
let icon: String
|
||||||
let iconColor: UIColor
|
let iconColor: UIColor
|
||||||
let title: String
|
let title: String
|
||||||
|
let identifier: String
|
||||||
}
|
}
|
||||||
|
|
||||||
private var menuItems: [[MenuItem]] = [
|
private var menuItems: [[MenuItem]] = [
|
||||||
[
|
[
|
||||||
MenuItem(icon: "tray.full", iconColor: .systemIndigo, title: "收集箱"),
|
MenuItem(icon: "tray.full", iconColor: .systemIndigo, title: "收集箱", identifier: "inbox"),
|
||||||
MenuItem(icon: "note.text", iconColor: .systemYellow, title: "打开备忘录"),
|
MenuItem(icon: "note.text", iconColor: .systemYellow, title: "打开备忘录", identifier: "notes"),
|
||||||
MenuItem(icon: "doc.text", iconColor: .systemBlue, title: "格式化日志"),
|
MenuItem(icon: "doc.text", iconColor: .systemBlue, title: "格式化日志", identifier: "formatLog"),
|
||||||
MenuItem(icon: "text.alignleft", iconColor: .systemGreen, title: "格式化笔记"),
|
MenuItem(icon: "text.alignleft", iconColor: .systemGreen, title: "格式化笔记", identifier: "formatNote"),
|
||||||
MenuItem(icon: "folder", iconColor: .systemOrange, title: "打开文件")
|
MenuItem(icon: "folder", iconColor: .systemOrange, title: "打开文件", identifier: "files")
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -92,19 +93,19 @@ extension ViewController: UITableViewDelegate {
|
|||||||
tableView.deselectRow(at: indexPath, animated: true)
|
tableView.deselectRow(at: indexPath, animated: true)
|
||||||
|
|
||||||
let item = menuItems[indexPath.section][indexPath.row]
|
let item = menuItems[indexPath.section][indexPath.row]
|
||||||
switch item.title {
|
switch item.identifier {
|
||||||
case "收集箱":
|
case "inbox":
|
||||||
let viewController = ClipInboxViewController()
|
let viewController = ClipInboxViewController()
|
||||||
navigationController?.pushViewController(viewController, animated: true)
|
navigationController?.pushViewController(viewController, animated: true)
|
||||||
case "打开备忘录":
|
case "notes":
|
||||||
openSystemNotesApp()
|
openSystemNotesApp()
|
||||||
case "格式化日志":
|
case "formatLog":
|
||||||
let viewController = FormatLogViewController()
|
let viewController = FormatLogViewController()
|
||||||
navigationController?.pushViewController(viewController, animated: true)
|
navigationController?.pushViewController(viewController, animated: true)
|
||||||
case "格式化笔记":
|
case "formatNote":
|
||||||
let viewController = FormatNoteViewController()
|
let viewController = FormatNoteViewController()
|
||||||
navigationController?.pushViewController(viewController, animated: true)
|
navigationController?.pushViewController(viewController, animated: true)
|
||||||
case "打开文件":
|
case "files":
|
||||||
openFilesApp()
|
openFilesApp()
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
@@ -128,11 +129,12 @@ extension ViewController: UITableViewDelegate {
|
|||||||
private func updateInboxTitle(_ title: String) {
|
private func updateInboxTitle(_ title: String) {
|
||||||
for (sectionIndex, section) in menuItems.enumerated() {
|
for (sectionIndex, section) in menuItems.enumerated() {
|
||||||
for (rowIndex, item) in section.enumerated() {
|
for (rowIndex, item) in section.enumerated() {
|
||||||
if item.title.hasPrefix("收集箱") {
|
if item.identifier == "inbox" {
|
||||||
menuItems[sectionIndex][rowIndex] = MenuItem(
|
menuItems[sectionIndex][rowIndex] = MenuItem(
|
||||||
icon: item.icon,
|
icon: item.icon,
|
||||||
iconColor: item.iconColor,
|
iconColor: item.iconColor,
|
||||||
title: title
|
title: title,
|
||||||
|
identifier: item.identifier
|
||||||
)
|
)
|
||||||
let indexPath = IndexPath(row: rowIndex, section: sectionIndex)
|
let indexPath = IndexPath(row: rowIndex, section: sectionIndex)
|
||||||
tableView.reloadRows(at: [indexPath], with: .none)
|
tableView.reloadRows(at: [indexPath], with: .none)
|
||||||
|
|||||||
Reference in New Issue
Block a user