Skip to content

Commit

Permalink
Add "Open Rules Folder" button to AdvancedRuleConfigurationView
Browse files Browse the repository at this point in the history
  • Loading branch information
Cay-Zhang committed Jul 24, 2023
1 parent 83123d2 commit c97a2fb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Shared/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,17 @@ struct ContentView: View {
Button("Error") {
viewModel.process(url: URLComponents(string: "example.com")!)
}
Button("Nothing Found") {
Button("Nothing Found" as String) {
viewModel.process(url: URLComponents(string: "https://www.baidu.com/")!)
}
Button("Toggle Onboarding") {
withAnimation(OnboardingView.transitionAnimation) { isOnboarding.toggle() }
}
if ProcessInfo.processInfo.isiOSAppOnMac {
Button("Open Rules Folder" as String) {
openURL(Core.ruleDirectoryURL.components!)
}
}
} label: {
Image(systemName: "hammer.fill")
}
Expand Down
7 changes: 7 additions & 0 deletions Shared/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ extension Core.RuleManagerView {
@State private var ruleFilesInfo: [RuleFileInfo] = RuleManager.shared.ruleFilesInfo
@AppStorage("isAdvancedRuleConfigurationEnabled", store: RSSBud.userDefaults) var isAdvancedRuleConfigurationEnabled: Bool = false
@AppStorage("lastRSSHubRadarRemoteRulesFetchDate", store: RSSBud.userDefaults) private var _lastRemoteRulesFetchDate: Double?
@Environment(\.customOpenURLAction) private var openURL

private var lastRemoteRulesFetchDate: Date? {
get { _lastRemoteRulesFetchDate.map(Date.init(timeIntervalSinceReferenceDate:)) }
Expand All @@ -376,6 +377,12 @@ extension Core.RuleManagerView {
}
}

if ProcessInfo.processInfo.isiOSAppOnMac {
Button("Open Rules Folder", systemImage: "arrow.up.forward.app.fill") {
openURL(Core.ruleDirectoryURL.components!)
}
}

HStack {
Button(
ruleManager.isFetchingRemoteRules ? "Updating Rules..." : "Save and update",
Expand Down
1 change: 1 addition & 0 deletions Shared/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"Remote URL" = "Remote URL";
"Leave Empty For Local Files" = "Leave empty for local files";
"Add new rule file" = "Add Rule File";
"Open Rules Folder" = "Open Rules Folder";

"Nothing Found" = "Nothing Found";
"Error Occurred" = "Oops...";
Expand Down
1 change: 1 addition & 0 deletions Shared/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"Remote URL" = "远程 URL";
"Leave Empty For Local Files" = "留空则为本地文件";
"Add new rule file" = "添加规则文件";
"Open Rules Folder" = "打开规则文件夹";

"Nothing Found" = "真的一滴也没有了 (/TДT)/";
"Error Occurred" = "出错了...";
Expand Down

0 comments on commit c97a2fb

Please sign in to comment.