File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99import Setting
1010import SwiftUI
1111
12- class PlaygroundSettingViewModel : ObservableObject { }
13-
1412struct PlaygroundSettingView : View {
1513 var body : some View {
1614 SettingStack {
1715 SettingPage ( title: " Settings " ) {
1816 SettingGroup {
1917 SettingPage ( title: " Subsettings " ) {
20- SettingGroup {
21-
22- }
18+ SettingGroup { }
2319 }
20+ . previewIcon ( " star.fill " )
2421 }
2522 }
2623 }
2724 }
2825}
26+
2927struct PlaygroundSettingView_Previews : PreviewProvider {
3028 static var previews : some View {
3129 PlaygroundSettingView ( )
3230 }
3331}
32+
33+ class PlaygroundSettingViewModel : ObservableObject { }
Original file line number Diff line number Diff line change @@ -70,10 +70,31 @@ public struct SettingPage: SettingItem {
7070 }
7171}
7272
73+ /// Convenience modifiers.
74+ public extension SettingPage {
75+ func previewIcon( _ icon: String , backgroundColor: Color = . blue) -> SettingPage {
76+ var page = self
77+ page. previewConfiguration. icon = . system( icon: icon, backgroundColor: backgroundColor)
78+ return page
79+ }
80+
81+ func previewIcon( icon: SettingIcon ) -> SettingPage {
82+ var page = self
83+ page. previewConfiguration. icon = icon
84+ return page
85+ }
86+
87+ func previewIndicator( _ indicator: String ) -> SettingPage {
88+ var page = self
89+ page. previewConfiguration. indicator = indicator
90+ return page
91+ }
92+ }
93+
7394struct SettingPageView < Content> : View where Content: View {
7495 var title : String
7596 var spacing = CGFloat ( 20 )
76- var verticalPadding = CGFloat ( 6 )
97+ var verticalPadding = CGFloat ( 12 )
7798 var backgroundColor = Setting . secondaryBackgroundColor
7899 var navigationTitleDisplayMode = SettingPage . NavigationTitleDisplayMode. inline
79100 var isInitialPage = false
You can’t perform that action at this time.
0 commit comments