-
Notifications
You must be signed in to change notification settings - Fork 6
feat: update “Import account” ui #1316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
zhouxl
wants to merge
30
commits into
develop
Choose a base branch
from
feat/importaccount
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 25 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
5277d15
feat: update “Import account” ui
zhouxl afa0025
feat: udpate multi-backup UI
zhouxl c02bc93
feat: rename ImportAccountListView
zhouxl 97e1316
feat: avatar
zhouxl 47da5c2
feat: Account Info View
zhouxl 982b8c9
feat: multi-account on sidemenu
zhouxl 726ba8e
feat: remove debug code
zhouxl 3eeaf45
feat: fetch count of token and NFT for accounts
zhouxl fbccde9
feat: enable EVM
zhouxl 0a97ced
feat: [SideMenu] sorted account by flow balance and nft count
zhouxl 92f40a7
feat: remove useless code
zhouxl c7891d8
feat: remove error
zhouxl bfd95a1
feat: switch Profile
zhouxl eca50d0
feat: update avatar to square
zhouxl 77f6e29
feat: upate setting Profile info
zhouxl 614976a
feat: update account list on setting-1
zhouxl f9a24ba
feat: update Account Detail
zhouxl af47031
feat: UI for linked account page
zhouxl dbc15ec
feat: unlink account & add maincount to `sendTransaction` of FlowNetwork
zhouxl 77aa81b
feat: don’t hide current account
zhouxl 7d7b593
feat: update logic of account filter
zhouxl 96b7121
feat: import profile
zhouxl fb6fef5
feat: sync multi-account by device
zhouxl be5ddc1
feat: update status of hide on account
zhouxl 5f6e2e4
feat: update wallet user profile
zhouxl 633f389
feat: remove testdata
zhouxl b4151b1
feat: update struct for account
zhouxl 308159f
feat: create a new account
zhouxl d7b1f65
feat: create account on side menu
zhouxl 6562b27
feat: update randomDifferentElements and rename filterAccounts
zhouxl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Large diffs are not rendered by default.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
FRW.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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,85 @@ | ||
// | ||
// AccountInfoProtocol.swift | ||
// FRW | ||
// | ||
// Created by cat on 5/29/25. | ||
// | ||
|
||
import FlowWalletKit | ||
import SwiftUI | ||
|
||
protocol AccountInfoProtocol { | ||
var infoName: String { get } | ||
var infoAddress: String { get } | ||
var accountType: FWAccount.AccountType { get } | ||
|
||
var walletMetadata: WalletUserProfile.User { get } | ||
|
||
func avatar(isSelected: Bool, subAvatar: AvatarSource?) -> AvatarView | ||
} | ||
|
||
extension AccountInfoProtocol { | ||
var walletMetadata: WalletUserProfile.User { | ||
WalletManager.shared.walletAccount.readInfo(at: infoAddress) | ||
} | ||
} | ||
|
||
// MARK: Account | ||
|
||
extension FlowWalletKit.Account: AccountInfoProtocol { | ||
func avatar(isSelected: Bool, subAvatar: AvatarSource?) -> AvatarView { | ||
AvatarView(mainAvatar: .user(walletMetadata), subAvatar: subAvatar, backgroundColor: Color.Summer.cards, isSelected: isSelected) | ||
} | ||
|
||
var infoName: String { | ||
walletMetadata.name | ||
} | ||
|
||
var infoAddress: String { | ||
hexAddr | ||
} | ||
|
||
var accountType: FWAccount.AccountType { | ||
.main | ||
} | ||
} | ||
|
||
// MARK: COA | ||
|
||
extension FlowWalletKit.COA: AccountInfoProtocol { | ||
func avatar(isSelected: Bool, subAvatar: AvatarSource?) -> AvatarView { | ||
AvatarView(mainAvatar: .user(walletMetadata), subAvatar: subAvatar, backgroundColor: Color.Summer.cards, isSelected: isSelected) | ||
} | ||
|
||
var infoName: String { | ||
walletMetadata.name | ||
} | ||
|
||
var infoAddress: String { | ||
address | ||
} | ||
|
||
var accountType: FWAccount.AccountType { | ||
.coa | ||
} | ||
} | ||
|
||
// MARK: FlowWalletKit.Account of AccountInfoProtocol | ||
|
||
extension FlowWalletKit.ChildAccount: AccountInfoProtocol { | ||
func avatar(isSelected: Bool, subAvatar: AvatarSource?) -> AvatarView { | ||
AvatarView(mainAvatar: .url(icon ?? AppPlaceholder.imageURL), subAvatar: subAvatar, isSelected: isSelected) | ||
} | ||
|
||
var infoName: String { | ||
name ?? "unknown" | ||
} | ||
|
||
var infoAddress: String { | ||
address.hexAddr | ||
} | ||
|
||
var accountType: FWAccount.AccountType { | ||
.child | ||
} | ||
} |
This file contains hidden or 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,56 @@ | ||
// | ||
// AccountModel.swift | ||
// FRW | ||
// | ||
// Created by cat on 6/3/25. | ||
// | ||
|
||
import Foundation | ||
|
||
struct AccountModel: Equatable { | ||
static func == (lhs: AccountModel, rhs: AccountModel) -> Bool { | ||
lhs.account.infoAddress == rhs.account.infoAddress | ||
} | ||
|
||
var account: any AccountInfoProtocol | ||
/// not nil when account type is coa or child,other is nil | ||
var mainAccount: (any AccountInfoProtocol)? | ||
var flowCount: String | ||
var nftCount: UInt | ||
} | ||
|
||
// MARK: - UI | ||
|
||
extension AccountModel { | ||
var hideFlow: Bool { | ||
account.accountType == .child | ||
} | ||
|
||
var showAmount: String { | ||
var amount = "" | ||
let flowCount = Double(flowCount) ?? 0 | ||
if flowCount >= 0 { | ||
amount += "\(flowCount.formatCurrencyString()) Flow" + " | " | ||
} | ||
if nftCount >= 0 { | ||
amount += "\(nftCount) NFT's" | ||
} | ||
return amount | ||
} | ||
|
||
func isSelected(_ address: String) -> Bool { | ||
account.infoAddress == address | ||
} | ||
|
||
var isMain: Bool { | ||
account.accountType == .main | ||
} | ||
|
||
var isCoa: Bool { | ||
account.accountType == .coa | ||
} | ||
|
||
var isChild: Bool { | ||
account.accountType == .child | ||
} | ||
} |
This file contains hidden or 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 hidden or 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,49 @@ | ||
import SwiftUI | ||
|
||
struct MockAccountInfo: AccountInfoProtocol { | ||
var infoName: String | ||
var infoAddress: String | ||
var accountType: FWAccount.AccountType | ||
var walletMetadata: WalletUserProfile.User | ||
|
||
func avatar(isSelected: Bool, subAvatar: AvatarSource?) -> AvatarView { | ||
AvatarView(mainAvatar: .system("person.crop.circle.fill"), subAvatar: subAvatar, backgroundColor: Color.Summer.cards, isSelected: isSelected) | ||
} | ||
} | ||
|
||
extension MockAccountInfo { | ||
static func mockSamples() -> [MockAccountInfo] { | ||
[ | ||
MockAccountInfo( | ||
infoName: "mainAccount", | ||
infoAddress: "0x1234567890abcdef", | ||
accountType: .main, | ||
walletMetadata: WalletUserProfile.User(emoji: .koala, address: "0x1234567890abcdef") | ||
), | ||
MockAccountInfo( | ||
infoName: "Child", | ||
infoAddress: "0xabcdef1234567890", | ||
accountType: .child, | ||
walletMetadata: WalletUserProfile.User(emoji: .lion, address: "0xabcdef1234567890") | ||
), | ||
MockAccountInfo( | ||
infoName: "EVM", | ||
infoAddress: "0x8e5b4a8e5b4a8e5b4a8e5b4a8e5b4a8e5b4a8e5b", | ||
accountType: .coa, | ||
walletMetadata: WalletUserProfile.User(emoji: .avocado, address: "0x8e5b4a8e5b4a8e5b4a8e5b4a8e5b4a8e5b4a8e5b") | ||
), | ||
] | ||
} | ||
} | ||
|
||
extension AccountModel { | ||
/// 生成一组典型的 AccountModel mock 测试数据 | ||
static func mockSamples() -> [AccountModel] { | ||
let accounts = MockAccountInfo.mockSamples() | ||
return [ | ||
AccountModel(account: accounts[0], mainAccount: nil, flowCount: "123.45", nftCount: 7), | ||
AccountModel(account: accounts[1], mainAccount: accounts[0], flowCount: "0.00", nftCount: 0), | ||
AccountModel(account: accounts[2], mainAccount: accounts[0], flowCount: "999.99", nftCount: 99), | ||
] | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
Double(flowCount)
conversion could fail silently ifflowCount
contains an invalid number format. Consider using a more robust number parsing approach or handling the failure case explicitly.