Notification controller, adding fullBleed toggle

This commit is contained in:
Sumanth Nadigadda 2023-04-04 16:29:51 +05:30
parent a329870c09
commit e8c92a0a05

View File

@ -18,6 +18,7 @@ class NotificationViewController: BaseViewController {
let firstButtonTextField = TextField()
let secondButtonTextField = TextField()
let hideCloseButtonToggle = Toggle()
let fullBleedToggle = Toggle()
let titleDefaultText = "This is title"
let subtitleDefaultText = "This is subtitle"
@ -36,6 +37,7 @@ class NotificationViewController: BaseViewController {
override func viewDidLoad() {
super.viewDidLoad()
addContentTopView(view: notificationView)
notificationView.title = titleDefaultText
notificationView.subTitle = subtitleDefaultText
@ -46,20 +48,19 @@ class NotificationViewController: BaseViewController {
firstButtonTextField.text = firstButtonDefaultText
secondButtonTextField.text = secondButtonDefaultText
addContentTopView(view: notificationView)
setupForm()
setupPicker()
}
func setupForm() {
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Style", view: notificationTypePickerSelectorView)
addFormRow(label: "Type", view: notificationTypePickerSelectorView)
addFormRow(label: "Layout", view: layoutTypePickerSelectorView)
addFormRow(label: "Title", view: titleTextField)
addFormRow(label: "SubTitle", view: subTitleTextField)
addFormRow(label: "Hide Button Group", view: buttonGroupToggle)
addFormRow(label: "Hide Close Button", view: hideCloseButtonToggle)
addFormRow(label: "Full bleed", view: fullBleedToggle)
addFormRow(label: "Button Action", view: label)
addFormRow(label: "First Button Text", view: firstButtonTextField)
addFormRow(label: "Second Button Text", view: secondButtonTextField)
@ -106,6 +107,17 @@ class NotificationViewController: BaseViewController {
hideCloseButtonToggle.publisher(for: .valueChanged).sink(receiveValue: { [weak self] toggle in
self?.notificationView.hideCloseButton = toggle.isOn
}).store(in: &subscribers)
fullBleedToggle.publisher(for: .valueChanged).sink(receiveValue: { [weak self] toggle in
self?.notificationView.fullBleed = toggle.isOn
let isFullBleed = self?.notificationView.fullBleed ?? false
self?.notificationView.leadingConstraint?.constant = isFullBleed ? 0 : 16
self?.notificationView.trailingConstraint?.constant = isFullBleed ? 0 : 16
self?.notificationView.leadingConstraint?.isActive = isFullBleed
self?.notificationView.trailingConstraint?.isActive = isFullBleed
}).store(in: &subscribers)
}
func setupPicker() {