-
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 #106 from 42Caterpie/feature/modify-competitionVie…
…w-Design
- Loading branch information
Showing
10 changed files
with
137 additions
and
75 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
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 |
---|---|---|
|
@@ -117,7 +117,6 @@ class CompetitionService: ObservableObject { | |
else { | ||
return | ||
} | ||
|
||
completionHandler(roomData) | ||
} | ||
} | ||
|
54 changes: 54 additions & 0 deletions
54
Git-Challenges/Let's Git it!/Service/UserImageService.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,54 @@ | ||
// | ||
// UserImage.swift | ||
// Let's Git it! | ||
// | ||
// Created by 강희영 on 2022/03/18. | ||
// | ||
|
||
import SwiftUI | ||
|
||
class UserImageService: ObservableObject { | ||
@Published var savedUserProfileImage: [String: Data] = [:] | ||
|
||
func currentUserProfileImage() -> some View { | ||
let userID = UserDefaults.shared.string(forKey: "userId") ?? "" | ||
let url = URL(string: "https://github.com/\(userID).png?s=80")! | ||
|
||
if let data = try? Data(contentsOf: url) { | ||
return Image(uiImage: UIImage(data: data)!) | ||
.resizable() | ||
.clipShape(Circle()) | ||
.frame(width: 77, height: 77) | ||
} else { | ||
return Image(systemName: "questionmark.circle.fill") | ||
.resizable() | ||
.clipShape(Circle()) | ||
.frame(width: 77, height: 77) | ||
} | ||
} | ||
|
||
func userProfileImage(ID userID: String) -> some View { | ||
let imageData: Data | ||
|
||
if self.savedUserProfileImage[userID] != nil { | ||
imageData = self.savedUserProfileImage[userID]! | ||
} else { | ||
let url = URL(string: "https://github.com/\(userID).png?s=40")! | ||
|
||
if let data = try? Data(contentsOf: url) { | ||
imageData = data | ||
self.savedUserProfileImage.updateValue(imageData, forKey: userID) | ||
} else { | ||
return AnyView(Image(systemName: "questionmark.circle.fill") | ||
.resizable() | ||
.foregroundColor(.gray) | ||
.clipShape(Circle()) | ||
.frame(width: 30, height: 30)) | ||
} | ||
} | ||
return AnyView(Image(uiImage: UIImage(data: imageData)!) | ||
.resizable() | ||
.clipShape(Circle()) | ||
.frame(width: 30, height: 30)) | ||
} | ||
} |
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
Oops, something went wrong.