Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
37 changes: 31 additions & 6 deletions Sources/DashUIKit/Components/AddressFieldView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 —
Expand Down Expand Up @@ -96,8 +98,8 @@ public struct AddressFieldView<Accessory: View>: View {
VStack(alignment: .leading, spacing: 10) {
HStack(spacing: 8) {
Text(label)
.dashFont(.footnote)
.foregroundStyle(Color.dash.gray500)
.dashFont(.footnoteMedium)
.foregroundStyle(contentColor)

Spacer(minLength: 0)

Expand Down Expand Up @@ -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)
Expand All @@ -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"))
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions Sources/DashUIKit/Foundation/Color+DashUI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions Sources/DashUIKit/Foundation/Icon_DashUI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion docs/buttons-and-inputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions docs/foundation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down Expand Up @@ -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
Expand Down
Loading