Skip to content

Commit

Permalink
Revert "Fix SwiftUI Unit tests."
Browse files Browse the repository at this point in the history
This reverts commit 2398c15.
  • Loading branch information
pixlwave committed Aug 18, 2022
1 parent 2643298 commit 9848782
Show file tree
Hide file tree
Showing 55 changed files with 1,051 additions and 191 deletions.
28 changes: 28 additions & 0 deletions DesignKit/Common.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// 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
20 changes: 20 additions & 0 deletions DesignKit/Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// 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"
27 changes: 27 additions & 0 deletions DesignKit/DesignKit.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// 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>


55 changes: 55 additions & 0 deletions DesignKit/Extensions/UIFont.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// 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)
}
}
22 changes: 22 additions & 0 deletions DesignKit/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?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>
20 changes: 20 additions & 0 deletions DesignKit/Release.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// 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"
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
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
Expand Down
52 changes: 52 additions & 0 deletions DesignKit/Source/ColorValues.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// 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]
}
73 changes: 73 additions & 0 deletions DesignKit/Source/Colors.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// 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 }
}
69 changes: 69 additions & 0 deletions DesignKit/Source/ColorsSwiftUI.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//
// 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) })
}
}
Loading

0 comments on commit 9848782

Please sign in to comment.