-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
484 Account storage alert - Extracted a reusable `StorageUsageView` from `WalletSettingView` - Added the `StorageUsageView` to `TokenDetailView` - Added `getAccountInfo` cadence - Handled the `insufficientStorage` case in the remote config to display an insufficient storage alert - Fixed bug causing `getAccountInfo()` to fail right after launching the app - Added system-wide popup to notify the user about storage transaction failure - Refactored `AlertView` to allow for injected custom content - Created `PersistentToastView` - Added storage usage progress in TokenDetailView - Added storage warning to move/send token/nft views - Implemented generic and reusable `InsufficientStorageToastView` as a drop-in specifically for showing the insufficient warning - Refactored the alert view, wrapped in a UIHostincController and injected in the presented view controller
- Loading branch information
Showing
56 changed files
with
1,310 additions
and
301 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// AccountModels.swift | ||
// FRW | ||
// | ||
// Created by Antonio Bello on 11/7/24. | ||
// | ||
|
||
import Foundation | ||
import Flow | ||
|
||
extension Flow { | ||
struct AccountInfo: Decodable { | ||
public let address: Flow.Address | ||
public let balance: Decimal | ||
public let availableBalance: Decimal | ||
public let storageUsed: UInt64 | ||
public let storageCapacity: UInt64 | ||
public let storageFlow: Decimal | ||
} | ||
} | ||
|
||
extension Flow.AccountInfo { | ||
var storageUsedRatio: Double { | ||
guard self.storageCapacity > 0 else { return 0 } | ||
let ratio = Double(self.storageUsed) / Double(self.storageCapacity) | ||
return min(1, max(0, ratio)) | ||
} | ||
|
||
var storageUsedString: String { | ||
let usedStr = humanReadableByteCount(bytes: self.storageUsed) | ||
let capacityStr = humanReadableByteCount(bytes: self.storageCapacity) | ||
return "\(usedStr) / \(capacityStr)" | ||
} | ||
|
||
private func humanReadableByteCount(bytes: UInt64) -> String { | ||
if bytes < 1024 { return "\(bytes) B" } | ||
let exp = Int(log2(Double(bytes)) / log2(1024.0)) | ||
let unit = ["KB", "MB", "GB", "TB", "PB", "EB"][exp - 1] | ||
let number = Double(bytes) / pow(1024, Double(exp)) | ||
if exp <= 1 || number >= 100 { | ||
return String(format: "%.0f %@", number, unit) | ||
} else { | ||
return String(format: "%.1f %@", number, unit) | ||
.replacingOccurrences(of: ".0", with: "") | ||
} | ||
} | ||
} |
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
Oops, something went wrong.