Replace DesignKit with package from ElementX.

This commit is contained in:
Doug 2022-05-20 18:43:35 +01:00 committed by Doug
parent 00d781ac22
commit ef5365ab24
32 changed files with 81 additions and 1021 deletions

View file

@ -1,28 +0,0 @@
//
// Copyright 2021 Vector Creations Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Configuration settings file format documentation can be found at:
// https://help.apple.com/xcode/#/dev745c5c974
#include "Config/AppIdentifiers.xcconfig"
#include "Config/AppVersion.xcconfig"
PRODUCT_NAME = DesignKit
PRODUCT_BUNDLE_IDENTIFIER = $(BASE_BUNDLE_IDENTIFIER).designkit
INFOPLIST_FILE = DesignKit/Info.plist
SKIP_INSTALL = YES

View file

@ -1,20 +0,0 @@
//
// Copyright 2021 Vector Creations Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Configuration settings file format documentation can be found at:
// https://help.apple.com/xcode/#/dev745c5c974
#include "Common.xcconfig"

View file

@ -1,27 +0,0 @@
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import <Foundation/Foundation.h>
//! Project version number for DesignKit.
FOUNDATION_EXPORT double DesignKitVersionNumber;
//! Project version string for DesignKit.
FOUNDATION_EXPORT const unsigned char DesignKitVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <DesignKit/PublicHeader.h>

View file

@ -1,55 +0,0 @@
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import UIKit
public extension UIFont {
// MARK: - Convenient methods
/// Update current font with a SymbolicTraits
func vc_withTraits(_ traits: UIFontDescriptor.SymbolicTraits) -> UIFont {
guard let descriptor = fontDescriptor.withSymbolicTraits(traits) else {
return self
}
return UIFont(descriptor: descriptor, size: 0) // Size 0 means keep the size as it is
}
/// Update current font with a given Weight
func vc_withWeight(weight: Weight) -> UIFont {
// Add the font weight to the descriptor
let weightedFontDescriptor = fontDescriptor.addingAttributes([
UIFontDescriptor.AttributeName.traits: [
UIFontDescriptor.TraitKey.weight: weight
]
])
return UIFont(descriptor: weightedFontDescriptor, size: 0)
}
// MARK: - Shortcuts
var vc_bold: UIFont {
return self.vc_withTraits(.traitBold)
}
var vc_semiBold: UIFont {
return self.vc_withWeight(weight: .semibold)
}
var vc_italic: UIFont {
return self.vc_withTraits(.traitItalic)
}
}

View file

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
</plist>

View file

@ -1,20 +0,0 @@
//
// Copyright 2021 Vector Creations Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Configuration settings file format documentation can be found at:
// https://help.apple.com/xcode/#/dev745c5c974
#include "Common.xcconfig"

View file

@ -1,52 +0,0 @@
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Foundation
import UIKit
/**
Struct for holding colour values for a particular theme.
*/
public struct ColorValues: Colors {
public let accent: UIColor
public let alert: UIColor
public let primaryContent: UIColor
public let secondaryContent: UIColor
public let tertiaryContent: UIColor
public let quarterlyContent: UIColor
public let quinaryContent: UIColor
public let separator: UIColor
public let system: UIColor
public let tile: UIColor
public let navigation: UIColor
public let background: UIColor
public let ems: UIColor
public let namesAndAvatars: [UIColor]
}

View file

@ -1,73 +0,0 @@
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Foundation
/// Colors at https://www.figma.com/file/X4XTH9iS2KGJ2wFKDqkyed/Compound?node-id=1255%3A1104
public protocol Colors {
associatedtype ColorType
/// - Focused/Active states
/// - CTAs
var accent: ColorType { get }
/// - Error messages
/// - Content requiring user attention
/// - Notification, alerts
var alert: ColorType { get }
/// - Text
/// - Icons
var primaryContent: ColorType { get }
/// - Text
/// - Icons
var secondaryContent: ColorType { get }
/// - Text
/// - Icons
var tertiaryContent: ColorType { get }
/// - Text
/// - Icons
var quarterlyContent: ColorType { get }
/// - separating lines and other UI components
var quinaryContent: ColorType { get }
/// - System-based areas and backgrounds
var system: ColorType { get }
/// Separating line
var separator: ColorType { get }
/// Cards, tiles
var tile: ColorType { get }
/// Top navigation background on iOS
var navigation: ColorType { get }
/// Background UI color
var background: ColorType { get }
/// Global color: The EMS brand's purple colour.
var ems: ColorType { get }
/// - Names in chat timeline
/// - Avatars default states that include first name letter
var namesAndAvatars: [ColorType] { get }
}

View file

@ -1,69 +0,0 @@
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Foundation
import SwiftUI
/**
Struct for holding colors for use in SwiftUI.
*/
public struct ColorSwiftUI: Colors {
public let accent: Color
public let alert: Color
public let primaryContent: Color
public let secondaryContent: Color
public let tertiaryContent: Color
public let quarterlyContent: Color
public let quinaryContent: Color
public let separator: Color
public var system: Color
public let tile: Color
public let navigation: Color
public let background: Color
public var ems: Color
public let namesAndAvatars: [Color]
init(values: ColorValues) {
accent = Color(values.accent)
alert = Color(values.alert)
primaryContent = Color(values.primaryContent)
secondaryContent = Color(values.secondaryContent)
tertiaryContent = Color(values.tertiaryContent)
quarterlyContent = Color(values.quarterlyContent)
quinaryContent = Color(values.quinaryContent)
separator = Color(values.separator)
system = Color(values.system)
tile = Color(values.tile)
navigation = Color(values.navigation)
background = Color(values.background)
ems = Color(values.ems)
namesAndAvatars = values.namesAndAvatars.map({ Color($0) })
}
}

View file

@ -1,67 +0,0 @@
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Foundation
import UIKit
/**
ObjC class for holding colors for use in UIKit.
*/
@objcMembers public class ColorsUIKit: NSObject {
public let accent: UIColor
public let alert: UIColor
public let primaryContent: UIColor
public let secondaryContent: UIColor
public let tertiaryContent: UIColor
public let quarterlyContent: UIColor
public let quinaryContent: UIColor
public let separator: UIColor
public let system: UIColor
public let tile: UIColor
public let navigation: UIColor
public let background: UIColor
public let namesAndAvatars: [UIColor]
init(values: ColorValues) {
accent = values.accent
alert = values.alert
primaryContent = values.primaryContent
secondaryContent = values.secondaryContent
tertiaryContent = values.tertiaryContent
quarterlyContent = values.quarterlyContent
quinaryContent = values.quinaryContent
separator = values.separator
system = values.system
tile = values.tile
navigation = values.navigation
background = values.background
namesAndAvatars = values.namesAndAvatars
}
}

View file

@ -1,85 +0,0 @@
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import UIKit
/// Describe fonts used in the application.
/// Font names are based on Element typograhy https://www.figma.com/file/X4XTH9iS2KGJ2wFKDqkyed/Compound?node-id=1362%3A0 which is based on Apple font text styles (UIFont.TextStyle): https://developer.apple.com/documentation/uikit/uifonttextstyle
/// Create a custom TextStyle enum (like DesignKit.Fonts.TextStyle) is also a possiblity
public protocol Fonts {
associatedtype FontType
/// The font for large titles.
var largeTitle: FontType { get }
/// `largeTitle` with a Bold weight.
var largeTitleB: FontType { get }
/// The font for first-level hierarchical headings.
var title1: FontType { get }
/// `title1` with a Bold weight.
var title1B: FontType { get }
/// The font for second-level hierarchical headings.
var title2: FontType { get }
/// `title2` with a Bold weight.
var title2B: FontType { get }
/// The font for third-level hierarchical headings.
var title3: FontType { get }
/// `title3` with a Semi Bold weight.
var title3SB: FontType { get }
/// The font for headings.
var headline: FontType { get }
/// The font for subheadings.
var subheadline: FontType { get }
/// The font for body text.
var body: FontType { get }
/// `body` with a Semi Bold weight.
var bodySB: FontType { get }
/// The font for callouts.
var callout: FontType { get }
/// `callout` with a Semi Bold weight.
var calloutSB: FontType { get }
/// The font for footnotes.
var footnote: FontType { get }
/// `footnote` with a Semi Bold weight.
var footnoteSB: FontType { get }
/// The font for standard captions.
var caption1: FontType { get }
/// `caption1` with a Semi Bold weight.
var caption1SB: FontType { get }
/// The font for alternate captions.
var caption2: FontType { get }
/// `caption2` with a Semi Bold weight.
var caption2SB: FontType { get }
}

View file

