Skip to content

Commit

Permalink
simplify the code for accessibleRed and keep original red for X buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
erikng committed Feb 24, 2022
1 parent 7834fd3 commit a02a1ed
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 13 deletions.
3 changes: 1 addition & 2 deletions Nudge/UI/Common/DeferView.swift
Expand Up @@ -13,7 +13,6 @@ struct DeferView: View {
@ObservedObject var viewObserved: ViewState
@Environment(\.presentationMode) var presentationMode
@Environment(\.colorScheme) var colorScheme
@Environment(\.accessibilityDifferentiateWithoutColor) var differentiateWithoutColor

@State var nudgeCustomEventDate = Date()

Expand All @@ -27,7 +26,7 @@ struct DeferView: View {
Image(systemName: "xmark.circle")
.resizable()
.frame(width: 20, height: 20)
.foregroundColor(differentiateWithoutColor ? Color(red: 230 / 255, green: 97 / 255, blue: 0 / 255) : .red)
.foregroundColor(.red)
}
.keyboardShortcut(.escape)
.buttonStyle(.plain)
Expand Down
3 changes: 1 addition & 2 deletions Nudge/UI/Common/DeviceInfo.swift
Expand Up @@ -11,7 +11,6 @@ import SwiftUI
// Sheet view for Device Information
struct DeviceInfo: View {
@Environment(\.presentationMode) var presentationMode
@Environment(\.accessibilityDifferentiateWithoutColor) var differentiateWithoutColor
@Environment(\.colorScheme) var colorScheme

// State variables
Expand All @@ -30,7 +29,7 @@ struct DeviceInfo: View {
Image(systemName: "xmark.circle")
.resizable()
.frame(width: 20, height: 20)
.foregroundColor(differentiateWithoutColor ? Color(red: 230 / 255, green: 97 / 255, blue: 0 / 255) : .red)
.foregroundColor(.red)
}
.buttonStyle(.plain)
.help("Click to close".localized(desiredLanguage: getDesiredLanguage()))
Expand Down
4 changes: 2 additions & 2 deletions Nudge/UI/SimpleMode/SimpleMode.swift
Expand Up @@ -51,12 +51,12 @@ struct SimpleMode: View {
} else if viewObserved.daysRemaining == 0 && !Utils().demoModeEnabled() {
Text("Hours Remaining To Update:".localized(desiredLanguage: getDesiredLanguage()))
Text(String(viewObserved.hoursRemaining))
.foregroundColor(differentiateWithoutColor ? Color(red: 230 / 255, green: 97 / 255, blue: 0 / 255) : .red)
.foregroundColor(differentiateWithoutColor ? .accessibleRed : .red)
.fontWeight(.bold)
} else {
Text("Days Remaining To Update:".localized(desiredLanguage: getDesiredLanguage()))
Text(String(viewObserved.daysRemaining))
.foregroundColor(differentiateWithoutColor ? Color(red: 230 / 255, green: 97 / 255, blue: 0 / 255) : .red)
.foregroundColor(differentiateWithoutColor ? .accessibleRed : .red)
.fontWeight(.bold)

}
Expand Down
4 changes: 2 additions & 2 deletions Nudge/UI/StandardMode/LeftSide.swift
Expand Up @@ -72,13 +72,13 @@ struct StandardModeLeftSide: View {
Text("Hours Remaining To Update:".localized(desiredLanguage: getDesiredLanguage()))
Spacer()
Text(String(viewObserved.hoursRemaining))
.foregroundColor(differentiateWithoutColor ? Color(red: 230 / 255, green: 97 / 255, blue: 0 / 255) : .red)
.foregroundColor(differentiateWithoutColor ? .accessibleRed : .red)
.fontWeight(.bold)
} else {
Text("Days Remaining To Update:".localized(desiredLanguage: getDesiredLanguage()))
Spacer()
Text(String(viewObserved.daysRemaining))
.foregroundColor(differentiateWithoutColor ? Color(red: 230 / 255, green: 97 / 255, blue: 0 / 255) : .red)
.foregroundColor(differentiateWithoutColor ? .accessibleRed : .red)
.fontWeight(.bold)

}
Expand Down
4 changes: 1 addition & 3 deletions Nudge/UI/StandardMode/RightSide.swift
Expand Up @@ -102,7 +102,7 @@ struct StandardModeRightSide: View {
Text(mainContentNote)
.font(.callout)
.fontWeight(.bold)
.foregroundColor(differentiateWithoutColor ? Color(red: 230 / 255, green: 97 / 255, blue: 0 / 255) : .red)
.foregroundColor(differentiateWithoutColor ? .accessibleRed : .red)
Spacer()
}

Expand All @@ -112,8 +112,6 @@ struct StandardModeRightSide: View {
HStack {
Text(mainContentText.replacingOccurrences(of: "\\n", with: "\n"))
.font(.callout)
.font(.body)
.fontWeight(.regular)
.multilineTextAlignment(.leading)
Spacer()
}
Expand Down
3 changes: 1 addition & 2 deletions Nudge/UI/StandardMode/ScreenShotZoom.swift
Expand Up @@ -12,7 +12,6 @@ import SwiftUI
struct ScreenShotZoom: View {
@Environment(\.presentationMode) var presentationMode
@Environment(\.colorScheme) var colorScheme
@Environment(\.accessibilityDifferentiateWithoutColor) var differentiateWithoutColor

var body: some View {
let darkMode = colorScheme == .dark
Expand All @@ -26,7 +25,7 @@ struct ScreenShotZoom: View {
Image(systemName: "xmark.circle")
.resizable()
.frame(width: 20, height: 20)
.foregroundColor(differentiateWithoutColor ? Color(red: 230 / 255, green: 97 / 255, blue: 0 / 255) : .red)
.foregroundColor(.red)
}
.buttonStyle(.plain)
.help("Click to close".localized(desiredLanguage: getDesiredLanguage()))
Expand Down
2 changes: 2 additions & 0 deletions Nudge/Utilities/Utils.swift
Expand Up @@ -563,6 +563,8 @@ extension FixedWidthInteger {
}

extension Color {
static let accessibleBlue = Color(red: 26 / 255, green: 133 / 255, blue: 255 / 255)
static let accessibleRed = Color(red: 230 / 255, green: 97 / 255, blue: 0 / 255)
static let accessibleSecondaryLight = Color(red: 100 / 255, green: 100 / 255, blue: 100 / 255)
static let accessibleSecondaryDark = Color(red: 150 / 255, green: 150 / 255, blue: 150 / 255)
}

0 comments on commit a02a1ed

Please sign in to comment.