Skip to content

Commit

Permalink
Release Authenticator 2.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrubin authored Apr 26, 2019
2 parents 1fdcbd4 + 2bd4a51 commit 9cf2b97
Show file tree
Hide file tree
Showing 26 changed files with 202 additions and 159 deletions.
25 changes: 5 additions & 20 deletions Authenticator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,6 @@
C944A5731A7F772600E08B1E /* iOS-Application.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "iOS-Application.xcconfig"; sourceTree = "<group>"; };
C944A5751A7F772600E08B1E /* iOS-Framework.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "iOS-Framework.xcconfig"; sourceTree = "<group>"; };
C944A5761A7F772600E08B1E /* iOS-StaticLibrary.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "iOS-StaticLibrary.xcconfig"; sourceTree = "<group>"; };
C944A5781A7F772600E08B1E /* Mac-Application.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Mac-Application.xcconfig"; sourceTree = "<group>"; };
C944A57A1A7F772600E08B1E /* Mac-DynamicLibrary.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Mac-DynamicLibrary.xcconfig"; sourceTree = "<group>"; };
C944A57B1A7F772600E08B1E /* Mac-Framework.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Mac-Framework.xcconfig"; sourceTree = "<group>"; };
C944A57C1A7F772600E08B1E /* Mac-StaticLibrary.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Mac-StaticLibrary.xcconfig"; sourceTree = "<group>"; };
C94765081C646E5E00C7527E /* Cartfile.private */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Cartfile.private; sourceTree = "<group>"; };
C959A63C190A69120042DEC0 /* Icon.svg */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = Icon.svg; sourceTree = "<group>"; };
C959A63E190A69E60042DEC0 /* GenerateIcons.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = GenerateIcons.sh; sourceTree = "<group>"; };
Expand Down Expand Up @@ -312,7 +308,6 @@
children = (
C944A5671A7F772500E08B1E /* Base */,
C944A5721A7F772600E08B1E /* iOS */,
C944A5771A7F772600E08B1E /* Mac OS X */,
);
name = Configuration;
path = Carthage/Checkouts/xcconfigs;
Expand All @@ -339,17 +334,6 @@
path = iOS;
sourceTree = "<group>";
};
C944A5771A7F772600E08B1E /* Mac OS X */ = {
isa = PBXGroup;
children = (
C944A5781A7F772600E08B1E /* Mac-Application.xcconfig */,
C944A57A1A7F772600E08B1E /* Mac-DynamicLibrary.xcconfig */,
C944A57B1A7F772600E08B1E /* Mac-Framework.xcconfig */,
C944A57C1A7F772600E08B1E /* Mac-StaticLibrary.xcconfig */,
);
path = "Mac OS X";
sourceTree = "<group>";
};
C9776E32185187E8003D53CB /* Docs */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -592,26 +576,27 @@
TargetAttributes = {
1D6058900D05DD3D006BFB54 = {
DevelopmentTeam = WD7ETSN9J9;
LastSwiftMigration = 0910;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
C9906A2D1812522100BAEF53 = {
LastSwiftMigration = 0910;
LastSwiftMigration = 1020;
TestTargetID = 1D6058900D05DD3D006BFB54;
};
C9A262CC1E170BD4004E6CEB = {
CreatedOnToolsVersion = 8.2.1;
LastSwiftMigration = 0910;
LastSwiftMigration = 1020;
TestTargetID = 1D6058900D05DD3D006BFB54;
};
};
};
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Authenticator" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 1;
knownRegions = (
en,
Base,
);
mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */;
projectDirPath = "";
Expand Down
2 changes: 1 addition & 1 deletion Authenticator/Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.1.0</string>
<string>2.1.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand Down
111 changes: 102 additions & 9 deletions Authenticator/Source/Menu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
// SOFTWARE.
//

