From e8c92a0a05876ee0ec253176c107d1465b2df378 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Tue, 4 Apr 2023 16:29:51 +0530 Subject: [PATCH] Notification controller, adding fullBleed toggle --- .../NotificationViewController.swift | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/VDSSample/ViewControllers/NotificationViewController.swift b/VDSSample/ViewControllers/NotificationViewController.swift index 3c4b5fa..82f1942 100644 --- a/VDSSample/ViewControllers/NotificationViewController.swift +++ b/VDSSample/ViewControllers/NotificationViewController.swift @@ -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() {