mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-21 09:02:44 +02:00
Create map callout view UserAnnotationCalloutContentView.
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Reusable
|
||||
|
||||
class UserAnnotationCalloutContentView: UIView, Themable, NibLoadable {
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
private static let sizingView = UserAnnotationCalloutContentView.instantiate()
|
||||
|
||||
private enum Constants {
|
||||
static let height: CGFloat = 44.0
|
||||
static let cornerRadius: CGFloat = 8.0
|
||||
}
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
// MARK: Outlets
|
||||
|
||||
@IBOutlet var backgroundView: UIView!
|
||||
@IBOutlet var titleLabel: UILabel!
|
||||
@IBOutlet var shareButton: UIButton!
|
||||
|
||||
// MARK: - Setup
|
||||
|
||||
static func instantiate() -> UserAnnotationCalloutContentView {
|
||||
return UserAnnotationCalloutContentView.loadFromNib()
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
func update(theme: Theme) {
|
||||
self.backgroundView.backgroundColor = theme.colors.background
|
||||
self.titleLabel.textColor = theme.colors.secondaryContent
|
||||
self.titleLabel.font = theme.fonts.callout
|
||||
self.shareButton.tintColor = theme.colors.secondaryContent
|
||||
}
|
||||
|
||||
// MARK: - Life cycle
|
||||
|
||||
override func awakeFromNib() {
|
||||
super.awakeFromNib()
|
||||
|
||||
self.titleLabel.text = VectorL10n.locationSharingLiveMapCalloutTitle
|
||||
self.backgroundView.layer.masksToBounds = true
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
|
||||
self.backgroundView.layer.cornerRadius = Constants.cornerRadius
|
||||
}
|
||||
|
||||
static func contentViewSize() -> CGSize {
|
||||
let sizingView = self.sizingView
|
||||
|
||||
sizingView.frame = CGRect(x: 0, y: 0, width: 1, height: Constants.height)
|
||||
|
||||
sizingView.setNeedsLayout()
|
||||
sizingView.layoutIfNeeded()
|
||||
|
||||
let fittingSize = CGSize(width: UIView.layoutFittingCompressedSize.width, height: Constants.height)
|
||||
|
||||
let size = sizingView.systemLayoutSizeFitting(fittingSize,
|
||||
withHorizontalFittingPriority: .fittingSizeLevel,
|
||||
verticalFittingPriority: .required)
|
||||
|
||||
return size
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
|
||||
<capability name="System colors in document resources" minToolsVersion="11.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<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="UserAnnotationCalloutContentView" customModule="RiotSwiftUI" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="0.0" width="222" height="62"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="WEX-LH-zYE">
|
||||
<rect key="frame" x="0.0" y="0.0" width="222" height="62"/>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||
</view>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8qV-yr-fDH">
|
||||
<rect key="frame" x="10" y="0.0" width="168" height="62"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="252" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Htx-uD-cf2">
|
||||
<rect key="frame" x="188" y="0.0" width="24" height="62"/>
|
||||
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
|
||||
<state key="normal" image="share_action_button"/>
|
||||
</button>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="WEX-LH-zYE" secondAttribute="trailing" id="3Rb-Vi-QNG"/>
|
||||
<constraint firstItem="Htx-uD-cf2" firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="WEX-LH-zYE" secondAttribute="bottom" id="8oX-y9-FA8"/>
|
||||
<constraint firstItem="8qV-yr-fDH" firstAttribute="top" secondItem="WEX-LH-zYE" secondAttribute="top" id="Cqh-a4-3xH"/>
|
||||
<constraint firstItem="WEX-LH-zYE" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="Glo-Kv-b9P"/>
|
||||
<constraint firstAttribute="bottom" secondItem="WEX-LH-zYE" secondAttribute="bottom" id="TVK-pw-MQi"/>
|
||||
<constraint firstItem="Htx-uD-cf2" firstAttribute="centerY" secondItem="8qV-yr-fDH" secondAttribute="centerY" id="VLm-I1-Xa5"/>
|
||||
<constraint firstItem="Htx-uD-cf2" firstAttribute="leading" secondItem="8qV-yr-fDH" secondAttribute="trailing" constant="10" id="aNO-Wu-hrO"/>
|
||||
<constraint firstItem="Htx-uD-cf2" firstAttribute="trailing" secondItem="WEX-LH-zYE" secondAttribute="trailing" constant="-10" id="eB7-OT-FSZ"/>
|
||||
<constraint firstItem="Htx-uD-cf2" firstAttribute="top" relation="greaterThanOrEqual" secondItem="WEX-LH-zYE" secondAttribute="top" id="gsk-Ld-Ahq"/>
|
||||
<constraint firstItem="WEX-LH-zYE" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="kVf-HO-jBq"/>
|
||||
<constraint firstItem="8qV-yr-fDH" firstAttribute="leading" secondItem="WEX-LH-zYE" secondAttribute="leading" constant="10" id="nDk-Sm-zM4"/>
|
||||
<constraint firstItem="8qV-yr-fDH" firstAttribute="bottom" secondItem="WEX-LH-zYE" secondAttribute="bottom" id="ypH-Wk-ly7"/>
|
||||
</constraints>
|
||||
<nil key="simulatedTopBarMetrics"/>
|
||||
<nil key="simulatedBottomBarMetrics"/>
|
||||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
|
||||
<connections>
|
||||
<outlet property="backgroundView" destination="WEX-LH-zYE" id="G7V-Kl-xz0"/>
|
||||
<outlet property="shareButton" destination="Htx-uD-cf2" id="crB-EP-vHO"/>
|
||||
<outlet property="titleLabel" destination="8qV-yr-fDH" id="9o1-jU-nR6"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="-7.2463768115942031" y="-193.52678571428569"/>
|
||||
</view>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="share_action_button" width="24" height="24"/>
|
||||
<systemColor name="systemBackgroundColor">
|
||||
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</systemColor>
|
||||
</resources>
|
||||
</document>
|
||||
Reference in New Issue
Block a user