Skip to content

Commit

Permalink
使用数字等宽字体
Browse files Browse the repository at this point in the history
Signed-off-by: 82Flex <[email protected]>
  • Loading branch information
Lessica committed Dec 31, 2023
1 parent cfe7120 commit c142a78
Show file tree
Hide file tree
Showing 23 changed files with 48 additions and 29 deletions.
2 changes: 2 additions & 0 deletions Reveil/DataModels/Presets/SecurityPresets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ struct SecurityPresets: Codable {
var secureEntitlementKeys: Set<String> = [
"get-task-allow",
"application-identifier",
"keychain-access-groups",
"com.apple.developer.team-identifier",
"com.apple.security.app-sandbox",
"com.apple.security.network.client",
"com.apple.private.security.container-required",
]

var secureMainBundleIdentifiers: Set<String> = [
Expand Down
6 changes: 3 additions & 3 deletions Reveil/Pages/AboutView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ struct AboutView: View {
)
}

Link(destination: URL(string: "https://twitter.com/82Flex")!) {
Link(destination: URL(string: "https://github.com/Lessica")!) {
LinkCell(
label: NSLocalizedString("DEVELOPER", comment: "Developer"),
description: "@82Flex",
description: "@Lessica",
hasClosure: true
)
}
Expand Down Expand Up @@ -99,7 +99,7 @@ struct AboutView: View {
description: gBuildDateString
)
} footer: {
Text(NSLocalizedString("COPYRIGHT_STRING", comment: "Copyright © 2023-2024 82Flex Team.\nAll rights reserved."))
Text(NSLocalizedString("COPYRIGHT_STRING", comment: "Copyright © 2023-2024 Lessica & Lakr Aream.\nAll rights reserved."))
.font(Font.system(.footnote))
.foregroundColor(Color(PlatformColor.secondaryLabelAlias))
.multilineTextAlignment(.center)
Expand Down
4 changes: 3 additions & 1 deletion Reveil/Pages/DashboardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ struct DashboardView: View {
var body: some View {
ScrollView(.vertical) {
VStack {
Section { CheckmarkWidget() }
if PinStorage.shared.isPinned(forKey: .Security) {
Section { CheckmarkWidget() }
}

ForEach(viewModel.entries, id: \.key) { entry in
Section {
Expand Down
2 changes: 1 addition & 1 deletion Reveil/Pages/Details/BatteryInformationListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct BatteryInformationListView: View, ModuleListView {
)
.navigationTitle(module.moduleName)
.navigationBarItems(trailing: PinButton(pin: AppCodableStorage(
wrappedValue: Pin(false), String(describing: BatteryInformation.self),
wrappedValue: Pin(false), .BatteryInformation,
store: PinStorage.shared.userDefaults
)))
.onReceive(GlobalTimer.shared.$tick) { _ in
Expand Down
2 changes: 1 addition & 1 deletion Reveil/Pages/Details/CPUInformationListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct CPUInformationListView: View, ModuleListView {
)
.navigationTitle(module.moduleName)
.navigationBarItems(trailing: PinButton(pin: AppCodableStorage(
wrappedValue: Pin(true), String(describing: CPUInformation.self),
wrappedValue: Pin(true), EntryKey.CPUInformation,
store: PinStorage.shared.userDefaults
)))
.onReceive(GlobalTimer.shared.$tick) { _ in
Expand Down
2 changes: 1 addition & 1 deletion Reveil/Pages/Details/DiskSpaceListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct DiskSpaceListView: View, ModuleListView {
)
.navigationTitle(module.moduleName)
.navigationBarItems(trailing: PinButton(pin: AppCodableStorage(
wrappedValue: Pin(true), String(describing: DiskSpace.self),
wrappedValue: Pin(true), .DiskSpace,
store: PinStorage.shared.userDefaults
)))
.onReceive(GlobalTimer.shared.$tick) { _ in
Expand Down
2 changes: 1 addition & 1 deletion Reveil/Pages/Details/FileSystemsListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct FileSystemsListView: View, ModuleListView {
.navigationTitle(module.moduleName)
.navigationBarItems(
trailing: PinButton(pin: AppCodableStorage(
wrappedValue: Pin(false), String(describing: FileSystems.self),
wrappedValue: Pin(false), .FileSystems,
store: PinStorage.shared.userDefaults
))
)
Expand Down
2 changes: 1 addition & 1 deletion Reveil/Pages/Details/MemoryInformationListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct MemoryInformationListView: View, ModuleListView {
)
.navigationTitle(module.moduleName)
.navigationBarItems(trailing: PinButton(pin: AppCodableStorage(
wrappedValue: Pin(true), String(describing: MemoryInformation.self),
wrappedValue: Pin(true), .MemoryInformation,
store: PinStorage.shared.userDefaults
)))
.onReceive(GlobalTimer.shared.$tick) { _ in
Expand Down
2 changes: 1 addition & 1 deletion Reveil/Pages/Details/NetworkInterfacesListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct NetworkInterfacesListView: View, ModuleListView {
.navigationTitle(module.moduleName)
.navigationBarItems(
trailing: PinButton(pin: AppCodableStorage(
wrappedValue: Pin(false), String(describing: NetworkInterfaces.self),
wrappedValue: Pin(false), .NetworkInterfaces,
store: PinStorage.shared.userDefaults
))
)
Expand Down
2 changes: 1 addition & 1 deletion Reveil/Pages/Details/NetworkUsageListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct NetworkUsageListView: View, ModuleListView {
)
.navigationTitle(module.moduleName)
.navigationBarItems(trailing: PinButton(pin: AppCodableStorage(
wrappedValue: Pin(false), String(describing: NetworkUsage.self),
wrappedValue: Pin(false), .NetworkUsage,
store: PinStorage.shared.userDefaults
)))
.onReceive(GlobalTimer.shared.$tick) { _ in
Expand Down
4 changes: 4 additions & 0 deletions Reveil/Pages/SecurityView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@ struct SecurityView: View {
var body: some View {
DetailsListView(basicEntries: securityModel.basicEntries)
.navigationTitle(NSLocalizedString("SECURITY", comment: "Security"))
.navigationBarItems(trailing: PinButton(pin: AppCodableStorage(
wrappedValue: Pin(true), .Security,
store: PinStorage.shared.userDefaults
)))
}
}
Binary file modified Reveil/Resources/PinStorage.plist
Binary file not shown.
4 changes: 2 additions & 2 deletions Reveil/Storage/AppCodableStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ struct AppCodableStorage<Value: PropertyListRepresentable>: DynamicProperty {
private let triggerUpdate: ObservedObject<DefaultsWriter<Value>>
private let writer: DefaultsWriter<Value>

init(wrappedValue: Value, _ key: String, store: UserDefaults? = nil) {
writer = DefaultsWriter<Value>.shared(defaultValue: wrappedValue, key: key, defaults: store ?? .standard)
init(wrappedValue: Value, _ key: EntryKey, store: UserDefaults? = nil) {
writer = DefaultsWriter<Value>.shared(defaultValue: wrappedValue, key: key.rawValue, defaults: store ?? .standard)
triggerUpdate = .init(wrappedValue: writer)
}

Expand Down
4 changes: 4 additions & 0 deletions Reveil/Storage/PinStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ final class PinStorage: ObservableObject {

@Published var pinnedEntryKeys: [EntryKey]

func isPinned(forKey key: EntryKey) -> Bool {
return pinnedEntryKeys.contains(key)
}

func reloadData() {
guard let dictRepr = persistentDomain else {
return
Expand Down
7 changes: 7 additions & 0 deletions Reveil/ViewModels/Enums/EntryKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import Foundation
enum EntryKey: Codable, Equatable, Hashable, RawRepresentable {
typealias RawValue = String

// Security
case Security

// Device Information
case DeviceName
case MarketingName
Expand Down Expand Up @@ -205,6 +208,8 @@ enum EntryKey: Codable, Equatable, Hashable, RawRepresentable {

init?(rawValue: String) {
switch rawValue {
case "Security":
self = .Security
case "DeviceName":
self = .DeviceName
case "MarketingName":
Expand Down Expand Up @@ -467,6 +472,8 @@ enum EntryKey: Codable, Equatable, Hashable, RawRepresentable {

var rawValue: String {
switch self {
case .Security:
"Security"
case .DeviceName:
"DeviceName"
case .MarketingName:
Expand Down
2 changes: 1 addition & 1 deletion Reveil/Views/Dashboard/ActivityWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct ActivityWidget: View {

HStack {
AnimatedText(String(format: "%.2f%%", Double(entry.values.last ?? 0) * 100.0))
.font(Font.system(.title).weight(.medium))
.font(Font.system(.title).weight(.medium).monospacedDigit())
.foregroundColor(.accentColor)
.lineLimit(1)
Spacer()
Expand Down
2 changes: 1 addition & 1 deletion Reveil/Views/Dashboard/FieldWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct FieldWidget: View {

HStack {
Text(entry.value)
.font(Font.system(.body).weight(.regular))
.font(Font.system(.body).weight(.regular).monospacedDigit())
.foregroundColor(Color(PlatformColor.secondaryLabelAlias))
.multilineTextAlignment(.leading)
.lineLimit(3)
Expand Down
8 changes: 4 additions & 4 deletions Reveil/Views/Dashboard/TrafficWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ struct TrafficWidget: View {
.font(Font.system(.body).weight(.regular))
.foregroundColor(Color(PlatformColor.secondaryLabelAlias))

AnimatedText(receivedDescription)
.font(Font.system(.body).weight(.regular))
Text(receivedDescription)
.font(Font.system(.body).weight(.regular).monospacedDigit())
.foregroundColor(Color(PlatformColor.secondaryLabelAlias))
.lineLimit(1)
}
Expand Down Expand Up @@ -164,8 +164,8 @@ struct TrafficWidget: View {
.font(Font.system(.body).weight(.regular))
.foregroundColor(Color(PlatformColor.secondaryLabelAlias))

AnimatedText(sentDescription)
.font(Font.system(.body).weight(.regular))
Text(sentDescription)
.font(Font.system(.body).weight(.regular).monospacedDigit())
.foregroundColor(Color(PlatformColor.secondaryLabelAlias))
.lineLimit(1)
}
Expand Down
4 changes: 2 additions & 2 deletions Reveil/Views/Dashboard/UsageWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ struct UsageWidget: View {

HStack(alignment: .lastTextBaseline) {
AnimatedText(String(format: "%.2f%%", (entry.firstRatio ?? 0.0) * 100.0))
.font(Font.system(.title).weight(.medium))
.font(Font.system(.title).weight(.medium).monospacedDigit())
.foregroundColor(.accentColor)
.lineLimit(1)
Spacer()

if let lastDescription = entry.lastDescription {
Text(lastDescription)
.font(Font.system(.body).weight(.regular))
.font(Font.system(.body).weight(.regular).monospacedDigit())
.foregroundColor(Color(PlatformColor.secondaryLabelAlias))
.lineLimit(1)
}
Expand Down
6 changes: 3 additions & 3 deletions Reveil/Views/Details/FieldCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private struct FieldCell_Internal: View {
Spacer()

Text(description)
.font(.system(.body))
.font(.system(.body).monospacedDigit())
.foregroundColor(Color(PlatformColor.secondaryLabelAlias))
.multilineTextAlignment(.trailing)
}
Expand All @@ -84,9 +84,9 @@ struct FieldCell: View {
delegate: delegate,
isPinnable: entry.key.isPinnable,
pin: entry.key.isPinnable ? AppCodableStorage(
wrappedValue: Pin(false), entry.key.rawValue,
wrappedValue: Pin(false), entry.key,
store: PinStorage.shared.userDefaults
) : AppCodableStorage(wrappedValue: Pin(false), String())
) : AppCodableStorage(wrappedValue: Pin(false), .Custom(name: String()))
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Reveil/Views/PinButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ struct PinButton: View {

struct PinButton_Previews: PreviewProvider {
static var previews: some View {
PinButton(pin: AppCodableStorage(wrappedValue: Pin(false), "PinButton.Pinned"))
PinButton(pin: AppCodableStorage(wrappedValue: Pin(false), .Security))
}
}
4 changes: 2 additions & 2 deletions Reveil/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@
/* Copied to clipboard */
"COPIED_TO_CLIPBOARD" = "Copied to clipboard";

/* Copyright © 2023-2024 82Flex Team.\nAll rights reserved. */
"COPYRIGHT_STRING" = "Copyright © 2023-2024 82Flex Team.\nAll rights reserved.";
/* Copyright © 2023-2024 Lessica & Lakr Aream.\nAll rights reserved. */
"COPYRIGHT_STRING" = "Copyright © 2023-2024 Lessica & Lakr Aream.\nAll rights reserved.";

/* COW Faults */
"COW_FAULTS" = "COW Faults";
Expand Down
4 changes: 2 additions & 2 deletions Reveil/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@
/* Copied to clipboard */
"COPIED_TO_CLIPBOARD" = "已拷贝到剪贴板";

/* Copyright © 2023-2024 82Flex Team.\nAll rights reserved. */
"COPYRIGHT_STRING" = "版权所有 © 2023-2024 82Flex Team.\n保留所有权利";
/* Copyright © 2023-2024 Lessica & Lakr Aream.\nAll rights reserved. */
"COPYRIGHT_STRING" = "版权所有 © 2023-2024 Lessica & Lakr Aream.\n保留所有权利";

/* COW Faults */
"COW_FAULTS" = "写时复制错误";
Expand Down

0 comments on commit c142a78

Please sign in to comment.