mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-29 20:56:57 +02:00
Merge branch 'gil/SP1_space_creation' into gil/5230_SP2-Adding_Rooms_to_Spaces
This commit is contained in:
@@ -23,38 +23,43 @@ class CoachMarkView: UIView, NibLoadable, Themable {
|
||||
|
||||
// MARK: Constants
|
||||
|
||||
@objc enum MarkPosition: Int, RawRepresentable {
|
||||
case topLeft
|
||||
case zero
|
||||
|
||||
public var origin: CGPoint {
|
||||
switch self {
|
||||
case .topLeft:
|
||||
return CGPoint(x: 16, y: 40)
|
||||
case .zero:
|
||||
return .zero
|
||||
}
|
||||
public static var TopLeftPosition: CGPoint {
|
||||
if UIDevice.current.orientation.isPortrait {
|
||||
return CGPoint(x: 16, y: 40)
|
||||
} else {
|
||||
return CGPoint(x: 16, y: 32)
|
||||
}
|
||||
}
|
||||
|
||||
enum MarkPosition: Int {
|
||||
case topLeft
|
||||
case topRight
|
||||
case bottomLeft
|
||||
case bottomRight
|
||||
}
|
||||
|
||||
// MARK: Private
|
||||
|
||||
@IBOutlet private weak var backgroundView: UIImageView!
|
||||
@IBOutlet private weak var textLabel: UILabel!
|
||||
@IBOutlet private weak var textLabelTopMargin: NSLayoutConstraint!
|
||||
@IBOutlet private weak var textLabelBottomMargin: NSLayoutConstraint!
|
||||
|
||||
private var text: String? {
|
||||
didSet {
|
||||
textLabel.text = text
|
||||
}
|
||||
}
|
||||
private var position: MarkPosition = .zero
|
||||
private var markPosition: MarkPosition = .topLeft
|
||||
private var position: CGPoint!
|
||||
|
||||
// MARK: Setup
|
||||
|
||||
class func instantiate(text: String?, position: MarkPosition) -> Self {
|
||||
class func instantiate(text: String?, from position: CGPoint, markPosition: MarkPosition) -> Self {
|
||||
let view = Self.loadFromNib()
|
||||
view.text = text
|
||||
view.position = position
|
||||
view.markPosition = markPosition
|
||||
return view
|
||||
}
|
||||
|
||||
@@ -76,11 +81,10 @@ class CoachMarkView: UIView, NibLoadable, Themable {
|
||||
return
|
||||
}
|
||||
|
||||
let origin = position.origin
|
||||
let layoutGuide = superview.safeAreaLayoutGuide
|
||||
translatesAutoresizingMaskIntoConstraints = false
|
||||
leadingAnchor.constraint(equalTo: layoutGuide.leadingAnchor, constant: origin.x).isActive = true
|
||||
topAnchor.constraint(equalTo: layoutGuide.topAnchor, constant: origin.y).isActive = true
|
||||
leadingAnchor.constraint(equalTo: layoutGuide.leadingAnchor, constant: position.x).isActive = true
|
||||
topAnchor.constraint(equalTo: layoutGuide.topAnchor, constant: position.y).isActive = true
|
||||
}
|
||||
|
||||
// MARK: Themable
|
||||
@@ -94,10 +98,31 @@ class CoachMarkView: UIView, NibLoadable, Themable {
|
||||
// MARK: Private
|
||||
|
||||
private func setupView() {
|
||||
let imageSize = Asset.Images.coachMark.image.size
|
||||
let image: UIImage = Asset.Images.coachMark.image
|
||||
let imageSize = image.size
|
||||
let center = CGPoint(x: ceil(imageSize.width / 2), y: ceil(imageSize.height / 2))
|
||||
backgroundView.image = Asset.Images.coachMark.image.resizableImage(withCapInsets: .init(top: center.y - 1, left: center.x - 1, bottom: center.y + 1, right: center.x + 1), resizingMode: .stretch)
|
||||
|
||||
backgroundView.image = image.resizableImage(withCapInsets: .init(top: center.y - 1, left: center.x - 1, bottom: center.y + 1, right: center.x + 1), resizingMode: .stretch)
|
||||
|
||||
switch markPosition {
|
||||
case .topLeft:
|
||||
backgroundView.transform = .identity
|
||||
case .topRight:
|
||||
backgroundView.transform = .init(scaleX: -1, y: 1)
|
||||
case .bottomLeft:
|
||||
backgroundView.transform = .init(scaleX: 1, y: -1)
|
||||
invertVerticalMargins()
|
||||
case .bottomRight:
|
||||
backgroundView.transform = .init(scaleX: -1, y: -1)
|
||||
invertVerticalMargins()
|
||||
}
|
||||
|
||||
textLabel.text = text
|
||||
}
|
||||
|
||||
private func invertVerticalMargins() {
|
||||
let temp = self.textLabelTopMargin.constant
|
||||
self.textLabelTopMargin.constant = self.textLabelBottomMargin.constant
|
||||
self.textLabelBottomMargin.constant = temp
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19529" 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="18093"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
@@ -43,6 +43,8 @@
|
||||
<connections>
|
||||
<outlet property="backgroundView" destination="Yri-TE-HDk" id="LtG-WV-2Rh"/>
|
||||
<outlet property="textLabel" destination="BK3-2S-2hk" id="rhq-K7-3Ix"/>
|
||||
<outlet property="textLabelBottomMargin" destination="ybh-Us-2uE" id="oPz-br-dkj"/>
|
||||
<outlet property="textLabelTopMargin" destination="xdg-IG-jef" id="ITN-e6-8n7"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="-200.72463768115944" y="-162.05357142857142"/>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user