Skip to content

Commit

Permalink
PM-15894: Update text fields to new designs (#1215)
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-livefront authored Dec 20, 2024
1 parent b33e785 commit e836062
Show file tree
Hide file tree
Showing 272 changed files with 293 additions and 180 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ struct SelfHostedView: View {
text: store.binding(
get: \.serverUrl,
send: SelfHostedAction.serverUrlChanged
),
placeholder: "ex. https://bitwarden.company.com"
)
)
.accessibilityIdentifier("ServerUrlEntry")
.autocorrectionDisabled()
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions BitwardenShared/UI/Auth/Login/LoginView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ struct LoginView: View {
} label: {
HStack(spacing: 8) {
Image(decorative: Asset.Images.mobile16)
.imageStyle(.accessoryIcon(scaleWithFont: true))
.imageStyle(.accessoryIcon16(scaleWithFont: true))
Text(Localizations.logInWithDevice)
}
}
Expand All @@ -105,7 +105,7 @@ struct LoginView: View {
} label: {
HStack(spacing: 8) {
Image(decorative: Asset.Images.provider16)
.imageStyle(.accessoryIcon(scaleWithFont: true))
.imageStyle(.accessoryIcon16(scaleWithFont: true))
Text(Localizations.logInSso)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ struct ProfileSwitcherRow: View {
.accessibilityLabel(Localizations.account)
case .addAccount:
Asset.Images.plus16.swiftUIImage
.imageStyle(.accessoryIcon(color: Asset.Colors.iconSecondary.swiftUIColor))
.imageStyle(.accessoryIcon16(color: Asset.Colors.iconSecondary.swiftUIColor))
.padding(4)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,16 @@ extension ImageStyle {
/// An `ImageStyle` for applying common properties to a circular accessory icon.
///
/// - Size: 16x16pt
/// - Color: `Asset.Colors.iconSecondary`
/// - Color: `Asset.Colors.iconPrimary`
///
static let accessoryIcon16 = accessoryIcon16()

/// An `ImageStyle` for applying common properties to a circular accessory icon.
///
/// - Size: 24x24pt
/// - Color: `Asset.Colors.iconPrimary`
///
static let accessoryIcon = accessoryIcon()
static let accessoryIcon24 = accessoryIcon24()

/// An `ImageStyle` for applying common properties for icons within a row.
///
Expand All @@ -55,16 +62,32 @@ extension ImageStyle {
/// - Color: Defaults to `Asset.Colors.iconSecondary`
///
/// - Parameters:
/// - color: The foreground color of the image. Defaults to `Asset.Colors.iconSecondary`.
/// - color: The foreground color of the image. Defaults to `Asset.Colors.iconPrimary`.
/// - scaleWithFont: Whether the image should scale with font size changes.
///
static func accessoryIcon(
color: Color = Asset.Colors.iconSecondary.swiftUIColor,
static func accessoryIcon16(
color: Color = Asset.Colors.iconPrimary.swiftUIColor,
scaleWithFont: Bool = false
) -> ImageStyle {
ImageStyle(color: color, scaleWithFont: scaleWithFont, width: 16, height: 16)
}

/// An `ImageStyle` for applying common properties to a circular accessory icon.
///
/// - Size: 24x24pt
/// - Color: Defaults to `Asset.Colors.iconSecondary`
///
/// - Parameters:
/// - color: The foreground color of the image. Defaults to `Asset.Colors.iconPrimary`.
/// - scaleWithFont: Whether the image should scale with font size changes.
///
static func accessoryIcon24(
color: Color = Asset.Colors.iconPrimary.swiftUIColor,
scaleWithFont: Bool = false
) -> ImageStyle {
ImageStyle(color: color, scaleWithFont: scaleWithFont, width: 24, height: 24)
}

/// An `ImageStyle` for applying common properties for icons within a row.
///
/// - Size: 22x22pt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ import SwiftUI
struct AccessoryButtonStyle: ButtonStyle {
func makeBody(configuration: Configuration) -> some View {
configuration.label
.frame(width: 14, height: 14)
.padding(10)
.foregroundColor(Asset.Colors.iconSecondary.swiftUIColor)
.background(Asset.Colors.Legacy.fillTertiary.swiftUIColor)
.clipShape(Circle())
.frame(width: 24, height: 24)
.foregroundColor(Asset.Colors.iconPrimary.swiftUIColor)
.opacity(configuration.isPressed ? 0.5 : 1)
.contentShape(Rectangle())
}
}

Expand All @@ -31,14 +29,14 @@ extension ButtonStyle where Self == AccessoryButtonStyle {
#if DEBUG
#Preview("Enabled") {
Button {} label: {
Asset.Images.copy16.swiftUIImage
Asset.Images.copy24.swiftUIImage
}
.buttonStyle(.accessory)
}

#Preview("Disabled") {
Button {} label: {
Asset.Images.copy16.swiftUIImage
Asset.Images.copy24.swiftUIImage
}
.buttonStyle(.accessory)
.disabled(true)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "copy16.pdf",
"filename" : "camera24.pdf",
"idiom" : "universal"
}
],
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "eye16.pdf",
"filename" : "cog24.pdf",
"idiom" : "universal"
}
],
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "eye-slash16.pdf",
"filename" : "eye-slash24.pdf",
"idiom" : "universal"
}
],
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "cog.pdf",
"filename" : "eye24.pdf",
"idiom" : "universal"
}
],
Expand Down
Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "check-circle.pdf",
"filename" : "minus-circle24.pdf",
"idiom" : "universal"
}
],
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct AccessoryButton: View {
AsyncButton(action: action) {
asset.swiftUIImage
.resizable()
.frame(width: 16, height: 16)
.frame(width: 24, height: 24)
}
.buttonStyle(.accessory)
.accessibilityLabel(Text(accessibilityLabel))
Expand All @@ -44,7 +44,7 @@ struct AccessoryButton: View {
Button(action: action) {
asset.swiftUIImage
.resizable()
.frame(width: 16, height: 16)
.frame(width: 24, height: 24)
}
.buttonStyle(.accessory)
.accessibilityLabel(Text(accessibilityLabel))
Expand Down Expand Up @@ -95,5 +95,5 @@ struct AccessoryButton: View {
// MARK: Previews

#Preview {
AccessoryButton(asset: Asset.Images.copy16, accessibilityLabel: Localizations.copy) {}
AccessoryButton(asset: Asset.Images.copy24, accessibilityLabel: Localizations.copy) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct ActionCard<LeadingContent: View>: View {
if let dismissButtonState {
AsyncButton(action: dismissButtonState.action) {
Image(asset: Asset.Images.close16, label: Text(dismissButtonState.title))
.imageStyle(.accessoryIcon(color: Asset.Colors.iconPrimary.swiftUIColor))
.imageStyle(.accessoryIcon16(color: Asset.Colors.iconPrimary.swiftUIColor))
.padding(16) // Add padding to increase tappable area...
}
.padding(-16) // ...but remove it to not affect layout.
Expand Down
109 changes: 79 additions & 30 deletions BitwardenShared/UI/Platform/Application/Views/BitwardenField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct BitwardenField<Content, AccessoryContent>: View where Content: View, Acce
/// The (optional) footer to display underneath the field.
var footer: String?

/// The (optional) accessibility identifier to apply to the fooder of the field (if it exists).
/// The (optional) accessibility identifier to apply to the footer of the field (if it exists).
var footerAccessibilityIdentifier: String?

/// The vertical padding to apply around `content`. Defaults to `8`.
Expand All @@ -32,35 +32,14 @@ struct BitwardenField<Content, AccessoryContent>: View where Content: View, Acce
// MARK: View

var body: some View {
VStack(alignment: .leading, spacing: 8) {
if let title {
Text(title)
.styleGuide(.subheadline, weight: .semibold)
.foregroundColor(Asset.Colors.textSecondary.swiftUIColor)
.accessibilityIdentifier(titleAccessibilityIdentifier ?? title)
}

HStack(spacing: 8) {
content
.frame(maxWidth: .infinity, minHeight: 28, alignment: .leading)
.padding(.horizontal, 16)
.padding(.vertical, verticalPadding)
.background(Asset.Colors.backgroundSecondary.swiftUIColor)
.clipShape(RoundedRectangle(cornerRadius: 10))

if let accessoryContent {
accessoryContent
.buttonStyle(.accessory)
}
}
VStack(alignment: .leading, spacing: 0) {
contentView()

if let footer {
Text(footer)
.styleGuide(.footnote)
.foregroundColor(Asset.Colors.textSecondary.swiftUIColor)
.accessibilityIdentifier(footerAccessibilityIdentifier ?? footer)
}
footerView()
}
.padding(.horizontal, 16)
.background(Asset.Colors.backgroundSecondary.swiftUIColor)
.clipShape(RoundedRectangle(cornerRadius: 8))
}

// MARK: Initialization
Expand All @@ -73,7 +52,7 @@ struct BitwardenField<Content, AccessoryContent>: View where Content: View, Acce
/// to the title of the field (if it exists)
/// - footer: The (optional) footer to display underneath the field.
/// - footerAccessibilityIdentifier: The (optional) accessibility identifier to apply
/// to the fooder of the field (if it exists)
/// to the footer of the field (if it exists)
/// - verticalPadding: The vertical padding to apply around `content`. Defaults to `8`.
/// - content: The content that should be displayed in the field.
/// - accessoryContent: Any accessory content that should be displayed on the trailing edge of
Expand All @@ -96,6 +75,56 @@ struct BitwardenField<Content, AccessoryContent>: View where Content: View, Acce
self.content = content()
self.accessoryContent = accessoryContent()
}

// MARK: Private

/// The main content for the view, containing the title and value.
@ViewBuilder
private func contentView() -> some View {
HStack(spacing: 8) {
VStack(alignment: .leading, spacing: 2) {
if let title {
Text(title)
.styleGuide(
.subheadline,
weight: .semibold,
includeLinePadding: false,
includeLineSpacing: false
)
.foregroundColor(Asset.Colors.textSecondary.swiftUIColor)
.accessibilityIdentifier(titleAccessibilityIdentifier ?? title)
}

content
.frame(maxWidth: .infinity, alignment: .leading)
}

if let accessoryContent {
HStack(spacing: 16) {
accessoryContent
.buttonStyle(.accessory)
}
}
}
.padding(.vertical, 12)
.frame(minHeight: 64)
}

/// The view to display at the footer below the main content.
@ViewBuilder
private func footerView() -> some View {
if let footer {
VStack(alignment: .leading, spacing: 0) {
Divider()

Text(footer)
.styleGuide(.footnote, includeLinePadding: false, includeLineSpacing: false)
.foregroundColor(Asset.Colors.textSecondary.swiftUIColor)
.accessibilityIdentifier(footerAccessibilityIdentifier ?? footer)
.padding(.vertical, 12)
}
}
}
}

extension BitwardenField where AccessoryContent == EmptyView {
Expand All @@ -107,7 +136,7 @@ extension BitwardenField where AccessoryContent == EmptyView {
/// to the title of the field (if it exists)
/// - footer: The (optional) footer to display underneath the field.
/// - footerAccessibilityIdentifier: The (optional) accessibility identifier to apply
/// to the fooder of the field (if it exists)
/// to the footer of the field (if it exists)
/// - verticalPadding: The vertical padding to apply around `content`. Defaults to `8`.
/// - content: The content that should be displayed in the field.
///
Expand All @@ -128,3 +157,23 @@ extension BitwardenField where AccessoryContent == EmptyView {
accessoryContent = nil
}
}

// MARK: Previews

#if DEBUG
#Preview {
VStack {
BitwardenField(title: "Title") {
Text("Value")
.styleGuide(.body)
.foregroundStyle(Asset.Colors.textPrimary.swiftUIColor)
}

BitwardenField(title: "Title", footer: "Footer") {
Text("Value")
}
}
.padding()
.background(Asset.Colors.backgroundPrimary.swiftUIColor)
}
#endif
Loading

0 comments on commit e836062

Please sign in to comment.