-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
19 changed files
with
205 additions
and
162 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
43 changes: 43 additions & 0 deletions
43
PlatformRouting/PlatformRouting/_iOS/_Transitions/PointsRating.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,43 @@ | ||
// | ||
// PointedRating.swift | ||
// Utilities | ||
// | ||
// Created by Qiang Huang on 9/19/19. | ||
// Copyright © 2019 dYdX. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
open class PointsRating: NSObject, RatingProtocol { | ||
public func add(points: Int) { | ||
self.points = self.points + points | ||
} | ||
|
||
private var pointsKey: String { | ||
return "\(String(describing: className)).points" | ||
} | ||
|
||
private var threshold: Int | ||
|
||
open var points: Int { | ||
get { | ||
return UserDefaults.standard.integer(forKey: pointsKey) | ||
} | ||
set { | ||
if newValue >= threshold { | ||
promptForRating() | ||
UserDefaults.standard.set(0, forKey: pointsKey) | ||
} else { | ||
UserDefaults.standard.set(newValue, forKey: pointsKey) | ||
} | ||
} | ||
} | ||
|
||
public init(threshold: Int) { | ||
self.threshold = threshold | ||
super.init() | ||
} | ||
|
||
open func promptForRating() { | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
PlatformRouting/PlatformRouting/_iOS/_Transitions/RatingService.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,17 @@ | ||
// | ||
// RatingService.swift | ||
// Utilities | ||
// | ||
// Created by Qiang Huang on 9/19/19. | ||
// Copyright © 2019 dYdX. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public protocol RatingProtocol: NSObjectProtocol { | ||
func add(points: Int) | ||
} | ||
|
||
public class RatingService { | ||
public static var shared: RatingProtocol? | ||
} |
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.