mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-17 15:09:31 +02:00
Finish extraction
- Moves SwiftUI code out of Riot and into RiotSwiftUI which has no dependency on Matrix SDK. - Git wasn't smart enough to see the file moves. Most feature function has remain unchanged. 1 change I did make was remove NotificationSettingsViewModel's dependence on MxPushRule, so that the view model could be moved into RiotSwiftUI. - Add LocaleProvider to abstract VectorL10n's use of Matrix SDK language so it can be used in RiotSwiftUI. - Split Theme into UKit/SwiftUI version to remove RiotSwiftUI's dependence on ThemeService and ThemeV1. - Migrated from ThemeObserver to ThemePublisher. We push updates to ThemePublisher so that we can remove ThemeService as dependency. - Add .DS_Store to .gitignore
This commit is contained in:
50
DesignKit/Source/ColorValues.swift
Normal file
50
DesignKit/Source/ColorValues.swift
Normal file
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// 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 namesAndAvatars: [UIColor]
|
||||
}
|
||||
@@ -18,58 +18,56 @@ import Foundation
|
||||
import UIKit
|
||||
import SwiftUI
|
||||
|
||||
public protocol DesignKitColorType { }
|
||||
|
||||
extension UIColor: DesignKitColorType { }
|
||||
|
||||
extension Color : DesignKitColorType { }
|
||||
|
||||
/// Colors at https://www.figma.com/file/X4XTH9iS2KGJ2wFKDqkyed/Compound?node-id=1255%3A1104
|
||||
public protocol Colors {
|
||||
|
||||
associatedtype ColorType
|
||||
|
||||
/// - Focused/Active states
|
||||
/// - CTAs
|
||||
var accent: DesignKitColorType { get }
|
||||
var accent: ColorType { get }
|
||||
|
||||
/// - Error messages
|
||||
/// - Content requiring user attention
|
||||
/// - Notification, alerts
|
||||
var alert: DesignKitColorType { get }
|
||||
var alert: ColorType { get }
|
||||
|
||||
/// - Text
|
||||
/// - Icons
|
||||
var primaryContent: DesignKitColorType { get }
|
||||
var primaryContent: ColorType { get }
|
||||
|
||||
/// - Text
|
||||
/// - Icons
|
||||
var secondaryContent: DesignKitColorType { get }
|
||||
var secondaryContent: ColorType { get }
|
||||
|
||||
/// - Text
|
||||
/// - Icons
|
||||
var tertiaryContent: DesignKitColorType { get }
|
||||
var tertiaryContent: ColorType { get }
|
||||
|
||||
/// - Text
|
||||
/// - Icons
|
||||
var quarterlyContent: DesignKitColorType { get }
|
||||
var quarterlyContent: ColorType { get }
|
||||
|
||||
/// - Text
|
||||
/// - Icons
|
||||
var quinaryContent: DesignKitColorType { get }
|
||||
/// - separating lines and other UI components
|
||||
var quinaryContent: ColorType { get }
|
||||
|
||||
/// - System-based areas and backgrounds
|
||||
var system: ColorType { get }
|
||||
|
||||
/// Separating line
|
||||
var separator: DesignKitColorType { get }
|
||||
var separator: ColorType { get }
|
||||
|
||||
// Cards, tiles
|
||||
var tile: DesignKitColorType { get }
|
||||
var tile: ColorType { get }
|
||||
|
||||
/// Top navigation background on iOS
|
||||
var navigation: DesignKitColorType { get }
|
||||
var navigation: ColorType { get }
|
||||
|
||||
/// Background UI color
|
||||
var background: DesignKitColorType { get }
|
||||
var background: ColorType { get }
|
||||
|
||||
/// - Names in chat timeline
|
||||
/// - Avatars default states that include first name letter
|
||||
var namesAndAvatars: [DesignKitColorType] { get }
|
||||
var namesAndAvatars: [ColorType] { get }
|
||||
|
||||
}
|
||||
|
||||
67
DesignKit/Source/ColorsSwiftUI.swift
Normal file
67
DesignKit/Source/ColorsSwiftUI.swift
Normal file
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// 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.
|
||||
*/
|
||||
@available(iOS 14.0, *)
|
||||
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 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)
|
||||
namesAndAvatars = values.namesAndAvatars.map({ Color($0) })
|
||||
}
|
||||
}
|
||||
67
DesignKit/Source/ColorsUIkit.swift
Normal file
67
DesignKit/Source/ColorsUIkit.swift
Normal file
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// 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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,75 +17,70 @@
|
||||
import UIKit
|
||||
import SwiftUI
|
||||
|
||||
public protocol DesignKitFontType { }
|
||||
|
||||
extension UIFont: DesignKitFontType { }
|
||||
|
||||
extension Font : DesignKitFontType { }
|
||||
|
||||
|
||||
/// 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: DesignKitFontType { get }
|
||||
var largeTitle: FontType { get }
|
||||
|
||||
/// `largeTitle` with a Bold weight.
|
||||
var largeTitleB: DesignKitFontType { get }
|
||||
var largeTitleB: FontType { get }
|
||||
|
||||
/// The font for first-level hierarchical headings.
|
||||
var title1: DesignKitFontType { get }
|
||||
var title1: FontType { get }
|
||||
|
||||
/// `title1` with a Bold weight.
|
||||
var title1B: DesignKitFontType { get }
|
||||
var title1B: FontType { get }
|
||||
|
||||
/// The font for second-level hierarchical headings.
|
||||
var title2: DesignKitFontType { get }
|
||||
var title2: FontType { get }
|
||||
|
||||
/// `title2` with a Bold weight.
|
||||
var title2B: DesignKitFontType { get }
|
||||
var title2B: FontType { get }
|
||||
|
||||
/// The font for third-level hierarchical headings.
|
||||
var title3: DesignKitFontType { get }
|
||||
var title3: FontType { get }
|
||||
|
||||
/// `title3` with a Semi Bold weight.
|
||||
var title3SB: DesignKitFontType { get }
|
||||
var title3SB: FontType { get }
|
||||
|
||||
/// The font for headings.
|
||||
var headline: DesignKitFontType { get }
|
||||
var headline: FontType { get }
|
||||
|
||||
/// The font for subheadings.
|
||||
var subheadline: DesignKitFontType { get }
|
||||
var subheadline: FontType { get }
|
||||
|
||||
/// The font for body text.
|
||||
var body: DesignKitFontType { get }
|
||||
var body: FontType { get }
|
||||
|
||||
/// `body` with a Semi Bold weight.
|
||||
var bodySB: DesignKitFontType { get }
|
||||
var bodySB: FontType { get }
|
||||
|
||||
/// The font for callouts.
|
||||
var callout: DesignKitFontType { get }
|
||||
var callout: FontType { get }
|
||||
|
||||
/// `callout` with a Semi Bold weight.
|
||||
var calloutSB: DesignKitFontType { get }
|
||||
var calloutSB: FontType { get }
|
||||
|
||||
/// The font for footnotes.
|
||||
var footnote: DesignKitFontType { get }
|
||||
var footnote: FontType { get }
|
||||
|
||||
/// `footnote` with a Semi Bold weight.
|
||||
var footnoteSB: DesignKitFontType { get }
|
||||
var footnoteSB: FontType { get }
|
||||
|
||||
/// The font for standard captions.
|
||||
var caption1: DesignKitFontType { get }
|
||||
var caption1: FontType { get }
|
||||
|
||||
/// `caption1` with a Semi Bold weight.
|
||||
var caption1SB: DesignKitFontType { get }
|
||||
var caption1SB: FontType { get }
|
||||
|
||||
/// The font for alternate captions.
|
||||
var caption2: DesignKitFontType { get }
|
||||
var caption2: FontType { get }
|
||||
|
||||
/// `caption2` with a Semi Bold weight.
|
||||
var caption2SB: DesignKitFontType { get }
|
||||
var caption2SB: FontType { get }
|
||||
}
|
||||
|
||||
88
DesignKit/Source/FontsSwiftUI.swift
Normal file
88
DesignKit/Source/FontsSwiftUI.swift
Normal file
@@ -0,0 +1,88 @@
|
||||
//
|
||||
// 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.
|
||||
*/
|
||||
@available(iOS 14.0, *)
|
||||
public struct FontSwiftUI: Fonts {
|
||||
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.largeTitle = Font(values.largeTitle)
|
||||
self.largeTitleB = Font(values.largeTitleB)
|
||||
self.title1 = Font(values.title1)
|
||||
self.title1B = Font(values.title1B)
|
||||
self.title2 = Font(values.title2)
|
||||
self.title2B = Font(values.title2B)
|
||||
self.title3 = Font(values.title3)
|
||||
self.title3SB = Font(values.title3SB)
|
||||
self.headline = Font(values.headline)
|
||||
self.subheadline = Font(values.subheadline)
|
||||
self.body = Font(values.body)
|
||||
self.bodySB = Font(values.bodySB)
|
||||
self.callout = Font(values.callout)
|
||||
self.calloutSB = Font(values.calloutSB)
|
||||
self.footnote = Font(values.footnote)
|
||||
self.footnoteSB = Font(values.footnoteSB)
|
||||
self.caption1 = Font(values.caption1)
|
||||
self.caption1SB = Font(values.caption1SB)
|
||||
self.caption2 = Font(values.caption2)
|
||||
self.caption2SB = Font(values.caption2SB)
|
||||
}
|
||||
}
|
||||
|
||||
87
DesignKit/Source/FontsUIkit.swift
Normal file
87
DesignKit/Source/FontsUIkit.swift
Normal file
@@ -0,0 +1,87 @@
|
||||
//
|
||||
// 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.
|
||||
*/
|
||||
@objc 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
|
||||
self.largeTitleB = values.largeTitleB
|
||||
self.title1 = values.title1
|
||||
self.title1B = values.title1B
|
||||
self.title2 = values.title2
|
||||
self.title2B = values.title2B
|
||||
self.title3 = values.title3
|
||||
self.title3SB = values.title3SB
|
||||
self.headline = values.headline
|
||||
self.subheadline = values.subheadline
|
||||
self.body = values.body
|
||||
self.bodySB = values.bodySB
|
||||
self.callout = values.callout
|
||||
self.calloutSB = values.calloutSB
|
||||
self.footnote = values.footnote
|
||||
self.footnoteSB = values.footnoteSB
|
||||
self.caption1 = values.caption1
|
||||
self.caption1SB = values.caption1SB
|
||||
self.caption2 = values.caption2
|
||||
self.caption2SB = values.caption2SB
|
||||
}
|
||||
}
|
||||
@@ -21,11 +21,23 @@ import UIKit
|
||||
@objc public protocol ThemeV2 {
|
||||
|
||||
/// Colors object
|
||||
var colors: Colors { get }
|
||||
var colors: ColorsUIKit { get }
|
||||
|
||||
/// Fonts object
|
||||
var fonts: Fonts { get }
|
||||
var fonts: FontsUIKit { get }
|
||||
|
||||
/// may contain more design components in future, like icons, audio files etc.
|
||||
}
|
||||
|
||||
/// Theme v2 for SwiftUI.
|
||||
@available(iOS 14.0, *)
|
||||
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.
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user