-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Interest form disclaimer view (#433)
Interest form disclaimer view
- Loading branch information
Showing
11 changed files
with
194 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// Copyright © FINN.no AS, Inc. All rights reserved. | ||
// | ||
|
||
import FinniversKit | ||
|
||
public class DisclaimerDemoView: UIView { | ||
|
||
private lazy var disclaimerView: DisclaimerView = { | ||
let view = DisclaimerView(withAutoLayout: true) | ||
view.configure(with: DisclaimerViewModel.default) | ||
return view | ||
}() | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
setup() | ||
} | ||
|
||
public required init?(coder aDecoder: NSCoder) { fatalError() } | ||
|
||
private func setup() { | ||
addSubview(disclaimerView) | ||
|
||
NSLayoutConstraint.activate([ | ||
disclaimerView.topAnchor.constraint(equalTo: topAnchor, constant: .largeSpacing), | ||
disclaimerView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: .mediumLargeSpacing), | ||
disclaimerView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -.mediumLargeSpacing) | ||
]) | ||
} | ||
} | ||
|
||
private extension DisclaimerViewModel { | ||
static var `default`: DisclaimerViewModel { | ||
let disclaimer = "Ved å legge inn din e-postadresse og ditt telefonnummer samtykker du til å motta e-poster samt eventuell henvendelse på telefon om boligprosjektet. Megler/utbygger blir selvstendig behandlingsansvarlig for personinformasjonen de mottar." | ||
let readMoreButtonTitle = "Les mer" | ||
return DisclaimerViewModel(disclaimerText: disclaimer, readMoreButtonTitle: readMoreButtonTitle) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+90.4 KB
...Tests/ReferenceImages_64/UnitTests.ComponentViewTests/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+22.3 KB
(110%)
...sts/ReferenceImages_64/UnitTests.FullscreenViewTests/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// | ||
// Copyright © FINN.no AS, Inc. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
public protocol DisclaimerViewDelegate: AnyObject { | ||
func disclaimerViewDidSelectReadMoreButton(_ disclaimerView: DisclaimerView) | ||
} | ||
|
||
public class DisclaimerView: UIView { | ||
|
||
// MARK: - Public properties | ||
|
||
public weak var delegate: DisclaimerViewDelegate? | ||
|
||
// MARK: - Private properties | ||
|
||
private lazy var disclaimerLabel: Label = { | ||
let label = Label(style: .detail) | ||
label.translatesAutoresizingMaskIntoConstraints = false | ||
label.numberOfLines = 0 | ||
return label | ||
}() | ||
|
||
private lazy var readMoreButton: Button = { | ||
let button = Button(style: .flat, size: .small) | ||
button.translatesAutoresizingMaskIntoConstraints = false | ||
button.addTarget(self, action: #selector(readMoreButtonTapped), for: .touchUpInside) | ||
return button | ||
}() | ||
|
||
// MARK: - Init | ||
|
||
public override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
setup() | ||
} | ||
|
||
public required init?(coder aDecoder: NSCoder) { | ||
super.init(coder: aDecoder) | ||
setup() | ||
} | ||
|
||
// MARK: - Setup | ||
|
||
private func setup() { | ||
addSubview(disclaimerLabel) | ||
addSubview(readMoreButton) | ||
|
||
NSLayoutConstraint.activate([ | ||
disclaimerLabel.topAnchor.constraint(equalTo: topAnchor), | ||
disclaimerLabel.leadingAnchor.constraint(equalTo: leadingAnchor), | ||
disclaimerLabel.trailingAnchor.constraint(equalTo: trailingAnchor), | ||
|
||
readMoreButton.topAnchor.constraint(equalTo: disclaimerLabel.bottomAnchor, constant: .mediumSpacing), | ||
readMoreButton.centerXAnchor.constraint(equalTo: centerXAnchor), | ||
readMoreButton.bottomAnchor.constraint(equalTo: bottomAnchor) | ||
]) | ||
} | ||
|
||
// MARK: - Private methods | ||
|
||
@objc private func readMoreButtonTapped(_ sender: Button) { | ||
delegate?.disclaimerViewDidSelectReadMoreButton(self) | ||
} | ||
|
||
// MARK: - Public methods | ||
|
||
public func configure(with viewModel: DisclaimerViewModel) { | ||
disclaimerLabel.text = viewModel.disclaimerText | ||
readMoreButton.setTitle(viewModel.readMoreButtonTitle, for: .normal) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// Copyright © FINN.no AS, Inc. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct DisclaimerViewModel { | ||
public let disclaimerText: String | ||
public let readMoreButtonTitle: String | ||
|
||
public init(disclaimerText: String, readMoreButtonTitle: String) { | ||
self.disclaimerText = disclaimerText | ||
self.readMoreButtonTitle = readMoreButtonTitle | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters