-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add toggles to Venmo demo * Remove ECD Venmo option
- Loading branch information
Showing
5 changed files
with
65 additions
and
75 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,42 @@ | ||
import UIKit | ||
|
||
class Toggle: UIView { | ||
|
||
private let toggle = UISwitch() | ||
private let title: String | ||
|
||
var isOn: Bool { | ||
toggle.isOn | ||
} | ||
|
||
init(title: String) { | ||
self.title = title | ||
super.init(frame: .zero) | ||
layoutUI() | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
private func layoutUI() { | ||
let label = UILabel() | ||
label.text = title | ||
label.translatesAutoresizingMaskIntoConstraints = false | ||
|
||
toggle.translatesAutoresizingMaskIntoConstraints = false | ||
|
||
let stackView = UIStackView(arrangedSubviews: [label, toggle]) | ||
stackView.alignment = .fill | ||
stackView.distribution = .fill | ||
stackView.translatesAutoresizingMaskIntoConstraints = false | ||
addSubview(stackView) | ||
|
||
NSLayoutConstraint.activate([ | ||
stackView.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor), | ||
stackView.bottomAnchor.constraint(equalTo: safeAreaLayoutGuide.bottomAnchor), | ||
stackView.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor), | ||
stackView.trailingAnchor.constraint(equalTo: safeAreaLayoutGuide.trailingAnchor) | ||
]) | ||
} | ||
} |
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
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