-
Notifications
You must be signed in to change notification settings - Fork 9
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
f0d3c17
commit 4f6f2e8
Showing
20 changed files
with
1,049 additions
and
34 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
16 changes: 16 additions & 0 deletions
16
...d/UI/Platform/Application/Support/Images.xcassets/Icons/down-angle.imageset/Contents.json
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,16 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "down-angle.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"preserves-vector-representation" : true, | ||
"template-rendering-intent" : "template" | ||
} | ||
} |
Binary file added
BIN
+2.89 KB
.../UI/Platform/Application/Support/Images.xcassets/Icons/down-angle.imageset/down-angle.pdf
Binary file not shown.
16 changes: 16 additions & 0 deletions
16
...red/UI/Platform/Application/Support/Images.xcassets/Icons/up-angle.imageset/Contents.json
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,16 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "up-angle.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"preserves-vector-representation" : true, | ||
"template-rendering-intent" : "template" | ||
} | ||
} |
Binary file added
BIN
+2.89 KB
...ared/UI/Platform/Application/Support/Images.xcassets/Icons/up-angle.imageset/up-angle.pdf
Binary file not shown.
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
124 changes: 124 additions & 0 deletions
124
AuthenticatorShared/UI/Platform/Application/Views/FormFields/FormMenuFieldView.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,124 @@ | ||
import SwiftUI | ||
|
||
// MARK: - FormMenuField | ||
|
||
/// The data necessary for displaying a `FormMenuFieldView`. | ||
/// | ||
struct FormMenuField<State, T: Menuable>: Equatable, Identifiable { | ||
// MARK: Properties | ||
|
||
/// The accessibility identifier to apply to the field. | ||
let accessibilityIdentifier: String? | ||
|
||
/// The footer text displayed below the menu field. | ||
let footer: String? | ||
|
||
/// A key path for updating the backing value for the menu field. | ||
let keyPath: WritableKeyPath<State, T> | ||
|
||
/// The options displayed in the menu. | ||
let options: [T] | ||
|
||
/// The current selection. | ||
let selection: T | ||
|
||
/// The title of the field. | ||
let title: String | ||
|
||
// MARK: Identifiable | ||
|
||
var id: String { | ||
"FormMenuField-\(title)" | ||
} | ||
|
||
// MARK: Initialization | ||
|
||
/// Initialize a `FormMenuField`. | ||
/// | ||
/// - Parameters: | ||
/// - accessibilityIdentifier: The accessibility identifier given to the menu field. | ||
/// - footer: The footer text displayed below the menu field. | ||
/// - keyPath: A key path for updating the backing value for the menu field. | ||
/// - options: The options displayed in the menu. | ||
/// - selection: The current selection. | ||
/// - title: The title of the field. | ||
init( | ||
accessibilityIdentifier: String?, | ||
footer: String? = nil, | ||
keyPath: WritableKeyPath<State, T>, | ||
options: [T], | ||
selection: T, | ||
title: String | ||
) { | ||
self.accessibilityIdentifier = accessibilityIdentifier | ||
self.footer = footer | ||
self.keyPath = keyPath | ||
self.options = options | ||
self.selection = selection | ||
self.title = title | ||
} | ||
} | ||
|
||
// MARK: - FormMenuFieldView | ||
|
||
/// A view that displays a menu field for display in a form. | ||
/// | ||
struct FormMenuFieldView<State, T: Menuable, TrailingContent: View>: View { | ||
// MARK: Properties | ||
|
||
/// A closure containing the action to take when the menu selection is changed. | ||
let action: (T) -> Void | ||
|
||
/// The data for displaying the field. | ||
let field: FormMenuField<State, T> | ||
|
||
/// Optional content view that is displayed to the right of the menu value. | ||
let trailingContent: TrailingContent | ||
|
||
// MARK: View | ||
|
||
var body: some View { | ||
BitwardenMenuField( | ||
title: field.title, | ||
footer: field.footer, | ||
accessibilityIdentifier: field.accessibilityIdentifier, | ||
options: field.options, | ||
selection: Binding(get: { field.selection }, set: action), | ||
trailingContent: { trailingContent } | ||
) | ||
} | ||
|
||
// MARK: Initialization | ||
|
||
/// Initialize a `FormMenuFieldView`. | ||
/// | ||
/// - Parameters: | ||
/// - field: The data for displaying the field. | ||
/// - action: A closure containing the action to take when the menu selection is changed. | ||
/// | ||
init( | ||
field: FormMenuField<State, T>, | ||
action: @escaping (T) -> Void | ||
) where TrailingContent == EmptyView { | ||
self.action = action | ||
self.field = field | ||
trailingContent = EmptyView() | ||
} | ||
|
||
/// Initialize a `FormMenuFieldView`. | ||
/// | ||
/// - Parameters: | ||
/// - field: The data for displaying the field. | ||
/// - action: A closure containing the action to take when the menu selection is changed. | ||
/// - trailingContent: Optional content view that is displayed to the right of the menu value. | ||
/// | ||
init( | ||
field: FormMenuField<State, T>, | ||
action: @escaping (T) -> Void, | ||
trailingContent: @escaping () -> TrailingContent | ||
) { | ||
self.action = action | ||
self.field = field | ||
self.trailingContent = trailingContent() | ||
} | ||
} |
Oops, something went wrong.