polish code
This commit is contained in:
parent
9a871ef852
commit
c76f1c24b0
2 changed files with 20 additions and 15 deletions
|
|
@ -19,6 +19,15 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
|
||||||
struct TableCell {
|
struct TableCell {
|
||||||
var title: String
|
var title: String
|
||||||
var content: String
|
var content: String
|
||||||
|
init() {
|
||||||
|
title = ""
|
||||||
|
content = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
init(title: String, content: String) {
|
||||||
|
self.title = title
|
||||||
|
self.content = content
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TableSection {
|
struct TableSection {
|
||||||
|
|
@ -63,6 +72,9 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
|
||||||
passwordImage = image
|
passwordImage = image
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tableData.append(TableSection(title: "", item: []))
|
||||||
|
tableData[0].item.append(TableCell())
|
||||||
|
|
||||||
DispatchQueue.global(qos: .userInitiated).async {
|
DispatchQueue.global(qos: .userInitiated).async {
|
||||||
do {
|
do {
|
||||||
self.password = try self.passwordEntity!.decrypt()!
|
self.password = try self.passwordEntity!.decrypt()!
|
||||||
|
|
@ -74,7 +86,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
|
||||||
self.present(alert, animated: true, completion: nil)
|
self.present(alert, animated: true, completion: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
var tableDataIndex = 0
|
var tableDataIndex = 1
|
||||||
self.tableData.append(TableSection(title: "", item: []))
|
self.tableData.append(TableSection(title: "", item: []))
|
||||||
if self.password.username != "" {
|
if self.password.username != "" {
|
||||||
self.tableData[tableDataIndex].item.append(TableCell(title: "username", content: self.password.username))
|
self.tableData[tableDataIndex].item.append(TableCell(title: "username", content: self.password.username))
|
||||||
|
|
@ -141,14 +153,11 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
|
||||||
|
|
||||||
|
|
||||||
override func numberOfSections(in tableView: UITableView) -> Int {
|
override func numberOfSections(in tableView: UITableView) -> Int {
|
||||||
return tableData.count + 1
|
return tableData.count
|
||||||
}
|
}
|
||||||
|
|
||||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||||
if section == 0 {
|
return tableData[section].item.count
|
||||||
return 1
|
|
||||||
}
|
|
||||||
return tableData[section - 1].item.count
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||||
|
|
@ -161,11 +170,10 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
|
||||||
cell.nameLabel.text = passwordEntity?.name
|
cell.nameLabel.text = passwordEntity?.name
|
||||||
cell.categoryLabel.text = passwordCategoryText
|
cell.categoryLabel.text = passwordCategoryText
|
||||||
return cell
|
return cell
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
let cell = tableView.dequeueReusableCell(withIdentifier: "labelCell", for: indexPath) as! LabelTableViewCell
|
let cell = tableView.dequeueReusableCell(withIdentifier: "labelCell", for: indexPath) as! LabelTableViewCell
|
||||||
let titleData = tableData[sectionIndex - 1].item[rowIndex].title
|
let titleData = tableData[sectionIndex].item[rowIndex].title
|
||||||
let contentData = tableData[sectionIndex - 1].item[rowIndex].content
|
let contentData = tableData[sectionIndex].item[rowIndex].content
|
||||||
cell.password = password
|
cell.password = password
|
||||||
cell.isPasswordCell = (titleData.lowercased() == "password" ? true : false)
|
cell.isPasswordCell = (titleData.lowercased() == "password" ? true : false)
|
||||||
cell.isURLCell = (titleData.lowercased() == "url" ? true : false)
|
cell.isURLCell = (titleData.lowercased() == "url" ? true : false)
|
||||||
|
|
@ -175,10 +183,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
|
||||||
}
|
}
|
||||||
|
|
||||||
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
|
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
|
||||||
if section == 0 {
|
return tableData[section].title
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return tableData[section - 1].title
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func tableView(_ tableView: UITableView, performAction action: Selector, forRowAt indexPath: IndexPath, withSender sender: Any?) {
|
override func tableView(_ tableView: UITableView, performAction action: Selector, forRowAt indexPath: IndexPath, withSender sender: Any?) {
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,12 @@
|
||||||
<key>UIApplicationShortcutItems</key>
|
<key>UIApplicationShortcutItems</key>
|
||||||
<array>
|
<array>
|
||||||
<dict>
|
<dict>
|
||||||
|
<key>UIApplicationShortcutItemIconType</key>
|
||||||
|
<string>UIApplicationShortcutIconTypeSearch</string>
|
||||||
<key>UIApplicationShortcutItemTitle</key>
|
<key>UIApplicationShortcutItemTitle</key>
|
||||||
<string>Search</string>
|
<string>Search</string>
|
||||||
<key>UIApplicationShortcutItemType</key>
|
<key>UIApplicationShortcutItemType</key>
|
||||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER).search</string>
|
<string>$(PRODUCT_BUNDLE_IDENTIFIER).search</string>
|
||||||
<key>UIApplicationShortcutItemIconType</key>
|
|
||||||
<string>UIApplicationShortcutIconTypeSearch</string>
|
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
<key>UILaunchStoryboardName</key>
|
<key>UILaunchStoryboardName</key>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue