fix labels view for mac compilation

This commit is contained in:
Satindar Dhillon
2022-04-13 17:31:01 -07:00
parent f8ba24bc79
commit a7e01275ae
4 changed files with 25 additions and 3 deletions

View File

@ -2,6 +2,7 @@ import Combine
import Models
import Services
import SwiftUI
import Utils
import Views
struct LabelsView: View {
@ -153,13 +154,13 @@ struct CreateLabelView: View {
}
.padding()
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
ToolbarItem(placement: .barLeading) {
Button(
action: { viewModel.showCreateEmailModal = false },
label: { Text("Cancel").foregroundColor(.appGrayTextContrast) }
)
}
ToolbarItem(placement: .navigationBarTrailing) {
ToolbarItem(placement: .barTrailing) {
Button(
action: {
viewModel.createLabel(

View File

@ -22,6 +22,7 @@ public extension Color {
static var systemBackground: Color { Color(.systemBackground) }
static var systemPlaceholder: Color { Color(.placeholderText) }
static var secondarySystemGroupedBackground: Color { Color(.secondarySystemGroupedBackground) }
static var systemGray6: Color { Color(.systemGray6) }
static var systemLabel: Color {
if #available(iOS 15.0, *) {
return Color(uiColor: .label)
@ -34,6 +35,7 @@ public extension Color {
static var systemBackground: Color { Color(.windowBackgroundColor) }
static var systemPlaceholder: Color { Color(.placeholderTextColor) }
static var systemLabel: Color { Color(.labelColor) }
static var systemGray6: Color { Color(NSColor.systemGray) }
// Just for compilation. secondarySystemGroupedBackground shouldn't be used on macOS
static var secondarySystemGroupedBackground: Color { Color(.windowBackgroundColor) }

View File

@ -33,7 +33,7 @@ public struct TextChip: View {
public struct TextChipButton: View {
public static func makeAddLabelButton(onTap: @escaping () -> Void) -> TextChipButton {
TextChipButton(title: "Labels", color: Color(.systemGray6), actionType: .show, onTap: onTap)
TextChipButton(title: "Labels", color: .systemGray6, actionType: .show, onTap: onTap)
}
public static func makeShowOptionsButton(title: String, onTap: @escaping () -> Void) -> TextChipButton {

View File

@ -0,0 +1,19 @@
import SwiftUI
public extension ToolbarItemPlacement {
static var barLeading: ToolbarItemPlacement {
#if os(iOS)
.navigationBarLeading
#else
.automatic
#endif
}
static var barTrailing: ToolbarItemPlacement {
#if os(iOS)
.navigationBarTrailing
#else
.automatic
#endif
}
}