@@ -472,6 +472,8 @@ private extension TwoFAViewController {
472472 for (reuseIdentifier, nib) in cells {
473473 tableView. register ( nib, forCellReuseIdentifier: reuseIdentifier)
474474 }
475+
476+ tableView. register ( SpacerTableViewCell . self, forCellReuseIdentifier: SpacerTableViewCell . reuseIdentifier)
475477 }
476478
477479 /// Describes how the tableView rows should be rendered.
@@ -483,9 +485,14 @@ private extension TwoFAViewController {
483485 rows. append ( . errorMessage)
484486 }
485487
488+ rows. append ( . spacer( 20 ) )
486489 rows. append ( . alternateInstructions)
490+
491+ rows. append ( . spacer( 4 ) )
487492 rows. append ( . sendCode)
493+
488494 if #available( iOS 16 , * ) , WordPressAuthenticator . shared. configuration. enablePasskeys, loginFields. nonceInfo? . nonceWebauthn != nil {
495+ rows. append ( . spacer( 4 ) )
489496 rows. append ( . enterSecurityKey)
490497 }
491498 }
@@ -506,6 +513,10 @@ private extension TwoFAViewController {
506513 configureEnterSecurityKeyLinkButton ( cell)
507514 case let cell as TextLabelTableViewCell where row == . errorMessage:
508515 configureErrorLabel ( cell)
516+ case let cell as SpacerTableViewCell :
517+ if case let . spacer( spacing) = row {
518+ configureSpacerCell ( cell, spacing: spacing)
519+ }
509520 default :
510521 WPAuthenticatorLogError ( " Error: Unidentified tableViewCell type found. " )
511522 }
@@ -579,6 +590,12 @@ private extension TwoFAViewController {
579590 }
580591 }
581592
593+ /// Configure the spacer cell.
594+ ///
595+ func configureSpacerCell( _ cell: SpacerTableViewCell , spacing: CGFloat ) {
596+ cell. spacing = spacing
597+ }
598+
582599 /// Configure the view for an editing state.
583600 ///
584601 func configureViewForEditingIfNeeded( ) {
@@ -604,13 +621,14 @@ private extension TwoFAViewController {
604621
605622 /// Rows listed in the order they were created.
606623 ///
607- enum Row {
624+ enum Row : Equatable {
608625 case instructions
609626 case code
610627 case alternateInstructions
611628 case sendCode
612629 case enterSecurityKey
613630 case errorMessage
631+ case spacer( CGFloat )
614632
615633 var reuseIdentifier : String {
616634 switch self {
@@ -626,6 +644,8 @@ private extension TwoFAViewController {
626644 return TextLinkButtonTableViewCell . reuseIdentifier
627645 case . errorMessage:
628646 return TextLabelTableViewCell . reuseIdentifier
647+ case . spacer:
648+ return SpacerTableViewCell . reuseIdentifier
629649 }
630650 }
631651 }
@@ -641,5 +661,53 @@ private extension TwoFAViewController {
641661 comment: " Error when the uses takes more than 1 minute to submit a security key. " )
642662 static let unknownError = NSLocalizedString ( " Whoops, something went wrong. Please try again! " , comment: " Generic error on the 2FA screen " )
643663 }
664+ }
665+
666+ private extension TwoFAViewController {
667+ /// Simple spacer cell for a table view.
668+ ///
669+ final class SpacerTableViewCell : UITableViewCell {
670+
671+ /// Static identifier
672+ ///
673+ static let reuseIdentifier = " SpacerTableViewCell "
644674
675+ /// Gets or sets the desired vertical spacing.
676+ ///
677+ var spacing : CGFloat {
678+ get {
679+ heightConstraint. constant
680+ }
681+ set {
682+ heightConstraint. constant = newValue
683+ }
684+ }
685+
686+ /// Determines the view height internally
687+ ///
688+ private let heightConstraint : NSLayoutConstraint
689+
690+
691+ override init ( style: UITableViewCell . CellStyle , reuseIdentifier: String ? ) {
692+
693+ let spacerView = UIView ( )
694+ spacerView. translatesAutoresizingMaskIntoConstraints = false
695+ heightConstraint = spacerView. heightAnchor. constraint ( equalToConstant: 0 )
696+
697+ super. init ( style: style, reuseIdentifier: reuseIdentifier)
698+
699+ addSubview ( spacerView)
700+ NSLayoutConstraint . activate ( [
701+ spacerView. topAnchor. constraint ( equalTo: topAnchor) ,
702+ spacerView. bottomAnchor. constraint ( equalTo: bottomAnchor) ,
703+ spacerView. leadingAnchor. constraint ( equalTo: leadingAnchor) ,
704+ spacerView. trailingAnchor. constraint ( equalTo: trailingAnchor) ,
705+ heightConstraint
706+ ] )
707+ }
708+
709+ required init ? ( coder: NSCoder ) {
710+ fatalError ( " Not implemented " )
711+ }
712+ }
645713}
0 commit comments