mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Add SwiftFormat to the project. (#129)
* Run swiftformat for whitespace. * Run swiftformat with some rules.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -14,8 +14,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import DesignTokens
|
||||
import SwiftUI
|
||||
|
||||
public extension ButtonStyle where Self == ElementActionButtonStyle {
|
||||
/// The CTA button style as defined in Compound.
|
||||
@@ -70,17 +70,17 @@ public struct ElementActionButtonStyle_Previews: PreviewProvider {
|
||||
Button("Enabled") { /* preview */ }
|
||||
.buttonStyle(ElementActionButtonStyle())
|
||||
|
||||
Button("Disabled") { /* preview */ }
|
||||
Button("Disabled") { /* preview */ }
|
||||
.buttonStyle(ElementActionButtonStyle())
|
||||
.disabled(true)
|
||||
|
||||
Button { /* preview */ } label: {
|
||||
Button { /* preview */ } label: {
|
||||
Text("Clear BG")
|
||||
.foregroundColor(.element.alert)
|
||||
}
|
||||
.buttonStyle(ElementActionButtonStyle(color: .clear))
|
||||
|
||||
Button("Red BG") { /* preview */ }
|
||||
Button("Red BG") { /* preview */ }
|
||||
.buttonStyle(ElementActionButtonStyle(color: .element.alert))
|
||||
}
|
||||
.padding()
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import DesignTokens
|
||||
import SwiftUI
|
||||
|
||||
public extension ButtonStyle where Self == ElementGhostButtonStyle {
|
||||
/// The Ghost button style as defined in Compound.
|
||||
|
||||
@@ -35,110 +35,111 @@ public class ElementSharedFonts {
|
||||
|
||||
/// Returns an instance of the font associated with the text style and scaled appropriately for the content size category defined in the trait collection.
|
||||
/// Keep this method private method at the moment and create a DesignKit.Fonts.TextStyle if needed.
|
||||
fileprivate func font(forTextStyle textStyle: UIFont.TextStyle, compatibleWith traitCollection: UITraitCollection? = nil) -> UIFont {
|
||||
return UIFont.preferredFont(forTextStyle: textStyle, compatibleWith: traitCollection)
|
||||
private func font(forTextStyle textStyle: UIFont.TextStyle, compatibleWith traitCollection: UITraitCollection? = nil) -> UIFont {
|
||||
UIFont.preferredFont(forTextStyle: textStyle, compatibleWith: traitCollection)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Fonts protocol
|
||||
extension ElementSharedFonts {
|
||||
|
||||
public extension ElementSharedFonts {
|
||||
|
||||
public var largeTitle: SharedFont {
|
||||
var largeTitle: SharedFont {
|
||||
let uiFont = font(forTextStyle: .largeTitle)
|
||||
return SharedFont(uiFont: uiFont, font: .largeTitle)
|
||||
}
|
||||
|
||||
public var largeTitleB: SharedFont {
|
||||
var largeTitleB: SharedFont {
|
||||
let uiFont = largeTitle.uiFont.bold
|
||||
return SharedFont(uiFont: uiFont, font: .largeTitle.bold())
|
||||
}
|
||||
|
||||
public var title1: SharedFont {
|
||||
var title1: SharedFont {
|
||||
let uiFont = font(forTextStyle: .title1)
|
||||
return SharedFont(uiFont: uiFont, font: .title)
|
||||
}
|
||||
|
||||
public var title1B: SharedFont {
|
||||
var title1B: SharedFont {
|
||||
let uiFont = title1.uiFont.bold
|
||||
return SharedFont(uiFont: uiFont, font: .title.bold())
|
||||
}
|
||||
|
||||
public var title2: SharedFont {
|
||||
var title2: SharedFont {
|
||||
let uiFont = font(forTextStyle: .title2)
|
||||
return SharedFont(uiFont: uiFont, font: .title2)
|
||||
}
|
||||
|
||||
public var title2B: SharedFont {
|
||||
var title2B: SharedFont {
|
||||
let uiFont = title2.uiFont.bold
|
||||
return SharedFont(uiFont: uiFont, font: .title2.bold())
|
||||
}
|
||||
|
||||
public var title3: SharedFont {
|
||||
var title3: SharedFont {
|
||||
let uiFont = font(forTextStyle: .title3)
|
||||
return SharedFont(uiFont: uiFont, font: .title3)
|
||||
}
|
||||
|
||||
public var title3SB: SharedFont {
|
||||
var title3SB: SharedFont {
|
||||
let uiFont = title3.uiFont.semiBold
|
||||
return SharedFont(uiFont: uiFont, font: .title3.weight(.semibold))
|
||||
}
|
||||
|
||||
public var headline: SharedFont {
|
||||
var headline: SharedFont {
|
||||
let uiFont = font(forTextStyle: .headline)
|
||||
return SharedFont(uiFont: uiFont, font: .headline)
|
||||
}
|
||||
|
||||
public var subheadline: SharedFont {
|
||||
var subheadline: SharedFont {
|
||||
let uiFont = font(forTextStyle: .subheadline)
|
||||
return SharedFont(uiFont: uiFont, font: .subheadline)
|
||||
}
|
||||
|
||||
public var body: SharedFont {
|
||||
var body: SharedFont {
|
||||
let uiFont = font(forTextStyle: .body)
|
||||
return SharedFont(uiFont: uiFont, font: .body)
|
||||
}
|
||||
|
||||
public var bodySB: SharedFont {
|
||||
var bodySB: SharedFont {
|
||||
let uiFont = body.uiFont.semiBold
|
||||
return SharedFont(uiFont: uiFont, font: .body.weight(.semibold))
|
||||
}
|
||||
|
||||
public var callout: SharedFont {
|
||||
var callout: SharedFont {
|
||||
let uiFont = font(forTextStyle: .callout)
|
||||
return SharedFont(uiFont: uiFont, font: .callout)
|
||||
}
|
||||
|
||||
public var calloutSB: SharedFont {
|
||||
var calloutSB: SharedFont {
|
||||
let uiFont = callout.uiFont.semiBold
|
||||
return SharedFont(uiFont: uiFont, font: .callout.weight(.semibold))
|
||||
}
|
||||
|
||||
public var footnote: SharedFont {
|
||||
var footnote: SharedFont {
|
||||
let uiFont = font(forTextStyle: .footnote)
|
||||
return SharedFont(uiFont: uiFont, font: .footnote)
|
||||
}
|
||||
|
||||
public var footnoteSB: SharedFont {
|
||||
var footnoteSB: SharedFont {
|
||||
let uiFont = footnote.uiFont.semiBold
|
||||
return SharedFont(uiFont: uiFont, font: .footnote.weight(.semibold))
|
||||
}
|
||||
|
||||
public var caption1: SharedFont {
|
||||
var caption1: SharedFont {
|
||||
let uiFont = font(forTextStyle: .caption1)
|
||||
return SharedFont(uiFont: uiFont, font: .caption)
|
||||
}
|
||||
|
||||
public var caption1SB: SharedFont {
|
||||
var caption1SB: SharedFont {
|
||||
let uiFont = caption1.uiFont.semiBold
|
||||
return SharedFont(uiFont: uiFont, font: .caption.weight(.semibold))
|
||||
}
|
||||
|
||||
public var caption2: SharedFont {
|
||||
var caption2: SharedFont {
|
||||
let uiFont = font(forTextStyle: .caption2)
|
||||
return SharedFont(uiFont: uiFont, font: .caption2)
|
||||
}
|
||||
|
||||
public var caption2SB: SharedFont {
|
||||
var caption2SB: SharedFont {
|
||||
let uiFont = caption2.uiFont.semiBold
|
||||
return SharedFont(uiFont: uiFont, font: .caption2.weight(.semibold))
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -44,14 +44,14 @@ public extension UIFont {
|
||||
// MARK: - Shortcuts
|
||||
|
||||
var bold: UIFont {
|
||||
return withTraits(.traitBold)
|
||||
withTraits(.traitBold)
|
||||
}
|
||||
|
||||
var semiBold: UIFont {
|
||||
return withWeight(weight: .semibold)
|
||||
withWeight(weight: .semibold)
|
||||
}
|
||||
|
||||
var italic: UIFont {
|
||||
return withTraits(.traitItalic)
|
||||
withTraits(.traitItalic)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -14,9 +14,9 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import DesignTokens
|
||||
import Introspect
|
||||
import SwiftUI
|
||||
|
||||
/// A bordered style of text input
|
||||
///
|
||||
@@ -48,7 +48,7 @@ public struct BorderedInputFieldStyle: TextFieldStyle {
|
||||
}
|
||||
|
||||
private var backgroundColor: Color {
|
||||
if !isEnabled && colorScheme == .dark {
|
||||
if !isEnabled, colorScheme == .dark {
|
||||
return .element.quinaryContent
|
||||
}
|
||||
return .element.background
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import DesignTokens
|
||||
import SwiftUI
|
||||
|
||||
@available(iOS 15.0, *)
|
||||
public extension TextFieldStyle where Self == ElementTextFieldStyle {
|
||||
|
||||
Reference in New Issue
Block a user