-
Notifications
You must be signed in to change notification settings - Fork 1
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 #7 from vespinola/5-add-dashboard-screen
5 add dashboard screen
- Loading branch information
Showing
38 changed files
with
959 additions
and
107 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.
12 changes: 12 additions & 0 deletions
12
mobile-courier-app/Assets.xcassets/shortLogo.imageset/Contents.json
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,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "shortLogo.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file not shown.
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,15 @@ | ||
// | ||
// AuthData.swift | ||
// mobile-courier-app | ||
// | ||
// Created by Vladimir Espinola on 2024-05-29. | ||
// | ||
|
||
import Foundation | ||
|
||
final class AuthData { | ||
static var shared: AuthData = .init() | ||
var loginData: LoginEntity? | ||
|
||
private init() {} | ||
} |
27 changes: 27 additions & 0 deletions
27
mobile-courier-app/Data/ConcreteRepositories/AddressRespository.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,27 @@ | ||
// | ||
// AddressRespository.swift | ||
// mobile-courier-app | ||
// | ||
// Created by Vladimir Espinola on 2024-06-06. | ||
// | ||
|
||
import Foundation | ||
|
||
struct AddressRespository: AddressRepositoryProtocol { | ||
private var apiRequestClient: APIRequestClientProtocol | ||
|
||
init(apiRequestClient: APIRequestClientProtocol) { | ||
self.apiRequestClient = apiRequestClient | ||
} | ||
|
||
func getAddress() async throws -> AddressesEntity { | ||
let model: AddressesModel = try await apiRequestClient.performRequest( | ||
endpoint: AddressEndpoints.addresses, | ||
decoder: JSONDecoder() | ||
) | ||
|
||
AppData.shared.setUsername(model.enviosAereos.cliente.clienteNombre) | ||
|
||
return model.asEntity() | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// AppData.swift | ||
// mobile-courier-app | ||
// | ||
// Created by Vladimir Espinola on 2024-06-05. | ||
// | ||
|
||
import Foundation | ||
|
||
final class AppData: ObservableObject { | ||
var token: String? | ||
@Published var username: String? | ||
|
||
static var shared: AppData = .init() | ||
|
||
func setUsername(_ newUsername: String?) { | ||
DispatchQueue.main.async { [weak self] in | ||
self?.username = newUsername | ||
} | ||
} | ||
|
||
func updateToken(_ newToken: String?) { | ||
token = newToken | ||
} | ||
|
||
func getToken() -> String? { | ||
token | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
mobile-courier-app/Data/Networking/CustomSessionDelegate.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,44 @@ | ||
// | ||
// CustomSessionDelegate.swift | ||
// mobile-courier-app | ||
// | ||
// Created by Vladimir Espinola on 2024-06-12. | ||
// | ||
|
||
import Foundation | ||
|
||
final class CustomSessionDelegate: NSObject, URLSessionDataDelegate { | ||
func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) { | ||
do { | ||
let jsonObject = try JSONSerialization.jsonObject(with: data, options: []) | ||
let jsonData = try JSONSerialization.data(withJSONObject: jsonObject, options: [.prettyPrinted]) | ||
|
||
if let jsonString = String(data: jsonData, encoding: .utf8) { | ||
let urlString = dataTask.currentRequest?.url?.absoluteString ?? "Unknown URL" | ||
print("Data received from '\(urlString)' ➡️ \n\(jsonString)") | ||
} | ||
} catch { | ||
print("Failed to parse JSON: \(error.localizedDescription)") | ||
} | ||
} | ||
|
||
func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) { | ||
if let error = error { | ||
print("Error: \(error.localizedDescription)") | ||
} else { | ||
print("Request completed successfully.") | ||
} | ||
} | ||
} | ||
|
||
extension CustomSessionDelegate { | ||
func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) { | ||
guard challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust, | ||
let serverTrust = challenge.protectionSpace.serverTrust else { | ||
completionHandler(.performDefaultHandling, nil) | ||
return | ||
} | ||
let credential = URLCredential(trust: serverTrust) | ||
completionHandler(.useCredential, credential) | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
mobile-courier-app/Data/Networking/Endpoints/AddressEndpoints.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,34 @@ | ||
// | ||
// AddressEndpoints.swift | ||
// mobile-courier-app | ||
// | ||
// Created by Vladimir Espinola on 2024-06-05. | ||
// | ||
|
||
import Foundation | ||
|
||
enum AddressEndpoints { | ||
case addresses | ||
} | ||
|
||
extension AddressEndpoints: Endpoint { | ||
var mockFile: String? { | ||
"" | ||
} | ||
|
||
var requestType: RequestType { | ||
.get | ||
} | ||
|
||
var path: String { | ||
"/frontliner-middleware/api/direccion" | ||
} | ||
|
||
var body: [AnyHashable: Any]? { | ||
nil | ||
} | ||
|
||
var queryParams: [String: String]? { | ||
nil | ||
} | ||
} |
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
Oops, something went wrong.