@ -1,91 +0,0 @@
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Foundation
import SwiftUI
/**
Struct for holding fonts for use in SwiftUI.
*/
public struct FontSwiftUI: Fonts {
public let uiFonts: FontsUIKit
public var largeTitle: Font
public var largeTitleB: Font
public var title1: Font
public var title1B: Font
public var title2: Font
public var title2B: Font
public var title3: Font
public var title3SB: Font
public var headline: Font
public var subheadline: Font
public var body: Font
public var bodySB: Font
public var callout: Font
public var calloutSB: Font
public var footnote: Font
public var footnoteSB: Font
public var caption1: Font
public var caption1SB: Font
public var caption2: Font
public var caption2SB: Font
public init(values: ElementFonts) {
self.uiFonts = FontsUIKit(values: values)
self.largeTitle = values.largeTitle.font
self.largeTitleB = values.largeTitleB.font
self.title1 = values.title1.font
self.title1B = values.title1B.font
self.title2 = values.title2.font
self.title2B = values.title2B.font
self.title3 = values.title3.font
self.title3SB = values.title3SB.font
self.headline = values.headline.font
self.subheadline = values.subheadline.font
self.body = values.body.font
self.bodySB = values.bodySB.font
self.callout = values.callout.font
self.calloutSB = values.calloutSB.font
self.footnote = values.footnote.font
self.footnoteSB = values.footnoteSB.font
self.caption1 = values.caption1.font
self.caption1SB = values.caption1SB.font
self.caption2 = values.caption2.font
self.caption2SB = values.caption2SB.font
}
}

View file

@ -1,87 +0,0 @@
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Foundation
import UIKit
/**
ObjC class for holding fonts for use in UIKit.
*/
@objcMembers public class FontsUIKit: NSObject, Fonts {
public var largeTitle: UIFont
public var largeTitleB: UIFont
public var title1: UIFont
public var title1B: UIFont
public var title2: UIFont
public var title2B: UIFont
public var title3: UIFont
public var title3SB: UIFont
public var headline: UIFont
public var subheadline: UIFont
public var body: UIFont
public var bodySB: UIFont
public var callout: UIFont
public var calloutSB: UIFont
public var footnote: UIFont
public var footnoteSB: UIFont
public var caption1: UIFont
public var caption1SB: UIFont
public var caption2: UIFont
public var caption2SB: UIFont
public init(values: ElementFonts) {
self.largeTitle = values.largeTitle.uiFont
self.largeTitleB = values.largeTitleB.uiFont
self.title1 = values.title1.uiFont
self.title1B = values.title1B.uiFont
self.title2 = values.title2.uiFont
self.title2B = values.title2B.uiFont
self.title3 = values.title3.uiFont
self.title3SB = values.title3SB.uiFont
self.headline = values.headline.uiFont
self.subheadline = values.subheadline.uiFont
self.body = values.body.uiFont
self.bodySB = values.bodySB.uiFont
self.callout = values.callout.uiFont
self.calloutSB = values.calloutSB.uiFont
self.footnote = values.footnote.uiFont
self.footnoteSB = values.footnoteSB.uiFont
self.caption1 = values.caption1.uiFont
self.caption1SB = values.caption1SB.uiFont
self.caption2 = values.caption2.uiFont
self.caption2SB = values.caption2SB.uiFont
}
}

View file

@ -1,51 +0,0 @@
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Foundation
import UIKit
import SwiftUI
/// Dark theme colors.
public class DarkColors {
private static let values = ColorValues(
accent: UIColor(rgb:0x0DBD8B),
alert: UIColor(rgb:0xFF4B55),
primaryContent: UIColor(rgb:0xFFFFFF),
secondaryContent: UIColor(rgb:0xA9B2BC),
tertiaryContent: UIColor(rgb:0x8E99A4),
quarterlyContent: UIColor(rgb:0x6F7882),
quinaryContent: UIColor(rgb:0x394049),
separator: UIColor(rgb:0x21262C),
system: UIColor(rgb:0x21262C),
tile: UIColor(rgb:0x394049),
navigation: UIColor(rgb:0x21262C),
background: UIColor(rgb:0x15191E),
ems: UIColor(rgb: 0x7E69FF),
namesAndAvatars: [
UIColor(rgb:0x368BD6),
UIColor(rgb:0xAC3BA8),
UIColor(rgb:0x03B381),
UIColor(rgb:0xE64F7A),
UIColor(rgb:0xFF812D),
UIColor(rgb:0x2DC2C5),
UIColor(rgb:0x5C56F5),
UIColor(rgb:0x74D12C)
]
)
public static var uiKit = ColorsUIKit(values: values)
public static var swiftUI = ColorSwiftUI(values: values)
}

View file

