Skip to content

Commit

Permalink
finalproject
Browse files Browse the repository at this point in the history
  • Loading branch information
Brenner committed Jun 7, 2020
0 parents commit ecfc48a
Show file tree
Hide file tree
Showing 112 changed files with 20,302 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
465 changes: 465 additions & 0 deletions GitIssues.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>GitIssues.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>3</integer>
</dict>
</dict>
</dict>
</plist>
10 changes: 10 additions & 0 deletions GitIssues.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions GitIssues.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
Binary file added GitIssues/.DS_Store
Binary file not shown.
37 changes: 37 additions & 0 deletions GitIssues/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// AppDelegate.swift
// GitIssues
//
// Created by Brenner on 07/06/20.
// Copyright © 2020 Brenner. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {



func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

// MARK: UISceneSession Lifecycle

func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}

func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}


}

98 changes: 98 additions & 0 deletions GitIssues/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"images" : [
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
6 changes: 6 additions & 0 deletions GitIssues/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
21 changes: 21 additions & 0 deletions GitIssues/Assets.xcassets/gitHub - logo.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "b15eedbdafbbdbca3249e3942f4faf3b.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions GitIssues/Assets.xcassets/github-issues.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "github-issues.jpeg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GitIssues/Base.lproj/.DS_Store
Binary file not shown.
71 changes: 71 additions & 0 deletions GitIssues/Base.lproj/GitIssuesDetailsViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//
// GitIssuesDetailsViewController.swift
// Challenge_GitIssues
//
// Created by Brenner on 06/06/20.
// Copyright © 2020 Brenner. All rights reserved.
//

import UIKit


class GitIssuesDetailsViewController: UIViewController {

@IBOutlet weak var ivAvatar: UIImageView!
@IBOutlet weak var lbTitle: UILabel!
@IBOutlet weak var lbCreatedAt: UILabel!
@IBOutlet weak var lbBy: UILabel!
@IBOutlet weak var tvDescription: UITextView!
@IBOutlet weak var aiLoading: UIActivityIndicatorView!

var userHtmlUrl: String!
var issueHtmlUrl: String!
var issue: Issue!
let alamofireServices = AlamofireServices()

override func viewDidLoad() {
super.viewDidLoad()
renderDetails()
}


@IBAction func openOnNavigator(_ sender: Any) {
UIApplication.shared.open(URL(string: issue.htmlUrl)!, options: [:], completionHandler: nil)
}

@IBAction func goAuthorProfile(_ sender: Any) {
UIApplication.shared.open(URL(string: issue.user.htmlUrl)!, options: [:], completionHandler: nil)

}

func formatDate(date: String) -> String {
let formatter = DateFormatter()
formatter.locale = Locale(identifier: "en_US_POSIX") // set locale to reliable US_POSIX
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"
let date = formatter.date(from: date)!
formatter.dateFormat = "dd/MM/yyyy"
formatter.locale = Locale(identifier: "pt-BR") // reset the locale
let dateString = formatter.string(from: date)
return dateString
}

func loadAvatar(){
aiLoading.startAnimating()
alamofireServices.loadAvatar(imageUrl: issue.user.avatarUrl) { (image) in
DispatchQueue.main.async {
self.ivAvatar.image = image
self.aiLoading.stopAnimating()
self.aiLoading.isHidden = true
}
}
}
private func renderDetails(){
loadAvatar()
lbTitle.text = issue.title
tvDescription.text = issue.body
lbBy.text = "By " + issue.user.login
lbCreatedAt.text = "Created at: " + formatDate(date: issue.createdAt)
}


}
75 changes: 75 additions & 0 deletions GitIssues/Base.lproj/GitIssuesTableViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
//
// GitIssuesTableViewController.swift
// Challenge_GitIssues
//
// Created by Brenner on 06/06/20.
// Copyright © 2020 Brenner. All rights reserved.
//

import UIKit


class GitIssuesTableViewController: UITableViewController {

let alamofireServices = AlamofireServices()

var issues: [Issue] = []

let spinner = UIActivityIndicatorView(style: .medium)

override func viewDidLoad() {
super.viewDidLoad()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

self.spinner.startAnimating()
self.tableView.backgroundView = self.spinner

alamofireServices.loadIssues(onSuccess: { (issues) in
self.issues = issues
DispatchQueue.main.async {
self.tableView.reloadData()
self.spinner.stopAnimating()
self.spinner.isHidden = true
}
}) { (error) in
let alert = UIAlertController(title: "Something happened :(", message: "Restart the application and try again!", preferredStyle: .alert)
let doneButton = UIAlertAction(title: "Ok!", style: .default, handler: nil)
alert.addAction(doneButton)
self.present(alert, animated: true, completion: nil)
}
}

// MARK: - Table view data source

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return issues.count
}


override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "reuseCell", for: indexPath)

let issue = issues[indexPath.row]
cell.textLabel?.text = issue.title
if IssueStatus.closed.rawValue == issue.state{
cell.detailTextLabel?.textColor = #colorLiteral(red: 1, green: 0, blue: 0, alpha: 1)
} else{
cell.detailTextLabel?.textColor = #colorLiteral(red: 0.1960784346, green: 0.3411764801, blue: 0.1019607857, alpha: 1)

}
cell.detailTextLabel?.text = issue.state.uppercased()

return cell
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "detailsPage" {

let vc = segue.destination as! GitIssuesDetailsViewController
vc.issue = issues[tableView.indexPathForSelectedRow!.row]

}
}
}
Loading

0 comments on commit ecfc48a

Please sign in to comment.