Skip to content

Commit

Permalink
Design improvements
Browse files Browse the repository at this point in the history
	- New general color : systemgray6 for all views
	- Colors are more united and
	- New option in settings : Auto-paste encryption text which enable the app to automatically paste the clipboard if an encrypted text is detected
	- Some views constraints has been reviewed to manage all types of device
	- Some design fix and improvement made and to come
  • Loading branch information
SeaweedbrainCY committed Apr 2, 2021
1 parent 53f635b commit 73727e3
Show file tree
Hide file tree
Showing 8 changed files with 246 additions and 187 deletions.
Binary file not shown.
244 changes: 124 additions & 120 deletions iLocked/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion iLocked/Extension/String.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extension String {
}
/// Convert a json string to a dictionnary [*String*:*String*]
func jsonToDictionary() -> [String: String]? {
print("TEXT = \(self)")
print("[*] jsonToDictionnary : text given = \(self)")
if let data = self.data(using: .utf8) {
do {
return try JSONSerialization.jsonObject(with: data, options: []) as? [String: String]
Expand Down
3 changes: 1 addition & 2 deletions iLocked/ViewController/AdvancedSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class AdvancedSettings: UIViewController, UITableViewDelegate, UITableViewDataSo
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! CustomTableViewCell

cell.textLabel?.font = UIFont(name: "Arial Rounded MT Bold", size: 17)
cell.backgroundColor = .black
cell.backgroundColor = .systemGray5
cell.textLabel?.textColor = .white
if indexPath.section == 0 {
switch indexPath.row {
Expand All @@ -97,7 +97,6 @@ class AdvancedSettings: UIViewController, UITableViewDelegate, UITableViewDataSo
}
cell.textLabel?.text = "📲 Open external links in app"
cell.accessoryView = self.inAppBrowserSwitch

default :
cell.textLabel?.text = "ERROR"
}
Expand Down
5 changes: 2 additions & 3 deletions iLocked/ViewController/KeyList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,8 @@ class KeyList : UIViewController, UITableViewDelegate, UITableViewDataSource{

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { // titre
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! CustomTableViewCell
cell.backgroundColor = .black
cell.backgroundColor = .systemGray5
cell.textLabel?.textColor = .white
cell.textLabel?.font = UIFont(name: "Arial Rounded MT Bold", size: 17)
if indexPath.section == 0 {
cell.textLabel!.text = self.nameList[indexPath.row]
} else {
Expand All @@ -120,7 +119,7 @@ class KeyList : UIViewController, UITableViewDelegate, UITableViewDataSource{
//Sections name
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
switch section {
case 0 : return "Saved public encryption keys"
case 0 : return "Encryption keys"
case 1 : if !selectModeIsActive { return "MY public encryption key"} else { return ""}
default : return "ERROR"
}
Expand Down
2 changes: 1 addition & 1 deletion iLocked/ViewController/Revoke.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Revoke: UIViewController {
timer.invalidate()
self.revokeButton.setTitle("REVOKE", for: .normal)
self.revokeButton.isEnabled = true
self.revokeButton.setTitleColor(.systemRed, for: .normal)
self.revokeButton.backgroundColor = .systemRed
}else if self.second < 0 {
timer.invalidate()
second = 0
Expand Down
88 changes: 70 additions & 18 deletions iLocked/ViewController/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Settings: UIViewController, UITableViewDelegate, UITableViewDataSource, MF

@IBOutlet weak var tableView: UITableView!
let protectionSwitch = UISwitch()
let autoPasteSwitch = UISwitch()


override func viewDidLoad() {
Expand All @@ -24,6 +25,8 @@ class Settings: UIViewController, UITableViewDelegate, UITableViewDataSource, MF
self.tableView.dataSource = self
tableView.register(CustomTableViewCell.self, forCellReuseIdentifier: "cell") //on associe la tableView au custom de Style/customeCelleTableView.swift
protectionSwitch.addTarget(self, action: #selector(protectionSwitchChanged), for: .valueChanged)
autoPasteSwitch.addTarget(self, action: #selector(autoPasteSwitchChanged), for: .valueChanged)


// Set up the setting label :
}
Expand Down Expand Up @@ -64,15 +67,16 @@ class Settings: UIViewController, UITableViewDelegate, UITableViewDataSource, MF

///number of section
func numberOfSections(in tableView: UITableView) -> Int {
return 3
return 4
}

/// Cells for each section
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
switch section {
case 0 : return 3
case 1 : return 4
case 2 : return 1
case 0 : return 1
case 1 : return 3
case 2 : return 4
case 3 : return 1
default : return 0

}
Expand All @@ -83,16 +87,45 @@ class Settings: UIViewController, UITableViewDelegate, UITableViewDataSource, MF
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! CustomTableViewCell

cell.textLabel?.font = UIFont(name: "Arial Rounded MT Bold", size: 17)
cell.backgroundColor = .black
cell.backgroundColor = .systemGray5
cell.textLabel?.textColor = .white
if indexPath.section == 0 {
switch indexPath.row {
case 0:
cell.textLabel?.text = "🔍 Auto-paste encrypted text"
var setting = getSetting()
if (setting.keys).contains("auto_paste"){ // Check if the setting is already init
if setting["auto_paste"] == "true"{
self.autoPasteSwitch.isOn = true
} else{
self.autoPasteSwitch.isOn = false
}
}else { // Not init. Se we do it
// default value
self.autoPasteSwitch.isOn = false
setting.updateValue("false", forKey: "auto_paste")
saveSetting(dict: setting)
}
cell.accessoryView = self.autoPasteSwitch

default:
cell.textLabel?.text = "ERROR"
}
} else if indexPath.section == 1 {
switch indexPath.row {
case 0 :
let setting = getSetting()
if setting["password"] == "false"{
self.protectionSwitch.isOn = false
} else {
self.protectionSwitch.isOn = true
var setting = getSetting()
if (setting.keys).contains("password"){ // Check if the setting is already init
if setting["password"] == "false"{
self.protectionSwitch.isOn = false
} else {
self.protectionSwitch.isOn = true
}
}else { // Not init. Se we do it
// default value
self.autoPasteSwitch.isOn = false
setting.updateValue("false", forKey: "password")
saveSetting(dict: setting)
}
cell.textLabel?.text = "🔑 Protect with a password"
cell.accessoryView = self.protectionSwitch
Expand All @@ -104,7 +137,7 @@ class Settings: UIViewController, UITableViewDelegate, UITableViewDataSource, MF
default :
cell.textLabel?.text = "ERROR"
}
} else if indexPath.section == 1 {
} else if indexPath.section == 2 {
switch indexPath.row {
case 0:
cell.textLabel?.text = "🔎 Report a bug"
Expand All @@ -118,7 +151,7 @@ class Settings: UIViewController, UITableViewDelegate, UITableViewDataSource, MF
cell.textLabel?.text = "🔏 Source code licence"
default : cell.textLabel?.text = "ERROR"
}
} else if indexPath.section == 2{
} else if indexPath.section == 3{
switch indexPath.row {
case 0 :
cell.textLabel?.text = "⚙️ Advanced settings"
Expand All @@ -138,24 +171,32 @@ class Settings: UIViewController, UITableViewDelegate, UITableViewDataSource, MF
/// Sections' name
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
switch section {
case 0 : return "Security 🔐"
case 1 : return "Developement 🔨"
case 2 : return ""
case 0 : return "Preferences ⚙️"
case 1 : return "Security 🔐"
case 2 : return "Developement 🔨"
case 3 : return ""
default : return "ERROR"
}
}


func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { // cellule selctionnée
if indexPath.section == 0 {
if indexPath.section == 0{
switch indexPath.row {
case 0:
break
default:
break
}
} else if indexPath.section == 1 {
switch indexPath.row {
case 1 : // lock app
performSegue(withIdentifier: "lockApp", sender: self)
case 2 : // revoke keys
self.performSegue(withIdentifier: "showRevocationView", sender: self)
default : break
}
} else if indexPath.section == 1 {
} else if indexPath.section == 2 {
switch indexPath.row {
case 0 : // report a bug
let alert = UIAlertController(title: "Report a bug", message: "Report a bug help the developer to upgrade this application and improve your experience", preferredStyle: .actionSheet)
Expand All @@ -175,7 +216,7 @@ class Settings: UIViewController, UITableViewDelegate, UITableViewDataSource, MF
UIApplication.shared.open(URL(string: "https://github.com/DevNathan/iLocked/blob/master/LICENSE")!, options: [:], completionHandler: nil)
default : break
}
} else if indexPath.section == 2{
} else if indexPath.section == 3{
switch indexPath.row {
case 0:
self.performSegue(withIdentifier: "advancedSettings", sender: self)
Expand Down Expand Up @@ -238,6 +279,17 @@ class Settings: UIViewController, UITableViewDelegate, UITableViewDataSource, MF
saveSetting(dict: settingDict)
}


@objc private func autoPasteSwitchChanged(){
var settingDict = getSetting()
if self.autoPasteSwitch.isOn {
settingDict.updateValue("true", forKey: "auto_paste")
} else {
settingDict.updateValue("false", forKey: "auto_paste")
}
saveSetting(dict: settingDict)
}

/**
Function called by **Delegate** when user ask for contact the developer
- Parameter _ controller : Correpond to MFMail
Expand Down
Loading

0 comments on commit 73727e3

Please sign in to comment.