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

Tidy up SwiftUI/Onboarding screens #6139

Merged
merged 5 commits into from
May 11, 2022
Merged
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
173 changes: 21 additions & 152 deletions DesignKit/Variants/Fonts/ElementFonts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,7 @@ public class ElementFonts {
/// (even if that font was created with the appropriate metrics).
public struct SharedFont {
public let uiFont: UIFont
/// The underlying font for the `font` property. This is stored
/// as an optional `Any` due to unavailability on iOS 12.
private let _font: Any?

@available(iOS 13.0, *)
public var font: Font {
_font as! Font
}

@available(iOS, deprecated: 13.0, message: "Use init(uiFont:font:) instead and remove this initialiser.")
init(uiFont: UIFont) {
self.uiFont = uiFont
self._font = nil
}

@available(iOS 13.0, *)
init(uiFont: UIFont, font: Font) {
self.uiFont = uiFont
self._font = font
}
public let font: Font
}

// MARK: - Setup
Expand All @@ -69,213 +50,101 @@ extension ElementFonts: Fonts {

public var largeTitle: SharedFont {
let uiFont = self.font(forTextStyle: .largeTitle)

if #available(iOS 13.0, *) {
return SharedFont(uiFont: uiFont, font: .largeTitle)
} else {
return SharedFont(uiFont: uiFont)
}
return SharedFont(uiFont: uiFont, font: .largeTitle)
}

public var largeTitleB: SharedFont {
let uiFont = self.largeTitle.uiFont.vc_bold

if #available(iOS 13.0, *) {
return SharedFont(uiFont: uiFont, font: .largeTitle.bold())
} else {
return SharedFont(uiFont: uiFont)
}
return SharedFont(uiFont: uiFont, font: .largeTitle.bold())
}

public var title1: SharedFont {
let uiFont = self.font(forTextStyle: .title1)

if #available(iOS 13.0, *) {
return SharedFont(uiFont: uiFont, font: .title)
} else {
return SharedFont(uiFont: uiFont)
}
return SharedFont(uiFont: uiFont, font: .title)
}

public var title1B: SharedFont {
let uiFont = self.title1.uiFont.vc_bold

if #available(iOS 13.0, *) {
return SharedFont(uiFont: uiFont, font: .title.bold())
} else {
return SharedFont(uiFont: uiFont)
}
return SharedFont(uiFont: uiFont, font: .title.bold())
}

public var title2: SharedFont {
let uiFont = self.font(forTextStyle: .title2)

if #available(iOS 14.0, *) {
return SharedFont(uiFont: uiFont, font: .title2)
} else if #available(iOS 13.0, *) {
return SharedFont(uiFont: uiFont, font: Font(uiFont))
} else {
return SharedFont(uiFont: uiFont)
}
return SharedFont(uiFont: uiFont, font: .title2)
}

public var title2B: SharedFont {
let uiFont = self.title2.uiFont.vc_bold

if #available(iOS 14.0, *) {
return SharedFont(uiFont: uiFont, font: .title2.bold())
} else if #available(iOS 13.0, *) {
return SharedFont(uiFont: uiFont, font: Font(uiFont))
} else {
return SharedFont(uiFont: uiFont)
}
return SharedFont(uiFont: uiFont, font: .title2.bold())
}

public var title3: SharedFont {
let uiFont = self.font(forTextStyle: .title3)

if #available(iOS 14.0, *) {
return SharedFont(uiFont: uiFont, font: .title3)
} else if #available(iOS 13.0, *) {
return SharedFont(uiFont: uiFont, font: Font(uiFont))
} else {
return SharedFont(uiFont: uiFont)
}
return SharedFont(uiFont: uiFont, font: .title3)
}

public var title3SB: SharedFont {
let uiFont = self.title3.uiFont.vc_semiBold

if #available(iOS 14.0, *) {
return SharedFont(uiFont: uiFont, font: .title3.weight(.semibold))
} else if #available(iOS 13.0, *) {
return SharedFont(uiFont: uiFont, font: Font(uiFont))
} else {
return SharedFont(uiFont: uiFont)
}
return SharedFont(uiFont: uiFont, font: .title3.weight(.semibold))
}

public var headline: SharedFont {
let uiFont = self.font(forTextStyle: .headline)

if #available(iOS 13.0, *) {
return SharedFont(uiFont: uiFont, font: .headline)
} else {
return SharedFont(uiFont: uiFont)
}
return SharedFont(uiFont: uiFont, font: .headline)
}

public var subheadline: SharedFont {
let uiFont = self.font(forTextStyle: .subheadline)

if #available(iOS 13.0, *) {
return SharedFont(uiFont: uiFont, font: .subheadline)
} else {
return SharedFont(uiFont: uiFont)
}
return SharedFont(uiFont: uiFont, font: .subheadline)
}

public var body: SharedFont {
let uiFont = self.font(forTextStyle: .body)

if #available(iOS 13.0, *) {
return SharedFont(uiFont: uiFont, font: .body)
} else {
return SharedFont(uiFont: uiFont)
}
return SharedFont(uiFont: uiFont, font: .body)
}

public var bodySB: SharedFont {
let uiFont = self.body.uiFont.vc_semiBold

if #available(iOS 13.0, *) {
return SharedFont(uiFont: uiFont, font: .body.weight(.semibold))
} else {
return SharedFont(uiFont: uiFont)
}
return SharedFont(uiFont: uiFont, font: .body.weight(.semibold))
}

public var callout: SharedFont {
let uiFont = self.font(forTextStyle: .callout)

if #available(iOS 13.0, *) {
return SharedFont(uiFont: uiFont, font: .callout)
} else {
return SharedFont(uiFont: uiFont)
}
return SharedFont(uiFont: uiFont, font: .callout)
}

