Skip to content

Commit

Permalink
Minor enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
liang2kl committed Apr 26, 2021
1 parent f6b7690 commit 02392a5
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 15 deletions.
18 changes: 9 additions & 9 deletions Source/Hollow.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,7 @@
0EC2452B26340311001AFC4B /* Types */ = {
isa = PBXGroup;
children = (
0EC2453426340311001AFC4B /* Data */,
0EC2452C26340311001AFC4B /* HollowConfig.swift */,
0EC2452D26340311001AFC4B /* Comment.swift */,
0EC2452E26340311001AFC4B /* ImageMetadata.swift */,
Expand All @@ -958,7 +959,6 @@
0EC2453126340311001AFC4B /* Post.swift */,
0EC2453226340311001AFC4B /* Vote.swift */,
0EC2453326340311001AFC4B /* DeviceInformationType.swift */,
0EC2453426340311001AFC4B /* Data */,
0EC2453926340311001AFC4B /* HollowType.swift */,
);
path = Types;
Expand All @@ -978,18 +978,18 @@
0EC2453A26340311001AFC4B /* Net */ = {
isa = PBXGroup;
children = (
0EC2453B26340311001AFC4B /* Contents */,
0EC2455626340311001AFC4B /* README.md */,
0EC2455B26340311001AFC4B /* Request.swift */,
0EC2456226340311001AFC4B /* RequestError.swift */,
0EC2454426340311001AFC4B /* DefaultRequest.swift */,
0EC2456026340311001AFC4B /* Request+publisher.swift */,
0EC2456126340311001AFC4B /* RequestPublisher.swift */,
0EC2453B26340311001AFC4B /* Contents */,
0EC2454526340311001AFC4B /* Config */,
0EC2454926340311001AFC4B /* Security */,
0EC2455226340311001AFC4B /* Other */,
0EC2455626340311001AFC4B /* README.md */,
0EC2455726340311001AFC4B /* Edit */,
0EC2455B26340311001AFC4B /* Request.swift */,
0EC2455C26340311001AFC4B /* Send */,
0EC2456026340311001AFC4B /* Request+publisher.swift */,
0EC2456126340311001AFC4B /* RequestPublisher.swift */,
0EC2456226340311001AFC4B /* RequestError.swift */,
);
path = Net;
sourceTree = "<group>";
Expand Down Expand Up @@ -1803,7 +1803,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Hollow/Hollow.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 42;
CURRENT_PROJECT_VERSION = 43;
DEVELOPMENT_TEAM = C5UH93T368;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = Hollow/Info.plist;
Expand All @@ -1829,7 +1829,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Hollow/Hollow.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 42;
CURRENT_PROJECT_VERSION = 43;
DEVELOPMENT_TEAM = C5UH93T368;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = Hollow/Info.plist;
Expand Down
4 changes: 3 additions & 1 deletion Source/Hollow/View/Components/Avatar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ struct Avatar: View {
ZStack {
Rectangle()
.foregroundColor(paddingColor)
Text(String(name.first ?? " "))
Text(name)
.fontWeight(.heavy)
.font(.system(.body, design: .rounded))
.foregroundColor(.white)
.lineLimit(1)
.minimumScaleFactor(0.3)
}
.aspectRatio(1, contentMode: .fill)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ struct HollowCommentContentView: View {
resolution: resolution,
padding: avatarWidth * 0.1,
hashValue: hash,
name: commentData.name
name: commentData.abbreviation
)
.frame(width: avatarWidth)
.clipShape(Circle())
Expand Down
2 changes: 1 addition & 1 deletion Source/Hollow/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@

"SETTINGSVIEW_OTHER_EXP_AVATAR_HEADER" = "Avatar";

"SETTINGSVIEW_OTHER_EXP_AVATAR_FOOTER" = "Avatar rendering has some issues on few devices. Turn on the options if you have encountered hitch problems when scrolling. Noted that enabling Off-Screen Render might result in even lower refresh rate.";
"SETTINGSVIEW_OTHER_EXP_AVATAR_FOOTER" = "Avatar rendering has some issues on a few devices. Turn on the options if you have encountered hitch problems when scrolling. Noted that enabling Off-Screen Render might result in even lower refresh rate.";

"SETTINGSVIEW_OTHER_EXP_AVATAR_OFFSCREEN_LABEL" = "Enable Off-Screen Render";

Expand Down
2 changes: 1 addition & 1 deletion Source/Shared/Model/Extensions/DefaultsKeys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ extension Defaults.Keys {
extension Defaults.Keys {
static let reduceImageQuality = Key<Bool>("user.settings.reduce.image.quality", default: false)
static let usingOffscreenRender = Key<Bool>("user.settings.using.offscreen.render", default: false)
static let usingSimpleAvatar = Key<Bool>("user.settings.using.simple.avatar", default: false)
static let usingSimpleAvatar = Key<Bool>("user.settings.using.simple.avatar", default: true)
}
#endif
15 changes: 14 additions & 1 deletion Source/Shared/Model/Types/Comment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@ extension Comment {
}

let hash = AvatarGenerator.hash(postId: pid, name: isDz ? "" : name)

let components = name.split(separator: " ")
var abbreviation = isDz ? name : ""
if !isDz {
for component in components {
if Int(component) != nil {
abbreviation = String(component)
break
}
abbreviation += component.first == nil ? "" : String(component.first!)
}
}

return CommentData(
commentId: cid,
Expand All @@ -81,7 +93,8 @@ extension Comment {
hasURL: (text?.links().count ?? 0) > 0,
hasCitedNumbers: (text?.citations().count ?? 0) > 0,
hash: hash,
colorIndex: AvatarGenerator.colorIndex(hash: hash)
colorIndex: AvatarGenerator.colorIndex(hash: hash),
abbreviation: abbreviation
)
}
}
3 changes: 2 additions & 1 deletion Source/Shared/Model/Types/Data/CommentData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ struct CommentData: Identifiable, Codable {
var hasCitedNumbers = false
var renderHighlight: Bool { hasURL || hasCitedNumbers }

// Color data used in avatar
// Data used in avatar
var hash: Int
var colorIndex: Int
var abbreviation: String

mutating func updateHashAndColor() {
hash = AvatarGenerator.hash(postId: postId, name: name)
Expand Down
4 changes: 4 additions & 0 deletions Source/Shared/Model/Utilities/DeviceModelUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import Foundation

struct DeviceModelUtilities {
static var modelIdentifier: String {
#if targetEnvironment(macCatalyst)
return "Mac"
#else
var systemInfo = utsname()
uname(&systemInfo)
let machineMirror = Mirror(reflecting: systemInfo.machine)
Expand All @@ -18,5 +21,6 @@ struct DeviceModelUtilities {
return identifier + String(UnicodeScalar(UInt8(value)))
}
return identifier
#endif
}
}

0 comments on commit 02392a5

Please sign in to comment.