-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c240a1f
commit f4d6203
Showing
13 changed files
with
295 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...WheelDemoiOS/SwiftFortuneWheelDemoiOS/Example2ViewController/Example2ViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// Example2ViewController.swift | ||
// SwiftFortuneWheelDemoiOS | ||
// | ||
// Created by Sherzod Khashimov on 6/25/20. | ||
// Copyright © 2020 Sherzod Khashimov. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import SwiftFortuneWheel | ||
|
||
class Example2ViewController: UIViewController { | ||
|
||
lazy var fortuneWheel: SwiftFortuneWheel = { | ||
var slices: [Slice] = [] | ||
|
||
for index in 1...4 { | ||
let headerContent = Slice.ContentType.text(text: "\(index)", preferenes: .example2AmountTextPreferences) | ||
let descriptionContent = Slice.ContentType.text(text: "DESCRIPTION", preferenes: .example2DescriptionTextPreferences) | ||
let slice = Slice(contents: [headerContent, descriptionContent]) | ||
slices.append(slice) | ||
} | ||
|
||
let frame = CGRect(x: 35, y: 100, width: 300, height: 300) | ||
|
||
let fortuneWheel = SwiftFortuneWheel(frame: frame, slices: slices, configuration: .example2Configuration) | ||
|
||
fortuneWheel.isPinHidden = true | ||
fortuneWheel.isSpinHidden = true | ||
return fortuneWheel | ||
}() | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
self.title = "Example2" | ||
|
||
view.addSubview(fortuneWheel) | ||
layoutWheel() | ||
|
||
} | ||
|
||
func layoutWheel() { | ||
guard let superview = fortuneWheel.superview else { return } | ||
fortuneWheel.translatesAutoresizingMaskIntoConstraints = false | ||
fortuneWheel.widthAnchor.constraint(equalToConstant: 300).isActive = true | ||
fortuneWheel.heightAnchor.constraint(equalToConstant: 300).isActive = true | ||
fortuneWheel.centerYAnchor.constraint(equalTo: superview.centerYAnchor).isActive = true | ||
fortuneWheel.centerXAnchor.constraint(equalTo: superview.centerXAnchor).isActive = true | ||
} | ||
|
||
} |
95 changes: 95 additions & 0 deletions
95
...tFortuneWheelDemoiOS/Example2ViewController/SwiftFortuneWheelConfiguration+Example2.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// | ||
// SwiftFortuneWheelConfiguration+Example2.swift | ||
// SwiftFortuneWheelDemoiOS | ||
// | ||
// Created by Sherzod Khashimov on 6/25/20. | ||
// Copyright © 2020 Sherzod Khashimov. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
import SwiftFortuneWheel | ||
|
||
private let circleStrokeWidth: CGFloat = 2 | ||
private let blackColor = UIColor(white: 51.0 / 255.0, alpha: 1.0) | ||
private let redColor = UIColor.red | ||
|
||
public extension SwiftFortuneWheelConfiguration { | ||
static var example2Configuration: SwiftFortuneWheelConfiguration { | ||
let configuration = SwiftFortuneWheelConfiguration(spinButtonPreferences: .example2SpinButtonPreferences, | ||
pinPreferences: .example2PinPreferences, | ||
wheelPreferences: .example2WheelPreferences) | ||
|
||
return configuration | ||
} | ||
} | ||
|
||
public extension SwiftFortuneWheelConfiguration.SpinButtonPreferences { | ||
static var example2SpinButtonPreferences: SwiftFortuneWheelConfiguration.SpinButtonPreferences { | ||
let preferences = SwiftFortuneWheelConfiguration.SpinButtonPreferences(size: CGSize(width: 80, height: 80), | ||
cornerRadius: 40, | ||
textColor: .white, | ||
font: .systemFont(ofSize: 20, weight: .bold), | ||
backgroundColor: blackColor) | ||
return preferences | ||
} | ||
} | ||
|
||
public extension SwiftFortuneWheelConfiguration.PinImageViewPreferences { | ||
static var example2PinPreferences: SwiftFortuneWheelConfiguration.PinImageViewPreferences { | ||
let preferences = SwiftFortuneWheelConfiguration.PinImageViewPreferences(size: CGSize(width: 12, height: 24), | ||
position: .top, | ||
verticalOffset: 30) | ||
return preferences | ||
} | ||
} | ||
|
||
public extension SwiftFortuneWheelConfiguration.WheelPreferences { | ||
static var example2WheelPreferences: SwiftFortuneWheelConfiguration.WheelPreferences { | ||
let preferences = SwiftFortuneWheelConfiguration.WheelPreferences(circlePreferences: .example2CirclePreferences, | ||
slicePreferences: .example2SlicePreferenes) | ||
return preferences | ||
} | ||
} | ||
|
||
public extension SwiftFortuneWheelConfiguration.CirclePreferences { | ||
static var example2CirclePreferences: SwiftFortuneWheelConfiguration.CirclePreferences { | ||
let preferences = SwiftFortuneWheelConfiguration.CirclePreferences(strokeWidth: circleStrokeWidth, | ||
strokeColor: blackColor) | ||
return preferences | ||
} | ||
} | ||
|
||
public extension SwiftFortuneWheelConfiguration.SlicePreferences { | ||
static var example2SlicePreferenes: SwiftFortuneWheelConfiguration.SlicePreferences { | ||
let backgroundColorType = SwiftFortuneWheelConfiguration.ColorType.evenOddColors(evenColor: blackColor, oddColor: redColor) | ||
let preferences = SwiftFortuneWheelConfiguration.SlicePreferences(backgroundColorType: backgroundColorType, | ||
strokeWidth: 1, | ||
strokeColor: blackColor) | ||
return preferences | ||
} | ||
} | ||
|
||
public extension TextPreferences { | ||
static var example2AmountTextPreferences: TextPreferences { | ||
let textColorType = SwiftFortuneWheelConfiguration.ColorType.customPatternColors(colors: nil, defaultColor: .white) | ||
let font = UIFont.systemFont(ofSize: 22, weight: .bold) | ||
let prefenreces = TextPreferences(textColorType: textColorType, | ||
font: font, | ||
verticalOffset: 10, | ||
isCurved: true) | ||
return prefenreces | ||
} | ||
|
||
static var example2DescriptionTextPreferences: TextPreferences { | ||
let textColorType = SwiftFortuneWheelConfiguration.ColorType.customPatternColors(colors: nil, defaultColor: .white) | ||
let font = UIFont.systemFont(ofSize: 12, weight: .bold) | ||
let prefenreces = TextPreferences(textColorType: textColorType, | ||
font: font, | ||
verticalOffset: 10, | ||
orientation: .vertical, | ||
flipUpsideDown: false, | ||
isCurved: false) | ||
return prefenreces | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.