Skip to content

Commit

Permalink
clean up cell size in leverage selector
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-dydx committed Jun 3, 2024
1 parent d528d0c commit c3ec353
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 27 deletions.
11 changes: 10 additions & 1 deletion dydx/dydx.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "1c0055be4aba3ed4d97a2f62f05486877839310f65e2cbdd18b067bef06a04a3",
"originHash" : "975d00e29efb8d2ca017c5e61df90418ac01f7d7143e85a3f9ddb4eb982154e4",
"pins" : [
{
"identity" : "bigint",
Expand Down Expand Up @@ -46,6 +46,15 @@
"revision" : "48134b5460435cc9d048223ad7560ee2e40f3d4a"
}
},
{
"identity" : "percy-xcui-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/percy/percy-xcui-swift",
"state" : {
"revision" : "a2e9a86dfc3f5b69ef53cbda28a0ea71098c9f77",
"version" : "1.0.0"
}
},
{
"identity" : "qrcode",
"kind" : "remoteSourceControl",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,38 +75,45 @@ public class dydxTargetLeverageViewModel: PlatformViewModel {
}

private func createOptionsGroup(parentStyle: ThemeStyle) -> some View {
let items = self.leverageOptions.compactMap {
Text($0.text)
.themeFont(fontType: .plus, fontSize: .small)
.themeColor(foreground: .textTertiary)
.padding(8)
.frame(minWidth: 60)
.themeColor(background: .layer5)
.border(borderWidth: 1, cornerRadius: 8, borderColor: ThemeColor.SemanticColor.layer5.color)
.wrappedViewModel
}
let selectedItems = self.leverageOptions.compactMap {
Text($0.text)
.themeFont(fontType: .plus, fontSize: .small)
.themeColor(foreground: .textPrimary)
.padding(8)
.frame(minWidth: 60)
.themeColor(background: .layer1)
.border(borderWidth: 1, cornerRadius: 8, borderColor: ThemeColor.SemanticColor.layer5.color)
.wrappedViewModel
}
let spacing: CGFloat = 8
let maxItemsToDisplay = CGFloat(max(5, leverageOptions.count))

return GeometryReader { geometry in
let width = (geometry.size.width + spacing) / maxItemsToDisplay - spacing
let items = self.leverageOptions.compactMap {
Text($0.text)
.themeFont(fontType: .plus, fontSize: .small)
.themeColor(foreground: .textTertiary)
.padding(8)
.frame(minWidth: width)
.themeColor(background: .layer5)
.borderAndClip(style: .cornerRadius(8), borderColor: ThemeColor.SemanticColor.layer5)
.wrappedViewModel
}

return
ScrollView(.horizontal, showsIndicators: false) {
let selectedItems = self.leverageOptions.compactMap {
Text($0.text)
.themeFont(fontType: .plus, fontSize: .small)
.themeColor(foreground: .textPrimary)
.padding(8)
.frame(minWidth: width)
.themeColor(background: .layer1)
.borderAndClip(style: .cornerRadius(8), borderColor: ThemeColor.SemanticColor.layer5)
.wrappedViewModel
}

return ScrollView(.horizontal, showsIndicators: false) {
TabGroupModel(items: items,
selectedItems: selectedItems,
currentSelection: self.selectedOptionIndex,
onSelectionChanged: { index in
selectedItems: selectedItems,
currentSelection: self.selectedOptionIndex,
onSelectionChanged: { index in
self.optionSelectedAction?(self.leverageOptions[index])
})
},
spacing: spacing)
.createView(parentStyle: parentStyle)
}
}
}
}

#if DEBUG
Expand Down

0 comments on commit c3ec353

Please sign in to comment.