mirror of
https://github.com/kiwix/kiwix-apple.git
synced 2025-09-24 04:03:03 -04:00
Group iOS code into a single component
This commit is contained in:
parent
ed4c64ae5c
commit
5ccd145463
@ -212,13 +212,7 @@ private struct Content: View {
|
|||||||
systemImage: "die.face.5",
|
systemImage: "die.face.5",
|
||||||
action: { browser.loadRandomArticle() })
|
action: { browser.loadRandomArticle() })
|
||||||
.disabled(zimFiles.isEmpty)
|
.disabled(zimFiles.isEmpty)
|
||||||
Button("common.search".localized,
|
ContentSearchButton(webView: browser.webView)
|
||||||
systemImage: "text.magnifyingglass",
|
|
||||||
action: {
|
|
||||||
browser.webView.isFindInteractionEnabled = true
|
|
||||||
browser.webView.findInteraction?.presentFindNavigator(showingReplace: false)
|
|
||||||
}
|
|
||||||
).disabled(browser.webView.url == nil)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,13 +43,7 @@ struct BrowserTab: View {
|
|||||||
#endif
|
#endif
|
||||||
BookmarkButton()
|
BookmarkButton()
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
Button("common.search".localized,
|
ContentSearchButton(webView: browser.webView)
|
||||||
systemImage: "text.magnifyingglass",
|
|
||||||
action: {
|
|
||||||
browser.webView.isFindInteractionEnabled = true
|
|
||||||
browser.webView.findInteraction?.presentFindNavigator(showingReplace: false)
|
|
||||||
}
|
|
||||||
).disabled(browser.webView.url == nil)
|
|
||||||
#endif
|
#endif
|
||||||
ArticleShortcutButtons(displayMode: .mainAndRandomArticle)
|
ArticleShortcutButtons(displayMode: .mainAndRandomArticle)
|
||||||
}
|
}
|
||||||
|
34
Views/BuildingBlocks/ContentSearchButton.swift
Normal file
34
Views/BuildingBlocks/ContentSearchButton.swift
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// This file is part of Kiwix for iOS & macOS.
|
||||||
|
//
|
||||||
|
// Kiwix is free software; you can redistribute it and/or modify it
|
||||||
|
// under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation; either version 3 of the License, or
|
||||||
|
// any later version.
|
||||||
|
//
|
||||||
|
// Kiwix is distributed in the hope that it will be useful, but
|
||||||
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Kiwix; If not, see https://www.gnu.org/licenses/.
|
||||||
|
|
||||||
|
#if os(iOS)
|
||||||
|
import SwiftUI
|
||||||
|
import WebKit
|
||||||
|
|
||||||
|
struct ContentSearchButton: View {
|
||||||
|
|
||||||
|
let webView: WKWebView
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
Button("common.search".localized,
|
||||||
|
systemImage: "text.magnifyingglass",
|
||||||
|
action: {
|
||||||
|
webView.isFindInteractionEnabled = true
|
||||||
|
webView.findInteraction?.presentFindNavigator(showingReplace: false)
|
||||||
|
}
|
||||||
|
).disabled(webView.url == nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user