mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Use generated UIColors everywhere. (#1405)
- Fix destructive buttons in the menu.
This commit is contained in:
@@ -12,7 +12,7 @@ let package = Package(
|
|||||||
.library(name: "DesignKit", targets: ["DesignKit"])
|
.library(name: "DesignKit", targets: ["DesignKit"])
|
||||||
],
|
],
|
||||||
dependencies: [
|
dependencies: [
|
||||||
.package(url: "https://github.com/vector-im/compound-ios.git", revision: "d9e119fbef20857eb790dd4aafbe16ff46011eca"),
|
.package(url: "https://github.com/vector-im/compound-ios.git", revision: "1f3eb60c4f87249d95addf84ce1aef22c2968763"),
|
||||||
.package(url: "https://github.com/vector-im/element-design-tokens.git", exact: "0.0.3"),
|
.package(url: "https://github.com/vector-im/element-design-tokens.git", exact: "0.0.3"),
|
||||||
.package(url: "https://github.com/siteline/SwiftUI-Introspect.git", from: "0.9.0")
|
.package(url: "https://github.com/siteline/SwiftUI-Introspect.git", from: "0.9.0")
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public struct ElementTextFieldStyle: TextFieldStyle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The color of the placeholder text inside the text field.
|
/// The color of the placeholder text inside the text field.
|
||||||
private var placeholderColor: Color {
|
private var placeholderColor: UIColor {
|
||||||
.compound.textPlaceholder
|
.compound.textPlaceholder
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ public struct ElementTextFieldStyle: TextFieldStyle {
|
|||||||
.introspect(.textField, on: .iOS(.v16)) { textField in
|
.introspect(.textField, on: .iOS(.v16)) { textField in
|
||||||
textField.clearButtonMode = .whileEditing
|
textField.clearButtonMode = .whileEditing
|
||||||
textField.attributedPlaceholder = NSAttributedString(string: textField.placeholder ?? "",
|
textField.attributedPlaceholder = NSAttributedString(string: textField.placeholder ?? "",
|
||||||
attributes: [NSAttributedString.Key.foregroundColor: UIColor(placeholderColor)])
|
attributes: [NSAttributedString.Key.foregroundColor: placeholderColor])
|
||||||
textField.accessibilityIdentifier = accessibilityIdentifier
|
textField.accessibilityIdentifier = accessibilityIdentifier
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3664,7 +3664,7 @@
|
|||||||
path = Timeline;
|
path = Timeline;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
"TEMP_43147A32-A06C-4EEF-8C45-FDEA43A25C1E" /* element-x-ios */ = {
|
"TEMP_8B4A8977-AAD5-44D7-8CB7-F1BC31A64C84" /* element-x-ios */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
41553551C55AD59885840F0E /* secrets.xcconfig */,
|
41553551C55AD59885840F0E /* secrets.xcconfig */,
|
||||||
@@ -5399,7 +5399,7 @@
|
|||||||
repositoryURL = "https://github.com/vector-im/compound-ios";
|
repositoryURL = "https://github.com/vector-im/compound-ios";
|
||||||
requirement = {
|
requirement = {
|
||||||
kind = revision;
|
kind = revision;
|
||||||
revision = d9e119fbef20857eb790dd4aafbe16ff46011eca;
|
revision = 1f3eb60c4f87249d95addf84ce1aef22c2968763;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
9A472EE0218FE7DCF5283429 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */ = {
|
9A472EE0218FE7DCF5283429 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */ = {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/vector-im/compound-design-tokens.git",
|
"location" : "https://github.com/vector-im/compound-design-tokens.git",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "cc950d575f8536ff5bebbd02e28c0b8ab541aa29"
|
"revision" : "aa55111d94486acbfd3344cf4d08b64723bd6703"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/vector-im/compound-ios.git",
|
"location" : "https://github.com/vector-im/compound-ios.git",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "d9e119fbef20857eb790dd4aafbe16ff46011eca"
|
"revision" : "1f3eb60c4f87249d95addf84ce1aef22c2968763"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,9 +37,7 @@ struct Application: App {
|
|||||||
.statusBarHidden(shouldHideStatusBar)
|
.statusBarHidden(shouldHideStatusBar)
|
||||||
.introspect(.window, on: .iOS(.v16)) { window in
|
.introspect(.window, on: .iOS(.v16)) { window in
|
||||||
// Workaround for SwiftUI not consistently applying the tint colour to Alerts/Confirmation Dialogs.
|
// Workaround for SwiftUI not consistently applying the tint colour to Alerts/Confirmation Dialogs.
|
||||||
window.tintColor = UIColor(named: "colorGray1400",
|
window.tintColor = .compound.textActionPrimary
|
||||||
in: Bundle(identifier: "CompoundDesignTokens-CompoundDesignTokens-resources"),
|
|
||||||
compatibleWith: nil)
|
|
||||||
}
|
}
|
||||||
.task {
|
.task {
|
||||||
appCoordinator.start()
|
appCoordinator.start()
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ struct AttributedStringBuilder: AttributedStringBuilderProtocol {
|
|||||||
attributedString.enumerateAttribute(.backgroundColor, in: .init(location: 0, length: attributedString.length), options: []) { value, range, _ in
|
attributedString.enumerateAttribute(.backgroundColor, in: .init(location: 0, length: attributedString.length), options: []) { value, range, _ in
|
||||||
if let value = value as? UIColor,
|
if let value = value as? UIColor,
|
||||||
value == temporaryCodeBlockMarkingColor {
|
value == temporaryCodeBlockMarkingColor {
|
||||||
attributedString.addAttribute(.backgroundColor, value: UIColor(.compound._bgCodeBlock) as Any, range: range)
|
attributedString.addAttribute(.backgroundColor, value: UIColor.compound._bgCodeBlock as Any, range: range)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ private struct UITextViewWrapper: UIViewRepresentable {
|
|||||||
textView.isMultiline = $isMultiline
|
textView.isMultiline = $isMultiline
|
||||||
textView.delegate = context.coordinator
|
textView.delegate = context.coordinator
|
||||||
textView.elementDelegate = context.coordinator
|
textView.elementDelegate = context.coordinator
|
||||||
textView.textColor = UIColor(.compound.textPrimary)
|
textView.textColor = .compound.textPrimary
|
||||||
textView.isEditable = true
|
textView.isEditable = true
|
||||||
textView.font = font
|
textView.font = font
|
||||||
textView.isSelectable = true
|
textView.isSelectable = true
|
||||||
|
|||||||
@@ -31,13 +31,23 @@ struct TimelineItemMacContextMenu: View {
|
|||||||
TimelineItemMenuAction.react.label
|
TimelineItemMenuAction.react.label
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ForEach(menuActions.actions) { action in
|
ForEach(menuActions.actions) { action in
|
||||||
Button { send(action) } label: { action.label }
|
Button(role: action.isDestructive ? .destructive : nil) {
|
||||||
|
send(action)
|
||||||
|
} label: {
|
||||||
|
action.label
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Section {
|
Section {
|
||||||
ForEach(menuActions.debugActions) { action in
|
ForEach(menuActions.debugActions) { action in
|
||||||
Button { send(action) } label: { action.label }
|
Button(role: action.isDestructive ? .destructive : nil) {
|
||||||
|
send(action)
|
||||||
|
} label: {
|
||||||
|
action.label
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,17 @@ enum TimelineItemMenuAction: Identifiable, Hashable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The item's label.
|
/// Whether or not the action is destructive.
|
||||||
|
var isDestructive: Bool {
|
||||||
|
switch self {
|
||||||
|
case .redact, .report:
|
||||||
|
return true
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The action's label.
|
||||||
var label: some View {
|
var label: some View {
|
||||||
switch self {
|
switch self {
|
||||||
case .copy: return Label(L10n.actionCopy, systemImage: "doc.on.doc")
|
case .copy: return Label(L10n.actionCopy, systemImage: "doc.on.doc")
|
||||||
@@ -232,7 +242,9 @@ public struct TimelineItemMenu: View {
|
|||||||
|
|
||||||
private func viewsForActions(_ actions: [TimelineItemMenuAction]) -> some View {
|
private func viewsForActions(_ actions: [TimelineItemMenuAction]) -> some View {
|
||||||
ForEach(actions, id: \.self) { action in
|
ForEach(actions, id: \.self) { action in
|
||||||
Button { send(action) } label: {
|
Button(role: action.isDestructive ? .destructive : nil) {
|
||||||
|
send(action)
|
||||||
|
} label: {
|
||||||
action.label
|
action.label
|
||||||
.labelStyle(FixedIconSizeLabelStyle())
|
.labelStyle(FixedIconSizeLabelStyle())
|
||||||
.multilineTextAlignment(.leading)
|
.multilineTextAlignment(.leading)
|
||||||
|
|||||||
+1
-1
@@ -54,7 +54,7 @@ packages:
|
|||||||
minorVersion: 5.13.0
|
minorVersion: 5.13.0
|
||||||
Compound:
|
Compound:
|
||||||
url: https://github.com/vector-im/compound-ios
|
url: https://github.com/vector-im/compound-ios
|
||||||
revision: d9e119fbef20857eb790dd4aafbe16ff46011eca
|
revision: 1f3eb60c4f87249d95addf84ce1aef22c2968763
|
||||||
# path: ../compound-ios
|
# path: ../compound-ios
|
||||||
Algorithms:
|
Algorithms:
|
||||||
url: https://github.com/apple/swift-algorithms
|
url: https://github.com/apple/swift-algorithms
|
||||||
|
|||||||
Reference in New Issue
Block a user