diff --git a/RiotSwiftUI/Modules/Room/LocationSharing/View/UserAnnotationCalloutContentView.swift b/RiotSwiftUI/Modules/Room/LocationSharing/View/UserAnnotationCalloutContentView.swift new file mode 100644 index 000000000..419213972 --- /dev/null +++ b/RiotSwiftUI/Modules/Room/LocationSharing/View/UserAnnotationCalloutContentView.swift @@ -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 + } +} diff --git a/RiotSwiftUI/Modules/Room/LocationSharing/View/UserAnnotationCalloutContentView.xib b/RiotSwiftUI/Modules/Room/LocationSharing/View/UserAnnotationCalloutContentView.xib new file mode 100644 index 000000000..8b438cac2 --- /dev/null +++ b/RiotSwiftUI/Modules/Room/LocationSharing/View/UserAnnotationCalloutContentView.xib @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +