tweak view contrain
This commit is contained in:
1 parent
916e9b65a6
commit
4cff75c531
2 files changed
+10
-20
No files matched your search
@@ -49,7 +49,7 @@ import UIKit
|
|||||||
"F2": 0x71
|
"F2": 0x71
|
||||||
]
|
]
|
||||||
|
|
||||||
private weak var viewController: CommandManagerViewController?
|
public weak var viewController: CommandManagerViewController?
|
||||||
|
|
||||||
private override init() {
|
private override init() {
|
||||||
super.init()
|
super.init()
|
||||||
@@ -81,7 +81,7 @@ import UIKit
|
|||||||
@objc public func addCommand(_ command: RemoteCommand) {
|
@objc public func addCommand(_ command: RemoteCommand) {
|
||||||
commands.append(command)
|
commands.append(command)
|
||||||
saveCommands()
|
saveCommands()
|
||||||
viewController?.reloadTableView()
|
viewController?.reloadTableView() // don't know why but this reload has to be called from the CommandManager, doesn't work by calling it in the viewcontroller, probably related with the dialog box.
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func deleteCommand(at index: Int) {
|
@objc public func deleteCommand(at index: Int) {
|
||||||
@@ -108,14 +108,4 @@ import UIKit
|
|||||||
UserDefaults.standard.set(data, forKey: "savedCommands")
|
UserDefaults.standard.set(data, forKey: "savedCommands")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func setupViewController(_ viewController: CommandManagerViewController) {
|
|
||||||
self.viewController = viewController
|
|
||||||
//let addButton = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(promptForNewCommand))
|
|
||||||
//viewController.navigationItem.rightBarButtonItem = addButton
|
|
||||||
//viewController.navigationItem.title = "Manage Commands"
|
|
||||||
|
|
||||||
//viewController.tableView.delegate = viewController
|
|
||||||
//viewController.tableView.dataSource = viewController
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -36,8 +36,8 @@ import UIKit
|
|||||||
|
|
||||||
// Register the cell class
|
// Register the cell class
|
||||||
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
|
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
|
||||||
|
//pass self to the CommandManager
|
||||||
CommandManager.shared.setupViewController(self)
|
CommandManager.shared.viewController = self
|
||||||
}
|
}
|
||||||
|
|
||||||
override public func viewDidLayoutSubviews() {
|
override public func viewDidLayoutSubviews() {
|
||||||
@@ -52,8 +52,8 @@ import UIKit
|
|||||||
view.layer.masksToBounds = true
|
view.layer.masksToBounds = true
|
||||||
|
|
||||||
// Set up the title label
|
// Set up the title label
|
||||||
titleLabel.text = SwiftLocalizationHelper.localizedString(forKey: "Send Special Keys")
|
titleLabel.text = SwiftLocalizationHelper.localizedString(forKey: "Send Commands")
|
||||||
titleLabel.font = UIFont.boldSystemFont(ofSize: 24) // Adjust font size as needed
|
titleLabel.font = UIFont.boldSystemFont(ofSize: 20) // Adjust font size as needed
|
||||||
titleLabel.textColor = UIColor.white // Adjust color as needed
|
titleLabel.textColor = UIColor.white // Adjust color as needed
|
||||||
titleLabel.textAlignment = .center
|
titleLabel.textAlignment = .center
|
||||||
view.addSubview(titleLabel)
|
view.addSubview(titleLabel)
|
||||||
@@ -105,14 +105,14 @@ import UIKit
|
|||||||
|
|
||||||
// Set the width and height of the view
|
// Set the width and height of the view
|
||||||
view.widthAnchor.constraint(equalTo: view.superview!.widthAnchor, multiplier: 0.7),
|
view.widthAnchor.constraint(equalTo: view.superview!.widthAnchor, multiplier: 0.7),
|
||||||
view.heightAnchor.constraint(equalTo: view.superview!.heightAnchor, multiplier: 0.75),
|
view.heightAnchor.constraint(equalTo: view.superview!.heightAnchor, multiplier: 0.9),
|
||||||
|
|
||||||
// Center the view horizontally and vertically
|
// Center the view horizontally and vertically
|
||||||
view.centerXAnchor.constraint(equalTo: view.superview!.centerXAnchor),
|
view.centerXAnchor.constraint(equalTo: view.superview!.centerXAnchor),
|
||||||
view.centerYAnchor.constraint(equalTo: view.superview!.centerYAnchor),
|
view.centerYAnchor.constraint(equalTo: view.superview!.centerYAnchor),
|
||||||
|
|
||||||
// ViewTitle constrains
|
// ViewTitle constrains
|
||||||
titleLabel.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 20),
|
titleLabel.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 13.5),
|
||||||
titleLabel.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 10),
|
titleLabel.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 10),
|
||||||
titleLabel.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -10),
|
titleLabel.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -10),
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ import UIKit
|
|||||||
// TableView constraints
|
// TableView constraints
|
||||||
tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 10),
|
tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 10),
|
||||||
tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -10),
|
tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -10),
|
||||||
tableView.topAnchor.constraint(equalTo: view.topAnchor, constant: 70),
|
tableView.topAnchor.constraint(equalTo: view.topAnchor, constant: 50),
|
||||||
tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -60),
|
tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -60),
|
||||||
|
|
||||||
// ExitButton constraints
|
// ExitButton constraints
|
||||||
@@ -161,7 +161,7 @@ import UIKit
|
|||||||
let alias = alert.textFields?[1].text ?? keyboardCmdString
|
let alias = alert.textFields?[1].text ?? keyboardCmdString
|
||||||
let newCommand = RemoteCommand(keyboardCmdString: keyboardCmdString, alias: alias)
|
let newCommand = RemoteCommand(keyboardCmdString: keyboardCmdString, alias: alias)
|
||||||
CommandManager.shared.addCommand(newCommand)
|
CommandManager.shared.addCommand(newCommand)
|
||||||
//self.reloadTableView()
|
//self.reloadTableView() // don't know why but this reload has to be called from the CommandManager, it doesn't work here.
|
||||||
}
|
}
|
||||||
|
|
||||||
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel)
|
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel)
|
||||||
|
|||||||
Reference in new issue
Block a user