@ -1,57 +0,0 @@
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Foundation
import UIKit
import SwiftUI
/// Light theme colors.
public class LightColors {
private static let values = ColorValues(
accent: UIColor(rgb:0x0DBD8B),
alert: UIColor(rgb:0xFF4B55),
primaryContent: UIColor(rgb:0x17191C),
secondaryContent: UIColor(rgb:0x737D8C),
tertiaryContent: UIColor(rgb:0x8D97A5),
quarterlyContent: UIColor(rgb:0xC1C6CD),
quinaryContent: UIColor(rgb:0xE3E8F0),
separator: UIColor(rgb:0xE3E8F0),
system: UIColor(rgb:0xF4F6FA),
tile: UIColor(rgb:0xF3F8FD),
navigation: UIColor(rgb:0xF4F6FA),
background: UIColor(rgb:0xFFFFFF),
ems: UIColor(rgb: 0x7E69FF),
namesAndAvatars: [
UIColor(rgb:0x368BD6),
UIColor(rgb:0xAC3BA8),
UIColor(rgb:0x03B381),
UIColor(rgb:0xE64F7A),
UIColor(rgb:0xFF812D),
UIColor(rgb:0x2DC2C5),
UIColor(rgb:0x5C56F5),
UIColor(rgb:0x74D12C)
]
)
public static var uiKit = ColorsUIKit(values: values)
public static var swiftUI = ColorSwiftUI(values: values)
}

View file

@ -1,150 +0,0 @@
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import SwiftUI
/// Fonts at https://www.figma.com/file/X4XTH9iS2KGJ2wFKDqkyed/Compound?node-id=1362%3A0
@objcMembers
public class ElementFonts {
// MARK: - Types
/// A wrapper to provide both a `UIFont` and a SwiftUI `Font` in the same type.
/// The need for this comes from `Font` not adapting for dynamic type until the app
/// is restarted (or working at all in Xcode Previews) when initialised from a `UIFont`
/// (even if that font was created with the appropriate metrics).
public struct SharedFont {
public let uiFont: UIFont
public let font: Font
}
// MARK: - Setup
public init() {
}
// MARK: - Private
/// 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)
}
}
// MARK: - Fonts protocol
extension ElementFonts: Fonts {
public var largeTitle: SharedFont {
let uiFont = self.font(forTextStyle: .largeTitle)
return SharedFont(uiFont: uiFont, font: .largeTitle)
}
public var largeTitleB: SharedFont {
let uiFont = self.largeTitle.uiFont.vc_bold
return SharedFont(uiFont: uiFont, font: .largeTitle.bold())
}
public var title1: SharedFont {
let uiFont = self.font(forTextStyle: .title1)
return SharedFont(uiFont: uiFont, font: .title)
}
public var title1B: SharedFont {
let uiFont = self.title1.uiFont.vc_bold
return SharedFont(uiFont: uiFont, font: .title.bold())
}
public var title2: SharedFont {
let uiFont = self.font(forTextStyle: .title2)
return SharedFont(uiFont: uiFont, font: .title2)
}
public var title2B: SharedFont {
let uiFont = self.title2.uiFont.vc_bold
return SharedFont(uiFont: uiFont, font: .title2.bold())
}
public var title3: SharedFont {
let uiFont = self.font(forTextStyle: .title3)
return SharedFont(uiFont: uiFont, font: .title3)
}
public var title3SB: SharedFont {
let uiFont = self.title3.uiFont.vc_semiBold
return SharedFont(uiFont: uiFont, font: .title3.weight(.semibold))
}
public var headline: SharedFont {
let uiFont = self.font(forTextStyle: .headline)
return SharedFont(uiFont: uiFont, font: .headline)
}
public var subheadline: SharedFont {
let uiFont = self.font(forTextStyle: .subheadline)
return SharedFont(uiFont: uiFont, font: .subheadline)
}
public var body: SharedFont {
let uiFont = self.font(forTextStyle: .body)
return SharedFont(uiFont: uiFont, font: .body)
}
public var bodySB: SharedFont {
let uiFont = self.body.uiFont.vc_semiBold
return SharedFont(uiFont: uiFont, font: .body.weight(.semibold))
}
public var callout: SharedFont {
let uiFont = self.font(forTextStyle: .callout)
return SharedFont(uiFont: uiFont, font: .callout)
}
public var calloutSB: SharedFont {
let uiFont = self.callout.uiFont.vc_semiBold
return SharedFont(uiFont: uiFont, font: .callout.weight(.semibold))
}
public var footnote: SharedFont {
let uiFont = self.font(forTextStyle: .footnote)
return SharedFont(uiFont: uiFont, font: .footnote)
}
public var footnoteSB: SharedFont {
let uiFont = self.footnote.uiFont.vc_semiBold
return SharedFont(uiFont: uiFont, font: .footnote.weight(.semibold))
}
public var caption1: SharedFont {
let uiFont = self.font(forTextStyle: .caption1)
return SharedFont(uiFont: uiFont, font: .caption)
}
public var caption1SB: SharedFont {
let uiFont = self.caption1.uiFont.vc_semiBold
return SharedFont(uiFont: uiFont, font: .caption.weight(.semibold))
}
public var caption2: SharedFont {
let uiFont = self.font(forTextStyle: .caption2)
return SharedFont(uiFont: uiFont, font: .caption2)
}
public var caption2SB: SharedFont {
let uiFont = self.caption2.uiFont.vc_semiBold
return SharedFont(uiFont: uiFont, font: .caption2.weight(.semibold))
}
}

