Skip to content

Commit 808471e

Browse files
committed
style: Auto Lint & Format
1 parent ba51165 commit 808471e

5 files changed

Lines changed: 40 additions & 35 deletions

File tree

Examples/SingleNavigator/01-SingleBasic/SingleBasic/Page/Home/HomeView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct HomeView: View {
4242
Text("open Page 2 as Sheet")
4343
.foregroundColor(.purple)
4444
}
45-
45+
4646
Button(action: {
4747
if #available(iOS 15.0, *) {
4848
navigator.detentSheet(linkItem: .init(pathList: ["page1", "page2"]), isAnimated: true, configuration: .default)

Sources/LinkNavigator/Core/Core/DetentConfiguration.swift

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,9 @@ import UIKit
22

33
@available(iOS 15.0, *)
44
public struct DetentConfiguration {
5-
6-
public static let `default` = DetentConfiguration(detents: [.medium(), .large()])
7-
8-
public let detents: [UISheetPresentationController.Detent]
9-
public let cornerRadius: CGFloat?
10-
public let largestUndimmedDetentIdentifier: UISheetPresentationController.Detent.Identifier?
11-
public let prefersScrollingExpandsWhenScrolledToEdge: Bool
12-
public let prefersGrabberVisible: Bool
13-
public let prefersEdgeAttachedInCompactHeight: Bool
14-
public let widthFollowsPreferredContentSizeWhenEdgeAttached: Bool
15-
public let selectedDetentIdentifier: UISheetPresentationController.Detent.Identifier?
16-
5+
6+
// MARK: Lifecycle
7+
178
/// Initializes a new DetentConfiguration.
189
///
1910
/// - Parameters:
@@ -33,8 +24,8 @@ public struct DetentConfiguration {
3324
prefersGrabberVisible: Bool = false,
3425
prefersEdgeAttachedInCompactHeight: Bool = false,
3526
widthFollowsPreferredContentSizeWhenEdgeAttached: Bool = false,
36-
selectedDetentIdentifier: UISheetPresentationController.Detent.Identifier? = nil
37-
) {
27+
selectedDetentIdentifier: UISheetPresentationController.Detent.Identifier? = nil)
28+
{
3829
self.detents = detents
3930
self.cornerRadius = cornerRadius
4031
self.largestUndimmedDetentIdentifier = largestUndimmedDetentIdentifier
@@ -44,4 +35,17 @@ public struct DetentConfiguration {
4435
self.widthFollowsPreferredContentSizeWhenEdgeAttached = widthFollowsPreferredContentSizeWhenEdgeAttached
4536
self.selectedDetentIdentifier = selectedDetentIdentifier
4637
}
38+
39+
// MARK: Public
40+
41+
public static let `default` = DetentConfiguration(detents: [.medium(), .large()])
42+
43+
public let detents: [UISheetPresentationController.Detent]
44+
public let cornerRadius: CGFloat?
45+
public let largestUndimmedDetentIdentifier: UISheetPresentationController.Detent.Identifier?
46+
public let prefersScrollingExpandsWhenScrolledToEdge: Bool
47+
public let prefersGrabberVisible: Bool
48+
public let prefersEdgeAttachedInCompactHeight: Bool
49+
public let widthFollowsPreferredContentSizeWhenEdgeAttached: Bool
50+
public let selectedDetentIdentifier: UISheetPresentationController.Detent.Identifier?
4751
}

Sources/LinkNavigator/Core/Core/SingleLinkNavigator.swift

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ extension SingleLinkNavigator {
140140
private func _sheet(linkItem: LinkItem, isAnimated: Bool) {
141141
sheetOpen(item: linkItem, isAnimated: isAnimated)
142142
}
143-
143+
144144
/// Opens a sheet with the specified link item and an option to animate the presentation.
145145
///
146146
/// - Parameters:
@@ -151,9 +151,9 @@ extension SingleLinkNavigator {
151151
/// - Available from iOS 15.0 and later.
152152
@available(iOS 15.0, *)
153153
private func _detentSheet(linkItem: LinkItem, isAnimated: Bool, configuration: DetentConfiguration) {
154-
detentSheetOpen(item: linkItem, isAnimated: isAnimated, configuration: configuration)
155-
}
156-
154+
detentSheetOpen(item: linkItem, isAnimated: isAnimated, configuration: configuration)
155+
}
156+
157157
/// Opens a full-screen sheet with options for animation and large titles.
158158
///
159159
/// - Parameters:
@@ -414,7 +414,7 @@ extension SingleLinkNavigator {
414414
subController = newController
415415
}
416416
}
417-
417+
418418
@available(iOS 15.0, *)
419419
public func detentSheetOpen(
420420
item: LinkItem,
@@ -427,15 +427,17 @@ extension SingleLinkNavigator {
427427

428428
rootController.dismiss(animated: true)
429429
let newController = UINavigationController()
430-
430+
431431
if let sheetPresentationController = newController.sheetPresentationController {
432432
sheetPresentationController.detents = configuration.detents
433433
sheetPresentationController.preferredCornerRadius = configuration.cornerRadius
434434
sheetPresentationController.largestUndimmedDetentIdentifier = configuration.largestUndimmedDetentIdentifier
435-
sheetPresentationController.prefersScrollingExpandsWhenScrolledToEdge = configuration.prefersScrollingExpandsWhenScrolledToEdge
435+
sheetPresentationController.prefersScrollingExpandsWhenScrolledToEdge = configuration
436+
.prefersScrollingExpandsWhenScrolledToEdge
436437
sheetPresentationController.prefersGrabberVisible = configuration.prefersGrabberVisible
437438
sheetPresentationController.prefersEdgeAttachedInCompactHeight = configuration.prefersEdgeAttachedInCompactHeight
438-
sheetPresentationController.widthFollowsPreferredContentSizeWhenEdgeAttached = configuration.widthFollowsPreferredContentSizeWhenEdgeAttached
439+
sheetPresentationController.widthFollowsPreferredContentSizeWhenEdgeAttached = configuration
440+
.widthFollowsPreferredContentSizeWhenEdgeAttached
439441
sheetPresentationController.selectedDetentIdentifier = configuration.selectedDetentIdentifier
440442
}
441443

@@ -444,7 +446,7 @@ extension SingleLinkNavigator {
444446
animated: false)
445447

446448
rootController.present(newController, animated: isAnimated)
447-
449+
448450
subController = newController
449451
}
450452
}
@@ -482,13 +484,13 @@ extension SingleLinkNavigator: LinkNavigatorProtocol {
482484
public func sheet(linkItem: LinkItem, isAnimated: Bool) {
483485
_sheet(linkItem: linkItem, isAnimated: isAnimated)
484486
}
485-
487+
486488
@available(iOS 15.0, *)
487489
public func detentSheet(
488490
linkItem: LinkItem,
489491
isAnimated: Bool,
490-
configuration: DetentConfiguration
491-
) {
492+
configuration: DetentConfiguration)
493+
{
492494
_detentSheet(linkItem: linkItem, isAnimated: isAnimated, configuration: configuration)
493495
}
494496

Sources/LinkNavigator/Core/Protocol/LinkNavigatorProtocol.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public protocol LinkNavigatorProtocol {
2525
/// - linkItem: The link item to present.
2626
/// - isAnimated: A Boolean value that determines whether the presentation is animated.
2727
func sheet(linkItem: LinkItem, isAnimated: Bool)
28-
28+
2929
/// Presents a sheet with the given link item.
3030
///
3131
/// - Parameters:
@@ -36,11 +36,10 @@ public protocol LinkNavigatorProtocol {
3636
/// - Available from iOS 15.0 and later.
3737
@available(iOS 15.0, *)
3838
func detentSheet(
39-
linkItem: LinkItem,
40-
isAnimated: Bool,
41-
configuration: DetentConfiguration
42-
)
43-
39+
linkItem: LinkItem,
40+
isAnimated: Bool,
41+
configuration: DetentConfiguration)
42+
4443
/// Presents a full sheet with the given link item.
4544
///
4645
/// - Parameters:

Sources/LinkNavigator/Test/SingleLinkNavigatorMock.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ extension SingleLinkNavigatorMock: LinkNavigatorProtocol {
118118
public func sheet(linkItem _: LinkItem, isAnimated _: Bool) {
119119
event.sheet += 1
120120
}
121-
121+
122122
@available(iOS 15.0, *)
123-
public func detentSheet(linkItem: LinkItem, isAnimated: Bool, configuration: DetentConfiguration) {
123+
public func detentSheet(linkItem _: LinkItem, isAnimated _: Bool, configuration _: DetentConfiguration) {
124124
event.sheet += 1
125125
}
126126

0 commit comments

Comments
 (0)