-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix inputs * update memo field and clients lib * add file * clean up * addresss feedback --------- Co-authored-by: Mike <[email protected]>
- Loading branch information
Showing
9 changed files
with
5,817 additions
and
4,305 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
9,749 changes: 5,562 additions & 4,187 deletions
9,749
dydx/dydxPresenters/dydxPresenters/_Features/v4-native-client.js
Large diffs are not rendered by default.
Oops, something went wrong.
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
35 changes: 35 additions & 0 deletions
35
dydx/dydxViews/dydxViews/Shared/dydxComponents/dydxTitledContent.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,35 @@ | ||
// | ||
// dydxTitledContent.swift | ||
// dydxViews | ||
// | ||
// Created by Michael Maguire on 10/25/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct dydxTitledContent<Content: View>: View { | ||
let title: String | ||
let content: Content | ||
|
||
init(title: String, @ViewBuilder content: () -> Content) { | ||
self.title = title | ||
self.content = content() | ||
} | ||
|
||
@ViewBuilder | ||
private var titleView: some View { | ||
Text(title) | ||
.themeColor(foreground: .textTertiary) | ||
.themeFont(fontType: .base, fontSize: .smaller) | ||
} | ||
|
||
var body: some View { | ||
VStack(alignment: .leading, spacing: 5) { | ||
titleView | ||
content | ||
} | ||
.padding(.vertical, 12) | ||
.padding(.horizontal, 16) | ||
.makeInput() | ||
} | ||
} |
109 changes: 109 additions & 0 deletions
109
dydx/dydxViews/dydxViews/Shared/dydxComponents/dydxTitledTextField.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,109 @@ | ||
// | ||
// dydxTitledTextField.swift | ||
// dydxViews | ||
// | ||
// Created by Michael Maguire on 10/24/24. | ||
// | ||
|
||
import SwiftUI | ||
import dydxFormatter | ||
import PlatformUI | ||
import Utilities | ||
|
||
/// Effectively a TextField which forces its input as a number | ||
/// Supports dydx-style title and title accesory view | ||
struct dydxTitledTextField: View { | ||
let title: String | ||
let placeholder: String | ||
let isPasteEnabled: Bool | ||
let isClearEnabled: Bool | ||
@Binding var text: String | ||
|
||
private static let inputFontType: ThemeFont.FontType = .base | ||
private static let inputFontSize: ThemeFont.FontSize = .medium | ||
private static let inputFontHeight: CGFloat = { | ||
ThemeSettings.shared.themeConfig.themeFont.uiFont(of: inputFontType, fontSize: inputFontSize)?.lineHeight ?? 0 | ||
}() | ||
|
||
init(title: String, placeholder: String, isPasteEnabled: Bool = false, isClearEnabled: Bool = true, text: Binding<String>) { | ||
self.title = title | ||
self.placeholder = placeholder | ||
self.isPasteEnabled = isPasteEnabled | ||
self.isClearEnabled = isClearEnabled | ||
self._text = text | ||
} | ||
|
||
@ViewBuilder | ||
private var titleView: some View { | ||
Text(title) | ||
.themeColor(foreground: .textTertiary) | ||
.themeFont(fontType: .base, fontSize: .smaller) | ||
} | ||
|
||
private var textFieldView: some View { | ||
TextField(text: $text) { | ||
placeholderView | ||
} | ||
.themeColor(foreground: .textPrimary) | ||
.themeFont(fontType: .base, fontSize: .medium) | ||
.truncationMode(.middle) | ||
} | ||
|
||
@ViewBuilder | ||
private var placeholderView: some View { | ||
Text(placeholder) | ||
.themeFont(fontType: .base, fontSize: .medium) | ||
.themeColor(foreground: .textTertiary) | ||
} | ||
|
||
private var clearButton: some View { | ||
let content = Image("icon_cancel", bundle: .dydxView) | ||
.resizable() | ||
.templateColor(.textSecondary) | ||
.padding(.all, 10) | ||
.frame(width: 32, height: 32) | ||
.borderAndClip(style: .circle, borderColor: .layer6) | ||
.wrappedViewModel | ||
|
||
return PlatformButtonViewModel(content: content, | ||
type: .iconType, | ||
state: .secondary) { | ||
self.text = "" | ||
} | ||
.createView() | ||
} | ||
|
||
private var pasteButton: some View { | ||
let buttonContent = Text(DataLocalizer.localize(path: "APP.GENERAL.PASTE")) | ||
.themeColor(foreground: .textSecondary) | ||
.themeFont(fontSize: .small) | ||
.wrappedViewModel | ||
|
||
return PlatformButtonViewModel(content: buttonContent, | ||
type: .defaultType(fillWidth: false, padding: .init(horizontal: 8, vertical: 6)), | ||
state: .secondary ) { | ||
self.text = UIPasteboard.general.string ?? "" | ||
} | ||
.createView() | ||
.frame(height: Self.inputFontHeight) | ||
} | ||
|
||
var body: some View { | ||
HStack(spacing: 0) { | ||
VStack(alignment: .leading, spacing: 5) { | ||
titleView | ||
textFieldView | ||
} | ||
if isPasteEnabled && text.isEmpty { | ||
Spacer() | ||
pasteButton | ||
} else if isClearEnabled && !text.isEmpty { | ||
Spacer() | ||
clearButton | ||
} | ||
} | ||
.padding(.vertical, 12) | ||
.padding(.horizontal, 16) | ||
.makeInput() | ||
} | ||
} |
Oops, something went wrong.