mirror of
https://github.com/kiwix/kiwix-apple.git
synced 2025-08-03 12:37:15 -04:00
Optionally disable TOC Button, Share button, Find in Page
This commit is contained in:
parent
be8f28ca49
commit
d224d00d1d
@ -196,19 +196,23 @@ private struct CompactView: View {
|
||||
browser?.webView.goForward()
|
||||
})
|
||||
Spacer()
|
||||
OutlineButton(browser: browser)
|
||||
Spacer()
|
||||
if !Brand.hideTOCButton {
|
||||
OutlineButton(browser: browser)
|
||||
Spacer()
|
||||
}
|
||||
BookmarkButton(articleBookmarked: browser.articleBookmarked,
|
||||
isButtonDisabled: browser.zimFileName.isEmpty,
|
||||
createBookmark: { [weak browser] in browser?.createBookmark() },
|
||||
deleteBookmark: { [weak browser] in browser?.deleteBookmark() })
|
||||
Spacer()
|
||||
ExportButton(
|
||||
webViewURL: browser.webView.url,
|
||||
pageDataWithExtension: browser.pageDataWithExtension,
|
||||
isButtonDisabled: browser.zimFileName.isEmpty
|
||||
)
|
||||
Spacer()
|
||||
if !Brand.hideShareButton {
|
||||
ExportButton(
|
||||
webViewURL: browser.webView.url,
|
||||
pageDataWithExtension: browser.pageDataWithExtension,
|
||||
isButtonDisabled: browser.zimFileName.isEmpty
|
||||
)
|
||||
Spacer()
|
||||
}
|
||||
TabsManagerButton()
|
||||
Spacer()
|
||||
if FeatureFlags.hasLibrary {
|
||||
@ -327,7 +331,9 @@ private struct Content<LaunchModel>: View where LaunchModel: LaunchProtocol {
|
||||
action: { [weak browser] in browser?.loadRandomArticle() })
|
||||
.disabled(zimFiles.isEmpty)
|
||||
}
|
||||
ContentSearchButton(browser: browser)
|
||||
if !Brand.hideFindInPage {
|
||||
ContentSearchButton(browser: browser)
|
||||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: scenePhase) { newValue in
|
||||
|
@ -48,7 +48,11 @@ enum Brand {
|
||||
static let appStoreId: String = Config.value(for: .appStoreID) ?? "id997079563"
|
||||
static let loadingLogoImage: String = "welcomeLogo"
|
||||
static var loadingLogoSize: CGSize = ImageInfo.sizeOf(imageName: loadingLogoImage)!
|
||||
static let hideFindInPage: Bool = Config.value(for: .hideFindInPage) ?? false
|
||||
static let hidePrintButton: Bool = Config.value(for: .hidePrintButton) ?? false
|
||||
static let hideRandomButton: Bool = Config.value(for: .hideRandomButton) ?? false
|
||||
static let hideShareButton: Bool = Config.value(for: .hideShareButton) ?? false
|
||||
static let hideTOCButton: Bool = Config.value(for: .hideTOCButton) ?? false
|
||||
|
||||
static let aboutText: String = Config.value(for: .aboutText) ?? LocalString.settings_about_description
|
||||
static let aboutWebsite: String = Config.value(for: .aboutWebsite) ?? "https://www.kiwix.org"
|
||||
@ -92,9 +96,13 @@ enum Config: String {
|
||||
case showSearchSnippetInSettings = "SETTINGS_SHOW_SEARCH_SNIPPET"
|
||||
case aboutText = "CUSTOM_ABOUT_TEXT"
|
||||
case aboutWebsite = "CUSTOM_ABOUT_WEBSITE"
|
||||
case hideDonation = "HIDE_DONATION"
|
||||
case hideRandomButton = "HIDE_RANDOM_BUTTON"
|
||||
case disableImmersiveReading = "DISABLE_IMMERSIVE_READING"
|
||||
case hideDonation = "HIDE_DONATION"
|
||||
case hideFindInPage = "HIDE_FIND_IN_PAGE"
|
||||
case hidePrintButton = "HIDE_PRINT_BUTTON"
|
||||
case hideRandomButton = "HIDE_RANDOM_BUTTON"
|
||||
case hideShareButton = "HIDE_SHARE_BUTTON"
|
||||
case hideTOCButton = "HIDE_TOC_BUTTON"
|
||||
|
||||
static func value<T>(for key: Config) -> T? where T: LosslessStringConvertible {
|
||||
guard let object = Bundle.main.object(forInfoDictionaryKey: key.rawValue) else {
|
||||
|
@ -64,32 +64,42 @@ struct BrowserTab: View {
|
||||
}
|
||||
#endif
|
||||
ToolbarItemGroup(placement: .primaryAction) {
|
||||
OutlineButton(browser: browser)
|
||||
if !Brand.hideTOCButton {
|
||||
OutlineButton(browser: browser)
|
||||
}
|
||||
#if os(iOS)
|
||||
ExportButton(
|
||||
webViewURL: browser.webView.url,
|
||||
pageDataWithExtension: { [weak browser] in await browser?.pageDataWithExtension() },
|
||||
isButtonDisabled: browser.zimFileName.isEmpty
|
||||
)
|
||||
if !Brand.hideShareButton {
|
||||
ExportButton(
|
||||
webViewURL: browser.webView.url,
|
||||
pageDataWithExtension: { [weak browser] in await browser?.pageDataWithExtension() },
|
||||
isButtonDisabled: browser.zimFileName.isEmpty
|
||||
)
|
||||
}
|
||||
#else
|
||||
ExportButton(
|
||||
relativeToView: browser.webView,
|
||||
webViewURL: browser.webView.url,
|
||||
pageDataWithExtension: { [weak browser] in await browser?.pageDataWithExtension() },
|
||||
isButtonDisabled: browser.zimFileName.isEmpty
|
||||
)
|
||||
PrintButton(browserURLName: { [weak browser] in
|
||||
browser?.url?.lastPathComponent
|
||||
}, browserDataAsPDF: { [weak browser] in
|
||||
try await browser?.webView.pdf()
|
||||
})
|
||||
if !Brand.hideShareButton {
|
||||
ExportButton(
|
||||
relativeToView: browser.webView,
|
||||
webViewURL: browser.webView.url,
|
||||
pageDataWithExtension: { [weak browser] in await browser?.pageDataWithExtension() },
|
||||
isButtonDisabled: browser.zimFileName.isEmpty
|
||||
)
|
||||
}
|
||||
if !Brand.hidePrintButton {
|
||||
PrintButton(browserURLName: { [weak browser] in
|
||||
browser?.url?.lastPathComponent
|
||||
}, browserDataAsPDF: { [weak browser] in
|
||||
try await browser?.webView.pdf()
|
||||
})
|
||||
}
|
||||
#endif
|
||||
BookmarkButton(articleBookmarked: browser.articleBookmarked,
|
||||
isButtonDisabled: browser.zimFileName.isEmpty,
|
||||
createBookmark: { [weak browser] in browser?.createBookmark() },
|
||||
deleteBookmark: { [weak browser] in browser?.deleteBookmark() })
|
||||
#if os(iOS)
|
||||
ContentSearchButton(browser: browser)
|
||||
if !Brand.hideFindInPage {
|
||||
ContentSearchButton(browser: browser)
|
||||
}
|
||||
#endif
|
||||
ArticleShortcutButtons(
|
||||
loadMainArticle: { [weak browser] zimFileID in
|
||||
@ -174,11 +184,13 @@ struct BrowserTab: View {
|
||||
}
|
||||
#if os(macOS)
|
||||
.overlay(alignment: .bottomTrailing) {
|
||||
ContentSearchBar(
|
||||
model: ContentSearchViewModel(
|
||||
findInWebPage: browser.webView.find(_:configuration:)
|
||||
if !Brand.hideFindInPage {
|
||||
ContentSearchBar(
|
||||
model: ContentSearchViewModel(
|
||||
findInWebPage: browser.webView.find(_:configuration:)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
case .catalog(.fetching):
|
||||
|
Loading…
x
Reference in New Issue
Block a user