mirror of
https://github.com/kiwix/kiwix-apple.git
synced 2025-09-23 03:32:13 -04:00
Merge pull request #832 from kiwix/831-fix-ui-warning-of-tab-reconfiguration-plus-improve-the-look-of-icons
Fix tab cell recycle, and favicon look for dark mode
This commit is contained in:
commit
ab96882dca
@ -160,9 +160,7 @@ class SidebarViewController: UICollectionViewController, NSFetchedResultsControl
|
||||
to: .tabs,
|
||||
animatingDifferences: dataSource.snapshot(for: .tabs).items.count > 0
|
||||
) {
|
||||
// [iOS 15] when a tab is selected, reload it to refresh title and icon
|
||||
guard #unavailable(iOS 16),
|
||||
let indexPath = self.collectionView.indexPathsForSelectedItems?.first,
|
||||
guard let indexPath = self.collectionView.indexPathsForSelectedItems?.first,
|
||||
let item = self.dataSource.itemIdentifier(for: indexPath),
|
||||
case .tab = item else { return }
|
||||
var snapshot = self.dataSource.snapshot()
|
||||
@ -190,9 +188,21 @@ class SidebarViewController: UICollectionViewController, NSFetchedResultsControl
|
||||
|
||||
private func configureCell(cell: UICollectionViewListCell, indexPath: IndexPath, item: NavigationItem) {
|
||||
if case let .tab(objectID) = item, let tab = try? Database.viewContext.existingObject(with: objectID) as? Tab {
|
||||
cell.contentConfiguration = UIHostingConfiguration {
|
||||
TabLabel(tab: tab)
|
||||
var config = cell.defaultContentConfiguration()
|
||||
config.text = tab.title ?? "common.tab.menu.new_tab".localized
|
||||
if let zimFile = tab.zimFile, let category = Category(rawValue: zimFile.category) {
|
||||
config.textProperties.numberOfLines = 1
|
||||
if let imgData = zimFile.faviconData {
|
||||
config.image = UIImage(data: imgData)
|
||||
} else {
|
||||
config.image = UIImage(named: category.icon)
|
||||
}
|
||||
config.imageProperties.maximumSize = CGSize(width: 22, height: 22)
|
||||
config.imageProperties.cornerRadius = 3
|
||||
} else {
|
||||
config.image = UIImage(systemName: "square")
|
||||
}
|
||||
cell.contentConfiguration = config
|
||||
} else {
|
||||
var config = cell.defaultContentConfiguration()
|
||||
config.text = item.name
|
||||
|
@ -28,10 +28,7 @@ struct Favicon: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ZStack(alignment: .center) {
|
||||
Color.white.clipShape(RoundedRectangle(cornerRadius: 3, style: .continuous))
|
||||
image.scaledToFit().cornerRadius(2).padding(1)
|
||||
}
|
||||
image.scaledToFit().cornerRadius(3)
|
||||
.aspectRatio(1, contentMode: .fit)
|
||||
.onAppear {
|
||||
guard let imageURL = imageURL, imageData == nil else { return }
|
||||
|
Loading…
x
Reference in New Issue
Block a user