2020-07-01 15:06:40 +02:00
//
// T i m e l i n e L a y o u t V i e w . s w i f t
// M u l t i p l a t f o r m i 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 / 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 TimelineLayoutView : View {
2020-07-06 11:54:11 +02:00
@ EnvironmentObject private var defaults : AppDefaults
2020-07-01 15:06:40 +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. "
var body : some View {
VStack ( spacing : 0 ) {
List {
Section ( header : Text ( " Icon Size " ) , content : {
iconSize
} )
Section ( header : Text ( " Number of Lines " ) , content : {
numberOfLines
} ) }
. listStyle ( InsetGroupedListStyle ( ) )
Divider ( )
timelineRowPreview . padding ( )
Divider ( )
}
. navigationBarTitle ( " Timeline Layout " )
}
var iconSize : some View {
2020-07-06 11:54:11 +02:00
Slider ( value : $ defaults . timelineIconDimensions , in : 20. . . 60 , step : 10 , minimumValueLabel : Text ( " Small " ) , maximumValueLabel : Text ( " Large " ) , label : {
Text ( String ( defaults . timelineIconDimensions ) )
2020-07-01 15:06:40 +02:00
} )
}
var numberOfLines : some View {
2020-07-06 11:54:11 +02:00
Slider ( value : $ defaults . timelineNumberOfLines , in : 1. . . 5 , step : 1 , minimumValueLabel : Text ( " 1 " ) , maximumValueLabel : Text ( " 5 " ) , label : {
Text ( " Article Title " )
2020-07-01 15:06:40 +02:00
} )
2020-07-06 11:54:11 +02:00
2020-07-01 15:06:40 +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 ( )
2020-07-06 11:54:11 +02:00
. frame ( width : CGFloat ( defaults . timelineIconDimensions ) , height : CGFloat ( defaults . timelineIconDimensions ) , alignment : . top )
2020-07-01 15:06:40 +02:00
. foregroundColor ( . accentColor )
VStack ( alignment : . leading , spacing : 4 ) {
Text ( sampleTitle )
. font ( . headline )
2020-07-06 11:54:11 +02:00
. lineLimit ( Int ( defaults . timelineNumberOfLines ) )
2020-07-01 15:06:40 +02:00
HStack {
Text ( " Feed Name " )
. foregroundColor ( . secondary )
. font ( . footnote )
Spacer ( )
Text ( " 10:31 " )
. font ( . footnote )
. foregroundColor ( . secondary )
}
}
}
}
}
struct TimelineLayout_Previews : PreviewProvider {
static var previews : some View {
TimelineLayoutView ( )
}
}