Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor FXIOS-10205 [Swiftlint] Resolve 12 implicitly_unwrapped_optional violations in Client/Frontend/Reader #23883

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions firefox-ios/Client/Frontend/Reader/ReadabilityService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class ReadabilityOperation: Operation, @unchecked Sendable {
extension ReadabilityOperation: WKNavigationDelegate {
func webView(
_ webView: WKWebView,
didFail navigation: WKNavigation!,
didFail navigation: WKNavigation?,
withError error: Error
) {
result = ReadabilityOperationResult.error(error as NSError)
Expand All @@ -107,14 +107,14 @@ extension ReadabilityOperation: WKNavigationDelegate {

func webView(
_ webView: WKWebView,
didFailProvisionalNavigation navigation: WKNavigation!,
didFailProvisionalNavigation navigation: WKNavigation?,
withError error: Error
) {
result = ReadabilityOperationResult.error(error as NSError)
semaphore.signal()
}

func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation?) {
webView.evaluateJavascriptInDefaultContentWorld("\(ReaderModeNamespace).checkReadability()")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ import Common

class ReaderModeStyleViewController: UIViewController, Themeable {
// UI views
private var fontTypeButtons: [ReaderModeFontTypeButton]!
private var fontSizeLabel: ReaderModeFontSizeLabel!
private var fontSizeButtons: [ReaderModeFontSizeButton]!
private var themeButtons: [ReaderModeThemeButton]!
private var fontTypeButtons: [ReaderModeFontTypeButton] = []
private var fontSizeLabel: ReaderModeFontSizeLabel?
private var fontSizeButtons: [ReaderModeFontSizeButton] = []
private var themeButtons: [ReaderModeThemeButton] = []
private var brightnessImageViews = [UIImageView]()
private var separatorLines = [UIView.build(), UIView.build(), UIView.build()]

private var fontTypeRow: UIView!
private var fontSizeRow: UIView!
private var brightnessRow: UIView!
private var fontTypeRow: UIView?
private var fontSizeRow: UIView?
private var brightnessRow: UIView?

private lazy var slider: UISlider = .build { slider in
slider.accessibilityLabel = .ReaderModeStyleBrightnessAccessibilityLabel
slider.addTarget(self, action: #selector(self.changeBrightness), for: .valueChanged)
}

private var viewModel: ReaderModeStyleViewModel!
private var viewModel: ReaderModeStyleViewModel
var themeManager: ThemeManager
var themeObserver: NSObjectProtocol?
var notificationCenter: NotificationProtocol
Expand Down Expand Up @@ -59,7 +59,8 @@ class ReaderModeStyleViewController: UIViewController, Themeable {
)

// Font type row
fontTypeRow = .build()

let fontTypeRow: UIView = .build()
view.addSubview(fontTypeRow)

NSLayoutConstraint.activate([
Expand All @@ -68,6 +69,7 @@ class ReaderModeStyleViewController: UIViewController, Themeable {
fontTypeRow.rightAnchor.constraint(equalTo: view.rightAnchor),
fontTypeRow.heightAnchor.constraint(equalToConstant: ReaderModeStyleViewModel.UX.RowHeight),
])
self.fontTypeRow = fontTypeRow

fontTypeButtons = [
ReaderModeFontTypeButton(fontType: ReaderModeFontType.sansSerif),
Expand All @@ -81,7 +83,7 @@ class ReaderModeStyleViewController: UIViewController, Themeable {

// Font size row

fontSizeRow = .build()
let fontSizeRow: UIView = .build()
view.addSubview(fontSizeRow)

NSLayoutConstraint.activate([
Expand All @@ -90,14 +92,16 @@ class ReaderModeStyleViewController: UIViewController, Themeable {
fontSizeRow.rightAnchor.constraint(equalTo: view.rightAnchor),
fontSizeRow.heightAnchor.constraint(equalToConstant: ReaderModeStyleViewModel.UX.RowHeight),
])
self.fontSizeRow = fontSizeRow

fontSizeLabel = .build()
let fontSizeLabel: ReaderModeFontSizeLabel = .build()
fontSizeRow.addSubview(fontSizeLabel)

NSLayoutConstraint.activate([
fontSizeLabel.centerXAnchor.constraint(equalTo: fontSizeRow.centerXAnchor),
fontSizeLabel.centerYAnchor.constraint(equalTo: fontSizeRow.centerYAnchor),
])
self.fontSizeLabel = fontSizeLabel

fontSizeButtons = [
ReaderModeFontSizeButton(fontSizeAction: FontSizeAction.smaller),
Expand Down Expand Up @@ -137,7 +141,7 @@ class ReaderModeStyleViewController: UIViewController, Themeable {

// Brightness row

brightnessRow = .build()
let brightnessRow: UIView = .build()
view.addSubview(brightnessRow)
NSLayoutConstraint.activate(
[
Expand All @@ -151,6 +155,7 @@ class ReaderModeStyleViewController: UIViewController, Themeable {
),
]
)
self.brightnessRow = brightnessRow

brightnessRow.addSubview(slider)
NSLayoutConstraint.activate(
Expand Down Expand Up @@ -216,7 +221,7 @@ class ReaderModeStyleViewController: UIViewController, Themeable {
view?.backgroundColor = theme.colors.layer1
}

fontSizeLabel.textColor = theme.colors.textPrimary
fontSizeLabel?.textColor = theme.colors.textPrimary

fontTypeButtons.forEach { button in
button.setTitleColor(theme.colors.textPrimary,
Expand Down Expand Up @@ -288,7 +293,7 @@ class ReaderModeStyleViewController: UIViewController, Themeable {
for button in themeButtons {
button.fontType = fontType
}
fontSizeLabel.fontType = fontType
fontSizeLabel?.fontType = fontType
}

@objc
Expand All @@ -314,7 +319,8 @@ class ReaderModeStyleViewController: UIViewController, Themeable {

@objc
func changeTheme(_ button: ReaderModeThemeButton) {
viewModel.readerModeDidChangeTheme(button.readerModeTheme)
guard let readerModeTheme = button.readerModeTheme else { return }
viewModel.readerModeDidChangeTheme(readerModeTheme)
}

@objc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import UIKit
import Shared

class ReaderModeThemeButton: UIButton {
var readerModeTheme: ReaderModeTheme!
var readerModeTheme: ReaderModeTheme?

var fontType: ReaderModeFontType = .sansSerif {
didSet {
Expand Down