Refactor sidebar styling to remove duplicate code

This commit is contained in:
Maurice Parker
2020-07-06 01:32:43 -05:00
parent bcbb38c120
commit 6695fcfca7
6 changed files with 87 additions and 60 deletions

View File

@@ -0,0 +1,34 @@
//
// SidebarStyleModifier.swift
// NetNewsWire
//
// Created by Maurice Parker on 7/6/20.
// Copyright © 2020 Ranchero Software. All rights reserved.
//
import SwiftUI
struct SidebarListStyleModifier: ViewModifier {
#if os(iOS)
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
#endif
@ViewBuilder func body(content: Content) -> some View {
content
#if os(macOS)
content
.listStyle(SidebarListStyle())
#else
if horizontalSizeClass == .compact {
content
.listStyle(PlainListStyle())
} else {
content
.listStyle(SidebarListStyle())
}
#endif
}
}