-
Notifications
You must be signed in to change notification settings - Fork 0
User profile modal #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: animated-profile-picture
Are you sure you want to change the base?
Conversation
| import Lucide | ||
| import Combine | ||
|
|
||
| public struct UserProfileModel: View { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be UserProfileModal?
| case (.some(let sessionId), .none): | ||
| return ("accountId".localized(), sessionId) | ||
| case (.some(let sessionId), .some(_)): | ||
| return ("accountId".localized(), sessionId.splitIntoLines(charactersForLines: [23, 23, 20])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't remember what the resolution was but I think Thomas mentioned that could be a problem if we (eventually) support dynamic font sizes - ie. is this going to break if a use increases the size to the max?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is not the perfect design rules as the screen width can change and the font on iOS can have different character width than the design file. Normally we should make it wrap naturally, but I checked the chat history on this and we eventually agreed on applying the rules and using it as a "hope for the best" approach.
There are other rules like 33-33 I couldn't apply because it is already broken on normal iPhone 16 screen. If I have to argue, I'll say we shouldn't have these rules and just let it wrap naturally with proper paddings.
| switch (info.sessionId, info.blindedId) { | ||
| case (.some(let sessionId), .none): | ||
| return ("accountId".localized(), sessionId) | ||
| case (.some(let sessionId), .some(_)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can omit the (_) in the .some case here - case (.some(let sessionId), .some):
| return ("accountId".localized(), sessionId.splitIntoLines(charactersForLines: [23, 23, 20])) | ||
| case (.none, .some(let blindedId)): | ||
| return ("blindedId".localized(), blindedId) | ||
| default : return ("", "") // Shouldn't happen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be better to explicitly handle case (.none, .none) here instead of default in case the info.sessionId type changes to something that has additional cases (in which case we would want it to throw a build error so we can resolve it)
| withAnimation(.easeInOut(duration: 0.25)) { | ||
| isSessionIdCopied.toggle() | ||
| } | ||
| DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(4250)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does the 4250 come from?
| struct ConditionalTruncation: ViewModifier { | ||
| let shouldTruncate: Bool | ||
|
|
||
| func body(content: Content) -> some View { | ||
| if shouldTruncate { | ||
| content | ||
| .lineLimit(1) | ||
| .truncationMode(.middle) | ||
| } else { | ||
| content | ||
| } | ||
| } | ||
| } | ||
|
|
||
| extension View { | ||
| func shouldTruncate(_ condition: Bool) -> some View { | ||
| modifier(ConditionalTruncation(shouldTruncate: condition)) | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering whether this should be in it's own file? (ie. do you think we might use it elsewhere at some point?)
| var backgroundColor: UIColor { | ||
| switch themeStyle { | ||
| case .light: return #colorLiteral(red: 0.1058823529, green: 0.1058823529, blue: 0.1058823529, alpha: 1) | ||
| default: return .white | ||
| } | ||
| } | ||
| var tintColor: UIColor { | ||
| switch themeStyle { | ||
| case .light: return .white | ||
| default: return #colorLiteral(red: 0.1058823529, green: 0.1058823529, blue: 0.1058823529, alpha: 1) | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these literals be constants in Theme+Colours?
|
|
||
| for count in charactersForLines { | ||
| let end = self.index(start, offsetBy: count, limitedBy: self.endIndex) ?? self.endIndex | ||
| var line = String(self[start..<end]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this crash if called on an empty string? (I think ..< has issues if start == end)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It won't crash when start == end. Only when start > end will it crash because of Swift precondition check failure
|
|
||
| VStack(spacing: 0) { | ||
| content{ close() } | ||
| content { completion in close(completion: completion) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😵💫
# Conflicts: # Session.xcodeproj/project.pbxproj
… modal in communities
No description provided.