Skip to content

Commit

Permalink
/issues/5298 - Add support for location m.asset types.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanceriu committed Jan 19, 2022
1 parent 1200dd9 commit 948e23d
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import UIKit
import Reusable
import Mapbox

class LocationUserMarkerView: MGLAnnotationView, NibLoadable {
class LocationMarkerView: MGLAnnotationView, NibLoadable {

@IBOutlet private var avatarView: UserAvatarView!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,21 @@
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="LocationUserMarkerView" customModule="Riot" customModuleProvider="target">
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="LocationMarkerView" customModule="Riot" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="50" height="54"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="location_user_marker" translatesAutoresizingMaskIntoConstraints="NO" id="ldO-kc-R5W">
<rect key="frame" x="0.0" y="0.0" width="50" height="54"/>
<constraints>
<constraint firstAttribute="width" constant="50" id="41S-fj-tn4"/>
<constraint firstAttribute="height" constant="54" id="MAX-5E-xvS"/>
</constraints>
</imageView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="location_marker_icon" translatesAutoresizingMaskIntoConstraints="NO" id="gQe-Hv-22e">
<rect key="frame" x="13" y="13" width="24" height="24"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="tintColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</imageView>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="qut-wn-BX3" customClass="UserAvatarView" customModule="Riot" customModuleProvider="target">
<rect key="frame" x="2" y="2" width="46" height="46"/>
Expand All @@ -41,6 +50,7 @@
</view>
</objects>
<resources>
<image name="location_marker_icon" width="24" height="24"/>
<image name="location_user_marker" width="51" height="54.5"/>
</resources>
</document>
22 changes: 9 additions & 13 deletions Riot/Modules/Room/Location/RoomTimelineLocationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ class RoomTimelineLocationView: UIView, NibLoadable, Themable, MGLMapViewDelegat

@IBOutlet private var descriptionContainerView: UIView!
@IBOutlet private var descriptionLabel: UILabel!
@IBOutlet private var descriptionIcon: UIImageView!

private var mapView: MGLMapView!
private var annotationView: LocationUserMarkerView?
private var annotationView: LocationMarkerView?

// MARK: Public

Expand Down Expand Up @@ -73,19 +74,13 @@ class RoomTimelineLocationView: UIView, NibLoadable, Themable, MGLMapViewDelegat

// MARK: - Public

public func displayLocation(_ location: CLLocationCoordinate2D,
userIdentifier: String,
userDisplayName: String,
userAvatarURLString: String?,
mediaManager: MXMediaManager) {

annotationView = LocationUserMarkerView.loadFromNib()
public func displayLocation(_ location: CLLocationCoordinate2D, userAvatarData: AvatarViewData? = nil) {

annotationView = LocationMarkerView.loadFromNib()

annotationView?.setAvatarData(AvatarViewData(matrixItemId: userIdentifier,
displayName: userDisplayName,
avatarUrl: userAvatarURLString,
mediaManager: mediaManager,
fallbackImage: .matrixItem(userIdentifier, userDisplayName)))
if let userAvatarData = userAvatarData {
annotationView?.setAvatarData(userAvatarData)
}

if let annotations = mapView.annotations {
mapView.removeAnnotations(annotations)
Expand All @@ -103,6 +98,7 @@ class RoomTimelineLocationView: UIView, NibLoadable, Themable, MGLMapViewDelegat
func update(theme: Theme) {
descriptionLabel.textColor = theme.colors.primaryContent
descriptionLabel.font = theme.fonts.footnote
descriptionIcon.tintColor = theme.colors.accent
layer.borderColor = theme.colors.quinaryContent.cgColor
}

Expand Down
1 change: 1 addition & 0 deletions Riot/Modules/Room/Location/RoomTimelineLocationView.xib
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<outlet property="descriptionContainerView" destination="oVd-gS-Rmb" id="Npu-jp-oYo"/>
<outlet property="descriptionIcon" destination="GP2-dA-giJ" id="7YL-UU-ClT"/>
<outlet property="descriptionLabel" destination="c68-l7-McA" id="HiH-8Q-yTp"/>
</connections>
<point key="canvasLocation" x="165.94202898550725" y="-100.78125"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,17 @@ class LocationBubbleCell: SizableBaseBubbleCell, BubbleCellReactionsDisplayable

let location = CLLocationCoordinate2D(latitude: locationContent.latitude, longitude: locationContent.longitude)

locationView.displayLocation(location,
userIdentifier: bubbleData.senderId,
userDisplayName: bubbleData.senderDisplayName,
userAvatarURLString: bubbleData.senderAvatarUrl,
mediaManager: bubbleData.mxSession.mediaManager)
if locationContent.assetType == .user {
let avatarViewData = AvatarViewData(matrixItemId: bubbleData.senderId,
displayName: bubbleData.senderDisplayName,
avatarUrl: bubbleData.senderAvatarUrl,
mediaManager: bubbleData.mxSession.mediaManager,
fallbackImage: .matrixItem(bubbleData.senderId, bubbleData.senderDisplayName))

locationView.displayLocation(location, userAvatarData: avatarViewData)
} else {
locationView.displayLocation(location)
}
}

override func setupViews() {
Expand Down

0 comments on commit 948e23d

Please sign in to comment.