struct Menu {
let infoList: InfoList
private(set) var child: Child
import Foundation

enum Child {
struct Menu: Component {
private let infoList: InfoList
private var child: Child

private enum Child {
case none
case info(Info)
case displayOptions(DisplayOptions)
Expand All @@ -54,6 +56,8 @@ struct Menu {
child = .info(info)
}

// MARK: View

func viewModel(digitGroupSize: Int) -> ViewModel {
return ViewModel(infoList: infoList.viewModel, child: child.viewModel(digitGroupSize: digitGroupSize))
}
Expand All @@ -69,34 +73,123 @@ struct Menu {
}
}

// MARK: Update

enum Action {
case dismissInfo
case dismissDisplayOptions

case infoListEffect(InfoList.Effect)
case infoEffect(Info.Effect)
case displayOptionsEffect(DisplayOptions.Effect)
}

enum Effect {
case dismissMenu
case showErrorMessage(String)
case showSuccessMessage(String)
case openURL(URL)
case setDigitGroupSize(Int)
}

mutating func update(with action: Action) throws -> Effect? {
switch action {
case .dismissInfo:
try dismissInfo()
return nil

case .dismissDisplayOptions:
try dismissDisplayOptions()
return nil

case .infoListEffect(let effect):
return try handleInfoListEffect(effect)

case .infoEffect(let effect):
return handleInfoEffect(effect)

case .displayOptionsEffect(let effect):
return handleDisplayOptionsEffect(effect)
}
}

private mutating func handleInfoListEffect(_ effect: InfoList.Effect) throws -> Effect? {
switch effect {
case .showDisplayOptions:
try showDisplayOptions()
return nil

case .showBackupInfo:
let backupInfo: Info
do {
backupInfo = try Info.backupInfo()
} catch {
return .showErrorMessage("Failed to load backup info.")
}
try showInfo(backupInfo)
return nil

case .showLicenseInfo:
let licenseInfo: Info
do {
licenseInfo = try Info.licenseInfo()
} catch {
return .showErrorMessage("Failed to load acknowledgements.")
}
try showInfo(licenseInfo)
return nil

case .done:
return .dismissMenu
}
}

private mutating func handleInfoEffect(_ effect: Info.Effect) -> Effect? {
switch effect {
case .done:
return .dismissMenu
case let .openURL(url):
return .openURL(url)
}
}

private mutating func handleDisplayOptionsEffect(_ effect: DisplayOptions.Effect) -> Effect? {
switch effect {
case .done:
return .dismissMenu
case let .setDigitGroupSize(digitGroupSize):
return .setDigitGroupSize(digitGroupSize)
}
}

// MARK: -

enum Error: Swift.Error {
private enum Error: Swift.Error {
case badChildState
}

mutating func showInfo(_ info: Info) throws {
private mutating func showInfo(_ info: Info) throws {
guard case .none = child else {
throw Error.badChildState
}
child = .info(info)
}

mutating func dismissInfo() throws {
private mutating func dismissInfo() throws {
guard case .info = child else {
throw Error.badChildState
}
child = .none
}

mutating func showDisplayOptions() throws {
private mutating func showDisplayOptions() throws {
guard case .none = child else {
throw Error.badChildState
}
child = .displayOptions(DisplayOptions())
}

mutating func dismissDisplayOptions() throws {
private mutating func dismissDisplayOptions() throws {
guard case .displayOptions = child else {
throw Error.badChildState
}
Expand Down
83 changes: 12 additions & 71 deletions Authenticator/Source/Root.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,7 @@ extension Root {
case tokenEntryFormAction(TokenEntryForm.Action)
case tokenEditFormAction(TokenEditForm.Action)
case tokenScannerAction(TokenScanner.Action)

case infoListEffect(InfoList.Effect)
case infoEffect(Info.Effect)
case displayOptionsEffect(DisplayOptions.Effect)
case dismissInfo
case dismissDisplayOptions
case menuAction(Menu.Action)

case addTokenFromURL(Token)
}
Expand Down Expand Up @@ -161,26 +156,11 @@ extension Root {
handleTokenScannerEffect(effect)
}

case .infoListEffect(let effect):
return try handleInfoListEffect(effect)

case .infoEffect(let effect):
return handleInfoEffect(effect)

case .displayOptionsEffect(let effect):
return handleDisplayOptionsEffect(effect)

case .dismissInfo:
try modal.withMenu { menu in
try menu.dismissInfo()
}
return nil

case .dismissDisplayOptions:
try modal.withMenu { menu in
try menu.dismissDisplayOptions()
case .menuAction(let action):
let effect = try modal.withMenu({ menu in try menu.update(with: action) })
return effect.flatMap { effect in
handleMenuEffect(effect)
}
return nil

case .addTokenFromURL(let token):
return .addToken(token,
Expand Down Expand Up @@ -323,60 +303,21 @@ extension Root {
}
}

private mutating func handleInfoListEffect(_ effect: InfoList.Effect) throws -> Effect? {
private mutating func handleMenuEffect(_ effect: Menu.Effect) -> Effect? {
switch effect {
case .showDisplayOptions:
try modal.withMenu { menu in
try menu.showDisplayOptions()
}
return nil

case .showBackupInfo:
let backupInfo: Info
do {
backupInfo = try Info.backupInfo()
} catch {
return .showErrorMessage("Failed to load backup info.")
}
try modal.withMenu { menu in
try menu.showInfo(backupInfo)
}
return nil

case .showLicenseInfo:
let licenseInfo: Info
do {
licenseInfo = try Info.licenseInfo()
} catch {
return .showErrorMessage("Failed to load acknowledgements.")
}
try modal.withMenu { menu in
try menu.showInfo(licenseInfo)
}
return nil

case .done:
case .dismissMenu:
modal = .none
return nil

}
}
case let .showErrorMessage(message):
return .showErrorMessage(message)

case let .showSuccessMessage(message):
return .showSuccessMessage(message)

private mutating func handleInfoEffect(_ effect: Info.Effect) -> Effect? {
switch effect {
case .done:
modal = .none
return nil
case let .openURL(url):
return .openURL(url)
}
}

private mutating func handleDisplayOptionsEffect(_ effect: DisplayOptions.Effect) -> Effect? {
switch effect {
case .done:
modal = .none
return nil
case let .setDigitGroupSize(digitGroupSize):
return .setDigitGroupSize(digitGroupSize)
}
Expand Down
14 changes: 7 additions & 7 deletions Authenticator/Source/RootViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,23 +155,23 @@ extension RootViewController {
case .info(let infoViewModel):
presentViewModels(menuViewModel.infoList,
using: InfoListViewController.self,
actionTransform: Root.Action.infoListEffect,
actionTransform: compose(Menu.Action.infoListEffect, Root.Action.menuAction),
and: infoViewModel,
using: InfoViewController.self,
actionTransform: Root.Action.infoEffect)
actionTransform: compose(Menu.Action.infoEffect, Root.Action.menuAction))

case .displayOptions(let displayOptionsViewModel):
presentViewModels(menuViewModel.infoList,
using: InfoListViewController.self,
actionTransform: Root.Action.infoListEffect,
actionTransform: compose(Menu.Action.infoListEffect, Root.Action.menuAction),
and: displayOptionsViewModel,
using: DisplayOptionsViewController.self,
actionTransform: Root.Action.displayOptionsEffect)
actionTransform: compose(Menu.Action.displayOptionsEffect, Root.Action.menuAction))

case .none:
presentViewModel(menuViewModel.infoList,
using: InfoListViewController.self,
actionTransform: Root.Action.infoListEffect)
actionTransform: compose(Menu.Action.infoListEffect, Root.Action.menuAction))
}
}
currentViewModel = viewModel
Expand Down Expand Up @@ -216,11 +216,11 @@ extension RootViewController: UINavigationControllerDelegate {
case .info:
// If the current modal state is the menu with an Info child, and the just-shown view controller is
// an InfoList, then the user has popped the Info view controller.
dispatchAction(.dismissInfo)
dispatchAction(.menuAction(.dismissInfo))
case .displayOptions:
// If the current modal state is the menu with a DisplayOptions child, and the just-shown view
// controller is an InfoList, then the user has popped the DisplayOptions view controller.
dispatchAction(.dismissDisplayOptions)
dispatchAction(.menuAction(.dismissDisplayOptions))
default:
break
}
Expand Down
2 changes: 1 addition & 1 deletion AuthenticatorScreenshots/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>2.1.0</string>
<string>2.1.1</string>
<key>CFBundleVersion</key>
<string>0</string>
</dict>
Expand Down
Loading

0 comments on commit 9cf2b97

Please sign in to comment.