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

[Location sharing] Live location cell in timeline #6055

Merged
merged 7 commits into from
Apr 26, 2022

Conversation

MaximeEvrard42
Copy link
Contributor

@MaximeEvrard42 MaximeEvrard42 commented Apr 21, 2022

close #6029

For now, the live location event is not handle, we will have to come back to this part when it will be done.

Light Dark
Simulator Screen Shot - iPhone 11 Pro - 2022-04-26 at 12 30 44 Simulator Screen Shot - iPhone 11 Pro - 2022-04-26 at 12 30 28
Simulator Screen Shot - iPhone 11 Pro - 2022-04-26 at 10 45 56 Simulator Screen Shot - iPhone 11 Pro - 2022-04-26 at 10 45 37
Simulator Screen Shot - iPhone 11 Pro - 2022-04-26 at 14 18 48 Simulator Screen Shot - iPhone 11 Pro - 2022-04-26 at 14 19 23
Simulator Screen Shot - iPhone 11 Pro - 2022-04-25 at 18 05 57 Simulator Screen Shot - iPhone 11 Pro - 2022-04-25 at 18 05 40
Simulator Screen Shot - iPhone 11 Pro - 2022-04-26 at 14 41 32 Simulator Screen Shot - iPhone 11 Pro - 2022-04-26 at 14 41 10

@github-actions
Copy link

github-actions bot commented Apr 21, 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/uQNY5V

Comment on lines 103 to 115
private lazy var incomingTimerFormatter: DateFormatter = {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "HH:mm"
return dateFormatter
}()

private lazy var outgoingTimerFormatter: DateComponentsFormatter = {
let formatter = DateComponentsFormatter()
formatter.zeroFormattingBehavior = .dropAll
formatter.allowedUnits = [.hour, .minute, .second]
formatter.unitsStyle = .brief
return formatter
}()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually put properties at the top of the file

@@ -76,7 +108,8 @@ class RoomTimelineLocationView: UIView, NibLoadable, Themable, MGLMapViewDelegat

public func displayLocation(_ location: CLLocationCoordinate2D,
Copy link
Contributor

@SBiOSoftWhare SBiOSoftWhare Apr 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can set this function private and use to separate methods. We should also handle all states of current user live location sharing. For example:

struct RoomTimelineLocationViewData {
	let location: CLLocationCoordinate2D
	let userAvatarData: AvatarViewData?
	let mapStyleURL: URL
}

struct LiveLocationBannerViewData {
     let icon: UIImage
     let title: String
     let timeLeftString: String?
     let rightButtonTitle: String?

     var showRightButton: Bool {
     	return rightButtonTitle != nil
     }
}

enum TimelineLiveLocationViewState {	
	case outgoing(_ status: LiveLocationSharingStatus) // live location started from current user
	case incoming(_ expiringDate: Date) // live location started by other users
}


enum LiveLocationSharingStatus {
	case starting
	case started(_ timeleft: TimeInterval)
	case failure
	case stopped
}

public func displayStaticLocation(with viewData: RoomTimelineLocationViewData) {

}

public func displayLiveLocation(with viewData: RoomTimelineLocationViewData, liveLocationViewState: TimelineLiveLocationViewState) {

let bannerViewData = self.liveLocationBannerViewData(from viewState: TimelineLiveLocationViewState)
...	
}

let timerString: String?
if isIncomingLocation {
timerString = VectorL10n.locationSharingLiveTimerIncoming(incomingTimerFormatter.string(from: Date(timeIntervalSince1970: timestamp)))
} else if let outgoingTimer = outgoingTimerFormatter.string(from: Date(timeIntervalSince1970: timestamp).timeIntervalSinceNow) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timestamp is in milliseconds

Comment on lines 23 to 24
func didTapStopButton()
func didTapRetryButton()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general we are referencing the delegate instance:

    func roomTimelineLocationViewDidTapStopButton(_ roomTimelineLocationView: RoomTimelineLocationView)
    func roomTimelineLocationViewDidTapRetryButton(_ roomTimelineLocationView: RoomTimelineLocationView)

Note: You can also use closures if want instead of delegation

@@ -105,6 +105,14 @@ class DefaultTheme: NSObject, Theme {

var roomCellOutgoingBubbleBackgroundColor: UIColor = UIColor(rgb: 0xE7F8F3)

var roomCellLocalisationTextColor: UIColor = UIColor(rgb: 0x17191C)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This color seems redundant with primaryContent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is, "primaryContent" color is White on dark theme, so it didn't work on the white background of the cell.

@@ -105,6 +105,14 @@ class DefaultTheme: NSObject, Theme {

var roomCellOutgoingBubbleBackgroundColor: UIColor = UIColor(rgb: 0xE7F8F3)

var roomCellLocalisationTextColor: UIColor = UIColor(rgb: 0x17191C)

var roomCellLocalisationStartedColor: UIColor = UIColor(rgb: 0x5C56F5)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can maybe precise icon: roomCellLocalisationIconStartedColor or use a generic liveLocationSharingIconStartedColor

@@ -155,6 +155,8 @@ class RoomTimelineLocationView: UIView, NibLoadable, Themable, MGLMapViewDelegat
clipsToBounds = true
layer.borderWidth = Constants.cellBorderRadius
layer.cornerRadius = Constants.cellCornerRadius

theme = ThemeService.shared().theme
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be updated in update(theme: Theme) also

Copy link

@gaelledel gaelledel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!
Maybe it's a visual illusion because of the shape of the letter but weirdly, it seems that the Avatar pointer isn't quite neat with the spacing of the border.
See:
Screenshot 2022-04-25 at 19 32 18

Also, the pointer on the loading/Stop state image in the timeline seems very big. Perhaps we could just load the map image and then the pointer separately?

Implementation:
Screenshot 2022-04-25 at 19 32 51

I have copies of the background map in the component section of Figma here: https://www.figma.com/file/uthEK6xuo9hSQRdWvPAre5/?node-id=470%3A51660
You can export in whatever format is best for you

Figma reference:
Screenshot 2022-04-25 at 19 33 28

We also need to change the style of the map and button on Dark mode. I'll add this in my to do list and will point you to a reference when ready.
Screenshot 2022-04-25 at 19 38 34

Copy link

@gaelledel gaelledel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks all good I'll just need to review the dark theme for next PR

@MaximeEvrard42 MaximeEvrard42 merged commit 7e3737a into develop Apr 26, 2022
@MaximeEvrard42 MaximeEvrard42 deleted the maximee/6029_lls_timeline_cell branch April 26, 2022 13: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] Live location cell on timeline
3 participants