Skip to content

Commit

Permalink
refactor: Refactor var name and modify guard
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthieu-dgl committed Oct 29, 2024
1 parent 44d5410 commit f7401fa
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ public struct SelfSizingPanelBackportViewModifier: ViewModifier {
return topPadding + titleSpacing + UIFont.preferredFont(forTextStyle: .headline).pointSize
}

private var shouldShowCloseButton: Bool {
private var isCompactMode: Bool {
return !isCompactWindow || (UIDevice.current.orientation.isLandscape && UIDevice.current.userInterfaceIdiom != .pad)
}

private var shouldShowHeader: Bool {
return title != nil || shouldShowCloseButton
return title != nil || isCompactMode
}

public init(dragIndicator: Visibility = Visibility.visible, title: String? = nil) {
Expand All @@ -119,7 +119,7 @@ public struct SelfSizingPanelBackportViewModifier: ViewModifier {
.font(Font(UIFont.preferredFont(forTextStyle: .headline)))
}

if shouldShowCloseButton {
if isCompactMode {
FloatingPanelCloseButton(size: .medium, dismissAction: dismiss)
.frame(maxWidth: .infinity, alignment: .trailing)
.padding(.trailing, value: .medium)
Expand Down Expand Up @@ -171,12 +171,12 @@ public struct SelfSizingPanelViewModifier: ViewModifier {
return topPadding + titleSpacing + UIFont.preferredFont(forTextStyle: .headline).pointSize
}

private var shouldShowCloseButton: Bool {
private var isCompactMode: Bool {
return !isCompactWindow || (UIDevice.current.orientation.isLandscape && UIDevice.current.userInterfaceIdiom != .pad)
}

private var shouldShowHeader: Bool {
return title != nil || shouldShowCloseButton
return title != nil || isCompactMode
}

public init(dragIndicator: Visibility = Visibility.visible, title: String? = nil) {
Expand All @@ -193,7 +193,7 @@ public struct SelfSizingPanelViewModifier: ViewModifier {
.font(Font(UIFont.preferredFont(forTextStyle: .headline)))
}

if shouldShowCloseButton {
if isCompactMode {
FloatingPanelCloseButton(size: .medium, dismissAction: dismiss)
.frame(maxWidth: .infinity, alignment: .trailing)
.padding(.trailing, value: .medium)
Expand All @@ -206,7 +206,7 @@ public struct SelfSizingPanelViewModifier: ViewModifier {
.padding(.bottom, value: .medium)
}
.introspect(.scrollView, on: .iOS(.v16, .v17, .v18)) { scrollView in
guard selection != .height(headerSize) else { return }
guard isCompactMode else { return }
let totalPanelContentHeight = scrollView.contentSize.height + headerSize
guard selection != .height(totalPanelContentHeight) else { return }

Expand Down

0 comments on commit f7401fa

Please sign in to comment.