Skip to content

Commit

Permalink
Refactor FXIOS-10205 [Swiftlint] Resolve 1 implicitly_unwrapped_optio…
Browse files Browse the repository at this point in the history
…nal violations in ContextualHintView (#23797)

Resolve warnings in ContextualHintView

Co-authored-by: Marceau Tonelli <[email protected]>
  • Loading branch information
tonell-m and tonelli-m authored Dec 17, 2024
1 parent a5df3e2 commit da3ae61
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Common
import UIKit

public class ContextualHintView: UIView, ThemeApplicable {
private var viewModel: ContextualHintViewModel!
private var viewModel: ContextualHintViewModel?

struct UX {
static let closeButtonSize = CGSize(width: 35, height: 35)
Expand Down Expand Up @@ -113,6 +113,8 @@ public class ContextualHintView: UIView, ThemeApplicable {
}

private func setupConstraints() {
guard let viewModel else { return }

let isArrowUp = viewModel.arrowDirection == .up
let topPadding = isArrowUp ? UX.stackViewTopArrowTopConstraint : UX.stackViewBottomArrowTopConstraint
let closeButtonPadding = isArrowUp ? UX.closeButtonTop : UX.closeButtonBottom
Expand Down Expand Up @@ -151,12 +153,12 @@ public class ContextualHintView: UIView, ThemeApplicable {

@objc
private func didTapCloseButton(sender: UIButton) {
viewModel.closeButtonAction?(sender)
viewModel?.closeButtonAction?(sender)
}

@objc
private func didTapActionButton(sender: UIButton) {
viewModel.actionButtonAction?(sender)
viewModel?.actionButtonAction?(sender)
}

public func applyTheme(theme: Theme) {
Expand All @@ -165,6 +167,8 @@ public class ContextualHintView: UIView, ThemeApplicable {
descriptionLabel.textColor = theme.colors.textOnDark
gradient.colors = theme.colors.layerGradient.cgColors

guard let viewModel else { return }

if viewModel.isActionType {
let textAttributes: [NSAttributedString.Key: Any] = [
.font: FXFontStyles.Regular.body.scaledFont(),
Expand Down

0 comments on commit da3ae61

Please sign in to comment.