diff --git a/XDeck.xcodeproj/project.pbxproj b/XDeck.xcodeproj/project.pbxproj index 300699c..f33f79d 100644 --- a/XDeck.xcodeproj/project.pbxproj +++ b/XDeck.xcodeproj/project.pbxproj @@ -12,6 +12,7 @@ 5B1CC26F2A95944A00DF7D83 /* AppearanceToggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B1CC26E2A95944A00DF7D83 /* AppearanceToggle.swift */; }; 5B1CC2712A95968E00DF7D83 /* SunIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B1CC2702A95968E00DF7D83 /* SunIcon.swift */; }; 5B1CC2732A95969600DF7D83 /* MoonIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B1CC2722A95969600DF7D83 /* MoonIcon.swift */; }; + 5B4A3FE22C17646F00043FC1 /* GitHubSponsorIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B4A3FE12C17646F00043FC1 /* GitHubSponsorIcon.swift */; }; 5B5685392A92FF2900298476 /* WebViewMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B5685382A92FF2900298476 /* WebViewMessage.swift */; }; 5B56853B2A93058500298476 /* Color+Hex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B56853A2A93058500298476 /* Color+Hex.swift */; }; 5B5F42252AAA368E0031658B /* AppConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B5F42242AAA368E0031658B /* AppConfig.swift */; }; @@ -32,6 +33,7 @@ 5B1CC26E2A95944A00DF7D83 /* AppearanceToggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppearanceToggle.swift; sourceTree = ""; }; 5B1CC2702A95968E00DF7D83 /* SunIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SunIcon.swift; sourceTree = ""; }; 5B1CC2722A95969600DF7D83 /* MoonIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoonIcon.swift; sourceTree = ""; }; + 5B4A3FE12C17646F00043FC1 /* GitHubSponsorIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GitHubSponsorIcon.swift; sourceTree = ""; }; 5B5685382A92FF2900298476 /* WebViewMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewMessage.swift; sourceTree = ""; }; 5B56853A2A93058500298476 /* Color+Hex.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Color+Hex.swift"; sourceTree = ""; }; 5B5F42242AAA368E0031658B /* AppConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppConfig.swift; sourceTree = ""; }; @@ -86,6 +88,7 @@ isa = PBXGroup; children = ( 5B1CC26A2A95026F00DF7D83 /* GitHubIcon.swift */, + 5B4A3FE12C17646F00043FC1 /* GitHubSponsorIcon.swift */, 5B1CC2722A95969600DF7D83 /* MoonIcon.swift */, 5B1CC2702A95968E00DF7D83 /* SunIcon.swift */, ); @@ -220,6 +223,7 @@ 5B90B8D52A8E7A2F00185EAA /* LoginView.swift in Sources */, 5B90B8C32A8E6D7300185EAA /* XDeckApp.swift in Sources */, 5B1CC2732A95969600DF7D83 /* MoonIcon.swift in Sources */, + 5B4A3FE22C17646F00043FC1 /* GitHubSponsorIcon.swift in Sources */, 5B0DC3542A8FC79400268684 /* WebViewConfigurations.swift in Sources */, 5BD50E852C14BBFE004D4A7E /* HideAdsToggle.swift in Sources */, 5B5F42252AAA368E0031658B /* AppConfig.swift in Sources */, diff --git a/XDeck/View/ContentView.swift b/XDeck/View/ContentView.swift index 1c944fe..7294801 100644 --- a/XDeck/View/ContentView.swift +++ b/XDeck/View/ContentView.swift @@ -47,7 +47,8 @@ struct ContentView: View { init(appConfig: AppConfig) { self.appConfig = appConfig - self._columnWidth = State(initialValue: appConfig.columnWidth.map(CGFloat.init) ?? Self.defaultColumnWidth) + self._columnWidth = State( + initialValue: appConfig.columnWidth.map(CGFloat.init) ?? Self.defaultColumnWidth) } @ViewBuilder @@ -105,7 +106,8 @@ struct ContentView: View { WebView( isLoading: $isLoading, url: url, alertMessage: $alertMessage, messageFromWebView: $webViewMessage, - scriptExecutionRequest: column.isXColumn ? $scriptExecutionRequest : .constant(nil), + scriptExecutionRequest: column.isXColumn + ? $scriptExecutionRequest : .constant(nil), refreshSwitch: refreshSwitch, configuration: WebViewConfigurations.makeConfiguration( onLoadScripts: baseConfiguration) @@ -134,11 +136,13 @@ struct ContentView: View { ZStack { Button("+") { pageZoom = pageZoom + 0.2 - columnWidth = (appConfig.columnWidth.map(CGFloat.init) ?? Self.defaultColumnWidth) * pageZoom + columnWidth = + (appConfig.columnWidth.map(CGFloat.init) ?? Self.defaultColumnWidth) * pageZoom }.keyboardShortcut("+").opacity(0) Button("-") { pageZoom = pageZoom - 0.2 - columnWidth = (appConfig.columnWidth.map(CGFloat.init) ?? Self.defaultColumnWidth) * pageZoom + columnWidth = + (appConfig.columnWidth.map(CGFloat.init) ?? Self.defaultColumnWidth) * pageZoom }.keyboardShortcut("-").opacity(0) Button("r") { refreshSwitch = !refreshSwitch @@ -166,7 +170,8 @@ struct ContentView: View { VStack(alignment: .leading, spacing: 0) { HStack(spacing: 0) { ForEach(appConfig.columns.indices, id: \.hashValue) { index in - let isLeftMostXColumn = index == (appConfig.columns.firstIndex { $0.isXColumn } ?? -1) + let isLeftMostXColumn = + index == (appConfig.columns.firstIndex { $0.isXColumn } ?? -1) makeColumn( column: appConfig.columns[index], isLeftMostXColumn: isLeftMostXColumn, @@ -208,6 +213,24 @@ struct ContentView: View { scriptExecutionRequest = WebViewConfigurations.showAds } }) + Button { + openURL(URL(string: "https://github.com/sponsors/morishin")!) + } label: { + Label { + Text("Sponsor") + .foregroundStyle(isDarkMode ? Color.white : Self.textColor(for: backgroundColor)) + } icon: { + GitHubSponsorIcon() + .foregroundColor(Color(hex: "#BF3989")).frame( + width: 16, height: 16) + } + }.buttonStyle(.bordered).onHover { inside in + if inside { + NSCursor.pointingHand.push() + } else { + NSCursor.pop() + } + } Text("⌘+ Zoom In").foregroundColor(Self.textColor(for: backgroundColor)) Text("⌘- Zoom out").foregroundColor(Self.textColor(for: backgroundColor)) Text("⌘R Refresh").foregroundColor(Self.textColor(for: backgroundColor)) diff --git a/XDeck/View/Icon/GitHubSponsorIcon.swift b/XDeck/View/Icon/GitHubSponsorIcon.swift new file mode 100644 index 0000000..16d5318 --- /dev/null +++ b/XDeck/View/Icon/GitHubSponsorIcon.swift @@ -0,0 +1,39 @@ +// Created by https://svg-to-swiftui.quassum.com/ +import SwiftUI + +struct GitHubSponsorIcon: Shape { + func path(in rect: CGRect) -> Path { + var path = Path() + let width = rect.size.width + let height = rect.size.height + path.move(to: CGPoint(x: 0.73438*width, y: 0.06246*height)) + path.addCurve(to: CGPoint(x: 0.5*width, y: 0.18871*height), control1: CGPoint(x: 0.63771*width, y: 0.06246*height), control2: CGPoint(x: 0.55296*width, y: 0.11258*height)) + path.addCurve(to: CGPoint(x: 0.26563*width, y: 0.06246*height), control1: CGPoint(x: 0.44704*width, y: 0.11258*height), control2: CGPoint(x: 0.36229*width, y: 0.06246*height)) + path.addCurve(to: CGPoint(x: 0, y: 0.34371*height), control1: CGPoint(x: 0.13037*width, y: 0.06246*height), control2: CGPoint(x: 0, y: 0.17721*height)) + path.addCurve(to: CGPoint(x: 0.24283*width, y: 0.76983*height), control1: CGPoint(x: 0, y: 0.52183*height), control2: CGPoint(x: 0.12783*width, y: 0.67067*height)) + path.addLine(to: CGPoint(x: 0.478*width, y: 0.93204*height)) + path.addLine(to: CGPoint(x: 0.47833*width, y: 0.93217*height)) + path.addLine(to: CGPoint(x: 0.47829*width, y: 0.93229*height)) + path.addCurve(to: CGPoint(x: 0.5*width, y: 0.9375*height), control1: CGPoint(x: 0.48508*width, y: 0.93583*height), control2: CGPoint(x: 0.49254*width, y: 0.93754*height)) + path.addCurve(to: CGPoint(x: 0.52171*width, y: 0.93229*height), control1: CGPoint(x: 0.50746*width, y: 0.93754*height), control2: CGPoint(x: 0.51492*width, y: 0.93579*height)) + path.addLine(to: CGPoint(x: 0.52167*width, y: 0.93217*height)) + path.addLine(to: CGPoint(x: 0.522*width, y: 0.93204*height)) + path.addLine(to: CGPoint(x: 0.52317*width, y: 0.93133*height)) + path.addCurve(to: CGPoint(x: width, y: 0.34371*height), control1: CGPoint(x: 0.87217*width, y: 0.67067*height), control2: CGPoint(x: width, y: 0.52183*height)) + path.addCurve(to: CGPoint(x: 0.73438*width, y: 0.06246*height), control1: CGPoint(x: width, y: 0.17721*height), control2: CGPoint(x: 0.86962*width, y: 0.06246*height)) + path.closeSubpath() + path.move(to: CGPoint(x: 0.69608*width, y: 0.69892*height)) + path.addLine(to: CGPoint(x: 0.49996*width, y: 0.837*height)) + path.addLine(to: CGPoint(x: 0.49979*width, y: 0.83708*height)) + path.addCurve(to: CGPoint(x: 0.09354*width, y: 0.34379*height), control1: CGPoint(x: 0.19229*width, y: 0.60279*height), control2: CGPoint(x: 0.09354*width, y: 0.47817*height)) + path.addCurve(to: CGPoint(x: 0.26542*width, y: 0.15629*height), control1: CGPoint(x: 0.09354*width, y: 0.22904*height), control2: CGPoint(x: 0.18192*width, y: 0.15629*height)) + path.addCurve(to: CGPoint(x: 0.45475*width, y: 0.30979*height), control1: CGPoint(x: 0.35125*width, y: 0.15629*height), control2: CGPoint(x: 0.4285*width, y: 0.21792*height)) + path.addCurve(to: CGPoint(x: 0.5*width, y: 0.34296*height), control1: CGPoint(x: 0.46071*width, y: 0.33042*height), control2: CGPoint(x: 0.47958*width, y: 0.343*height)) + path.addCurve(to: CGPoint(x: 0.54521*width, y: 0.30979*height), control1: CGPoint(x: 0.52042*width, y: 0.343*height), control2: CGPoint(x: 0.53929*width, y: 0.33038*height)) + path.addCurve(to: CGPoint(x: 0.73454*width, y: 0.15629*height), control1: CGPoint(x: 0.57146*width, y: 0.21792*height), control2: CGPoint(x: 0.64871*width, y: 0.15629*height)) + path.addCurve(to: CGPoint(x: 0.90642*width, y: 0.34379*height), control1: CGPoint(x: 0.81804*width, y: 0.15629*height), control2: CGPoint(x: 0.90642*width, y: 0.22904*height)) + path.addCurve(to: CGPoint(x: 0.69608*width, y: 0.69892*height), control1: CGPoint(x: 0.90642*width, y: 0.47817*height), control2: CGPoint(x: 0.80767*width, y: 0.60279*height)) + path.closeSubpath() + return path + } +}