View file

@ -1,33 +0,0 @@
name: DesignKit
schemes:
DesignKit:
analyze:
config: Debug
archive:
config: Release
build:
targets:
DesignKit:
- running
- profiling
- analyzing
- archiving
profile:
config: Release
run:
config: Debug
disableMainThreadChecker: true
targets:
DesignKit:
type: framework
platform: iOS
configFiles:
Debug: Debug.xcconfig
Release: Release.xcconfig
sources:
- path: .
- path: ../Riot/Categories/UIColor.swift

View file

@ -14,29 +14,38 @@
// limitations under the License.
//
import Foundation
import UIKit
import DesignKit
import DesignTokens
/// Theme v2. May be named again as `Theme` when the migration completed.
@objc public protocol ThemeV2 {
/// Colors object
var colors: ColorsUIKit { get }
var colors: ElementUIColors { get }
/// Fonts object
var fonts: FontsUIKit { get }
var fonts: ElementUIFonts { get }
/// may contain more design components in future, like icons, audio files etc.
}
/// Theme v2 for SwiftUI.
public protocol ThemeSwiftUIType {
/// Colors object
var colors: ColorSwiftUI { get }
/// Fonts object
var fonts: FontSwiftUI { get }
/// may contain more design components in future, like icons, audio files etc.
#warning("Temporary missing colors")
public extension ElementUIColors {
var quarterlyContent: UIColor { quaternaryContent }
var navigation: UIColor { system }
var tile: UIColor { system }
var separator: UIColor { system }
var namesAndAvatars: [UIColor] {
[
globalAzure,
globalGrape,
globalVerde,
globalPolly,
globalMelon,
globalAqua,
globalPrune,
globalKiwi
]
}
}

View file

@ -181,9 +181,9 @@ class DarkTheme: NSObject, Theme {
button.setTitleColor(self.tintColor, for: .normal)
}
/// MARK: - Theme v2
var colors: ColorsUIKit = DarkColors.uiKit
// MARK: - Theme v2
var colors = UIColor.element
var fonts: FontsUIKit = FontsUIKit(values: ElementFonts())
var fonts = UIFont.element
}

View file

@ -14,7 +14,6 @@
limitations under the License.
*/
import Foundation
import UIKit
import DesignKit
@ -186,8 +185,8 @@ class DefaultTheme: NSObject, Theme {
button.setTitleColor(self.tintColor, for: .normal)
}
/// MARK: - Theme v2
var colors: ColorsUIKit = LightColors.uiKit
// MARK: - Theme v2
var colors = UIColor.element
var fonts: FontsUIKit = FontsUIKit(values: ElementFonts())
var fonts = UIFont.element
}

View file

@ -493,7 +493,7 @@ enum {
// Customize label style
UITableViewHeaderFooterView *tableViewHeaderFooterView = (UITableViewHeaderFooterView*)view;
tableViewHeaderFooterView.textLabel.textColor = ThemeService.shared.theme.colors.secondaryContent;
tableViewHeaderFooterView.textLabel.font = ThemeService.shared.theme.fonts.footnote;
tableViewHeaderFooterView.textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote];
}
}

View file

@ -1297,7 +1297,7 @@ TableViewSectionsDelegate>
// Customize label style
UITableViewHeaderFooterView *tableViewHeaderFooterView = (UITableViewHeaderFooterView*)view;
tableViewHeaderFooterView.textLabel.textColor = ThemeService.shared.theme.colors.secondaryContent;
tableViewHeaderFooterView.textLabel.font = ThemeService.shared.theme.fonts.footnote;
tableViewHeaderFooterView.textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote];
}
}

