mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-07 00:08:39 +09:00
Dactyloidae iOS initial commit
This commit is contained in:
parent
daa6179d22
commit
7154a0497e
2123 changed files with 197052 additions and 0 deletions
47
mobile/ios/Client/Frontend/Settings/SearchEnginePicker.swift
Normal file
47
mobile/ios/Client/Frontend/Settings/SearchEnginePicker.swift
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import UIKit
|
||||
|
||||
class SearchEnginePicker: UITableViewController {
|
||||
weak var delegate: SearchEnginePickerDelegate?
|
||||
var engines: [OpenSearchEngine]!
|
||||
var selectedSearchEngineName: String?
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
navigationItem.title = NSLocalizedString("Default Search Engine", comment: "Title for default search engine picker.")
|
||||
navigationItem.leftBarButtonItem = UIBarButtonItem(title: NSLocalizedString("Cancel", comment: "Label for Cancel button"), style: .plain, target: self, action: #selector(SearchEnginePicker.cancel))
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
return engines.count
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
let engine = engines[indexPath.item]
|
||||
let cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: nil)
|
||||
cell.textLabel?.text = engine.shortName
|
||||
cell.imageView?.image = engine.image.createScaled(CGSize(width: OpenSearchEngine.PreferredIconSize, height: OpenSearchEngine.PreferredIconSize))
|
||||
if engine.shortName == selectedSearchEngineName {
|
||||
cell.accessoryType = UITableViewCellAccessoryType.checkmark
|
||||
}
|
||||
return cell
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
let engine = engines[indexPath.item]
|
||||
delegate?.searchEnginePicker(self, didSelectSearchEngine: engine)
|
||||
tableView.cellForRow(at: indexPath)?.accessoryType = UITableViewCellAccessoryType.checkmark
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
|
||||
tableView.cellForRow(at: indexPath)?.accessoryType = UITableViewCellAccessoryType.none
|
||||
}
|
||||
|
||||
func cancel() {
|
||||
delegate?.searchEnginePicker(self, didSelectSearchEngine: nil)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue