-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[16][6][13] Refactoring / Switchcraft integration / Support for Alerts (
#15) * - DebugMenuView now in NavigationView to support alerts - Refactor PasswordEntryAlertWrapper to be used as TextFieldAlertWrapper - General refactors - Clean up project - Support for Alert actions - DebugMenuView can now surface an alert as a response - Min version set to iOS 14 - DebugMenuAccessConfig * - Organized files to separate folders * - Clean up - Switchcraft integration to example project
- Loading branch information
1 parent
afcec9b
commit 553b829
Showing
30 changed files
with
537 additions
and
211 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// | ||
// DebugAction.swift | ||
// | ||
// | ||
// Created by Alejandro Zielinsky on 2022-03-10. | ||
// | ||
|
||
import SwiftUI | ||
|
||
public protocol DebugAction { | ||
var asAnyView: AnyView { get } | ||
} |
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
22 changes: 22 additions & 0 deletions
22
DebugMenu/DebugMenu/Actions/DebugHostControllerAction.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,22 @@ | ||
// | ||
// DebugHostControllerAction.swift | ||
// | ||
// | ||
// Created by Alejandro Zielinsky on 2022-03-10. | ||
// | ||
|
||
import SwiftUI | ||
|
||
public struct DebugHostControllerAction: DebugAction { | ||
let title: String | ||
let action: (UIHostingController<AnyView>) -> Void | ||
|
||
public var asAnyView: AnyView { | ||
AnyView(DebugHostControllerRow(action: self)) | ||
} | ||
|
||
public init(title: String, action: @escaping (UIHostingController<AnyView>) -> Void) { | ||
self.title = title | ||
self.action = action | ||
} | ||
} |
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,22 @@ | ||
// | ||
// DebugSubmenuAction.swift | ||
// | ||
// | ||
// Created by Alejandro Zielinsky on 2022-03-10. | ||
// | ||
|
||
import SwiftUI | ||
|
||
public struct DebugSubmenuAction: DebugAction { | ||
let title: String | ||
let dataSource: BaseDebugDataSource | ||
|
||
public var asAnyView: AnyView { | ||
AnyView(DebugSubmenuButtonRow(action: self)) | ||
} | ||
|
||
public init(title: String, dataSource: BaseDebugDataSource) { | ||
self.title = title | ||
self.dataSource = dataSource | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
DebugMenu/DebugMenu/Actions/DebugTextFieldAlertAction.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,22 @@ | ||
// | ||
// DebugTextFieldAlertAction.swift | ||
// | ||
// | ||
// Created by Alejandro Zielinsky on 2022-03-10. | ||
// | ||
|
||
import SwiftUI | ||
|
||
public struct DebugTextFieldAlertAction: DebugAction { | ||
let title: String | ||
let alert: DebugTextFieldAlert | ||
|
||
public var asAnyView: AnyView { | ||
AnyView(DebugTextFieldAlertRow(action: self)) | ||
} | ||
|
||
public init(title: String, alert: DebugTextFieldAlert) { | ||
self.title = title | ||
self.alert = alert | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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,13 @@ | ||
// | ||
// DebugResettable.swift | ||
// | ||
// | ||
// Created by Alejandro Zielinsky on 2022-03-10. | ||
// | ||
|
||
import Foundation | ||
|
||
public protocol DebugResettable { | ||
var defaultValue: Bool { get } | ||
func resetToDefault() | ||
} |
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,31 @@ | ||
// | ||
// DebugAlert.swift | ||
// | ||
// | ||
// Created by Alejandro Zielinsky on 2022-03-10. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct DebugAlert: Identifiable { | ||
public let id = UUID() | ||
public let title: String | ||
public let message: String? | ||
public let primaryButtonTitle: String | ||
public let secondaryButtonTitle: String | ||
public let action: (() -> Void)? | ||
|
||
public init( | ||
title: String, | ||
message: String? = nil, | ||
primaryButtonTitle: String = "OK", | ||
secondaryButtonTitle: String = "Cancel", | ||
action: (() -> Void)? = nil | ||
) { | ||
self.title = title | ||
self.message = message | ||
self.primaryButtonTitle = primaryButtonTitle | ||
self.secondaryButtonTitle = secondaryButtonTitle | ||
self.action = action | ||
} | ||
} |
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,18 @@ | ||
// | ||
// DebugMenuAccessConfig.swift | ||
// | ||
// | ||
// Created by Alejandro Zielinsky on 2022-03-10. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct DebugMenuAccessConfig { | ||
public var passwordSHA256: String | ||
public var longPressDuration: Double | ||
|
||
public init(passwordSHA256: String, longPressDuration: Double) { | ||
self.passwordSHA256 = passwordSHA256 | ||
self.longPressDuration = longPressDuration | ||
} | ||
} |
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,42 @@ | ||
// | ||
// DebugTextFieldAlert.swift | ||
// | ||
// | ||
// Created by Alejandro Zielinsky on 2022-03-10. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
|
||
public struct DebugTextFieldAlert { | ||
|
||
var title: String | ||
var message: String? | ||
var placeholder: String? | ||
var accept: String | ||
var cancel: String? | ||
var secondaryActionTitle: String? | ||
var keyboardType: UIKeyboardType | ||
var action: (String?) -> Void | ||
var secondaryAction: (() -> Void)? | ||
|
||
public init(title: String, | ||
message: String? = nil, | ||
placeholder: String? = nil, | ||
accept: String = "OK", | ||
cancel: String? = "Cancel", | ||
secondaryActionTitle: String? = nil, | ||
keyboardType: UIKeyboardType = .default, | ||
action: @escaping (String?) -> Void, | ||
secondaryAction: (() -> Void)? = nil) { | ||
self.title = title | ||
self.message = message | ||
self.placeholder = placeholder | ||
self.accept = accept | ||
self.cancel = cancel | ||
self.secondaryActionTitle = secondaryActionTitle | ||
self.keyboardType = keyboardType | ||
self.action = action | ||
self.secondaryAction = secondaryAction | ||
} | ||
} |
Oops, something went wrong.