Permalink
Browse files

Remove deferred protocols and rename standard implementations

  • Loading branch information...
danielsaidi committed Oct 8, 2018
1 parent 555c6f2 commit f97bc30ae1f45df907fc5cd3a10cf58fdf1b54b2
@@ -12,7 +12,9 @@ minor version bumps, but not on revision bumps.
This version has some breaking changes:
* The `DeferredHint` protocol has been removed
* The `DeferredTutorial` protocol has been removed
* `StandardDeferredHint` has been renamed to `DeferredHint`
* `StandardDeferredTutorial` has been renamed to `DeferredTutorial`
@@ -37,8 +37,7 @@
4552710F1FD7C18A00462ECD /* StandardTutorial.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4552710E1FD7C18A00462ECD /* StandardTutorial.swift */; };
4562D1AE1FDDC85F000069F3 /* TutorialViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4562D1AC1FDDC85F000069F3 /* TutorialViewController.xib */; };
4562D1B81FDE5D13000069F3 /* FadeInTransition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4562D1B71FDE5D13000069F3 /* FadeInTransition.swift */; };
45667A1C20D90FAE0002F257 /* DeferredTutorial.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45667A1B20D90FAE0002F257 /* DeferredTutorial.swift */; };
45667A1F20D957680002F257 /* StandardDeferredTutorial.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45667A1E20D957680002F257 /* StandardDeferredTutorial.swift */; };
45667A1F20D957680002F257 /* DeferredTutorial.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45667A1E20D957680002F257 /* DeferredTutorial.swift */; };
45667A2220D958F40002F257 /* MockTutorialPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45667A2120D958F40002F257 /* MockTutorialPresenter.swift */; };
45667A2420D959620002F257 /* StandardDeferredTutorialTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45667A2320D959620002F257 /* StandardDeferredTutorialTests.swift */; };
457046731FDDC15A00D16844 /* UIScrollView+Page.swift in Sources */ = {isa = PBXBuildFile; fileRef = 457046721FDDC15A00D16844 /* UIScrollView+Page.swift */; };
@@ -160,8 +159,7 @@
4552710E1FD7C18A00462ECD /* StandardTutorial.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StandardTutorial.swift; sourceTree = "<group>"; };
4562D1AC1FDDC85F000069F3 /* TutorialViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TutorialViewController.xib; sourceTree = "<group>"; };
4562D1B71FDE5D13000069F3 /* FadeInTransition.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FadeInTransition.swift; sourceTree = "<group>"; };
45667A1B20D90FAE0002F257 /* DeferredTutorial.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeferredTutorial.swift; sourceTree = "<group>"; };
45667A1E20D957680002F257 /* StandardDeferredTutorial.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StandardDeferredTutorial.swift; sourceTree = "<group>"; };
45667A1E20D957680002F257 /* DeferredTutorial.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeferredTutorial.swift; sourceTree = "<group>"; };
45667A2120D958F40002F257 /* MockTutorialPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockTutorialPresenter.swift; sourceTree = "<group>"; };
45667A2320D959620002F257 /* StandardDeferredTutorialTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StandardDeferredTutorialTests.swift; sourceTree = "<group>"; };
457046721FDDC15A00D16844 /* UIScrollView+Page.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIScrollView+Page.swift"; sourceTree = "<group>"; };
@@ -362,9 +360,8 @@
453EF4BD20D8CC0100C56DEB /* Models */ = {
isa = PBXGroup;
children = (
45667A1B20D90FAE0002F257 /* DeferredTutorial.swift */,
45A102751FD921E70032884A /* LocalizedTutorial.swift */,
45667A1E20D957680002F257 /* StandardDeferredTutorial.swift */,
45667A1E20D957680002F257 /* DeferredTutorial.swift */,
4552710E1FD7C18A00462ECD /* StandardTutorial.swift */,
4552710C1FD7BF9A00462ECD /* Tutorial.swift */,
);
@@ -666,7 +663,7 @@
45A102941FD939CA0032884A /* TutorialPresenter.swift in Sources */,
45CE37AF201670F9003384C2 /* AlertHintPresenter.swift in Sources */,
45B3AD531FDA0955005C590C /* TutorialViewControllerCell.swift in Sources */,
45667A1F20D957680002F257 /* StandardDeferredTutorial.swift in Sources */,
45667A1F20D957680002F257 /* DeferredTutorial.swift in Sources */,
453EF4AC20D7F17800C56DEB /* OnboardingPersistence.swift in Sources */,
452F92BF20D7D73C00B0A05D /* DeferredOnboarding.swift in Sources */,
45A1028C1FD935AA0032884A /* HintPresenter.swift in Sources */,
@@ -676,7 +673,6 @@
458021EB1FD7B87E00CE157F /* Hint.swift in Sources */,
4552710D1FD7BF9A00462ECD /* Tutorial.swift in Sources */,
457046731FDDC15A00D16844 /* UIScrollView+Page.swift in Sources */,
45667A1C20D90FAE0002F257 /* DeferredTutorial.swift in Sources */,
4587F63E201135170040E0D2 /* TutorialTransition.swift in Sources */,
4552710F1FD7C18A00462ECD /* StandardTutorial.swift in Sources */,
4537E8B11FD431A90007501C /* StandardHint.swift in Sources */,
@@ -1,11 +1,71 @@
//
// DeferredTutorial.swift
// StandardDeferredTutorial.swift
// Tutti
//
// Created by Daniel Saidi on 2018-06-19.
// Copyright © 2018 Daniel Saidi. All rights reserved.
//
import Foundation
/*
This is a standard implementation of the `DeferredTutorial`
protocol. You can use it as is or inherit it to create your
own specific hint types.
*/
public protocol DeferredTutorial: Tutorial, DeferredOnboarding { }
import UIKit
open class DeferredTutorial: StandardTutorial, DeferredOnboarding {
// MARK: - Initialization
public init(
identifier: String,
pageCount: Int,
requiredPresentationAttempts: Int,
userId: String? = nil,
keySegmentSeparator: String = "_",
persistence: OnboardingPersistence = UserDefaults.standard) {
self.requiredPresentationAttempts = requiredPresentationAttempts
super.init(
identifier: identifier,
pageCount: pageCount,
userId: userId,
keySegmentSeparator: keySegmentSeparator,
persistence: persistence)
}
public init(
fromLocalizationWithPageIndicationKey key: String,
identifier: String,
requiredPresentationAttempts: Int,
userId: String? = nil,
keySegmentSeparator: String = "_",
persistence: OnboardingPersistence = UserDefaults.standard) {
self.requiredPresentationAttempts = requiredPresentationAttempts
super.init(
fromLocalizationWithPageIndicationKey: key,
identifier: identifier,
userId: userId,
keySegmentSeparator: keySegmentSeparator,
persistence: persistence)
}
// MARK: - Properties
public let requiredPresentationAttempts: Int
open override var shouldBePresented: Bool {
return super.shouldBePresented && remainingPresentationAttempts == 0
}
// MARK: - Public Functions
open override func prepareForPresentation() {
registerPresentationAttempt()
}
}

This file was deleted.

Oops, something went wrong.
@@ -26,7 +26,7 @@ extension ViewController {
}
func getDeferredTutorial(forUser userId: String?) -> DeferredTutorial {
return StandardDeferredTutorial(
return DeferredTutorial(
identifier: "deferred",
pageCount: 3,
requiredPresentationAttempts: 5,
@@ -37,10 +37,10 @@ class MockHintPresenter: HintPresenter {
presentInvokeViews.append(view)
}
func present(_ hint: Hint, in vc: UIViewController, from item: UIBarButtonItem) {
func present(_ hint: Hint, in vc: UIViewController, from barButtonItem: UIBarButtonItem) {
presentInvokeCount += 1
presentInvokeHints.append(hint)
presentInvokeVcs.append(vc)
presentInvokeItems.append(item)
presentInvokeItems.append(barButtonItem)
}
}
@@ -22,8 +22,8 @@ class StandardDeferredHintTests: QuickSpec {
presenter = MockHintPresenter()
}
func createHint(requiredPresentationAttempts: Int) -> StandardDeferredHint {
return StandardDeferredHint(
func createHint(requiredPresentationAttempts: Int) -> DeferredHint {
return DeferredHint(
identifier: "hint",
title: "foo",
text: "bar",
@@ -46,7 +46,7 @@ class StandardDeferredHintTests: QuickSpec {
}
it("uses user default persistence by default") {
let hint = StandardDeferredHint(identifier: "", title: "", text: "", requiredPresentationAttempts: 121, userId: "")
let hint = DeferredHint(identifier: "", title: "", text: "", requiredPresentationAttempts: 121, userId: "")
expect(hint.persistence).to(be(UserDefaults.standard))
}
}
@@ -22,8 +22,8 @@ class StandardDeferredTutorialTests: QuickSpec {
presenter = MockTutorialPresenter()
}
func createTutorial(requiredPresentationAttempts: Int) -> StandardDeferredTutorial {
return StandardDeferredTutorial(
func createTutorial(requiredPresentationAttempts: Int) -> DeferredTutorial {
return DeferredTutorial(
identifier: "foo",
pageCount: 3,
requiredPresentationAttempts: requiredPresentationAttempts,
@@ -46,7 +46,7 @@ class StandardDeferredTutorialTests: QuickSpec {
}
it("uses user default persistence by default") {
let tutorial = StandardDeferredTutorial(identifier: "", pageCount: 1, requiredPresentationAttempts: 121)
let tutorial = DeferredTutorial(identifier: "", pageCount: 1, requiredPresentationAttempts: 121)
expect(tutorial.persistence).to(be(UserDefaults.standard))
}
}

0 comments on commit f97bc30

Please sign in to comment.