Skip to content
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

Merged
merged 6 commits into from
Mar 24, 2022

Conversation

MaximeEvrard42
Copy link
Contributor

@MaximeEvrard42 MaximeEvrard42 commented Mar 17, 2022

close #5720

iPhone 8 plus Light
Simulator Screen Shot - iPhone 8 Plus - 2022-03-23 at 15 41 52

iPhone 11 Pro Dark
Simulator Screen Shot - iPhone 11 Pro - 2022-03-23 at 15 44 22

@github-actions
Copy link

github-actions bot commented Mar 17, 2022

📱 Scan the QR code below to install the build for this PR.
🔒 This build is for internal testing purpose. Only devices listed in the ad-hoc provisioning profile can install Element Alpha.

QR code

If you can't scan the QR code you can install the build via this link: https://i.diawi.com/C6Cuwu

Copy link
Contributor

@SBiOSoftWhare SBiOSoftWhare left a 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?

Riot/Modules/Room/Location/LocationMarkerView.swift Outdated Show resolved Hide resolved
@@ -20,14 +20,23 @@ import Mapbox

class LocationMarkerView: MGLAnnotationView, NibLoadable {

@IBOutlet private var markerBackground: UIImageView!
Copy link
Contributor

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:

Suggested change
@IBOutlet private var markerBackground: UIImageView!
@IBOutlet private var backgroundImageView: UIImageView!

Riot/Modules/Room/Location/LocationMarkerView.swift Outdated Show resolved Hide resolved
override func awakeFromNib() {
super.awakeFromNib()
translatesAutoresizingMaskIntoConstraints = false
}

func setAvatarData(_ avatarData: AvatarViewDataProtocol) {
Self.usernameColorGenerator.defaultColor = theme.colors.primaryContent
Self.usernameColorGenerator.userNameColors = theme.colors.namesAndAvatars
Copy link
Contributor

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
    }
}

.frame(width: 40, height: 40)
Image(uiImage: image)
.renderingMode(.template)
.foregroundColor(Color.white)
Copy link
Contributor

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)
Copy link
Contributor

@SBiOSoftWhare SBiOSoftWhare Mar 18, 2022

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 {
Copy link
Contributor

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
Copy link
Contributor

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

Copy link
Contributor

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())
Copy link
Contributor

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())
Copy link
Contributor

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())
Copy link
Contributor

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())
Copy link
Contributor

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 {

Copy link
Contributor

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:

Suggested change
@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 Show resolved Hide resolved
// MARK: - Others colors

/// White
var white: ColorType { get }
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

@MaximeEvrard42 MaximeEvrard42 merged commit 5a4c5e5 into develop Mar 24, 2022
@MaximeEvrard42 MaximeEvrard42 deleted the maximee/5720_location_sharing_UI_change branch March 24, 2022 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Location sharing] Update share location screen
2 participants