Skip to content

Commit 5dbf4ee

Browse files
committed
Switch to real Table for history on macOS
Also removed the separate window used to display the history, because the history is now just part of the regular navigation list like it has been on iOS.
1 parent 4ad6207 commit 5dbf4ee

File tree

5 files changed

+18
-62
lines changed

5 files changed

+18
-62
lines changed

Global/RNGToolApp.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ struct RNGToolApp: App {
2424
Settings {
2525
SettingsView().environmentObject(settingsData)
2626
}
27-
WindowGroup("History") {
28-
History().environmentObject(settingsData)
29-
.frame(width: 400, height: 200)
30-
.frame(maxWidth: 400, maxHeight: 200)
31-
}.handlesExternalEvents(matching: Set(arrayLiteral: "History"))
3227
WindowGroup("Update") {
3328
UpdateCheck()
3429
.frame(width: 300, height: 100)
@@ -40,7 +35,6 @@ struct RNGToolApp: App {
4035

4136
#if os(macOS)
4237
enum OpenWindows: String, CaseIterable {
43-
case History = "History"
4438
case Update = "Update"
4539

4640
func open(){

Global/RNGToolCommands.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@ struct RNGToolCommands: Commands {
1818
OpenWindows.Update.open()
1919
}
2020
}
21-
CommandGroup(before: CommandGroupPlacement.sidebar) {
22-
Button("Show History") {
23-
OpenWindows.History.open()
24-
}
25-
.keyboardShortcut("h", modifiers: [.command, .shift])
26-
Divider()
27-
}
2821
#endif
2922
}
3023
}

RNGTool.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@
609609
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
610610
CODE_SIGN_STYLE = Automatic;
611611
COMBINE_HIDPI_IMAGES = YES;
612-
CURRENT_PROJECT_VERSION = 4;
612+
CURRENT_PROJECT_VERSION = 5;
613613
DEAD_CODE_STRIPPING = YES;
614614
DEVELOPMENT_ASSET_PATHS = "\"RNGTool/Preview Content\"";
615615
DEVELOPMENT_TEAM = 5GF7GKNTK4;
@@ -641,7 +641,7 @@
641641
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
642642
CODE_SIGN_STYLE = Automatic;
643643
COMBINE_HIDPI_IMAGES = YES;
644-
CURRENT_PROJECT_VERSION = 4;
644+
CURRENT_PROJECT_VERSION = 5;
645645
DEAD_CODE_STRIPPING = YES;
646646
DEVELOPMENT_ASSET_PATHS = "\"RNGTool/Preview Content\"";
647647
DEVELOPMENT_TEAM = 5GF7GKNTK4;

RNGTool/History.swift

Lines changed: 16 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -10,61 +10,31 @@ import Foundation
1010

1111
struct History: View {
1212
@EnvironmentObject var settingsData: SettingsData
13+
@State private var selectedEntries = Set<HistoryTable.ID>()
1314

1415
var body: some View {
15-
GeometryReader { geometry in
16-
ScrollView {
17-
HStack {
18-
VStack(alignment: .leading) {
19-
Text("ID")
20-
.foregroundColor(.secondary)
21-
Divider()
22-
ForEach(0..<settingsData.historyTable.count, id: \.self) { index in
23-
Text("\(index)")
24-
.padding(.bottom, 3)
16+
// History on macOS, now with 100% more actual table! This looks much much better.
17+
Table(settingsData.historyTable, selection: $selectedEntries) {
18+
TableColumn("Mode Used") { item in
19+
Text(item.modeUsed)
20+
.contextMenu {
21+
Button("Copy") {
22+
copyToClipboard(item: item.modeUsed)
2523
}
26-
Spacer()
2724
}
28-
.frame(width: 50)
29-
VStack(alignment: .leading) {
30-
Text("Mode Used")
31-
.foregroundColor(.secondary)
32-
Divider()
33-
ForEach(0..<settingsData.historyTable.count, id: \.self) { index in
34-
Text("\(settingsData.historyTable[index].modeUsed)")
35-
.padding(.bottom, 3)
36-
}
37-
Spacer()
38-
}
39-
.frame(width: 150)
40-
VStack(alignment: .leading) {
41-
Text("Result(s)")
42-
.foregroundColor(.secondary)
43-
Divider()
44-
ForEach(0..<settingsData.historyTable.count, id: \.self) { index in
45-
Text("\(settingsData.historyTable[index].numbers)")
46-
.padding(.bottom, 3)
47-
.contextMenu {
48-
Button(action: {
49-
copyToClipboard(item: settingsData.historyTable[index].numbers)
50-
}) {
51-
Text("Copy")
52-
}
53-
}
25+
}
26+
TableColumn("Result(s)") { item in
27+
Text(item.numbers)
28+
.contextMenu {
29+
Button("Copy") {
30+
copyToClipboard(item: item.numbers)
5431
}
55-
Spacer()
5632
}
57-
.frame(width: 200)
58-
}
59-
.padding(.top, 6)
60-
.padding(.leading, 8)
6133
}
6234
}
6335
}
6436
}
6537

66-
struct History_Previews: PreviewProvider {
67-
static var previews: some View {
68-
History().environmentObject(SettingsData())
69-
}
38+
#Preview {
39+
History().environmentObject(SettingsData())
7040
}

RNGTool/Modes/DiceMode.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ struct DiceMode: View {
1313
@State private var numDice: Int = 1
1414
@State private var confirmReset: Bool = false
1515
@State private var randomNumbers: [Int] = [0]
16-
@State private var numsInArray: Int = 0
1716
@State private var diceImages: [String] = Array(repeating: "d1", count: 18)
1817
@State private var rollCount: Int = 0
1918
@State private var showRollHint: Bool = true

0 commit comments

Comments
 (0)