Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Ice.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
knownRegions = (
en,
Base,
"zh-Hans",
);
mainGroup = 716683212A767E6A006ABF84;
packageReferences = (
Expand Down Expand Up @@ -306,12 +307,13 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Ice/Ice.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1117;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
Expand All @@ -338,12 +340,13 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Ice/Ice.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1117;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// Ice
//

import SwiftUI

/// An identifier used for navigation in the settings interface.
enum SettingsNavigationIdentifier: String, NavigationIdentifier {
case general = "General"
Expand All @@ -11,4 +13,19 @@ enum SettingsNavigationIdentifier: String, NavigationIdentifier {
case hotkeys = "Hotkeys"
case advanced = "Advanced"
case about = "About"

var localized: LocalizedStringKey {
switch self {
case .general: "General"
case .menuBarLayout: "Menu Bar Layout"
case .menuBarAppearance: "Menu Bar Appearance"
case .hotkeys: "Hotkeys"
case .advanced: "Advanced"
case .about: "About"
}
}

func localized(for language: Language) -> String {
rawValue.localized(for: language)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ struct MenuBarAppearanceEditor: View {
private var stackHeader: some View {
if case .popover(let closePopover) = location {
ZStack {
Text("Menu Bar Appearance")
Text(verbatim: "Menu Bar Appearance".localized(for: appState.settingsManager.generalSettingsManager.language))
.font(.title2)
.frame(maxWidth: .infinity, alignment: .center)
Button("Done", action: closePopover)
Button {
closePopover()
} label: {
Text(verbatim: "Done".localized(for: appState.settingsManager.generalSettingsManager.language))
}
.controlSize(.large)
.frame(maxWidth: .infinity, alignment: .trailing)
}
Expand Down Expand Up @@ -68,7 +72,10 @@ struct MenuBarAppearanceEditor: View {
} else {
StaticPartialEditor()
}
IceSection("Menu Bar Shape") {
IceSection(header: {
Text(verbatim: "Menu Bar Shape".localized(for: appState.settingsManager.generalSettingsManager.language))
.font(.headline)
}) {
shapePicker
isInset
}
Expand All @@ -79,7 +86,7 @@ struct MenuBarAppearanceEditor: View {
font: .callout.bold()
) {
Label {
Text("Tip: you can also edit these settings by right-clicking in an empty area of the menu bar")
Text(verbatim: "Tip: you can also edit these settings by right-clicking in an empty area of the menu bar".localized(for: appState.settingsManager.generalSettingsManager.language))
} icon: {
Image(systemName: "lightbulb")
}
Expand All @@ -90,8 +97,10 @@ struct MenuBarAppearanceEditor: View {
!appState.menuBarManager.isMenuBarHiddenBySystemUserDefaults,
appearanceManager.configuration != .defaultConfiguration
{
Button("Reset") {
Button {
appearanceManager.configuration = .defaultConfiguration
} label: {
Text(verbatim: "Reset".localized(for: appState.settingsManager.generalSettingsManager.language))
}
.controlSize(.large)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottomLeading)
Expand All @@ -101,13 +110,17 @@ struct MenuBarAppearanceEditor: View {

@ViewBuilder
private var isDynamicToggle: some View {
Toggle("Use dynamic appearance", isOn: appearanceManager.bindings.configuration.isDynamic)
.annotation("Apply different settings based on the current system appearance")
Toggle(isOn: appearanceManager.bindings.configuration.isDynamic) {
Text(verbatim: "Use dynamic appearance".localized(for: appState.settingsManager.generalSettingsManager.language))
}
.annotation {
Text(verbatim: "Apply different settings based on the current system appearance".localized(for: appState.settingsManager.generalSettingsManager.language))
}
}

@ViewBuilder
private var cannotEdit: some View {
Text("Ice cannot edit the appearance of automatically hidden menu bars")
Text(verbatim: "Ice cannot edit the appearance of automatically hidden menu bars".localized(for: appState.settingsManager.generalSettingsManager.language))
.font(.title3)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
}
Expand All @@ -121,16 +134,16 @@ struct MenuBarAppearanceEditor: View {
@ViewBuilder
private var isInset: some View {
if appearanceManager.configuration.shapeKind != .none {
Toggle(
"Use inset shape on screens with notch",
isOn: appearanceManager.bindings.configuration.isInset
)
Toggle(isOn: appearanceManager.bindings.configuration.isInset) {
Text(verbatim: "Use inset shape on screens with notch".localized(for: appState.settingsManager.generalSettingsManager.language))
}
}
}
}

private struct UnlabeledPartialEditor: View {
@Binding var configuration: MenuBarAppearancePartialConfiguration
@EnvironmentObject var appState: AppState

var body: some View {
IceSection {
Expand All @@ -146,12 +159,14 @@ private struct UnlabeledPartialEditor: View {

@ViewBuilder
private var tintPicker: some View {
IceLabeledContent("Tint") {
IceLabeledContent {
HStack {
IcePicker("Tint", selection: $configuration.tintKind) {
IcePicker(selection: $configuration.tintKind) {
ForEach(MenuBarTintKind.allCases) { tintKind in
Text(tintKind.localized).tag(tintKind)
}
} label: {
Text(verbatim: "Tint".localized(for: appState.settingsManager.generalSettingsManager.language))
}
.labelsHidden()

Expand All @@ -174,28 +189,36 @@ private struct UnlabeledPartialEditor: View {
}
}
.frame(height: 24)
} label: {
Text(verbatim: "Tint".localized(for: appState.settingsManager.generalSettingsManager.language))
}
}

@ViewBuilder
private var shadowToggle: some View {
Toggle("Shadow", isOn: $configuration.hasShadow)
Toggle(isOn: $configuration.hasShadow) {
Text(verbatim: "Shadow".localized(for: appState.settingsManager.generalSettingsManager.language))
}
}

@ViewBuilder
private var borderToggle: some View {
Toggle("Border", isOn: $configuration.hasBorder)
Toggle(isOn: $configuration.hasBorder) {
Text(verbatim: "Border".localized(for: appState.settingsManager.generalSettingsManager.language))
}
}

@ViewBuilder
private var borderColor: some View {
if configuration.hasBorder {
IceLabeledContent("Border Color") {
IceLabeledContent {
CustomColorPicker(
selection: $configuration.borderColor,
supportsOpacity: true,
mode: .crayon
)
} label: {
Text(verbatim: "Border Color".localized(for: appState.settingsManager.generalSettingsManager.language))
}
}
}
Expand All @@ -204,12 +227,13 @@ private struct UnlabeledPartialEditor: View {
private var borderWidth: some View {
if configuration.hasBorder {
IcePicker(
"Border Width",
selection: $configuration.borderWidth
) {
Text("1").tag(1.0)
Text("2").tag(2.0)
Text("3").tag(3.0)
} label: {
Text(verbatim: "Border Width".localized(for: appState.settingsManager.generalSettingsManager.language))
}
}
}
Expand Down Expand Up @@ -293,6 +317,8 @@ private struct PreviewButton: View {
}

@EnvironmentObject var appearanceManager: MenuBarAppearanceManager
@EnvironmentObject var appState: AppState


@State private var frame = CGRect.zero
@State private var isPressed = false
Expand All @@ -303,7 +329,7 @@ private struct PreviewButton: View {
ZStack {
DummyButton(isPressed: $isPressed)
.allowsHitTesting(false)
Text("Hold to Preview")
Text(verbatim: "Hold to Preview".localized(for: appState.settingsManager.generalSettingsManager.language))
.baselineOffset(1.5)
.padding(.horizontal, 10)
.contentShape(Rectangle())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import SwiftUI

struct MenuBarShapePicker: View {
@EnvironmentObject var appearanceManager: MenuBarAppearanceManager
@EnvironmentObject var appState: AppState
@Environment(\.colorScheme) private var colorScheme

var body: some View {
Expand All @@ -16,25 +17,27 @@ struct MenuBarShapePicker: View {

@ViewBuilder
private var shapeKindPicker: some View {
IcePicker("Shape Kind", selection: appearanceManager.bindings.configuration.shapeKind) {
IcePicker(selection: appearanceManager.bindings.configuration.shapeKind) {
ForEach(MenuBarShapeKind.allCases, id: \.self) { shape in
switch shape {
case .none:
Text("None").tag(shape)
Text(verbatim: "None".localized(for: appState.settingsManager.generalSettingsManager.language)).tag(shape)
case .full:
Text("Full").tag(shape)
Text(verbatim: "Full".localized(for: appState.settingsManager.generalSettingsManager.language)).tag(shape)
case .split:
Text("Split").tag(shape)
Text(verbatim: "Split".localized(for: appState.settingsManager.generalSettingsManager.language)).tag(shape)
}
}
} label: {
Text(verbatim: "Shape Kind".localized(for: appState.settingsManager.generalSettingsManager.language))
}
}

@ViewBuilder
private var exampleView: some View {
switch appearanceManager.configuration.shapeKind {
case .none:
Text("No shape kind selected")
Text(verbatim: "No shape kind selected".localized(for: appState.settingsManager.generalSettingsManager.language))
.foregroundStyle(.secondary)
.frame(maxWidth: .infinity, alignment: .center)
case .full:
Expand Down
2 changes: 1 addition & 1 deletion Ice/MenuBar/Search/MenuBarSearchPanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ private struct MenuBarSearchContentView: View {
}

let headerItem = ListItem.header(id: .header(section)) {
Text(section.displayString)
Text(verbatim: section.displayString.localized(for: itemManager.appState?.settingsManager.generalSettingsManager.language ?? .english))
.fontWeight(.semibold)
.foregroundStyle(.secondary)
.frame(maxWidth: .infinity, alignment: .leading)
Expand Down
24 changes: 12 additions & 12 deletions Ice/Permissions/PermissionsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ struct PermissionsView: View {

private var continueButtonText: LocalizedStringKey {
if case .hasRequiredPermissions = permissionsManager.permissionsState {
"Continue in Limited Mode"
LocalizedStringKey("Continue in Limited Mode".localized(for: permissionsManager.appState?.settingsManager.generalSettingsManager.language ?? .english))
} else {
"Continue"
LocalizedStringKey("Continue".localized(for: permissionsManager.appState?.settingsManager.generalSettingsManager.language ?? .english))
}
}

Expand Down Expand Up @@ -58,7 +58,7 @@ struct PermissionsView: View {
@ViewBuilder
private var headerView: some View {
Label {
Text("Permissions")
Text("Permissions".localized(for: permissionsManager.appState?.settingsManager.generalSettingsManager.language ?? .english))
.font(.system(size: 36))
} icon: {
if let nsImage = NSImage(named: NSImage.applicationIconName) {
Expand All @@ -74,8 +74,8 @@ struct PermissionsView: View {
private var explanationView: some View {
IceSection {
VStack {
Text("Ice needs permission to manage the menu bar.")
Text("Absolutely no personal information is collected or stored.")
Text("Ice needs permission to manage the menu bar.".localized(for: permissionsManager.appState?.settingsManager.generalSettingsManager.language ?? .english))
Text("Absolutely no personal information is collected or stored.".localized(for: permissionsManager.appState?.settingsManager.generalSettingsManager.language ?? .english))
.bold()
.foregroundStyle(.red)
}
Expand Down Expand Up @@ -108,7 +108,7 @@ struct PermissionsView: View {
Button {
NSApp.terminate(nil)
} label: {
Text("Quit")
Text("Quit".localized(for: permissionsManager.appState?.settingsManager.generalSettingsManager.language ?? .english))
.frame(maxWidth: .infinity)
}
}
Expand All @@ -134,20 +134,20 @@ struct PermissionsView: View {
private func permissionBox(_ permission: Permission) -> some View {
IceSection {
VStack(spacing: 10) {
Text(permission.title)
Text(permission.title.localized(for: permissionsManager.appState?.settingsManager.generalSettingsManager.language ?? .english))
.font(.title)
.underline()

VStack(spacing: 0) {
Text("Ice needs this to:")
Text("Ice needs this to:".localized(for: permissionsManager.appState?.settingsManager.generalSettingsManager.language ?? .english))
.font(.title3)
.bold()

VStack(alignment: .leading) {
ForEach(permission.details, id: \.self) { detail in
HStack {
Text("•").bold()
Text(detail)
Text(detail.localized(for: permissionsManager.appState?.settingsManager.generalSettingsManager.language ?? .english))
}
}
}
Expand All @@ -165,10 +165,10 @@ struct PermissionsView: View {
}
} label: {
if permission.hasPermission {
Text("Permission Granted")
Text("Permission Granted".localized(for: permissionsManager.appState?.settingsManager.generalSettingsManager.language ?? .english))
.foregroundStyle(.green)
} else {
Text("Grant Permission")
Text("Grant Permission".localized(for: permissionsManager.appState?.settingsManager.generalSettingsManager.language ?? .english))
}
}
.allowsHitTesting(!permission.hasPermission)
Expand All @@ -180,7 +180,7 @@ struct PermissionsView: View {
font: .callout.bold()
) {
Label {
Text("Ice can work in a limited mode without this permission.")
Text("Ice can work in a limited mode without this permission.".localized(for: permissionsManager.appState?.settingsManager.generalSettingsManager.language ?? .english))
} icon: {
Image(systemName: "checkmark.shield")
.foregroundStyle(.green)
Expand Down
Loading