This repository was archived by the owner on Mar 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRepoViewController.swift
More file actions
69 lines (55 loc) · 2.43 KB
/
RepoViewController.swift
File metadata and controls
69 lines (55 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//
// RepoViewController.swift
// GithubIssues
//
// Created by Leonard on 2017. 9. 10..
// Copyright © 2017년 intmain. All rights reserved.
//
import UIKit
class RepoViewController: UIViewController {
@IBOutlet var ownerTextField: UITextField!
@IBOutlet var repoTextField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
ownerTextField.text = GlobalState.instance.owner
repoTextField.text = GlobalState.instance.repo
// repoTextField.layer.frame = CGRect(x: 100, y: 100, width: 100, height: 100)
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Navigation
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
guard let owner = ownerTextField.text, let repo = repoTextField.text else { return false }
return !(owner.isEmpty || repo.isEmpty)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "EnterRepoSegue" {
guard let owner = ownerTextField.text, let repo = repoTextField.text else { return }
GlobalState.instance.owner = owner
GlobalState.instance.repo = repo
GlobalState.instance.addRepo(owner: owner, repo: repo)
guard let issuesViewController = segue.destination as? IssuesViewController else { return }
issuesViewController.owner = owner
issuesViewController.repo = repo
}
}
@IBAction func unwindFromRepos(_ segue: UIStoryboardSegue) {
if let reposViewController = segue.source as? ReposViewController, let (owner, repo) = reposViewController.selectedRepo {
ownerTextField.text = owner
repoTextField.text = repo
DispatchQueue.main.async { [weak self] in
self?.performSegue(withIdentifier: "EnterRepoSegue", sender: nil)
}
}
}
@IBAction func logoutButtonTapped(_ sender: Any?) {
GlobalState.instance.token = ""
let loginViewController = LoginViewController.viewController
DispatchQueue.main.asyncAfter(deadline: .now() + 0.0, execute: { [weak self] in
self?.present(loginViewController, animated: true, completion: nil)
})
}
}