public var calloutSB: SharedFont {
let uiFont = self.callout.uiFont.vc_semiBold

if #available(iOS 13.0, *) {
return SharedFont(uiFont: uiFont, font: .callout.weight(.semibold))
} else {
return SharedFont(uiFont: uiFont)
}
return SharedFont(uiFont: uiFont, font: .callout.weight(.semibold))
}

public var footnote: SharedFont {
let uiFont = self.font(forTextStyle: .footnote)

if #available(iOS 13.0, *) {
return SharedFont(uiFont: uiFont, font: .footnote)
} else {
return SharedFont(uiFont: uiFont)
}
return SharedFont(uiFont: uiFont, font: .footnote)
}

public var footnoteSB: SharedFont {
let uiFont = self.footnote.uiFont.vc_semiBold

if #available(iOS 13.0, *) {
return SharedFont(uiFont: uiFont, font: .footnote.weight(.semibold))
} else {
return SharedFont(uiFont: uiFont)
}
return SharedFont(uiFont: uiFont, font: .footnote.weight(.semibold))
}

public var caption1: SharedFont {
let uiFont = self.font(forTextStyle: .caption1)

if #available(iOS 13.0, *) {
return SharedFont(uiFont: uiFont, font: .caption)
} else {
return SharedFont(uiFont: uiFont)
}
return SharedFont(uiFont: uiFont, font: .caption)
}

public var caption1SB: SharedFont {
let uiFont = self.caption1.uiFont.vc_semiBold

if #available(iOS 13.0, *) {
return SharedFont(uiFont: uiFont, font: .caption.weight(.semibold))
} else {
return SharedFont(uiFont: uiFont)
}
return SharedFont(uiFont: uiFont, font: .caption.weight(.semibold))
}

public var caption2: SharedFont {
let uiFont = self.font(forTextStyle: .caption2)

if #available(iOS 14.0, *) {
return SharedFont(uiFont: uiFont, font: .caption2)
} else if #available(iOS 13.0, *) {
return SharedFont(uiFont: uiFont, font: Font(uiFont))
} else {
return SharedFont(uiFont: uiFont)
}
return SharedFont(uiFont: uiFont, font: .caption2)
}

public var caption2SB: SharedFont {
let uiFont = self.caption2.uiFont.vc_semiBold

if #available(iOS 14.0, *) {
return SharedFont(uiFont: uiFont, font: .caption2.weight(.semibold))
} else if #available(iOS 13.0, *) {
return SharedFont(uiFont: uiFont, font: Font(uiFont))
} else {
return SharedFont(uiFont: uiFont)
}
return SharedFont(uiFont: uiFont, font: .caption2.weight(.semibold))
}
}
7 changes: 0 additions & 7 deletions Riot/Modules/Onboarding/AuthenticationCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import UIKit

@available(iOS 14.0, *)
struct AuthenticationCoordinatorParameters {
let navigationRouter: NavigationRouterType
/// The screen that should be shown when starting the flow.
Expand All @@ -28,7 +27,6 @@ struct AuthenticationCoordinatorParameters {
}

/// A coordinator that handles authentication, verification and setting a PIN.
@available(iOS 14.0, *)
final class AuthenticationCoordinator: NSObject, AuthenticationCoordinatorProtocol {

enum EntryPoint {
Expand Down Expand Up @@ -150,7 +148,6 @@ final class AuthenticationCoordinator: NSObject, AuthenticationCoordinatorProtoc
}
}

@available(iOS 14.0, *)
/// Shows the next screen in the flow after the server selection screen.
@MainActor private func serverSelectionCoordinator(_ coordinator: AuthenticationServerSelectionCoordinator,
didCompleteWith result: AuthenticationServerSelectionCoordinatorResult) {
Expand Down Expand Up @@ -189,7 +186,6 @@ final class AuthenticationCoordinator: NSObject, AuthenticationCoordinatorProtoc
}

/// Displays the next view in the flow after the registration screen.
@available(iOS 14.0, *)
@MainActor private func registrationCoordinator(_ coordinator: AuthenticationRegistrationCoordinator,
didCompleteWith result: AuthenticationRegistrationCoordinatorResult) {
switch result {
Expand Down Expand Up @@ -292,7 +288,6 @@ final class AuthenticationCoordinator: NSObject, AuthenticationCoordinatorProtoc
}

// MARK: - KeyVerificationCoordinatorDelegate
@available(iOS 14.0, *)
extension AuthenticationCoordinator: KeyVerificationCoordinatorDelegate {
func keyVerificationCoordinatorDidComplete(_ coordinator: KeyVerificationCoordinatorType, otherUserId: String, otherDeviceId: String) {
if let crypto = session?.crypto,
Expand All @@ -314,7 +309,6 @@ extension AuthenticationCoordinator: KeyVerificationCoordinatorDelegate {
}

// MARK: - UIAdaptivePresentationControllerDelegate
@available(iOS 14.0, *)
extension AuthenticationCoordinator: UIAdaptivePresentationControllerDelegate {
func presentationControllerShouldDismiss(_ presentationController: UIPresentationController) -> Bool {
// Prevent Key Verification from using swipe to dismiss
Expand All @@ -325,7 +319,6 @@ extension AuthenticationCoordinator: UIAdaptivePresentationControllerDelegate {


// MARK: - Unused conformances
@available(iOS 14.0, *)
extension AuthenticationCoordinator {
var customServerFieldsVisible: Bool {
get { false }
Expand Down
Loading