diff --git a/NightViewSampleProject/NightViewSampleProject.xcodeproj/project.pbxproj b/NightViewSampleProject/NightViewSampleProject.xcodeproj/project.pbxproj index b56dc57..a0bceb3 100644 --- a/NightViewSampleProject/NightViewSampleProject.xcodeproj/project.pbxproj +++ b/NightViewSampleProject/NightViewSampleProject.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ C31E42111D333B5C00A4A7A4 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C31E420F1D333B5C00A4A7A4 /* LaunchScreen.storyboard */; }; C31E42281D333BBB00A4A7A4 /* NightView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C31E42271D333BBB00A4A7A4 /* NightView.swift */; }; C3B4E3891D34020A0089FC02 /* NightViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B4E3881D34020A0089FC02 /* NightViewTests.swift */; }; + C3B4E38B1D34CC240089FC02 /* CustomizationTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B4E38A1D34CC240089FC02 /* CustomizationTableViewController.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -38,6 +39,7 @@ C31E421D1D333B5C00A4A7A4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; C31E42271D333BBB00A4A7A4 /* NightView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NightView.swift; sourceTree = ""; }; C3B4E3881D34020A0089FC02 /* NightViewTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NightViewTests.swift; sourceTree = ""; }; + C3B4E38A1D34CC240089FC02 /* CustomizationTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomizationTableViewController.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -82,6 +84,7 @@ children = ( C31E42061D333B5C00A4A7A4 /* AppDelegate.swift */, C31E42081D333B5C00A4A7A4 /* ViewController.swift */, + C3B4E38A1D34CC240089FC02 /* CustomizationTableViewController.swift */, C31E420A1D333B5C00A4A7A4 /* Main.storyboard */, C31E420D1D333B5C00A4A7A4 /* Assets.xcassets */, C31E420F1D333B5C00A4A7A4 /* LaunchScreen.storyboard */, @@ -210,6 +213,7 @@ buildActionMask = 2147483647; files = ( C31E42091D333B5C00A4A7A4 /* ViewController.swift in Sources */, + C3B4E38B1D34CC240089FC02 /* CustomizationTableViewController.swift in Sources */, C31E42281D333BBB00A4A7A4 /* NightView.swift in Sources */, C31E42071D333B5C00A4A7A4 /* AppDelegate.swift in Sources */, ); diff --git a/NightViewSampleProject/NightViewSampleProject/Base.lproj/Main.storyboard b/NightViewSampleProject/NightViewSampleProject/Base.lproj/Main.storyboard index 86f7a7e..72bc810 100644 --- a/NightViewSampleProject/NightViewSampleProject/Base.lproj/Main.storyboard +++ b/NightViewSampleProject/NightViewSampleProject/Base.lproj/Main.storyboard @@ -4,6 +4,7 @@ + @@ -36,9 +37,17 @@ + + @@ -50,6 +59,7 @@ + @@ -59,6 +69,503 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/NightViewSampleProject/NightViewSampleProject/CustomizationTableViewController.swift b/NightViewSampleProject/NightViewSampleProject/CustomizationTableViewController.swift new file mode 100644 index 0000000..bc151b5 --- /dev/null +++ b/NightViewSampleProject/NightViewSampleProject/CustomizationTableViewController.swift @@ -0,0 +1,136 @@ +// +// CustomizationTableViewController.swift +// NightViewSampleProject +// +// Created by Bobo on 7/11/16. +// Copyright © 2016 Boris Emorine. All rights reserved. +// + +import UIKit + +class CustomizationTableViewController: UITableViewController { + + @IBOutlet weak var numberOfPointsForStarLabel: UILabel! + @IBOutlet weak var starSizeLabel: UILabel! + @IBOutlet weak var starSizeMinRandomizerLabel: UILabel! + @IBOutlet weak var starSizeMaxRandomizerLabel: UILabel! + @IBOutlet weak var minStarOpacityLabel: UILabel! + @IBOutlet weak var glowingIntensityLabel: UILabel! + @IBOutlet weak var glowingDurationLabel: UILabel! + @IBOutlet weak var starTypeLabel: UILabel! + + @IBOutlet weak var numberOfPointsForStarSlider: UISlider! + @IBOutlet weak var starSizeSlider: UISlider! + @IBOutlet weak var starSizeMinRandomizerSlider: UISlider! + @IBOutlet weak var starSizeMaxRandomizerSlider: UISlider! + @IBOutlet weak var minStarOpacitySlider: UISlider! + @IBOutlet weak var glowingIntensitySlider: UISlider! + @IBOutlet weak var glowingDurationSlider: UISlider! + @IBOutlet weak var starTypeSegmentedControl: UISegmentedControl! + + var nightView: NightView? + + override func viewDidLoad() { + super.viewDidLoad() + + if let numberOfPointsForStar = nightView?.numberOfPointsForStar { + numberOfPointsForStarLabel.text = String(format: "%.1f", numberOfPointsForStar) + numberOfPointsForStarSlider.value = Float(numberOfPointsForStar) + } + + if let starSize = nightView?.starSize { + starSizeLabel.text = String(format: "%.1f", starSize) + starSizeSlider.value = Float(starSize) + } + + if let starSizeMinRandomizer = nightView?.starSizeMinRandomizer { + starSizeMinRandomizerLabel.text = String(format: "%.1f", starSizeMinRandomizer) + starSizeMinRandomizerSlider.value = Float(starSizeMinRandomizer) + } + + if let starSizeMaxRandomizer = nightView?.starSizeMaxRandomizer { + starSizeMaxRandomizerLabel.text = String(format: "%.1f", starSizeMaxRandomizer) + starSizeMaxRandomizerSlider.value = Float(starSizeMaxRandomizer) + } + + if let minStarOpacity = nightView?.minStarOpacity { + minStarOpacityLabel.text = String(format: "%.1f", minStarOpacity) + minStarOpacitySlider.value = Float(minStarOpacity) + } + + if let glowingIntensity = nightView?.glowingIntensity { + glowingIntensityLabel.text = String(format: "%.1f", glowingIntensity) + glowingIntensitySlider.value = Float(glowingIntensity) + } + + if let glowingDuration = nightView?.glowingDuration { + glowingDurationLabel.text = String(format: "%.1f", glowingDuration) + glowingDurationSlider.value = Float(glowingDuration) + } + + if let starType = nightView?.starType { + switch starType { + case .round: + starTypeSegmentedControl.selectedSegmentIndex = 0 + break + case .fiveBranchStar: + starTypeSegmentedControl.selectedSegmentIndex = 1 + break + } + } + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + } + + @IBAction func handleSlideNumberOfPointsForStarSlider(sender: UISlider) { + nightView?.numberOfPointsForStar = CGFloat(sender.value) + numberOfPointsForStarLabel.text = String(format: "%.1f", sender.value) + } + + @IBAction func handleStarSizeSlider(sender: UISlider) { + nightView?.starSize = CGFloat(sender.value) + starSizeLabel.text = String(format: "%.1f", sender.value) + } + + @IBAction func handleStarSizeMinRandomizerSlider(sender: UISlider) { + nightView?.starSizeMinRandomizer = Double(sender.value) + starSizeMinRandomizerLabel.text = String(format: "%.1f", sender.value) + } + + @IBAction func handleStarSizeMaxRandomizerSlider(sender: UISlider) { + nightView?.starSizeMaxRandomizer = Double(sender.value) + starSizeMaxRandomizerLabel.text = String(format: "%.1f", sender.value) + } + + @IBAction func handleMinStarOpacitySlider(sender: UISlider) { + nightView?.minStarOpacity = sender.value + minStarOpacityLabel.text = String(format: "%.1f", sender.value) + } + + @IBAction func handleGlowingIntensitySlider(sender: UISlider) { + nightView?.glowingIntensity = sender.value + glowingIntensityLabel.text = String(format: "%.1f", sender.value) + } + + @IBAction func handleGlowingDurationSlider(sender: UISlider) { + nightView?.glowingDuration = Double(sender.value) + glowingDurationLabel.text = String(format: "%.1f", sender.value) + } + + @IBAction func handleTapDoneButton(sender: AnyObject) { + dismissViewControllerAnimated(true, completion: nil) + } + + @IBAction func handleStarTypeSegmentedControl(sender: UISegmentedControl) { + switch sender.selectedSegmentIndex { + case 0: + nightView?.starType = .round + break + default: + nightView?.starType = .fiveBranchStar + break + } + } +} diff --git a/NightViewSampleProject/NightViewSampleProject/ViewController.swift b/NightViewSampleProject/NightViewSampleProject/ViewController.swift index 3729aa2..3f2ce40 100644 --- a/NightViewSampleProject/NightViewSampleProject/ViewController.swift +++ b/NightViewSampleProject/NightViewSampleProject/ViewController.swift @@ -14,14 +14,19 @@ class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() - // Dispose of any resources that can be recreated. } + override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { + if segue.identifier == "toCustomization" { + if let navVC = segue.destinationViewController as? UINavigationController, let customizationVC = navVC.topViewController as? CustomizationTableViewController { + customizationVC.nightView = nightView + } + } + } }