diff --git a/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testDisabled.disabled-dark.png b/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testDisabled.disabled-dark.png index d66c7e8..9b75e9c 100644 Binary files a/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testDisabled.disabled-dark.png and b/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testDisabled.disabled-dark.png differ diff --git a/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testDisabled.disabled-light.png b/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testDisabled.disabled-light.png index 41dc17d..8fcb49c 100644 Binary files a/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testDisabled.disabled-light.png and b/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testDisabled.disabled-light.png differ diff --git a/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testEmpty.empty-dark.png b/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testEmpty.empty-dark.png index bf56c8e..9ce88de 100644 Binary files a/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testEmpty.empty-dark.png and b/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testEmpty.empty-dark.png differ diff --git a/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testEmpty.empty-light.png b/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testEmpty.empty-light.png index 3307d4d..ebe18ff 100644 Binary files a/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testEmpty.empty-light.png and b/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testEmpty.empty-light.png differ diff --git a/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testError.error-dark.png b/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testError.error-dark.png index e2a07f3..35c3077 100644 Binary files a/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testError.error-dark.png and b/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testError.error-dark.png differ diff --git a/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testError.error-light.png b/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testError.error-light.png index 6df86b9..48ec2e6 100644 Binary files a/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testError.error-light.png and b/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testError.error-light.png differ diff --git a/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testFilled.filled-dark.png b/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testFilled.filled-dark.png index 2fc6006..381aaab 100644 Binary files a/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testFilled.filled-dark.png and b/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testFilled.filled-dark.png differ diff --git a/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testFilled.filled-light.png b/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testFilled.filled-light.png index 69b7348..d46a656 100644 Binary files a/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testFilled.filled-light.png and b/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testFilled.filled-light.png differ diff --git a/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testLabelAccessory.label-accessory-dark.png b/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testLabelAccessory.label-accessory-dark.png index 6d8211b..bd10262 100644 Binary files a/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testLabelAccessory.label-accessory-dark.png and b/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testLabelAccessory.label-accessory-dark.png differ diff --git a/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testLabelAccessory.label-accessory-light.png b/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testLabelAccessory.label-accessory-light.png index fc8c7aa..56de587 100644 Binary files a/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testLabelAccessory.label-accessory-light.png and b/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/AddressFieldViewSnapshotTests/testLabelAccessory.label-accessory-light.png differ diff --git a/Sources/DashUIKit/Components/AddressFieldView.swift b/Sources/DashUIKit/Components/AddressFieldView.swift index 48aa3d3..bed4d7e 100644 --- a/Sources/DashUIKit/Components/AddressFieldView.swift +++ b/Sources/DashUIKit/Components/AddressFieldView.swift @@ -23,7 +23,9 @@ private enum Layout { static let hSpacing: CGFloat = 20 static let lPadding: CGFloat = 20 static let tPadding: CGFloat = 10 - static let iconSize: CGFloat = 17 + /// The scan glyph's drawn box: Figma's 17pt `ScanQR` frame plus the half + /// of its 2pt stroke that falls outside it on each side. + static let iconSize: CGFloat = 19 static let cornerRadius: CGFloat = 16 static let actionTapArea: CGFloat = 40 /// Width of the focus / error ring, drawn hard-edged outside the field — @@ -96,8 +98,8 @@ public struct AddressFieldView: View { VStack(alignment: .leading, spacing: 10) { HStack(spacing: 8) { Text(label) - .dashFont(.footnote) - .foregroundStyle(Color.dash.gray500) + .dashFont(.footnoteMedium) + .foregroundStyle(contentColor) Spacer(minLength: 0) @@ -219,14 +221,14 @@ extension AddressFieldView { // line height cannot be applied to `Text` anyway. prompt: Text(placeholder) .font(Font.dash.subhead) - .foregroundStyle(Color.dash.black1000Alpha30), + .foregroundStyle(placeholderColor), axis: .vertical ) .lineLimit(1...2) .dashFont(.subhead) .textInputAutocapitalization(.never) .autocorrectionDisabled() - .foregroundStyle(Color.dash.primaryText) + .foregroundStyle(contentColor) .tint(Color.dash.primaryText) .focused($isTextFieldFocused) .disabled(isDisabled) @@ -241,9 +243,10 @@ extension AddressFieldView { // did nothing. if let onScanQR { Button(action: onScanQR) { - DashIcon.Other.textFieldQR.image + DashIcon.Other.textFieldScanQR.image .resizable() .scaledToFit() + .foregroundStyle(Color.dash.textFieldCryptoAddressIcon) .frame(width: Layout.iconSize, height: Layout.iconSize) } .accessibilityLabel(NSLocalizedString("Scan QR code", bundle: .module, comment: "DashUIKit")) @@ -276,6 +279,16 @@ extension AddressFieldView { // MARK: - Styling + /// Label and entered text. A disabled field steps them down one text + /// level, as `MenuItem` does, so it does not read as one that takes input. + private var contentColor: Color { + isDisabled ? Color.dash.secondaryText : Color.dash.primaryText + } + + private var placeholderColor: Color { + isDisabled ? Color.dash.tertiaryText : Color.dash.textFieldPlaceholder + } + private var backgroundColor: Color { if isFocusedState { return .clear } if hasError { return Color.dash.redAlpha5 } @@ -420,6 +433,18 @@ extension AddressFieldView { .padding() } +#Preview("Disabled") { + AddressFieldView( + text: .constant("bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh"), + label: "Destination address", + placeholder: "BTC address", + hasError: false, errorText: nil, + isDisabled: true, + onScanQR: {} + ) + .padding() +} + #Preview("Label accessory") { AddressFieldView( text: .constant("yV1D1ivvSUyKPJnbFmzSTVh1MyZ3JbeVkY"), diff --git a/Sources/DashUIKit/Foundation/Color+DashUI.swift b/Sources/DashUIKit/Foundation/Color+DashUI.swift index 3556007..25bc7b3 100644 --- a/Sources/DashUIKit/Foundation/Color+DashUI.swift +++ b/Sources/DashUIKit/Foundation/Color+DashUI.swift @@ -175,6 +175,7 @@ public enum DashColors { public static var textFieldCryptoAddressBackground: Color { dashAsset("TextFieldCryptoAddressBackground") } public static var textFieldCryptoAddressIcon: Color { dashAsset("TextFieldCryptoAddressIcon") } + public static var textFieldPlaceholder: Color { dashAsset("TextFieldPlaceholder") } // MARK: Toast diff --git a/Sources/DashUIKit/Foundation/Icon_DashUI.swift b/Sources/DashUIKit/Foundation/Icon_DashUI.swift index 4464c5a..20c36be 100644 --- a/Sources/DashUIKit/Foundation/Icon_DashUI.swift +++ b/Sources/DashUIKit/Foundation/Icon_DashUI.swift @@ -263,6 +263,7 @@ public enum DashIcon { public enum Other: String, CaseIterable, DashIconAsset { case textFieldClear = "text-field-clear" case textFieldQR = "text-field-qr" + case textFieldScanQR = "text-field-scan-qr" } // MARK: - AdditionalInfo diff --git a/Sources/DashUIKit/Resources/Media.xcassets/Colors/TextField/TextFieldPlaceholder.colorset/Contents.json b/Sources/DashUIKit/Resources/Media.xcassets/Colors/TextField/TextFieldPlaceholder.colorset/Contents.json new file mode 100644 index 0000000..f6c01f9 --- /dev/null +++ b/Sources/DashUIKit/Resources/Media.xcassets/Colors/TextField/TextFieldPlaceholder.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.500", + "blue" : "0x0D", + "green" : "0x0A", + "red" : "0x0A" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.500", + "blue" : "0xFF", + "green" : "0xFF", + "red" : "0xFF" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/DashUIKit/Resources/Media.xcassets/Icons & Illustrations/Other/text-field-scan-qr.imageset/Contents.json b/Sources/DashUIKit/Resources/Media.xcassets/Icons & Illustrations/Other/text-field-scan-qr.imageset/Contents.json new file mode 100644 index 0000000..b2a424b --- /dev/null +++ b/Sources/DashUIKit/Resources/Media.xcassets/Icons & Illustrations/Other/text-field-scan-qr.imageset/Contents.json @@ -0,0 +1,16 @@ +{ + "images" : [ + { + "filename" : "text-field-scan-qr.svg", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" + } +} diff --git a/Sources/DashUIKit/Resources/Media.xcassets/Icons & Illustrations/Other/text-field-scan-qr.imageset/text-field-scan-qr.svg b/Sources/DashUIKit/Resources/Media.xcassets/Icons & Illustrations/Other/text-field-scan-qr.imageset/text-field-scan-qr.svg new file mode 100644 index 0000000..a6015e8 --- /dev/null +++ b/Sources/DashUIKit/Resources/Media.xcassets/Icons & Illustrations/Other/text-field-scan-qr.imageset/text-field-scan-qr.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/buttons-and-inputs.md b/docs/buttons-and-inputs.md index 7dcbc5e..2b7b0d1 100644 --- a/docs/buttons-and-inputs.md +++ b/docs/buttons-and-inputs.md @@ -145,7 +145,12 @@ State-driven styling: - **Blurred + filled (no error):** clean read-out — the trailing action button is hidden but kept in the layout (opacity 0, non-interactive) so the field width/wrapping doesn't shift between focused/unfocused. -- **Disabled:** field non-editable, action button omitted. +- **Disabled:** field non-editable, action button omitted; label and entered text drop to + `secondaryText`, the placeholder to `tertiaryText` (the `MenuItem` disabled step). + +Label: `footnoteMedium` in `primaryText`. Placeholder: `subhead` in `textFieldPlaceholder` +(#0A0A0D / white, both at 50 %). Scan button: the corner-brackets +`DashIcon.Other.textFieldScanQR` (template, `textFieldCryptoAddressIcon`) in a 40pt tap area. `showsClearButton: false` drops the trailing ✕ for a field short enough to clear by hand; with no `onScanQR` either, no trailing space is reserved at all. diff --git a/docs/foundation.md b/docs/foundation.md index 951b43f..cc68ec4 100644 --- a/docs/foundation.md +++ b/docs/foundation.md @@ -31,7 +31,7 @@ Token groups (see the source for the full list): applicable). These back `DashButtonStyle`. - **Component-specific:** `grabberFill`, `searchBackground`/`searchIcon`/…, `segmentControl…`, `select…`, `stepper…`, `switchTrackFillOn/Off…`, `textFieldCryptoAddress…`, - `toastBackground`/`toastText`, `toolbar…`, `topIntro…`, `bottomNavBackground`, + `textFieldPlaceholder`, `toastBackground`/`toastText`, `toolbar…`, `topIntro…`, `bottomNavBackground`, `navBackButton`, `backgroundOverlay`, `listGiftCardNumberBackground`, `badgeBackground…`, `statusBarElements`, `shortcutBarBackground` - **Raw tokens:** `blue` (+ `blueAlpha5…90`), `black`/`black1000Alpha5…90`/`black800/900`, @@ -118,7 +118,7 @@ Many components accept a `DashIconSource?` directly (`DashButton.leadingIcon`, Bundled custom assets (under `Media.xcassets/Icons & Illustrations/`) include nav icons (`navigationbar-back/close/plus/info`), search icons, currency glyphs (`icon_dash_currency`, `enter-amount-dash`, `chevron-down-currency-select`), checkbox -icons, text-field icons (`text-field-qr`, `text-field-clear`), menu icons +icons, text-field icons (`text-field-qr`, `text-field-scan-qr`, `text-field-clear`), menu icons (`menu-send/receive`, `support`, …), explainer-sheet feature icons (`feature-shield`, `feature-timer`, `feature-identity`, `feature-platform`, each with a `-purple` variant where one exists), segmented-control arrows