This file contains hidden or 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
class SourcesTableViewController : UITableViewController { | |
private var webservice :Webservice! | |
private var sourceListViewModel :SourceListViewModel! | |
private var dataSource :TableViewDataSource<SourceTableViewCell,SourceViewModel>! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
This file contains hidden or 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
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | |
if segue.identifier == SegueIdentifier.showSourceDetails { | |
performSegueForShowSourceDetails(segue: segue) | |
} else if segue.identifier == SegueIdentifier.addSource { | |
performSegueForAddSource(segue: segue) | |
} | |
} |
This file contains hidden or 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
struct Maximum { | |
static let allowedCharactersForDescription = 70 | |
} | |
struct Cells { | |
static let headline = "HeadlineTableViewCell" | |
static let source = "SourceTableViewCell" | |
} | |
struct SegueIdentifier { |
This file contains hidden or 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
class BindingTextView : UITextView, UITextViewDelegate { | |
var numberOfCharactersEntered :(Int,Int) -> () = { _,_ in } | |
var limit :Int = 0 | |
required init?(coder aDecoder: NSCoder) { | |
super.init(coder: aDecoder) | |
self.delegate = self | |
} | |
This file contains hidden or 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
class AddSourceViewModel { | |
var title :String! | |
var description :String! | |
func remainingNumberOfAllowedCharacters(numberOfCharactersEntered :Int, limit :Int) -> Int { | |
let count = limit - numberOfCharactersEntered | |
if count < 0 { |
This file contains hidden or 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
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.addSourceViewModel = AddSourceViewModel() | |
self.descriptionTextView.bind { count,limit in | |
self.remainingCharactersCountLabel.text = "\(self.addSourceViewModel.remainingNumberOfAllowedCharacters(numberOfCharactersEntered: count, limit:limit))" | |
}.limit(to: Maximum.allowedCharactersForDescription) | |
} |
This file contains hidden or 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
class When_User_Is_Registering_For_A_New_Account: XCTestCase { | |
private var app :XCUIApplication! | |
override func setUp() { | |
super.setUp() | |
continueAfterFailure = false | |
self.app = XCUIApplication() | |
self.app.launch() |
This file contains hidden or 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
extension XCUIElement { | |
func tapAndType(text :String) { | |
tap() | |
typeText(text) | |
} | |
func tapAndClear() { | |
tap() | |
typeText("") |
This file contains hidden or 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
@IBAction func saveButtonClicked() { | |
let user = User(username: self.usernameTextField.text!, password: self.passwordTextField.text!) | |
let isSaved = self.dataAccess.saveUser(user) | |
if isSaved { | |
performSegue(withIdentifier: "LoginTableViewController", sender: self) | |
} else { | |
self.messageLabel.text = "User name is already taken" |
This file contains hidden or 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
public class User { | |
var username :String! | |
var password :String! | |
var userId :String! | |
init(username :String, password :String) { | |
self.username = username | |
self.password = password | |
} |