View file

@ -2634,7 +2634,7 @@ ChangePasswordCoordinatorBridgePresenterDelegate>
// Customize label style
UITableViewHeaderFooterView *tableViewHeaderFooterView = (UITableViewHeaderFooterView*)view;
tableViewHeaderFooterView.textLabel.textColor = ThemeService.shared.theme.colors.secondaryContent;
tableViewHeaderFooterView.textLabel.font = ThemeService.shared.theme.fonts.footnote;
tableViewHeaderFooterView.textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote];
}
}

View file

@ -34,8 +34,8 @@ targets:
- target: RiotShareExtension
- target: SiriIntents
- target: RiotNSE
- target: DesignKit
- target: CommonKit
- package: DesignKit
- package: Mapbox
- package: OrderedCollections

View file

@ -30,6 +30,8 @@ targets:
RiotShareExtension:
platform: iOS
type: app-extension
dependencies:
- package: DesignKit
configFiles:
Debug: Debug.xcconfig

View file

@ -17,6 +17,8 @@
import Foundation
import UIKit
// TODO: Move into element-design-tokens repo.
// Figma Avatar Sizes: https://www.figma.com/file/X4XTH9iS2KGJ2wFKDqkyed/Compound?node-id=1258%3A19678
public enum AvatarSize: Int {
case xxSmall = 16

View file

@ -14,10 +14,43 @@
// limitations under the License.
//
import Foundation
import SwiftUI
import DesignKit
import DesignTokens
protocol ThemeSwiftUI: ThemeSwiftUIType {
var identifier: ThemeIdentifier { get }
var isDark: Bool { get }
}
/// Theme v2 for SwiftUI.
@available(iOS 14.0, *)
public protocol ThemeSwiftUIType {
/// Colors object
var colors: ElementColors { get }
/// Fonts object
var fonts: ElementFonts { get }
/// may contain more design components in future, like icons, audio files etc.
}
#warning("Temporary missing colors")
public extension ElementColors {
var quarterlyContent: Color { quaternaryContent }
var navigation: Color { system }
var tile: Color { system }
var namesAndAvatars: [Color] {
[
globalAzure,
globalGrape,
globalVerde,
globalPolly,
globalMelon,
globalAqua,
globalPrune,
globalKiwi
]
}
}

View file

@ -14,12 +14,12 @@
// limitations under the License.
//
import Foundation
import SwiftUI
import DesignKit
struct DarkThemeSwiftUI: ThemeSwiftUI {
var identifier: ThemeIdentifier = .dark
let isDark: Bool = true
var colors: ColorSwiftUI = DarkColors.swiftUI
var fonts: FontSwiftUI = FontSwiftUI(values: ElementFonts())
var colors = Color.element
var fonts = Font.element
}

View file

@ -14,12 +14,12 @@
// limitations under the License.
//
import Foundation
import SwiftUI
import DesignKit
struct DefaultThemeSwiftUI: ThemeSwiftUI {
var identifier: ThemeIdentifier = .light
let isDark: Bool = false
var colors: ColorSwiftUI = LightColors.swiftUI
var fonts: FontSwiftUI = FontSwiftUI(values: ElementFonts())
var colors = Color.element
var fonts = Font.element
}

View file

@ -75,7 +75,7 @@ struct MultilineTextField: View {
.overlay(rect.stroke(borderColor, lineWidth: borderWidth))
.introspectTextView { textView in
textView.textColor = UIColor(textColor)
textView.font = theme.fonts.uiFonts.callout
textView.font = .element.callout
}
}

View file

@ -30,7 +30,7 @@ targets:
type: application
platform: iOS
dependencies:
- target: DesignKit
- package: DesignKit
- package: Mapbox
sources:
- path: .

View file

@ -32,7 +32,6 @@ include:
- path: RiotShareExtension/target.yml
- path: SiriIntents/target.yml
- path: RiotNSE/target.yml
- path: DesignKit/target.yml
- path: RiotSwiftUI/target.yml
- path: RiotSwiftUI/targetUnitTests.yml
- path: RiotSwiftUI/targetUITests.yml
@ -40,6 +39,9 @@ include:
- path: CommonKit/targetUnitTests.yml
packages:
DesignKit:
url: https://github.com/vector-im/element-x-ios
branch: doug/designkit
Mapbox:
url: https://github.com/maplibre/maplibre-gl-native-distribution
minVersion: 5.12.2