From 3bb3cca885733a3e4f84e8a86aa0574d0260ea31 Mon Sep 17 00:00:00 2001 From: Tim Xie Date: Fri, 8 Mar 2024 01:57:32 -0800 Subject: [PATCH] update!!! --- CubeTime/Helper/HelperButtons.swift | 22 +++++++++++-------- CubeTime/Stats/StatsDetailView.swift | 14 ++++++------ .../StopwatchManager+Stats.swift | 20 ++++++++--------- CubeTime/TimeList/TimeDetailView.swift | 11 +++++----- 4 files changed, 36 insertions(+), 31 deletions(-) diff --git a/CubeTime/Helper/HelperButtons.swift b/CubeTime/Helper/HelperButtons.swift index c998863..7e562a2 100644 --- a/CubeTime/Helper/HelperButtons.swift +++ b/CubeTime/Helper/HelperButtons.swift @@ -169,6 +169,7 @@ struct CTButtonBase: View { var staticHeight: CGFloat = 0 @Environment(\.dynamicTypeSize) private var dynamicTypeSize + @Environment(\.colorScheme) private var colourScheme let horizontalPadding: CGFloat let fontType: Font @@ -206,7 +207,7 @@ struct CTButtonBase: View { self.colourShadow = Color.black.opacity(0.07) case .coloured(let colour): - self.colourBg = colour?.opacity(0.25) ?? Color("accent").opacity(0.20) + self.colourBg = colour?.opacity(0.25) ?? Color("accent").opacity(0.22) self.colourFg = colour ?? Color("accent") self.colourShadow = colour?.opacity(0.16) ?? Color("accent").opacity(0.08) @@ -277,21 +278,24 @@ struct CTButtonBase: View { ZStack { let frameHeight: CGFloat = (self.supportsDynamicResizing ? self.dynamicHeight : self.staticHeight) - if (self.hasBackground) { + if (self.hasBackground && colourScheme == .light) { RoundedRectangle(cornerRadius: 6, style: .continuous) - .fill(Material.thinMaterial) + .fill(Material.ultraThinMaterial) .frame(width: square ? frameHeight : nil, height: frameHeight) } RoundedRectangle(cornerRadius: 6, style: .continuous) .fill(self.hasBackground ? self.colourBg.opacity(0.92) : Color.white.opacity(0.001)) .frame(width: square ? frameHeight : nil, height: frameHeight) - .shadow(color: self.hasShadow - ? self.colourShadow - : Color.clear, - radius: self.hasShadow ? 4 : 0, - x: 0, - y: self.hasShadow ? 1 : 0) + .if(colourScheme == .light) { view in + view + .shadow(color: self.hasShadow + ? self.colourShadow + : Color.clear, + radius: self.hasShadow ? 4 : 0, + x: 0, + y: self.hasShadow ? 1 : 0) + } Group { if (dynamicTypeSize > .xLarge) { diff --git a/CubeTime/Stats/StatsDetailView.swift b/CubeTime/Stats/StatsDetailView.swift index e274fd9..654e11f 100644 --- a/CubeTime/Stats/StatsDetailView.swift +++ b/CubeTime/Stats/StatsDetailView.swift @@ -102,11 +102,6 @@ struct StatsDetailView: View { ThemedDivider() HStack { - Text(solves.name == "Comp Sim Solve" ? "COMPSIM" : solves.name.uppercased()) - - Text("|") - .offset(y: -1) // slight offset of bar - HStack(alignment: .center, spacing: 4) { if (SessionType(rawValue: session.sessionType)! == .playground) { Text("Playground") @@ -123,9 +118,14 @@ struct StatsDetailView: View { .frame(width: 16, height: 16) } - } + Text("|") + .offset(y: -1) // slight offset of bar + + Text(solves.name == "Comp Sim Solve" ? "compsim" : solves.name.lowercased()) + + Spacer() } .font(.subheadline.weight(.medium)) @@ -180,7 +180,7 @@ struct StatsDetailView: View { } } .navigationBarTitleDisplayMode(.inline) - .navigationTitle(solves.name == "Comp Sim Solve" ? "Comp Sim" : solves.name) + .navigationTitle("Stats Detail") .sheet(item: $solveDetail) { item in TimeDetailView(for: item, currentSolve: $solveDetail) diff --git a/CubeTime/StopwatchManager/StopwatchManager+Stats.swift b/CubeTime/StopwatchManager/StopwatchManager+Stats.swift index a0bbdbe..7f3c9dc 100644 --- a/CubeTime/StopwatchManager/StopwatchManager+Stats.swift +++ b/CubeTime/StopwatchManager/StopwatchManager+Stats.swift @@ -126,7 +126,7 @@ extension StopwatchManager { return nil } - return Self.getCalculatedAverage(forSolves: solvesByDate.suffix(period), name: "Current ao", isCompsim: false) + return Self.getCalculatedAverage(forSolves: solvesByDate.suffix(period), name: "current ao", isCompsim: false) } } @@ -382,7 +382,7 @@ extension StopwatchManager { ) || (currentAo5.totalPen, bestAo5!.totalPen) == (Penalty.none, Penalty.dnf) { // current is none and best is dnf self.bestAo5 = currentAo5 - self.bestAo5?.name = "Best ao5" + self.bestAo5?.name = "best ao5" #warning("TODO: unhardcode") } } @@ -394,7 +394,7 @@ extension StopwatchManager { ) || (currentAo12.totalPen, bestAo12!.totalPen) == (Penalty.none, Penalty.dnf) { // current is none and best is dnf self.bestAo12 = currentAo12 - self.bestAo12?.name = "Best ao12" + self.bestAo12?.name = "best ao12" #warning("TODO: unhardcode") } } @@ -406,7 +406,7 @@ extension StopwatchManager { ) || (currentAo100.totalPen, bestAo100!.totalPen) == (Penalty.none, Penalty.dnf) { // current is none and best is dnf self.bestAo100 = currentAo100 - self.bestAo100?.name = "Best ao100" + self.bestAo100?.name = "best ao100" #warning("TODO: unhardcode") } } @@ -489,7 +489,7 @@ extension StopwatchManager { if groupLastSolve.count != 5 { return nil } else { - return Self.getCalculatedAverage(forSolves: groupLastSolve, name: "Current Comp Sim", isCompsim: true) + return Self.getCalculatedAverage(forSolves: groupLastSolve, name: "current compsim", isCompsim: true) } } else { @@ -499,10 +499,10 @@ extension StopwatchManager { if lastInGroup.count == 5 { - return Self.getCalculatedAverage(forSolves: lastInGroup, name: "Current Comp Sim", isCompsim: true) + return Self.getCalculatedAverage(forSolves: lastInGroup, name: "current compsim", isCompsim: true) } else { - return Self.getCalculatedAverage(forSolves: (groupLastTwoSolves.last!.solves!.allObjects as! [Solve]), name: "Current Comp Sim", isCompsim: true) + return Self.getCalculatedAverage(forSolves: (groupLastTwoSolves.last!.solves!.allObjects as! [Solve]), name: "current compsim", isCompsim: true) } } } else { @@ -528,7 +528,7 @@ extension StopwatchManager { if solvegroup.solves!.allObjects.count == 5 { - let currentAvg = Self.getCalculatedAverage(forSolves: solvegroup.solves!.allObjects as! [Solve], name: "Best Comp Sim", isCompsim: true) + let currentAvg = Self.getCalculatedAverage(forSolves: solvegroup.solves!.allObjects as! [Solve], name: "best compsim", isCompsim: true) if currentAvg?.totalPen == .dnf { continue @@ -689,13 +689,13 @@ extension StopwatchManager { let allSolves = trimmedSolves + countedSolvesIndices.map({ solvesByDate[Int($0)] }) if (bestAverage == .infinity) { - return CalculatedAverage(name: "Best ao \(width)", + return CalculatedAverage(name: "best ao \(width)", average: bestAverage, accountedSolves: allSolves, totalPen: .dnf, trimmedSolves: trimmedSolves) } else { - return CalculatedAverage(name: "Best ao\(width)", + return CalculatedAverage(name: "best ao\(width)", average: bestAverage, accountedSolves: allSolves, totalPen: .none, diff --git a/CubeTime/TimeList/TimeDetailView.swift b/CubeTime/TimeList/TimeDetailView.swift index 60d1e04..ec92a56 100644 --- a/CubeTime/TimeList/TimeDetailView.swift +++ b/CubeTime/TimeList/TimeDetailView.swift @@ -112,11 +112,6 @@ struct TimeDetailView: View { HStack { - Text(date, formatter: getSolveDateFormatter(date)) - - Text("|") - .offset(y: -1) // slight offset of bar - HStack(alignment: .center, spacing: 4) { Text(puzzle_type.name) @@ -125,6 +120,12 @@ struct TimeDetailView: View { .frame(width: 16, height: 16) } + Text("|") + .offset(y: -1) // slight offset of bar + + Text(date, formatter: getSolveDateFormatter(date)) + + Spacer() } .font(.subheadline.weight(.medium))