Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 4be9a93

Browse files
authored
Add insets to readme (#2038)
* fix build error from #2037 * inset readmes
1 parent e6a83f8 commit 4be9a93

File tree

6 files changed

+55
-15
lines changed

6 files changed

+55
-15
lines changed

Classes/Issues/IssuesViewController.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ final class IssuesViewController:
4040
private var bookmarkNavController: BookmarkNavigationController? = nil
4141
private var autocompleteController: AutocompleteController!
4242
private let manageController: IssueManagingContextController
43+
private let threadInset = UIEdgeInsets(
44+
top: Styles.Sizes.rowSpacing / 2,
45+
left: Styles.Sizes.gutter,
46+
bottom: 2 * Styles.Sizes.rowSpacing + Styles.Sizes.tableCellHeight,
47+
right: Styles.Sizes.gutter
48+
)
4349

4450
private var needsScrollToBottom = false
4551
private var lastTimelineElement: ListDiffable?
@@ -49,7 +55,7 @@ final class IssuesViewController:
4955

5056
lazy private var feed: Feed = {
5157
let f = Feed(viewController: self, delegate: self, managesLayout: false)
52-
f.collectionView.contentInset = Styles.Sizes.threadInset
58+
f.collectionView.contentInset = threadInset
5359
f.collectionView.backgroundColor = .white
5460
return f
5561
}()
@@ -209,7 +215,7 @@ final class IssuesViewController:
209215

210216
override func viewSafeAreaInsetsDidChange() {
211217
super.viewSafeAreaInsetsDidChange()
212-
feed.collectionView.updateSafeInset(container: view, base: Styles.Sizes.threadInset)
218+
feed.collectionView.updateSafeInset(container: view, base: threadInset)
213219
}
214220

215221
override func didLayout() {

Classes/PullRequestReviews/PullRequestReviewCommentsViewController.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,16 @@ final class PullRequestReviewCommentsViewController: MessageViewController,
2424
private let textActionsController = TextActionsController()
2525
private var autocompleteController: AutocompleteController!
2626
private var focusedReplyModel: PullRequestReviewReplyModel?
27+
private let threadInset = UIEdgeInsets(
28+
top: Styles.Sizes.rowSpacing,
29+
left: Styles.Sizes.gutter,
30+
bottom: Styles.Sizes.rowSpacing,
31+
right: Styles.Sizes.gutter
32+
)
2733

2834
lazy private var feed: Feed = {
2935
let f = Feed(viewController: self, delegate: self, managesLayout: false)
30-
f.collectionView.contentInset = Styles.Sizes.threadInset
36+
f.collectionView.contentInset = threadInset
3137
f.collectionView.backgroundColor = .white
3238
return f
3339
}()
@@ -90,8 +96,7 @@ final class PullRequestReviewCommentsViewController: MessageViewController,
9096

9197
override func viewSafeAreaInsetsDidChange() {
9298
super.viewSafeAreaInsetsDidChange()
93-
feed.collectionView.updateSafeInset(container: view, base: Styles.Sizes.threadInset)
94-
99+
feed.collectionView.updateSafeInset(container: view, base: threadInset)
95100
}
96101

97102
// MARK: FeedDelegate

Classes/Repository/RepositoryOverviewViewController.swift

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,34 @@ import UIKit
1010
import IGListKit
1111
import GitHubAPI
1212

13+
class HackScrollIndicatorInsetsCollectionView: UICollectionView {
14+
override var scrollIndicatorInsets: UIEdgeInsets {
15+
set {
16+
super.scrollIndicatorInsets = UIEdgeInsets(top: newValue.top, left: 0, bottom: newValue.bottom, right: 0)
17+
}
18+
get { return super.scrollIndicatorInsets }
19+
}
20+
}
21+
1322
class RepositoryOverviewViewController: BaseListViewController<NSString>,
1423
BaseListViewControllerDataSource {
1524

1625
private let repo: RepositoryDetails
1726
private let client: RepositoryClient
1827
private var readme: RepositoryReadmeModel?
1928

29+
// lazy var _feed: Feed = { Feed(
30+
// viewController: self,
31+
// delegate: self,
32+
// collectionView: HackScrollIndicatorInsetsCollectionView(
33+
// frame: .zero,
34+
// collectionViewLayout: ListCollectionViewLayout.basic()
35+
// ))
36+
// }()
37+
// override var feed: Feed {
38+
// return _feed
39+
// }
40+
2041
init(client: GithubClient, repo: RepositoryDetails) {
2142
self.repo = repo
2243
self.client = RepositoryClient(githubClient: client, owner: repo.owner, name: repo.name)
@@ -25,6 +46,12 @@ BaseListViewControllerDataSource {
2546
)
2647
self.dataSource = self
2748
title = NSLocalizedString("Overview", comment: "")
49+
// self.feed.collectionView.contentInset = UIEdgeInsets(
50+
// top: Styles.Sizes.rowSpacing,
51+
// left: Styles.Sizes.gutter,
52+
// bottom: Styles.Sizes.rowSpacing,
53+
// right: Styles.Sizes.gutter
54+
// )
2855
}
2956

3057
required init?(coder aDecoder: NSCoder) {
@@ -41,7 +68,8 @@ BaseListViewControllerDataSource {
4168

4269
override func fetch(page: NSString?) {
4370
let repo = self.repo
44-
let width = view.bounds.width
71+
// let contentInset = feed.collectionView.contentInset
72+
let width = view.bounds.width - Styles.Sizes.gutter * 2
4573
let contentSizeCategory = UIContentSizeCategory.preferred
4674

4775
client.githubClient.client

Classes/Repository/RepositoryReadmeSectionController.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ ListBindingSectionControllerDataSource {
2525
override init() {
2626
super.init()
2727
dataSource = self
28+
inset = UIEdgeInsets(top: 0, left: Styles.Sizes.gutter, bottom: 0, right: Styles.Sizes.gutter)
2829
}
2930

3031
// MARK: ListBindingSectionControllerDataSource
@@ -41,14 +42,16 @@ ListBindingSectionControllerDataSource {
4142
sizeForViewModel viewModel: Any,
4243
at index: Int
4344
) -> CGSize {
44-
guard let width = collectionContext?.containerSize.width else { fatalError("Missing context") }
45+
guard let width = collectionContext?.containerSize.width
46+
else { fatalError("Missing context") }
47+
let insetWidth = width - inset.left - inset.right
4548
let height = BodyHeightForComment(
4649
viewModel: viewModel,
47-
width: width,
50+
width: insetWidth,
4851
webviewCache: webviewCache,
4952
imageCache: imageCache
5053
)
51-
return CGSize(width: width, height: height)
54+
return CGSize(width: insetWidth, height: height)
5255
}
5356

5457
func sectionController(

Classes/Views/Styles.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ enum Styles {
4343
static let labelSpacing: CGFloat = 8
4444
static let labelTextPadding: CGFloat = 4
4545
static let cardCornerRadius: CGFloat = 6
46-
static let threadInset = UIEdgeInsets(
47-
top: rowSpacing / 2,
48-
left: gutter,
49-
bottom: 2 * rowSpacing + tableCellHeight,
50-
right: gutter
51-
)
5246
static let maxImageHeight: CGFloat = 300
5347
static let contextMenuSize: CGSize = CGSize(width: 280, height: 240)
5448

Freetime.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@
205205
2963A93B1EE25F6F0066509C /* LabelableFields+IssueLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2963A93A1EE25F6F0066509C /* LabelableFields+IssueLabelModel.swift */; };
206206
2965F3702071508C003CC92F /* StyledTextBuilder+Checkbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2965F36F2071508C003CC92F /* StyledTextBuilder+Checkbox.swift */; };
207207
2965F37220715161003CC92F /* StyledTextBuilder+NewBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2965F37120715161003CC92F /* StyledTextBuilder+NewBase.swift */; };
208+
2967DC56211751CB00FD3683 /* UIContentSizeCategory+Preferred.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2967DC55211751CB00FD3683 /* UIContentSizeCategory+Preferred.swift */; };
208209
29693EE520FAA05F00336200 /* IssueAutocomplete.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29693EE420FAA05F00336200 /* IssueAutocomplete.swift */; };
209210
296A4960210E7B9A00BBBF2B /* IssueDetailBadgeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 296A495F210E7B9A00BBBF2B /* IssueDetailBadgeView.swift */; };
210211
296A4962210E7E0E00BBBF2B /* CheckIfSentWithGitHawk.swift in Sources */ = {isa = PBXBuildFile; fileRef = 296A4961210E7E0E00BBBF2B /* CheckIfSentWithGitHawk.swift */; };
@@ -716,6 +717,7 @@
716717
2963A93A1EE25F6F0066509C /* LabelableFields+IssueLabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "LabelableFields+IssueLabelModel.swift"; sourceTree = "<group>"; };
717718
2965F36F2071508C003CC92F /* StyledTextBuilder+Checkbox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "StyledTextBuilder+Checkbox.swift"; sourceTree = "<group>"; };
718719
2965F37120715161003CC92F /* StyledTextBuilder+NewBase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "StyledTextBuilder+NewBase.swift"; sourceTree = "<group>"; };
720+
2967DC55211751CB00FD3683 /* UIContentSizeCategory+Preferred.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIContentSizeCategory+Preferred.swift"; sourceTree = "<group>"; };
719721
29693EE420FAA05F00336200 /* IssueAutocomplete.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IssueAutocomplete.swift; sourceTree = "<group>"; };
720722
296A495F210E7B9A00BBBF2B /* IssueDetailBadgeView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IssueDetailBadgeView.swift; sourceTree = "<group>"; };
721723
296A4961210E7E0E00BBBF2B /* CheckIfSentWithGitHawk.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckIfSentWithGitHawk.swift; sourceTree = "<group>"; };
@@ -2046,6 +2048,7 @@
20462048
DCA5ED111FAEE3AE0072F074 /* Store.swift */,
20472049
29B75ADC210AA14F00C28131 /* String+Size.swift */,
20482050
754488B01F7ADF8D0032D08C /* UIAlertController+Action.swift */,
2051+
2967DC55211751CB00FD3683 /* UIContentSizeCategory+Preferred.swift */,
20492052
98835BCD1F1965E2005BA24F /* UIDevice+Model.swift */,
20502053
98B5A0851F6D0FFE000617D6 /* UINavigationController+Replace.swift */,
20512054
299F63DF205DDF6B0015D901 /* UIViewController+Routing.swift */,
@@ -2746,6 +2749,7 @@
27462749
292FCAF71EDFCC510026635E /* IssueCommentCodeBlockModel.swift in Sources */,
27472750
292FCAF91EDFCC510026635E /* IssueCommentDetailCell.swift in Sources */,
27482751
DC3238931F9BA29D007DD924 /* SearchQuery.swift in Sources */,
2752+
2967DC56211751CB00FD3683 /* UIContentSizeCategory+Preferred.swift in Sources */,
27492753
7BBFEE5B1F8A8A0400C68E47 /* SearchBarSectionController.swift in Sources */,
27502754
292FCAFA1EDFCC510026635E /* IssueCommentDetailsViewModel.swift in Sources */,
27512755
2949674E1EF9719300B1CF1A /* IssueCommentHrCell.swift in Sources */,

0 commit comments

Comments
 (0)