@@ -3,8 +3,7 @@ import Hue
33import Presentation
44
55class ViewController : PresentationController {
6-
7- struct BackgroundImage {
6+ private struct BackgroundImage {
87 let name : String
98 let left : CGFloat
109 let top : CGFloat
@@ -29,41 +28,43 @@ class ViewController: PresentationController {
2928 }
3029 }
3130
32- lazy var leftButton : UIBarButtonItem = { [ unowned self] in
31+ private lazy var leftButton : UIBarButtonItem = { [ unowned self] in
3332 let leftButton = UIBarButtonItem (
3433 title: " Previous " ,
3534 style: . plain,
3635 target: self ,
3736 action: #selector( moveBack) )
3837
3938 leftButton. setTitleTextAttributes (
40- [ NSForegroundColorAttributeName : UIColor . black] ,
41- for: . normal)
39+ [ NSAttributedStringKey . foregroundColor : UIColor . black] ,
40+ for: . normal
41+ )
4242
4343 return leftButton
44- } ( )
44+ } ( )
4545
46- lazy var rightButton : UIBarButtonItem = { [ unowned self] in
46+ private lazy var rightButton : UIBarButtonItem = { [ unowned self] in
4747 let rightButton = UIBarButtonItem (
4848 title: " Next " ,
4949 style: . plain,
5050 target: self ,
51- action: #selector( moveForward) )
51+ action: #selector( moveForward)
52+ )
5253
5354 rightButton. setTitleTextAttributes (
54- [ NSForegroundColorAttributeName : UIColor . black] ,
55- for: . normal)
55+ [ NSAttributedStringKey . foregroundColor : UIColor . black] ,
56+ for: . normal
57+ )
5658
5759 return rightButton
58- } ( )
60+ } ( )
5961
6062 override func viewDidLoad( ) {
6163 super. viewDidLoad ( )
6264
6365 setNavigationTitle = false
6466 navigationItem. leftBarButtonItem = leftButton
6567 navigationItem. rightBarButtonItem = rightButton
66-
6768 view. backgroundColor = UIColor ( hex: " FFBC00 " )
6869
6970 configureSlides ( )
@@ -72,15 +73,18 @@ class ViewController: PresentationController {
7273
7374 // MARK: - Configuration
7475
75- func configureSlides( ) {
76+ private func configureSlides( ) {
7677 let ratio : CGFloat = UIDevice . current. userInterfaceIdiom == . pad ? 1 : 0.6
7778 let font = UIFont ( name: " HelveticaNeue " , size: 34.0 * ratio) !
7879 let color = UIColor ( hex: " FFE8A9 " )
7980 let paragraphStyle = NSMutableParagraphStyle ( )
8081 paragraphStyle. alignment = NSTextAlignment . center
8182
82- let attributes = [ NSFontAttributeName: font, NSForegroundColorAttributeName: color,
83- NSParagraphStyleAttributeName: paragraphStyle]
83+ let attributes = [
84+ NSAttributedStringKey . font: font,
85+ NSAttributedStringKey . foregroundColor: color,
86+ NSAttributedStringKey . paragraphStyle: paragraphStyle
87+ ]
8488
8589 let titles = [
8690 " Parallax is a displacement or difference in the apparent position of an object viewed along two different lines of sight. " ,
@@ -101,14 +105,13 @@ class ViewController: PresentationController {
101105 for index in 0 ... 4 {
102106 let controller = SlideController ( contents: [ titles [ index] ] )
103107 controller. add ( animations: [ Content . centerTransition ( forSlideContent: titles [ index] ) ] )
104-
105108 slides. append ( controller)
106109 }
107110
108111 add ( slides)
109112 }
110113
111- func configureBackground( ) {
114+ private func configureBackground( ) {
112115 let backgroundImages = [
113116 BackgroundImage ( name: " Trees " , left: 0.0 , top: 0.743 , speed: - 0.3 ) ,
114117 BackgroundImage ( name: " Bus " , left: 0.02 , top: 0.77 , speed: 0.25 ) ,
@@ -136,23 +139,26 @@ class ViewController: PresentationController {
136139 for (column, backgroundImage) in backgroundImages. enumerated ( ) {
137140 if let position = backgroundImage. positionAt ( row) , let content = contents. at ( column) {
138141 addAnimation ( TransitionAnimation ( content: content, destination: position,
139- duration: 2.0 , damping: 1.0 ) , forPage: row)
142+ duration: 2.0 , damping: 1.0 ) , forPage: row)
140143 }
141144 }
142145 }
143146
144147 let groundView = UIView ( frame: CGRect ( x: 0 , y: 0 , width: 1024 , height: 60 ) )
145148 groundView. backgroundColor = UIColor ( hex: " FFCD41 " )
146- let groundContent = Content ( view: groundView,
147- position: Position ( left: 0.0 , bottom: 0.063 ) , centered: false )
148- contents. append ( groundContent)
149149
150+ let groundContent = Content (
151+ view: groundView,
152+ position: Position ( left: 0.0 , bottom: 0.063 ) ,
153+ centered: false
154+ )
155+
156+ contents. append ( groundContent)
150157 addToBackground ( [ groundContent] )
151158 }
152159}
153160
154- extension Array {
155-
161+ private extension Array {
156162 func at( _ index: Int ? ) -> Element ? {
157163 var object : Element ?
158164 if let index = index , index >= 0 && index < endIndex {
0 commit comments