Move ZimFileContextMenu to a new class, add warning on dependencies injected

This commit is contained in:
Balazs Perlaki-Horvath 2025-04-12 14:52:19 +02:00
parent 42b7edc645
commit 1b49e65830
2 changed files with 33 additions and 14 deletions

View File

@ -151,7 +151,10 @@ struct DetailSidePanel<Content: View>: View {
}
}.frame(width: 275).background(.ultraThinMaterial)
}
}.environmentObject(selection)
}
// !important, otherwise the wrapped contentView
// won't get the selection dependency
.environmentObject(selection)
}
}
@ -189,19 +192,6 @@ struct MultiZimFilesOpenedContext<Content: View>: View {
}
#endif
struct ZimFileContextMenu: View {
let zimFile: ZimFile
var body: some View {
if zimFile.fileURLBookmark != nil, !zimFile.isMissing {
Section { ArticleActions(zimFileID: zimFile.fileID) }
}
if let downloadURL = zimFile.downloadURL {
Section { CopyPasteMenu(downloadURL: downloadURL) }
}
}
}
/// On macOS, makes the content view clickable, to select a single ZIM file
/// On iOS, converts the modified view to a NavigationLink that goes to the zim file detail.
struct LibraryZimFileContext<Content: View>: View {

View File

@ -0,0 +1,29 @@
// 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/.
import SwiftUI
struct ZimFileContextMenu: View {
let zimFile: ZimFile
var body: some View {
if zimFile.fileURLBookmark != nil, !zimFile.isMissing {
Section { ArticleActions(zimFileID: zimFile.fileID) }
}
if let downloadURL = zimFile.downloadURL {
Section { CopyPasteMenu(downloadURL: downloadURL) }
}
}
}