generated from bitwarden/template
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PM-11150: Add import logins step 1 (#1031)
- Loading branch information
1 parent
87d6e41
commit 5a47964
Showing
21 changed files
with
354 additions
and
15 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
79 changes: 79 additions & 0 deletions
79
BitwardenShared/UI/Platform/Application/Views/NumberedList.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,79 @@ | ||
import SwiftUI | ||
|
||
// MARK: - NumberedList | ||
|
||
/// A view that displays a numbered list of views, separated by a divider. The list has the | ||
/// secondary background color applied with rounded corners. | ||
/// | ||
/// Adapted from: https://movingparts.io/variadic-views-in-swiftui | ||
/// | ||
struct NumberedList<Content: View>: View { | ||
// MARK: Properties | ||
|
||
/// The content to display in the numbered list. Each child view will receive it's own number. | ||
let content: Content | ||
|
||
// MARK: View | ||
|
||
var body: some View { | ||
_VariadicView.Tree(Layout()) { | ||
content | ||
} | ||
} | ||
|
||
// MARK: Initialization | ||
|
||
/// Initialize a `NumberedList`. | ||
/// | ||
/// - Parameter content: The content to display in the numbered list. | ||
/// | ||
init(@ViewBuilder content: () -> Content) { | ||
self.content = content() | ||
} | ||
} | ||
|
||
extension NumberedList { | ||
/// The layout for the numbered list. | ||
private struct Layout: _VariadicView_UnaryViewRoot { | ||
func body(children: _VariadicView.Children) -> some View { | ||
let last = children.last?.id | ||
|
||
VStack(spacing: 0) { | ||
ForEachIndexed(children) { index, child in | ||
HStack(spacing: 12) { | ||
Text(String(index + 1)) | ||
.styleGuide(.title2, weight: .bold) | ||
.foregroundStyle(Asset.Colors.textInteraction.swiftUIColor) | ||
.frame(minWidth: 24, alignment: .center) | ||
.padding(.leading, 12) | ||
|
||
VStack(alignment: .leading, spacing: 0) { | ||
child | ||
|
||
if child.id != last { | ||
Divider() | ||
} | ||
} | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
} | ||
} | ||
} | ||
.background(Asset.Colors.backgroundSecondary.swiftUIColor) | ||
.clipShape(RoundedRectangle(cornerRadius: 10)) | ||
} | ||
} | ||
} | ||
|
||
// MARK: Previews | ||
|
||
#if DEBUG | ||
#Preview { | ||
NumberedList { | ||
NumberedListRow(title: "Apple 🍎") | ||
NumberedListRow(title: "Banana 🍌") | ||
NumberedListRow(title: "Grapes 🍇") | ||
} | ||
.padding() | ||
.background(Asset.Colors.backgroundPrimary.swiftUIColor) | ||
} | ||
#endif |
56 changes: 56 additions & 0 deletions
56
BitwardenShared/UI/Platform/Application/Views/NumberedListRow.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,56 @@ | ||
import SwiftUI | ||
|
||
/// A view that displays a single row within a `NumberedList`. | ||
/// | ||
struct NumberedListRow: View { | ||
// MARK: Properties | ||
|
||
/// The title to display in the row. | ||
let title: String | ||
|
||
/// An optional subtitle to display in the row. | ||
let subtitle: String? | ||
|
||
// MARK: View | ||
|
||
var body: some View { | ||
VStack(alignment: .leading, spacing: 2) { | ||
Text(LocalizedStringKey(title)) | ||
.styleGuide(.body) | ||
.foregroundStyle(Asset.Colors.textPrimary.swiftUIColor) | ||
|
||
if let subtitle { | ||
Text(LocalizedStringKey(subtitle)) | ||
.styleGuide(.subheadline) | ||
.foregroundStyle(Asset.Colors.textSecondary.swiftUIColor) | ||
} | ||
} | ||
.padding(.vertical, 12) | ||
.padding(.trailing, 16) // Leading padding is handled by `NumberedList`. | ||
} | ||
|
||
// MARK: Initialization | ||
|
||
/// Initializes a `NumberedListRow`. | ||
/// | ||
/// - Parameters: | ||
/// - title: The title to display in the row. | ||
/// - subtitle: An optional subtitle to display in the row. | ||
/// | ||
init(title: String, subtitle: String? = nil) { | ||
self.title = title | ||
self.subtitle = subtitle | ||
} | ||
} | ||
|
||
// MARK: Previews | ||
|
||
#if DEBUG | ||
#Preview { | ||
NumberedList { | ||
NumberedListRow(title: "Apple 🍎") | ||
NumberedListRow(title: "Banana 🍌") | ||
NumberedListRow(title: "Grapes 🍇") | ||
} | ||
} | ||
#endif |
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 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.