Cosmetic changes
This commit is contained in:
parent
61f073109c
commit
dab4d6075a
|
@ -42,6 +42,8 @@
|
|||
D6E24360278B97240005E546 /* Group+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6E2435C278B97240005E546 /* Group+CoreDataProperties.swift */; };
|
||||
D6E24363278BA1410005E546 /* ItemCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6E24361278BA1410005E546 /* ItemCollectionViewCell.swift */; };
|
||||
D6E24367278BA2660005E546 /* SwiftSoup in Frameworks */ = {isa = PBXBuildFile; productRef = D6E24366278BA2660005E546 /* SwiftSoup */; };
|
||||
D6E24369278BABB40005E546 /* UIColor+App.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6E24368278BABB40005E546 /* UIColor+App.swift */; };
|
||||
D6E2436B278BB1880005E546 /* HomeCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6E2436A278BB1880005E546 /* HomeCollectionViewCell.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
|
@ -120,6 +122,8 @@
|
|||
D6E2435B278B97240005E546 /* Group+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Group+CoreDataClass.swift"; sourceTree = "<group>"; };
|
||||
D6E2435C278B97240005E546 /* Group+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Group+CoreDataProperties.swift"; sourceTree = "<group>"; };
|
||||
D6E24361278BA1410005E546 /* ItemCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemCollectionViewCell.swift; sourceTree = "<group>"; };
|
||||
D6E24368278BABB40005E546 /* UIColor+App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+App.swift"; sourceTree = "<group>"; };
|
||||
D6E2436A278BB1880005E546 /* HomeCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeCollectionViewCell.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
|
@ -178,6 +182,7 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
D65B18C027505348004A9448 /* HomeViewController.swift */,
|
||||
D6E2436A278BB1880005E546 /* HomeCollectionViewCell.swift */,
|
||||
);
|
||||
path = Home;
|
||||
sourceTree = "<group>";
|
||||
|
@ -226,6 +231,7 @@
|
|||
D6C687ED272CD27600874C10 /* SceneDelegate.swift */,
|
||||
D65B18B527504920004A9448 /* FervorController.swift */,
|
||||
D65B18BD275051A1004A9448 /* LocalData.swift */,
|
||||
D6E24368278BABB40005E546 /* UIColor+App.swift */,
|
||||
D6A8A33527766E9300CCEC72 /* CoreData */,
|
||||
D65B18AF2750468B004A9448 /* Screens */,
|
||||
D6C687F7272CD27700874C10 /* Assets.xcassets */,
|
||||
|
@ -463,7 +469,9 @@
|
|||
D65B18B627504920004A9448 /* FervorController.swift in Sources */,
|
||||
D6C687EC272CD27600874C10 /* AppDelegate.swift in Sources */,
|
||||
D6C687F6272CD27600874C10 /* Reader.xcdatamodeld in Sources */,
|
||||
D6E2436B278BB1880005E546 /* HomeCollectionViewCell.swift in Sources */,
|
||||
D6E2435F278B97240005E546 /* Group+CoreDataClass.swift in Sources */,
|
||||
D6E24369278BABB40005E546 /* UIColor+App.swift in Sources */,
|
||||
D6E2435D278B97240005E546 /* Item+CoreDataClass.swift in Sources */,
|
||||
D6E24360278B97240005E546 /* Group+CoreDataProperties.swift in Sources */,
|
||||
D6E2434C278B456A0005E546 /* ItemsViewController.swift in Sources */,
|
||||
|
|
|
@ -68,6 +68,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||
private func createAppUI() {
|
||||
let home = HomeViewController(fervorController: fervorController)
|
||||
let nav = UINavigationController(rootViewController: home)
|
||||
nav.navigationBar.prefersLargeTitles = true
|
||||
window!.rootViewController = nav
|
||||
|
||||
Task(priority: .userInitiated) {
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
//
|
||||
// HomeCollectionViewCell.swift
|
||||
// Reader
|
||||
//
|
||||
// Created by Shadowfacts on 1/9/22.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class HomeCollectionViewCell: UICollectionViewListCell {
|
||||
|
||||
override func updateConfiguration(using state: UICellConfigurationState) {
|
||||
var backgroundConfig = UIBackgroundConfiguration.listGroupedCell().updated(for: state)
|
||||
if !state.isHighlighted && !state.isSelected {
|
||||
backgroundConfig.backgroundColor = .appBackground
|
||||
}
|
||||
// todo: this breaks the deselection animation
|
||||
self.backgroundConfiguration = backgroundConfig
|
||||
}
|
||||
|
||||
}
|
|
@ -30,11 +30,22 @@ class HomeViewController: UIViewController {
|
|||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
view.backgroundColor = .systemBackground
|
||||
// todo: account info
|
||||
title = "Reader"
|
||||
|
||||
var configuration = UICollectionLayoutListConfiguration(appearance: .insetGrouped)
|
||||
configuration.headerMode = .supplementary
|
||||
let layout = UICollectionViewCompositionalLayout.list(using: configuration)
|
||||
var config = UICollectionLayoutListConfiguration(appearance: .grouped)
|
||||
config.headerMode = .supplementary
|
||||
config.backgroundColor = .appBackground
|
||||
config.separatorConfiguration.topSeparatorVisibility = .visible
|
||||
config.separatorConfiguration.bottomSeparatorVisibility = .hidden
|
||||
config.itemSeparatorHandler = { indexPath, defaultConfig in
|
||||
var config = defaultConfig
|
||||
if indexPath.section == 0 && indexPath.row == 0 {
|
||||
config.topSeparatorVisibility = .hidden
|
||||
}
|
||||
return config
|
||||
}
|
||||
let layout = UICollectionViewCompositionalLayout.list(using: config)
|
||||
collectionView = UICollectionView(frame: view.bounds, collectionViewLayout: layout)
|
||||
collectionView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
||||
collectionView.delegate = self
|
||||
|
@ -77,7 +88,7 @@ class HomeViewController: UIViewController {
|
|||
config.text = section.title
|
||||
supplementaryView.contentConfiguration = config
|
||||
}
|
||||
let listCell = UICollectionView.CellRegistration<UICollectionViewListCell, Item> { cell, indexPath, item in
|
||||
let listCell = UICollectionView.CellRegistration<HomeCollectionViewCell, Item> { cell, indexPath, item in
|
||||
var config = UIListContentConfiguration.valueCell()
|
||||
config.text = item.title
|
||||
if let req = item.countFetchRequest,
|
||||
|
@ -195,7 +206,8 @@ extension HomeViewController: UICollectionViewDelegate {
|
|||
guard let item = dataSource.itemIdentifier(for: indexPath) else {
|
||||
return
|
||||
}
|
||||
let req = item.fetchRequest
|
||||
show(ItemsViewController(fervorController: fervorController, fetchRequest: req), sender: nil)
|
||||
let vc = ItemsViewController(fervorController: fervorController, fetchRequest: item.fetchRequest)
|
||||
vc.title = item.title
|
||||
show(vc, sender: nil)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import UIKit
|
||||
import SwiftSoup
|
||||
|
||||
class ItemCollectionViewCell: UICollectionViewCell {
|
||||
class ItemCollectionViewCell: UICollectionViewListCell {
|
||||
|
||||
private let titleLabel = UILabel()
|
||||
private let feedTitleLabel = UILabel()
|
||||
|
@ -17,6 +17,8 @@ class ItemCollectionViewCell: UICollectionViewCell {
|
|||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
|
||||
backgroundConfiguration = .clear()
|
||||
|
||||
let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .title3).withSymbolicTraits(.traitBold)!.withDesign(.serif)!
|
||||
titleLabel.font = UIFont(descriptor: descriptor, size: 0)
|
||||
titleLabel.numberOfLines = 0
|
||||
|
@ -25,13 +27,7 @@ class ItemCollectionViewCell: UICollectionViewCell {
|
|||
feedTitleLabel.textColor = .tintColor
|
||||
|
||||
contentLabel.font = UIFont(descriptor: .preferredFontDescriptor(withTextStyle: .body).withDesign(.serif)!, size: 0)
|
||||
contentLabel.textColor = UIColor(dynamicProvider: { traitCollection in
|
||||
if traitCollection.userInterfaceStyle == .dark {
|
||||
return .lightGray
|
||||
} else {
|
||||
return .darkGray
|
||||
}
|
||||
})
|
||||
contentLabel.textColor = .appContentPreviewLabel
|
||||
contentLabel.numberOfLines = 0
|
||||
|
||||
let stack = UIStackView(arrangedSubviews: [
|
||||
|
@ -48,6 +44,7 @@ class ItemCollectionViewCell: UICollectionViewCell {
|
|||
stack.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -20),
|
||||
stack.topAnchor.constraint(equalTo: topAnchor, constant: 8),
|
||||
stack.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -8),
|
||||
separatorLayoutGuide.leadingAnchor.constraint(equalTo: stack.leadingAnchor),
|
||||
])
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,8 @@ class ItemsViewController: UIViewController {
|
|||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
let configuration = UICollectionLayoutListConfiguration(appearance: .plain)
|
||||
var configuration = UICollectionLayoutListConfiguration(appearance: .plain)
|
||||
configuration.backgroundColor = .appBackground
|
||||
let layout = UICollectionViewCompositionalLayout.list(using: configuration)
|
||||
collectionView = UICollectionView(frame: view.bounds, collectionViewLayout: layout)
|
||||
collectionView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
||||
|
@ -51,10 +52,11 @@ class ItemsViewController: UIViewController {
|
|||
}
|
||||
|
||||
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
|
||||
let dataSource = UICollectionViewDiffableDataSource<Section, Item>(collectionView: collectionView) { collectionView, indexPath, item in
|
||||
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "itemCell", for: indexPath) as! ItemCollectionViewCell
|
||||
let itemCell = UICollectionView.CellRegistration<ItemCollectionViewCell, Item> { cell, indexPath, item in
|
||||
cell.updateUI(item: item)
|
||||
return cell
|
||||
}
|
||||
let dataSource = UICollectionViewDiffableDataSource<Section, Item>(collectionView: collectionView) { collectionView, indexPath, item in
|
||||
return collectionView.dequeueConfiguredReusableCell(using: itemCell, for: indexPath, item: item)
|
||||
}
|
||||
return dataSource
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
//
|
||||
// UIColor+App.swift
|
||||
// Reader
|
||||
//
|
||||
// Created by Shadowfacts on 1/9/22.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
extension UIColor {
|
||||
|
||||
static let appBackground = UIColor { traitCollection in
|
||||
switch traitCollection.userInterfaceStyle {
|
||||
case .dark:
|
||||
return UIColor(white: 0.1, alpha: 1)
|
||||
case .unspecified, .light:
|
||||
fallthrough
|
||||
@unknown default:
|
||||
return .white
|
||||
}
|
||||
}
|
||||
|
||||
static let appContentPreviewLabel = UIColor { traitCollection in
|
||||
switch traitCollection.userInterfaceStyle {
|
||||
case .dark:
|
||||
return .lightGray
|
||||
case .unspecified, .light:
|
||||
fallthrough
|
||||
@unknown default:
|
||||
return .darkGray
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue