-
Notifications
You must be signed in to change notification settings - Fork 489
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
Update UI in location sharing view #5720 #5859
Update UI in location sharing view #5720 #5859
Conversation
📱 Scan the QR code below to install the build for this PR. If you can't scan the QR code you can install the build via this link: https://i.diawi.com/C6Cuwu |
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.
Can you add a screenshot for light and dark theme please?
@@ -20,14 +20,23 @@ import Mapbox | |||
|
|||
class LocationMarkerView: MGLAnnotationView, NibLoadable { | |||
|
|||
@IBOutlet private var markerBackground: UIImageView! |
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.
Because we are in the LocationMarkerView
maybe we can use this kind of name:
@IBOutlet private var markerBackground: UIImageView! | |
@IBOutlet private var backgroundImageView: UIImageView! |
override func awakeFromNib() { | ||
super.awakeFromNib() | ||
translatesAutoresizingMaskIntoConstraints = false | ||
} | ||
|
||
func setAvatarData(_ avatarData: AvatarViewDataProtocol) { | ||
Self.usernameColorGenerator.defaultColor = theme.colors.primaryContent | ||
Self.usernameColorGenerator.userNameColors = theme.colors.namesAndAvatars |
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.
As we are starting to use the UserNameColorGenerator
in several places we can probably factorize the theming part like this in the UserNameColorGenerator
class:
// MARK: - Themable
extension UserNameColorGenerator: Themable {
func update(theme: Theme) {
self.defaultColor = theme.colors.primaryContent
self.userNameColors = theme.colors.namesAndAvatars
}
}
RiotSwiftUI/Modules/Room/LocationSharing/View/LocationSharingUserMarkerView.swift
Outdated
Show resolved
Hide resolved
.frame(width: 40, height: 40) | ||
Image(uiImage: image) | ||
.renderingMode(.template) | ||
.foregroundColor(Color.white) |
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.
We should use Theme
colors
LocationSharingOptionButton(text: VectorL10n.locationSharingLiveShareTitle) { | ||
// TODO: - Start live location sharing | ||
} content: { | ||
LocationSharingOptionButtonIcon(fillColor: Color.purple, image: Asset.Images.locationLiveIcon.image) |
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.
We should use Theme
colors. If it does not exist yet we should add a property. In this case we should add the color to ThemeSwiftUIType
directly.
let action: () -> (Void) | ||
@ViewBuilder var content: Content | ||
|
||
var body: some 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.
Does the parent accent color apply to the background if you change the theme?
// MARK: Public | ||
|
||
let isMarker: Bool |
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.
Can we add a small comment to indicate what does it mean
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 think we can create a reusable BorderedAvatarImage
that have a UserNameColorGenerator
property in view model or view. And then integrate this BorderedAvatarImage
in LocationSharingUserMarkerView
as subview. LocationSharingUserMarkerView
and BorderedAvatarImage
shared the same UserNameColorGenerator
instance to set the right color.
|
||
} buttonIcon: { | ||
AvatarImage(avatarData: AvatarInput(mxContentUri: nil, matrixItemId: "Alice", displayName: "Alice"), size: nil) | ||
.shapedBorder(color: Color.green, borderWidth: 3, shape: Circle()) |
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.
Use convenient method quoted above: AvatarImage(avatarData: AvatarInput(mxContentUri: nil, matrixItemId: "Alice", displayName: "Alice")).border(color: theme.colors.accent)
|
||
} buttonIcon: { | ||
AvatarImage(avatarData: AvatarInput(mxContentUri: nil, matrixItemId: "Alice", displayName: "Alice"), size: nil) | ||
.shapedBorder(color: Color.green, borderWidth: 3, shape: Circle()) |
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.
We should use colors from ThemeSwiftUI
, in this case the color is theme.colors.accent
context.send(viewAction: .share) | ||
} buttonIcon: { | ||
AvatarImage(avatarData: context.viewState.userAvatarData, size: nil) | ||
.shapedBorder(color: theme.displayUserColor(for: context.viewState.userAvatarData.matrixItemId), borderWidth: 3, shape: Circle()) |
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.
Use convenient border()
extension method quoted above.
guard let avatarImageView = UIHostingController(rootView: LocationSharingUserMarkerView(avatarData: avatarData)).view else { | ||
guard let avatarImageView = UIHostingController(rootView: LocationSharingMarkerView(backgroundColor: theme.displayUserColor(for: avatarData.matrixItemId)) { | ||
AvatarImage(avatarData: avatarData, size: nil) | ||
.shapedBorder(color: theme.displayUserColor(for: avatarData.matrixItemId), borderWidth: 3, shape: Circle()) |
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.
Use convenient border(color: Color)
extension method quoted above.
@@ -59,7 +66,7 @@ struct AvatarImage: 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.
To help factorize BorderModifier
usage:
@available(iOS 14.0, *) | |
extension AvatarImage { | |
func border(color: Color) -> some View { | |
modifier(BorderModifier(color: color, borderWidth: 3, shape: Circle())) | |
} | |
/// Use display name color as border color by default | |
func border() -> some View { | |
let borderColor = theme.displayNameColor(for: matrixItemId) | |
return self.border(color: borderColor) | |
} | |
} |
DesignKit/Source/Colors.swift
Outdated
// MARK: - Others colors | ||
|
||
/// White | ||
var white: ColorType { get } |
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.
The property name should reflect the purpose. It seems that this color is not used.
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.
We should also create another protocol to handle other colors. Colors.swift
handles only colors from Figma Compound. We need to create public protocol OtherColors
in a separated file and add otherColors
property on ThemeV2
and ThemeSwiftUIType
.
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 removed here, they was no longuer necessary. For the protocol, I am looking how colors was handle in former project, I'll work on it later.
close #5720
iPhone 8 plus Light
iPhone 11 Pro Dark