Skip to content

Commit

Permalink
feat:优化聊天对话头像无法显示问题
Browse files Browse the repository at this point in the history
  • Loading branch information
iHTCboy committed Dec 13, 2022
1 parent 8bb850f commit ea8e0ce
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
4 changes: 2 additions & 2 deletions iChatGPT.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.1.1;
MARKETING_VERSION = 1.1.2;
PRODUCT_BUNDLE_IDENTIFIER = com.37iOS.iChatGPT;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -550,7 +550,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.1.1;
MARKETING_VERSION = 1.1.2;
PRODUCT_BUNDLE_IDENTIFIER = com.37iOS.iChatGPT;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
6 changes: 5 additions & 1 deletion iChatGPT/AIChatView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ struct AIChatView: View {
}
Divider()
HStack(alignment: .top) {
AvatarImageView(url: item.botAvatarUrl)
Image("chatgpt-icon")
.resizable()
.frame(width: 25, height: 25)
.cornerRadius(5)
.padding(.trailing, 10)
if item.isResponse {
// Text(.init(item.answer))
MarkdownText(item.answer ?? "")
Expand Down
21 changes: 21 additions & 0 deletions iChatGPT/Assets.xcassets/chatgpt-icon.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "apple-touch-icon.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.
8 changes: 5 additions & 3 deletions iChatGPT/Extensions/ImageLoaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,23 @@ struct ImageLoaderView<Placeholder: View, ConfiguredImage: View>: View {
} else {
imageContent
.onReceive(imageLoader.$image) { imageData in
self.imageData = imageData
if imageData != nil {
self.imageData = imageData
}
}
}
}
}

class ImageLoader: ObservableObject {
@Published var image = UIImage()
@Published var image: UIImage?

init(urlString:String) {
guard let url = URL(string: urlString) else { return }
let task = URLSession.shared.dataTask(with: url) { data, response, error in
guard let data = data else { return }
DispatchQueue.main.async {
self.image = UIImage(data: data) ?? UIImage()
self.image = UIImage(data: data)
}
}
task.resume()
Expand Down

0 comments on commit ea8e0ce

Please sign in to comment.