-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from divvun/feature/user-dictionary
Feature/user dictionary #47
- Loading branch information
Showing
49 changed files
with
2,505 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
HostingApp/Controllers/KeyboardLocalesViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import UIKit | ||
|
||
class KeyboardLocalesViewController: SettingsViewController { | ||
|
||
override var rows: [Row] { | ||
var rows: [Row] = [] | ||
|
||
for locale in KeyboardLocale.allLocales { | ||
let row = Row(title: locale.languageName) { () -> UIViewController in | ||
UserDictionaryViewController(keyboardLocale: locale) | ||
} | ||
rows.append(row) | ||
} | ||
|
||
return rows | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import UIKit | ||
|
||
typealias ViewControllerMaker = (() -> UIViewController)? | ||
|
||
struct Row { | ||
let title: String | ||
let destinationViewController: ViewControllerMaker | ||
} | ||
|
||
class SettingsViewController: UITableViewController { | ||
|
||
var rows: [Row] { | ||
let destinationViewController: ViewControllerMaker | ||
let locales = KeyboardLocale.allLocales | ||
if locales.count == 1 { | ||
destinationViewController = { | ||
UserDictionaryViewController(keyboardLocale: locales.first!) | ||
} | ||
} else { | ||
destinationViewController = { | ||
KeyboardLocalesViewController() | ||
} | ||
} | ||
|
||
return [ | ||
Row(title: Strings.userDictionary, destinationViewController: destinationViewController) | ||
] | ||
} | ||
|
||
init() { | ||
super.init(style: .grouped) | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
tableView.register(DisclosureCell.self) | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
return rows.count | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
let cell = tableView.dequeueReusableCell(DisclosureCell.self) | ||
cell.textLabel?.text = rows[indexPath.item].title | ||
return cell | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | ||
let row = rows[indexPath.row] | ||
guard let viewController = row.destinationViewController?() else { | ||
return | ||
} | ||
navigationController?.pushViewController(viewController, animated: true) | ||
} | ||
|
||
} |
Oops, something went wrong.