Digital ACT192 story ONEAPP-11297 - Updating insets to allow for more flexibility and edge using. Removing the status bar view because it is no longer used.
This commit is contained in:
parent
fe5bd4a9ac
commit
44adc76dcb
8
MVMCoreUI/Atomic/Atoms/Views/Spacer.swift
Normal file
8
MVMCoreUI/Atomic/Atoms/Views/Spacer.swift
Normal file
@ -0,0 +1,8 @@
|
||||
//
|
||||
// Untitled.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Scott Pfeil on 10/16/24.
|
||||
// Copyright © 2024 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
8
MVMCoreUI/Atomic/Atoms/Views/SpacerModel.swift
Normal file
8
MVMCoreUI/Atomic/Atoms/Views/SpacerModel.swift
Normal file
@ -0,0 +1,8 @@
|
||||
//
|
||||
// SpacerMdoel.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Scott Pfeil on 10/16/24.
|
||||
// Copyright © 2024 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
@ -37,7 +37,8 @@ import VDSCoreTokens
|
||||
verticalStack.alignment = .fill
|
||||
verticalStack.distribution = .fill
|
||||
addSubview(verticalStack)
|
||||
NSLayoutConstraint.constraintPinSubview(verticalStack, pinTop: true, topConstant: 0, pinBottom: true, bottomConstant: 0, pinLeft: true, leftConstant: 0, pinRight: true, rightConstant: 0)
|
||||
verticalStack.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor).isActive = true
|
||||
NSLayoutConstraint.constraintPinSubview(verticalStack, pinTop: false, topConstant: 0, pinBottom: true, bottomConstant: 0, pinLeft: true, leftConstant: 0, pinRight: true, rightConstant: 0)
|
||||
|
||||
reset()
|
||||
subscribeForNotifications()
|
||||
@ -223,6 +224,10 @@ extension CollapsableNotification: StatusBarUI {
|
||||
topView.label.textColor.getWhite(&greyScale, alpha: nil)
|
||||
return (color, greyScale > 0.5 ? .lightContent : .default)
|
||||
}
|
||||
|
||||
public func shouldUseSafeAreaLayoutGuide() -> Bool {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
extension CollapsableNotification: AccessibilityProtocol {
|
||||
|
||||
@ -332,7 +332,7 @@ open class Carousel: View {
|
||||
|
||||
addSubview(pagingView)
|
||||
pagingView.centerXAnchor.constraint(equalTo: collectionView.centerXAnchor).isActive = true
|
||||
collectionView.bottomAnchor.constraint(equalTo: pagingView.centerYAnchor, constant: position).isActive = true
|
||||
collectionView.safeAreaLayoutGuide.bottomAnchor.constraint(equalTo: pagingView.centerYAnchor, constant: position).isActive = true
|
||||
pagingBottomPin = bottomAnchor.constraint(greaterThanOrEqualTo: pagingView.bottomAnchor)
|
||||
pagingBottomPin?.isActive = true
|
||||
bottomPin = bottomAnchor.constraint(equalTo: collectionView.bottomAnchor)
|
||||
|
||||
@ -19,4 +19,10 @@ public protocol ContainerModelProtocol {
|
||||
var useVerticalMargins: Bool? { get set }
|
||||
var topPadding: CGFloat? { get set }
|
||||
var bottomPadding: CGFloat? { get set }
|
||||
|
||||
var useSafeAreaInsets: Bool? { get set }
|
||||
}
|
||||
|
||||
public extension ContainerModelProtocol {
|
||||
var useSafeAreaInsets: Bool? { get { return nil } set {} }
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
public var header: MoleculeModelProtocol?
|
||||
public var anchorFooter: Bool = false
|
||||
public var footer: MoleculeModelProtocol?
|
||||
public var fullScreen: Bool = false
|
||||
|
||||
public override var rootMolecules: [MoleculeModelProtocol] {
|
||||
[navigationBar, header, footer].compactMap { $0 }
|
||||
@ -50,6 +51,7 @@
|
||||
case header
|
||||
case anchorFooter
|
||||
case footer
|
||||
case fullScreen
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -66,6 +68,7 @@
|
||||
anchorFooter = anchor
|
||||
}
|
||||
footer = try typeContainer.decodeModelIfPresent(codingKey: .footer)
|
||||
fullScreen = try typeContainer.decodeIfPresent(Bool.self, forKey: .fullScreen) ?? false
|
||||
try super.init(from: decoder)
|
||||
}
|
||||
|
||||
@ -76,6 +79,7 @@
|
||||
try container.encodeModelIfPresent(header, forKey: .header)
|
||||
try container.encodeIfPresent(anchorFooter, forKey: .anchorFooter)
|
||||
try container.encodeModelIfPresent(footer, forKey: .footer)
|
||||
try container.encodeIfPresent(fullScreen, forKey: .fullScreen)
|
||||
}
|
||||
|
||||
public override func isEqual(to model: any ModelComparisonProtocol) -> Bool {
|
||||
|
||||
@ -18,9 +18,24 @@ import UIKit
|
||||
return try parseTemplate(loadObject: loadObject)
|
||||
}
|
||||
|
||||
open override func setContentHeightConstraint() {
|
||||
// The height is used to keep the bottom view at the bottom.
|
||||
if let contentView = contentView, let scrollView = scrollView {
|
||||
let anchor = templateModel?.fullScreen == true ? scrollView.heightAnchor : scrollView.safeAreaLayoutGuide.heightAnchor
|
||||
heightConstraint = contentView.heightAnchor.constraint(equalTo: anchor, multiplier: 1.0)
|
||||
heightConstraint?.priority = UILayoutPriority.defaultLow
|
||||
}
|
||||
}
|
||||
|
||||
open override func updateUI(for molecules: [MoleculeModelProtocol]? = nil) {
|
||||
topViewOutsideOfScroll = templateModel?.anchorHeader ?? false
|
||||
bottomViewOutsideOfScroll = templateModel?.anchorFooter ?? false
|
||||
|
||||
// Check if we are respecting the safe areas or not.
|
||||
scrollView.contentInsetAdjustmentBehavior = templateModel?.fullScreen == true ? .never : .automatic
|
||||
heightConstraint?.isActive = false
|
||||
setContentHeightConstraint()
|
||||
|
||||
super.updateUI(for: molecules)
|
||||
}
|
||||
|
||||
|
||||
@ -55,6 +55,6 @@ open class CollectionView: UICollectionView, MVMCoreViewProtocol {
|
||||
showsVerticalScrollIndicator = false
|
||||
backgroundColor = .clear
|
||||
isAccessibilityElement = false
|
||||
contentInsetAdjustmentBehavior = .always
|
||||
contentInsetAdjustmentBehavior = .never
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,6 +65,7 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo
|
||||
open func updateView(_ size: CGFloat) {
|
||||
if let model = model as? ContainerModelProtocol {
|
||||
containerHelper.updateViewMargins(contentView, model: model, size: size)
|
||||
contentView.insetsLayoutMarginsFromSafeArea = model.useSafeAreaInsets == true
|
||||
}
|
||||
(molecule as? MVMCoreViewProtocol)?.updateView(size)
|
||||
}
|
||||
|
||||
@ -117,6 +117,8 @@ import UIKit
|
||||
contentView.directionalLayoutMargins = directionalLayoutMargins
|
||||
}
|
||||
|
||||
contentView.insetsLayoutMarginsFromSafeArea = listItemModel?.useSafeAreaInsets == true
|
||||
|
||||
topSeparatorView?.updateView(size)
|
||||
bottomSeparatorView?.updateView(size)
|
||||
(molecule as? MVMCoreViewProtocol)?.updateView(size)
|
||||
|
||||
@ -42,6 +42,10 @@ open class ThreeLayerViewController: ProgrammaticScrollViewController, RotorView
|
||||
|
||||
open override func loadView() {
|
||||
super.loadView()
|
||||
setContentHeightConstraint()
|
||||
}
|
||||
|
||||
open func setContentHeightConstraint() {
|
||||
// The height is used to keep the bottom view at the bottom.
|
||||
if let contentView = contentView, let scrollView = scrollView {
|
||||
heightConstraint = contentView.heightAnchor.constraint(equalTo: scrollView.safeAreaLayoutGuide.heightAnchor, multiplier: 1.0)
|
||||
|
||||
@ -15,6 +15,9 @@ import MVMCore
|
||||
public protocol StatusBarUI {
|
||||
/// Returns the background color of the status bar view and the style of the status bar.
|
||||
func getStatusBarUI() -> (color: UIColor, style: UIStatusBarStyle)
|
||||
|
||||
/// Returns if this view should use the safe area layout guide or not (be below the status bar or behind the status bar)
|
||||
func shouldUseSafeAreaLayoutGuide() -> Bool
|
||||
}
|
||||
|
||||
// Navigation bar update functions
|
||||
@ -230,8 +233,7 @@ public extension MVMCoreUISplitViewController {
|
||||
func setStatusBar(for viewController: UIViewController?) {
|
||||
let viewController = viewController as? MVMCoreUIDetailViewProtocol
|
||||
let backgroundColor = viewController?.defaultStatusBarBackgroundColor?() ??
|
||||
navigationController?.navigationBar.standardAppearance.backgroundColor ??
|
||||
statusBarView?.backgroundColor
|
||||
navigationController?.navigationBar.standardAppearance.backgroundColor
|
||||
|
||||
let style = viewController?.defaultStatusBarStyle?() ??
|
||||
getStatusBarStyle(for: backgroundColor)
|
||||
|
||||
@ -43,9 +43,6 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) {
|
||||
// Reference to the top alert view
|
||||
@property (nullable, weak, nonatomic) UIView *topAlertView;
|
||||
|
||||
// Reference to the status bar view
|
||||
@property (nullable, weak, nonatomic) UIView *statusBarView;
|
||||
|
||||
// References to the current navigation item settings.
|
||||
@property (nonatomic, readonly) BOOL leftPanelIsAccessible;
|
||||
@property (nonatomic, readonly) BOOL rightPanelIsAccessible;
|
||||
@ -183,10 +180,4 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) {
|
||||
/// Updates the status bar with the given style and background color
|
||||
- (void)setStatusBarBackgroundColor:(nullable UIColor *)backgroundColor style:(UIStatusBarStyle)style;
|
||||
|
||||
/// Shows the view under the status bar.
|
||||
- (void)expandStatusBarView;
|
||||
|
||||
/// Hides the view under the status bar.
|
||||
- (void)collapseStatusBarView;
|
||||
|
||||
@end
|
||||
|
||||
@ -63,8 +63,6 @@ typedef NS_OPTIONS(NSInteger, MFExtendedDrawer) {
|
||||
@property (strong, nonatomic) NSNumber *transitionWidth;
|
||||
|
||||
@property (nonatomic) UIStatusBarStyle statusBarStyle;
|
||||
@property (strong, nonatomic) NSLayoutConstraint *statusBarHeightConstraint;
|
||||
@property (strong, nonatomic) NSLayoutConstraint *statusBarBottomConstraint;
|
||||
|
||||
// Dismisses any panel
|
||||
- (void)dismissPanels:(id)sender;
|
||||
@ -865,7 +863,6 @@ CGFloat const PanelAnimationDuration = 0.2;
|
||||
#pragma mark - Status Bar
|
||||
|
||||
- (void)setStatusBarBackgroundColor:(UIColor *)backgroundColor style:(UIStatusBarStyle)style {
|
||||
self.statusBarView.backgroundColor = backgroundColor;
|
||||
self.statusBarStyle = style;
|
||||
|
||||
// Triggers preferredStatusBarStyle
|
||||
@ -876,24 +873,6 @@ CGFloat const PanelAnimationDuration = 0.2;
|
||||
return self.statusBarStyle;
|
||||
}
|
||||
|
||||
- (void)expandStatusBarView {
|
||||
__weak typeof(self) weakSelf = self;
|
||||
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
||||
weakSelf.statusBarBottomConstraint.active = YES;
|
||||
weakSelf.statusBarHeightConstraint.active = NO;
|
||||
[weakSelf.view layoutIfNeeded];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)collapseStatusBarView {
|
||||
__weak typeof(self) weakSelf = self;
|
||||
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
||||
weakSelf.statusBarBottomConstraint.active = NO;
|
||||
weakSelf.statusBarHeightConstraint.active = YES;
|
||||
[weakSelf.view layoutIfNeeded];
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - View Cyle
|
||||
|
||||
- (void)loadView {
|
||||
@ -902,17 +881,6 @@ CGFloat const PanelAnimationDuration = 0.2;
|
||||
view.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
self.view = view;
|
||||
|
||||
// Status bar
|
||||
UIView *statusBarView = [MVMCoreUICommonViewsUtility commonView];
|
||||
statusBarView.backgroundColor = [UIColor whiteColor];
|
||||
[self.view addSubview:statusBarView];
|
||||
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[statusBarView]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(statusBarView)]];
|
||||
id topGuide = view.safeAreaLayoutGuide;
|
||||
self.statusBarBottomConstraint = [NSLayoutConstraint constraintWithItem:statusBarView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:topGuide attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
|
||||
self.statusBarBottomConstraint.active = YES;
|
||||
self.statusBarHeightConstraint = [statusBarView.heightAnchor constraintEqualToConstant:0];
|
||||
self.statusBarView = statusBarView;
|
||||
|
||||
// Top Alert
|
||||
if (self.topAlertView) {
|
||||
[self.view addSubview:self.topAlertView];
|
||||
@ -954,9 +922,9 @@ CGFloat const PanelAnimationDuration = 0.2;
|
||||
|
||||
if (self.topAlertView) {
|
||||
UIView *topAlertView = self.topAlertView;
|
||||
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[statusBarView]-0-[topAlertView]-0-[mainView]-0-[progressView]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(statusBarView,topAlertView, mainView, progressView)]];
|
||||
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[topAlertView]-0-[mainView]-0-[progressView]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topAlertView, mainView, progressView)]];
|
||||
} else {
|
||||
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[statusBarView]-0-[mainView]-0-[progressView]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(statusBarView,mainView, progressView)]];
|
||||
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[mainView]-0-[progressView]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(mainView, progressView)]];
|
||||
}
|
||||
|
||||
// Add tabbar if we have it.
|
||||
|
||||
@ -64,6 +64,7 @@ open class Container: View, ContainerProtocol {
|
||||
super.updateView(size)
|
||||
(view as? MVMCoreViewProtocol)?.updateView(size)
|
||||
containerHelper.updateViewMargins(self, model: containerModel, size: size)
|
||||
insetsLayoutMarginsFromSafeArea = containerModel?.useSafeAreaInsets == true
|
||||
}
|
||||
|
||||
/// Will be called only once.
|
||||
|
||||
@ -30,6 +30,8 @@ open class ContainerModel: ContainerModelProtocol, Codable, ModelComparisonProto
|
||||
|
||||
public var cornerRadius: CGFloat?
|
||||
|
||||
public var useSafeAreaInsets: Bool?
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Keys
|
||||
//--------------------------------------------------
|
||||
@ -46,6 +48,7 @@ open class ContainerModel: ContainerModelProtocol, Codable, ModelComparisonProto
|
||||
case topPadding
|
||||
case bottomPadding
|
||||
case cornerRadius
|
||||
case useSafeAreaInsets
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -101,6 +104,7 @@ open class ContainerModel: ContainerModelProtocol, Codable, ModelComparisonProto
|
||||
topPadding = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .topPadding)
|
||||
bottomPadding = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .bottomPadding)
|
||||
cornerRadius = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .cornerRadius)
|
||||
useSafeAreaInsets = try typeContainer.decodeIfPresent(Bool.self, forKey: .useSafeAreaInsets)
|
||||
setDefaults()
|
||||
}
|
||||
|
||||
@ -117,6 +121,7 @@ open class ContainerModel: ContainerModelProtocol, Codable, ModelComparisonProto
|
||||
try container.encodeIfPresent(topPadding, forKey: .topPadding)
|
||||
try container.encodeIfPresent(bottomPadding, forKey: .bottomPadding)
|
||||
try container.encodeIfPresent(cornerRadius, forKey: .cornerRadius)
|
||||
try container.encodeIfPresent(useSafeAreaInsets, forKey: .useSafeAreaInsets)
|
||||
}
|
||||
|
||||
public func isEqual(to model: any ModelComparisonProtocol) -> Bool {
|
||||
|
||||
@ -32,7 +32,14 @@ extension NotificationContainerView: NotificationTransitionDelegateProtocol {
|
||||
public func show(notification: UIView) async {
|
||||
currentNotificationView?.removeFromSuperview()
|
||||
addSubview(notification)
|
||||
NSLayoutConstraint.constraintPinSubview(toSuperview: notification)
|
||||
if (notification as? StatusBarUI)?.shouldUseSafeAreaLayoutGuide() ?? true {
|
||||
NSLayoutConstraint.activate([notification.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor),
|
||||
safeAreaLayoutGuide.bottomAnchor.constraint(equalTo: notification.bottomAnchor),
|
||||
notification.leadingAnchor.constraint(equalTo: leadingAnchor),
|
||||
trailingAnchor.constraint(equalTo: notification.trailingAnchor)])
|
||||
} else {
|
||||
NSLayoutConstraint.constraintPinSubview(toSuperview: notification)
|
||||
}
|
||||
currentNotificationView = notification
|
||||
|
||||
if let conformer = notification as? MVMCoreViewProtocol {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user