mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-24 10:32:46 +02:00
Stop using a cell for basic info, remove unneccessary GroupedTableViewCell
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// Copyright 2020 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 UIKit
|
||||
import Reusable
|
||||
|
||||
class RoomInfoBasicView: UIView {
|
||||
|
||||
@IBOutlet private weak var mainStackView: UIStackView!
|
||||
@IBOutlet private weak var avatarImageView: MXKImageView!
|
||||
@IBOutlet private weak var shadowView: UIView! {
|
||||
didSet {
|
||||
let shadowPath = UIBezierPath(roundedRect: shadowView.bounds, cornerRadius: 0)
|
||||
let layer = CALayer()
|
||||
layer.shadowPath = shadowPath.cgPath
|
||||
layer.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.12).cgColor
|
||||
layer.shadowOpacity = 1
|
||||
layer.shadowRadius = 25
|
||||
layer.shadowOffset = CGSize(width: 0, height: 4)
|
||||
layer.bounds = shadowView.bounds
|
||||
layer.position = shadowView.center
|
||||
|
||||
shadowView.layer.addSublayer(layer)
|
||||
}
|
||||
}
|
||||
@IBOutlet private weak var badgeImageView: UIImageView!
|
||||
@IBOutlet private weak var roomNameLabel: UILabel!
|
||||
@IBOutlet private weak var roomAddressLabel: UILabel!
|
||||
@IBOutlet private weak var roomTopicLabel: UILabel!
|
||||
|
||||
func configure(withViewData viewData: RoomInfoBasicViewData) {
|
||||
let avatarImage = AvatarGenerator.generateAvatar(forMatrixItem: viewData.roomId, withDisplayName: viewData.roomDisplayName)
|
||||
|
||||
if let avatarUrl = viewData.avatarUrl {
|
||||
avatarImageView.enableInMemoryCache = true
|
||||
|
||||
avatarImageView.setImageURI(avatarUrl,
|
||||
withType: nil,
|
||||
andImageOrientation: .up,
|
||||
toFitViewSize: avatarImageView.frame.size,
|
||||
with: MXThumbnailingMethodCrop,
|
||||
previewImage: avatarImage,
|
||||
mediaManager: viewData.mediaManager)
|
||||
} else {
|
||||
avatarImageView.image = avatarImage
|
||||
}
|
||||
badgeImageView.image = viewData.encryptionImage
|
||||
roomNameLabel.text = viewData.roomDisplayName
|
||||
roomAddressLabel.text = viewData.mainRoomAlias
|
||||
roomAddressLabel.isHidden = (roomAddressLabel.text?.count ?? 0) == 0
|
||||
roomTopicLabel.text = viewData.roomTopic
|
||||
roomTopicLabel.isHidden = (roomTopicLabel.text?.count ?? 0) == 0
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension RoomInfoBasicView: NibLoadable {}
|
||||
|
||||
extension RoomInfoBasicView: Themable {
|
||||
|
||||
func update(theme: Theme) {
|
||||
backgroundColor = theme.headerBackgroundColor
|
||||
roomNameLabel.textColor = theme.textPrimaryColor
|
||||
roomAddressLabel.textColor = theme.textSecondaryColor
|
||||
roomTopicLabel.textColor = theme.textSecondaryColor
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
|
||||
<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="RoomInfoBasicView" customModule="Riot" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="0.0" width="414" height="183"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" verticalCompressionResistancePriority="751" axis="vertical" distribution="equalSpacing" alignment="center" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="xmU-kN-zva">
|
||||
<rect key="frame" x="0.0" y="0.0" width="414" height="183"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Tgy-Pv-0Gz">
|
||||
<rect key="frame" x="87" y="0.0" width="240" height="1"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="1" id="5Hy-Jn-UrY"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="uhx-GK-2je">
|
||||
<rect key="frame" x="167" y="11" width="80" height="80"/>
|
||||
<subviews>
|
||||
<view clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="6tV-Ha-dWM" customClass="MXKImageView">
|
||||
<rect key="frame" x="0.0" y="0.0" width="80" height="80"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
|
||||
<integer key="value" value="40"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</view>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="szu-r5-TIX">
|
||||
<rect key="frame" x="0.0" y="0.0" width="80" height="80"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</view>
|
||||
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="CPx-Kp-81p">
|
||||
<rect key="frame" x="56" y="56" width="24" height="24"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="24" id="i5v-oL-sm2"/>
|
||||
<constraint firstAttribute="width" constant="24" id="xNQ-sH-hA2"/>
|
||||
</constraints>
|
||||
</imageView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="CPx-Kp-81p" secondAttribute="trailing" id="6RG-lL-haL"/>
|
||||
<constraint firstItem="6tV-Ha-dWM" firstAttribute="top" secondItem="uhx-GK-2je" secondAttribute="top" id="BoZ-qJ-yLh"/>
|
||||
<constraint firstItem="6tV-Ha-dWM" firstAttribute="leading" secondItem="uhx-GK-2je" secondAttribute="leading" id="Cct-TF-2Cj"/>
|
||||
<constraint firstItem="szu-r5-TIX" firstAttribute="leading" secondItem="uhx-GK-2je" secondAttribute="leading" id="D8c-8Q-pof"/>
|
||||
<constraint firstItem="szu-r5-TIX" firstAttribute="top" secondItem="uhx-GK-2je" secondAttribute="top" id="GI9-rA-rhp"/>
|
||||
<constraint firstAttribute="bottom" secondItem="6tV-Ha-dWM" secondAttribute="bottom" id="ISw-Ft-Kvj"/>
|
||||
<constraint firstAttribute="width" constant="80" id="Wak-DS-q4j"/>
|
||||
<constraint firstAttribute="height" constant="80" id="am1-8t-b28"/>
|
||||
<constraint firstAttribute="bottom" secondItem="szu-r5-TIX" secondAttribute="bottom" id="mqD-nK-e6K"/>
|
||||
<constraint firstAttribute="bottom" secondItem="CPx-Kp-81p" secondAttribute="bottom" id="vLA-vu-R2o"/>
|
||||
<constraint firstAttribute="trailing" secondItem="6tV-Ha-dWM" secondAttribute="trailing" id="wCp-YW-duP"/>
|
||||
<constraint firstAttribute="trailing" secondItem="szu-r5-TIX" secondAttribute="trailing" id="xqQ-Ue-Ldl"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ekk-PI-fnh">
|
||||
<rect key="frame" x="182" y="100.5" width="50.5" height="24"/>
|
||||
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="20"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Yjw-ez-u4W">
|
||||
<rect key="frame" x="187.5" y="134.5" width="39.5" height="19.5"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Qyh-eC-KBG">
|
||||
<rect key="frame" x="187.5" y="163.5" width="39.5" height="19.5"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</stackView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="xmU-kN-zva" secondAttribute="trailing" id="JAT-xr-qng"/>
|
||||
<constraint firstAttribute="bottom" secondItem="xmU-kN-zva" secondAttribute="bottom" id="Zen-46-8Ks"/>
|
||||
<constraint firstItem="xmU-kN-zva" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="ciH-WD-B1a"/>
|
||||
<constraint firstItem="xmU-kN-zva" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="qbE-Xx-IK9"/>
|
||||
</constraints>
|
||||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
|
||||
<connections>
|
||||
<outlet property="avatarImageView" destination="6tV-Ha-dWM" id="HPF-WW-KeR"/>
|
||||
<outlet property="badgeImageView" destination="CPx-Kp-81p" id="YTo-hB-enE"/>
|
||||
<outlet property="mainStackView" destination="xmU-kN-zva" id="Hsg-6X-ATq"/>
|
||||
<outlet property="roomAddressLabel" destination="Yjw-ez-u4W" id="R1L-VC-qHV"/>
|
||||
<outlet property="roomNameLabel" destination="ekk-PI-fnh" id="prM-OG-suY"/>
|
||||
<outlet property="roomTopicLabel" destination="Qyh-eC-KBG" id="qN7-ic-y6n"/>
|
||||
<outlet property="shadowView" destination="szu-r5-TIX" id="LDd-uy-FAG"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="243.47826086956525" y="-273.54910714285711"/>
|
||||
</view>
|
||||
</objects>
|
||||
</document>
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// Copyright 2020 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 MatrixKit
|
||||
|
||||
struct RoomInfoBasicViewData {
|
||||
let avatarUrl: String?
|
||||
let mediaManager: MXMediaManager?
|
||||
|
||||
let roomId: String
|
||||
let roomDisplayName: String?
|
||||
let mainRoomAlias: String?
|
||||
let roomTopic: String?
|
||||
let encryptionImage: UIImage?
|
||||
}
|
||||
Reference in New Issue
Block a user