Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CustomKeyboard.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@
A870F7C61940D2B400534539 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftMigration = 0710;
LastSwiftUpdateCheck = 0710;
LastUpgradeCheck = 0600;
ORGANIZATIONNAME = "Brian Donohue";
TargetAttributes = {
Expand Down
Binary file not shown.
5 changes: 3 additions & 2 deletions CustomKeyboard/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
self.window!.rootViewController = CustomKeyboardViewController()
self.window!.backgroundColor = UIColor.whiteColor()
Expand Down
2 changes: 1 addition & 1 deletion Keyboard/KeyButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class KeyButton: UIButton {
self.contentHorizontalAlignment = .Center
}

required init(coder aDecoder: NSCoder) {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
}
18 changes: 9 additions & 9 deletions Keyboard/KeyboardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class KeyboardViewController: UIInputViewController {
border.backgroundColor = UIColor(red: 210.0/255, green: 205.0/255, blue: 193.0/255, alpha: 1)
self.view.addSubview(border)

var thirdRowTopPadding: CGFloat = topPadding + (keyHeight + rowSpacing) * 2
let thirdRowTopPadding: CGFloat = topPadding + (keyHeight + rowSpacing) * 2
shiftKey = KeyButton(frame: CGRect(x: 2.0, y: thirdRowTopPadding, width:shiftWidth, height:shiftHeight))
shiftKey!.addTarget(self, action: Selector("shiftKeyPressed:"), forControlEvents: .TouchUpInside)
shiftKey!.selected = true
Expand All @@ -63,7 +63,7 @@ class KeyboardViewController: UIInputViewController {
deleteKey!.setImage(UIImage(named: "delete-selected.png"), forState:.Highlighted)
self.view.addSubview(deleteKey!)

var bottomRowTopPadding = topPadding + keyHeight * 3 + rowSpacing * 2 + 10
let bottomRowTopPadding = topPadding + keyHeight * 3 + rowSpacing * 2 + 10
spaceKey = KeyButton(frame: CGRect(x:(320.0 - spaceWidth) / 2, y: bottomRowTopPadding, width:spaceWidth, height:spaceHeight))
spaceKey!.setTitle(" ", forState: .Normal)
spaceKey!.addTarget(self, action: Selector("keyPressed:"), forControlEvents: .TouchUpInside)
Expand All @@ -82,7 +82,7 @@ class KeyboardViewController: UIInputViewController {
self.view.addSubview(returnButton!)

var y: CGFloat = topPadding
var width = UIScreen.mainScreen().applicationFrame.size.width
let width = UIScreen.mainScreen().applicationFrame.size.width
for row in rows {
var x: CGFloat = ceil((width - (CGFloat(row.count) - 1) * (keySpacing + keyWidth) - keyWidth) / 2.0)
for label in row {
Expand All @@ -102,7 +102,7 @@ class KeyboardViewController: UIInputViewController {
}

func returnKeyPressed(sender: UIButton) {
var proxy = self.textDocumentProxy as UITextDocumentProxy
let proxy = self.textDocumentProxy as UITextDocumentProxy
proxy.insertText("\n")
numCharacters++
shiftPosArr[shiftPosArr.count - 1]++
Expand All @@ -116,7 +116,7 @@ class KeyboardViewController: UIInputViewController {

func deleteKeyPressed(sender: UIButton) {
if numCharacters > 0 {
var proxy = self.textDocumentProxy as UITextDocumentProxy
let proxy = self.textDocumentProxy as UITextDocumentProxy
proxy.deleteBackward()
numCharacters--
var charactersSinceShift = shiftPosArr[shiftPosArr.count - 1]
Expand Down Expand Up @@ -149,7 +149,7 @@ class KeyboardViewController: UIInputViewController {
}

func keyPressed(sender: UIButton) {
var proxy = self.textDocumentProxy as UITextDocumentProxy
let proxy = self.textDocumentProxy as UITextDocumentProxy
if spacePressed && sender.titleLabel?.text == " " {
proxy.deleteBackward()
proxy.insertText(". ")
Expand Down Expand Up @@ -197,15 +197,15 @@ class KeyboardViewController: UIInputViewController {
}
}

override func textWillChange(textInput: UITextInput) {
override func textWillChange(textInput: UITextInput?) {
// The app is about to change the document's contents. Perform any preparation here.
}

override func textDidChange(textInput: UITextInput) {
override func textDidChange(textInput: UITextInput?) {
// The app has just changed the document's contents, the document context has been updated.

var textColor: UIColor
var proxy = self.textDocumentProxy as UITextDocumentProxy
let proxy = self.textDocumentProxy as UITextDocumentProxy
if proxy.keyboardAppearance == UIKeyboardAppearance.Dark {
textColor = UIColor.whiteColor()
} else {
Expand Down