2020-07-17 04:01:20 +02:00
//
// L a y o u t P r e f e r e n c e s V i e w . s w i f t
// M u l t i p l a t f o r m m a c O S
//
// C r e a t e d b y S t u a r t B r e c k e n r i d g e o n 1 7 / 7 / 2 0 .
// C o p y r i g h t © 2 0 2 0 R a n c h e r o S o f t w a r e . A l l r i g h t s r e s e r v e d .
//
import SwiftUI
struct LayoutPreferencesView : View {
2020-08-05 14:06:44 +02:00
@ StateObject private var defaults = AppDefaults . shared
2020-07-17 04:01:20 +02:00
private let colorPalettes = UserInterfaceColorPalette . allCases
2020-07-17 14:47:49 +02:00
private let sampleTitle = " Lorem dolor sed viverra ipsum. Gravida rutrum quisque non tellus. Rutrum tellus pellentesque eu tincidunt tortor. Sed blandit libero volutpat sed cras ornare. Et netus et malesuada fames ac. Ultrices eros in cursus turpis massa tincidunt dui ut ornare. Lacus sed viverra tellus in. Sollicitudin ac orci phasellus egestas. Purus in mollis nunc sed. Sollicitudin ac orci phasellus egestas tellus rutrum tellus pellentesque. Interdum consectetur libero id faucibus nisl tincidunt eget. "
2020-07-17 04:01:20 +02:00
var body : some View {
2020-07-17 14:47:49 +02:00
VStack {
Form {
Picker ( " Appearance " , selection : $ defaults . userInterfaceColorPalette , content : {
ForEach ( colorPalettes , id : \ . self , content : {
Text ( $0 . description )
} )
2020-07-17 04:01:20 +02:00
} )
2020-07-17 14:47:49 +02:00
Divider ( )
Text ( " Timeline: " )
Picker ( " Number of Lines " , selection : $ defaults . timelineNumberOfLines , content : {
ForEach ( 1. . < 6 , content : { i in
Text ( String ( i ) )
. tag ( Double ( i ) )
} )
} ) . padding ( . leading , 16 )
Slider ( value : $ defaults . timelineIconDimensions , in : 20. . . 60 , step : 10 , minimumValueLabel : Text ( " Small " ) , maximumValueLabel : Text ( " Large " ) , label : {
Text ( " Icon size " )
} ) . padding ( . leading , 16 )
}
2020-07-17 04:01:20 +02:00
2020-07-17 14:47:49 +02:00
timelineRowPreview
. frame ( width : 300 )
. padding ( )
. overlay (
RoundedRectangle ( cornerRadius : 8 , style : . continuous )
. stroke ( Color . gray , lineWidth : 1 )
)
. animation ( . default )
Text ( " PREVIEW " )
. font ( . caption )
. tracking ( 0.3 )
Spacer ( )
2020-07-17 04:01:20 +02:00
2020-07-17 14:47:49 +02:00
} . frame ( width : 400 , height : 300 , alignment : . center )
2020-07-17 04:01:20 +02:00
}
2020-07-17 14:47:49 +02:00
2020-08-13 16:25:34 +02:00
2020-07-17 14:47:49 +02:00
var timelineRowPreview : some View {
HStack ( alignment : . top ) {
Image ( systemName : " circle.fill " )
. resizable ( )
. frame ( width : 10 , height : 10 , alignment : . top )
. foregroundColor ( . accentColor )
Image ( systemName : " paperplane.circle " )
. resizable ( )
. frame ( width : CGFloat ( defaults . timelineIconDimensions ) , height : CGFloat ( defaults . timelineIconDimensions ) , alignment : . top )
. foregroundColor ( . accentColor )
VStack ( alignment : . leading , spacing : 4 ) {
Text ( sampleTitle )
. font ( . headline )
. lineLimit ( Int ( defaults . timelineNumberOfLines ) )
HStack {
Text ( " Feed Name " )
. foregroundColor ( . secondary )
. font ( . footnote )
Spacer ( )
Text ( " 10:31 " )
. font ( . footnote )
. foregroundColor ( . secondary )
}
}
}
}
2020-07-17 04:01:20 +02:00
}
struct SwiftUIView_Previews : PreviewProvider {
static var previews : some View {
LayoutPreferencesView ( )
}
}