-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MOB-1905 - UI for token amount input (#453)
* Updated receive button place. Removed current profile switcher. Added send button * Updated home screen title view * Added send crypto view. Show from the home view. Added input field and scan qr option * Added section with user's wallets * Added send crypto view model Added UI for following selection * Refactoring * Updated nav bar customisation * Disable interactive dismiss when navigate * Extracted tab selection view from explore module * Refactoring * Created UI for token balance * Make tokens selectable * Added UI for domains list in assets selection Adjusted navigation header UI * Created senc crypto flow actions Handle actions in view model Hide empty sections on receiver selection screen * Pass actions from select receiver and asset type views * Refactoring * Fixed initial onAppear call in token icons view * Created UDNumberButtonView * Created number pad view and input interpreter. Created tests for interpreter * Improved number pad logic * Added UI for input and token info * Added converted value label and toggle * Added confirmation button * Refactoring * Disable animation for primary input view * Swap buy and send actions on home screen * Fixed copy on select receiver screen * Added token icon near primary input value * Adjusted UI for nav bar and in the IP SE
- Loading branch information
1 parent
9ccc5bf
commit 071002f
Showing
20 changed files
with
720 additions
and
134 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
51 changes: 51 additions & 0 deletions
51
unstoppable-ios-app/domains-manager-ios/Entities/NumberPadInputInterpreter.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,51 @@ | ||
// | ||
// NumberPadInputInterpreter.swift | ||
// domains-manager-ios | ||
// | ||
// Created by Oleg Kuplin on 20.03.2024. | ||
// | ||
|
||
import Foundation | ||
|
||
struct NumberPadInputInterpreter { | ||
private var input: String = "" | ||
|
||
mutating func addInput(_ inputType: UDNumberButtonView.InputType) { | ||
switch inputType { | ||
case .number(let num): | ||
if num == 0, | ||
input == "0" { | ||
return | ||
} | ||
input.append(String(num)) | ||
case .dot: | ||
if !isContainsDot() { | ||
input += .dotSeparator | ||
} | ||
case .erase: | ||
if !input.isEmpty { | ||
input.removeLast() | ||
} | ||
} | ||
} | ||
|
||
private func isContainsDot() -> Bool { | ||
input.contains(.dotSeparator) | ||
} | ||
|
||
func getInterpretedNumber() -> Double { | ||
if input.last == .dotSeparator { | ||
return Double(input.dropLast()) ?? 0 | ||
} | ||
return Double(input) ?? 0 | ||
} | ||
|
||
func getInput() -> String { | ||
if input.isEmpty { | ||
return "0" | ||
} else if input.first == String.dotSeparator.first { | ||
return "0" + input | ||
} | ||
return input | ||
} | ||
} |
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
71 changes: 71 additions & 0 deletions
71
unstoppable-ios-app/domains-manager-ios/Modules/BalanceTokenIconsView.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,71 @@ | ||
// | ||
// BalanceTokenIconsView.swift | ||
// domains-manager-ios | ||
// | ||
// Created by Oleg Kuplin on 20.03.2024. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct BalanceTokenIconsView: View { | ||
|
||
let token: BalanceTokenUIDescription | ||
|
||
@State private var icon: UIImage? | ||
@State private var parentIcon: UIImage? | ||
|
||
var body: some View { | ||
ZStack(alignment: .bottomTrailing) { | ||
Image(uiImage: icon ?? .init()) | ||
.resizable() | ||
.squareFrame(40) | ||
.background(Color.backgroundSubtle) | ||
.skeletonable() | ||
.clipShape(Circle()) | ||
|
||
if token.parentSymbol != nil { | ||
Image(uiImage: parentIcon ?? .init()) | ||
.resizable() | ||
.squareFrame(20) | ||
.background(Color.backgroundDefault) | ||
.skeletonable() | ||
.clipShape(Circle()) | ||
.overlay { | ||
Circle() | ||
.stroke(lineWidth: 2) | ||
.foregroundStyle(Color.backgroundDefault) | ||
} | ||
.offset(x: 4, y: 4) | ||
} | ||
} | ||
.onChange(of: token, perform: { newValue in | ||
loadIconFor(token: newValue) | ||
}) | ||
.onAppear(perform: onAppear) | ||
} | ||
} | ||
|
||
// MARK: - Private methods | ||
private extension BalanceTokenIconsView { | ||
func onAppear() { | ||
loadIconFor(token: token) | ||
} | ||
|
||
func loadIconFor(token: BalanceTokenUIDescription) { | ||
guard !token.isSkeleton else { | ||
icon = nil | ||
parentIcon = nil | ||
return } | ||
|
||
token.loadTokenIcon { image in | ||
self.icon = image | ||
} | ||
token.loadParentIcon { image in | ||
self.parentIcon = image | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
BalanceTokenIconsView(token: MockEntitiesFabric.Tokens.mockUIToken()) | ||
} |
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
Oops, something went wrong.