Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
IOS-7988: Apply [email protected] to all example project sources
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Fedorov <[email protected]>
  • Loading branch information
Andrey Fedorov committed Oct 10, 2024
1 parent ec854e7 commit 1a5d3d2
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 124 deletions.
2 changes: 0 additions & 2 deletions BlockchainSdkExample/APIListUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ struct ConfigUtils {
}
}


typealias APIListDTO = [String: [APIInfoDTO]]

struct APIInfoDTO: Decodable {
Expand Down Expand Up @@ -203,7 +202,6 @@ struct Keys: Decodable {
let bittensorOnfinalityKey: String
}


struct TonCenterApiKeys: Decodable {
let mainnet: String
let testnet: String
Expand Down
2 changes: 1 addition & 1 deletion BlockchainSdkExample/BlockchainSdkExampleApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import SwiftUI
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
let model = BlockchainSdkExampleViewModel()

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let contentView = BlockchainSdkExampleView()
.environmentObject(model)
Expand Down
53 changes: 26 additions & 27 deletions BlockchainSdkExample/BlockchainSdkExampleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SwiftUI

struct BlockchainSdkExampleView: View {
@EnvironmentObject var model: BlockchainSdkExampleViewModel

var body: some View {
NavigationView {
Form {
Expand All @@ -20,7 +20,7 @@ struct BlockchainSdkExampleView: View {
} label: {
Text("Scan card")
}

Picker("Blockchain", selection: $model.blockchainName) {
Text("Not selected").tag("")
ForEach(model.blockchains, id: \.1) { blockchain in
Expand All @@ -30,7 +30,7 @@ struct BlockchainSdkExampleView: View {
}
.disabled(model.cardWallets.isEmpty)
.modifier(PickerStyleModifier())

if model.blockchainsWithCurveSelection.contains(model.blockchainName) {
Picker("Curve", selection: $model.curve) {
ForEach(model.curves, id: \.self) { curve in
Expand All @@ -41,31 +41,31 @@ struct BlockchainSdkExampleView: View {
.disabled(model.card == nil)
.modifier(PickerStyleModifier())
}

Toggle("Testnet", isOn: $model.isTestnet)
.disabled(model.card == nil)

if #available(iOS 14.0, *) {
DisclosureGroup(model.tokenSectionName, isExpanded: $model.tokenExpanded) {
Toggle("Enabled", isOn: $model.tokenEnabled)
TextField("Symbol", text: $model.tokenSymbol)
TextField("Contract address", text: $model.tokenContractAddress)
Stepper("Decimal places \(model.tokenDecimalPlaces)", value: $model.tokenDecimalPlaces, in: 0...24)
Stepper("Decimal places \(model.tokenDecimalPlaces)", value: $model.tokenDecimalPlaces, in: 0 ... 24)
}
}

if #available(iOS 14.0, *) {
DisclosureGroup("Using dummy address / public key", isExpanded: $model.dummyExpanded) {
TextField("Public Key", text: $model.dummyPublicKey)
.disableAutocorrection(true)
.keyboardType(.alphabet)
.truncationMode(.middle)

TextField("Address", text: $model.dummyAddress)
.disableAutocorrection(true)
.keyboardType(.alphabet)
.truncationMode(.middle)

HStack {
Button {
model.updateDummyAction()
Expand All @@ -75,7 +75,7 @@ struct BlockchainSdkExampleView: View {
.frame(maxWidth: .infinity)
}
.buttonStyle(BorderlessButtonStyle())

Spacer()

Button {
Expand All @@ -91,7 +91,7 @@ struct BlockchainSdkExampleView: View {
}
}
}

Section(header: Text("Source address and balance")) {
if model.sourceAddresses.isEmpty {
Text("--")
Expand All @@ -104,71 +104,71 @@ struct BlockchainSdkExampleView: View {
.font(.caption)
.foregroundColor(.gray)
}

Text(address.value)
.lineLimit(1)
.truncationMode(.middle)
}

Spacer()

Button {
model.copySourceAddressToClipboard(address)
} label: {
Image(systemName: "doc.on.doc")
}
}
}

if model.isUseDummy {
Text("Attention: Using a dummy address, please do not send transactions!")
.foregroundColor(.red)
}
}

HStack {
Text(model.balance)
.modifier(TextSelectionConditionalModifier())

Spacer()

Button {
model.updateBalance()
} label: {
Image(systemName: "arrow.clockwise")
}
}
}

Section(header: Text("Destination and amount to send")) {
// Don't change the placeholder to 'Destination', otherwise SwiftUI is going to suggest your address there
TextField("0xABCD01234", text: $model.destination)
.disableAutocorrection(true)
.keyboardType(.alphabet)
.truncationMode(.middle)

TextField("0.001", text: $model.amountToSend)
.keyboardType(.decimalPad)
}

Section(header: Text("Transaction")) {
Button {
model.sendTransaction()
} label: {
Text("Send \(model.enteredToken != nil ? "token" : "coin") transaction")
}

Text(model.transactionResult)
}
.disabled(model.walletManager == nil)

Section(header: Text("Fees")) {
Button {
model.checkFee()
} label: {
Text("Check fee")
}

if model.feeDescriptions.isEmpty {
Text("--")
} else {
Expand All @@ -188,7 +188,7 @@ struct BlockchainSdkExampleView: View {
}
}

fileprivate struct PickerStyleModifier: ViewModifier {
private struct PickerStyleModifier: ViewModifier {
func body(content: Content) -> some View {
if #available(iOS 14, *) {
content
Expand All @@ -200,7 +200,7 @@ fileprivate struct PickerStyleModifier: ViewModifier {
}
}

fileprivate struct TextSelectionConditionalModifier: ViewModifier {
private struct TextSelectionConditionalModifier: ViewModifier {
func body(content: Content) -> some View {
if #available(iOS 15, *) {
content
Expand All @@ -211,7 +211,6 @@ fileprivate struct TextSelectionConditionalModifier: ViewModifier {
}
}


struct ContentView_Previews: PreviewProvider {
static var previews: some View {
BlockchainSdkExampleView()
Expand Down
Loading

0 comments on commit 1a5d3d2

Please sign in to comment.