mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-22 18:44:31 +00:00
wallet tokens list ui updates
This commit is contained in:
parent
51c00372e4
commit
b7497f8dfe
2 changed files with 51 additions and 36 deletions
|
@ -3,12 +3,10 @@ import 'dart:async';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:isar/isar.dart';
|
|
||||||
import 'package:stackwallet/db/isar/main_db.dart';
|
|
||||||
import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart';
|
|
||||||
import 'package:stackwallet/pages/add_wallet_views/add_token_view/add_token_view.dart';
|
import 'package:stackwallet/pages/add_wallet_views/add_token_view/add_token_view.dart';
|
||||||
import 'package:stackwallet/pages/token_view/sub_widgets/my_tokens_list.dart';
|
import 'package:stackwallet/pages/token_view/sub_widgets/my_tokens_list.dart';
|
||||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||||
|
import 'package:stackwallet/services/coins/ethereum/ethereum_wallet.dart';
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
import 'package:stackwallet/utilities/constants.dart';
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
|
@ -32,46 +30,18 @@ class MyTokensView extends ConsumerStatefulWidget {
|
||||||
final String walletId;
|
final String walletId;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ConsumerState<MyTokensView> createState() => _TokenDetailsViewState();
|
ConsumerState<MyTokensView> createState() => _MyTokensViewState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TokenDetailsViewState extends ConsumerState<MyTokensView> {
|
class _MyTokensViewState extends ConsumerState<MyTokensView> {
|
||||||
late final String walletAddress;
|
late final String walletAddress;
|
||||||
late final TextEditingController _searchController;
|
late final TextEditingController _searchController;
|
||||||
final searchFieldFocusNode = FocusNode();
|
final searchFieldFocusNode = FocusNode();
|
||||||
String _searchString = "";
|
String _searchString = "";
|
||||||
|
|
||||||
List<EthContract> _filter(String searchTerm) {
|
|
||||||
if (searchTerm.isNotEmpty) {
|
|
||||||
final term = searchTerm.toLowerCase();
|
|
||||||
return MainDB.instance
|
|
||||||
.getEthContracts()
|
|
||||||
.filter()
|
|
||||||
.walletIdsElementEqualTo(widget.walletId)
|
|
||||||
.and()
|
|
||||||
.group(
|
|
||||||
(q) => q
|
|
||||||
.nameContains(term, caseSensitive: false)
|
|
||||||
.or()
|
|
||||||
.symbolContains(term, caseSensitive: false)
|
|
||||||
.or()
|
|
||||||
.addressContains(term, caseSensitive: false),
|
|
||||||
)
|
|
||||||
.findAllSync();
|
|
||||||
// return tokens.toList();
|
|
||||||
}
|
|
||||||
//implement search/filter
|
|
||||||
return MainDB.instance
|
|
||||||
.getEthContracts()
|
|
||||||
.filter()
|
|
||||||
.walletIdsElementEqualTo(widget.walletId)
|
|
||||||
.findAllSync();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
_searchController = TextEditingController();
|
_searchController = TextEditingController();
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +54,8 @@ class _TokenDetailsViewState extends ConsumerState<MyTokensView> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
debugPrint("BUILD: $runtimeType");
|
||||||
|
|
||||||
final isDesktop = Util.isDesktop;
|
final isDesktop = Util.isDesktop;
|
||||||
|
|
||||||
return MasterScaffold(
|
return MasterScaffold(
|
||||||
|
@ -290,7 +262,12 @@ class _TokenDetailsViewState extends ConsumerState<MyTokensView> {
|
||||||
Expanded(
|
Expanded(
|
||||||
child: MyTokensList(
|
child: MyTokensList(
|
||||||
walletId: widget.walletId,
|
walletId: widget.walletId,
|
||||||
tokens: _filter(_searchString),
|
searchTerm: _searchString,
|
||||||
|
tokenContracts: ref
|
||||||
|
.watch(walletsChangeNotifierProvider.select((value) => value
|
||||||
|
.getManager(widget.walletId)
|
||||||
|
.wallet as EthereumWallet))
|
||||||
|
.getWalletTokenContractAddresses(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:isar/isar.dart';
|
||||||
|
import 'package:stackwallet/db/isar/main_db.dart';
|
||||||
import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart';
|
import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart';
|
||||||
import 'package:stackwallet/pages/token_view/sub_widgets/my_token_select_item.dart';
|
import 'package:stackwallet/pages/token_view/sub_widgets/my_token_select_item.dart';
|
||||||
|
|
||||||
|
@ -7,16 +9,52 @@ class MyTokensList extends StatelessWidget {
|
||||||
const MyTokensList({
|
const MyTokensList({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.walletId,
|
required this.walletId,
|
||||||
required this.tokens,
|
required this.searchTerm,
|
||||||
|
required this.tokenContracts,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final String walletId;
|
final String walletId;
|
||||||
final List<EthContract> tokens;
|
final String searchTerm;
|
||||||
|
final List<String> tokenContracts;
|
||||||
|
|
||||||
|
List<EthContract> _filter(String searchTerm) {
|
||||||
|
if (tokenContracts.isEmpty) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (searchTerm.isNotEmpty) {
|
||||||
|
final term = searchTerm.toLowerCase();
|
||||||
|
return MainDB.instance
|
||||||
|
.getEthContracts()
|
||||||
|
.filter()
|
||||||
|
.anyOf<String, EthContract>(
|
||||||
|
tokenContracts, (q, e) => q.addressEqualTo(e))
|
||||||
|
.and()
|
||||||
|
.group(
|
||||||
|
(q) => q
|
||||||
|
.nameContains(term, caseSensitive: false)
|
||||||
|
.or()
|
||||||
|
.symbolContains(term, caseSensitive: false)
|
||||||
|
.or()
|
||||||
|
.addressContains(term, caseSensitive: false),
|
||||||
|
)
|
||||||
|
.findAllSync();
|
||||||
|
// return tokens.toList();
|
||||||
|
}
|
||||||
|
//implement search/filter
|
||||||
|
return MainDB.instance
|
||||||
|
.getEthContracts()
|
||||||
|
.filter()
|
||||||
|
.anyOf<String, EthContract>(
|
||||||
|
tokenContracts, (q, e) => q.addressEqualTo(e))
|
||||||
|
.findAllSync();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Consumer(
|
return Consumer(
|
||||||
builder: (_, ref, __) {
|
builder: (_, ref, __) {
|
||||||
|
final tokens = _filter(searchTerm);
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
itemCount: tokens.length,
|
itemCount: tokens.length,
|
||||||
itemBuilder: (ctx, index) {
|
itemBuilder: (ctx, index) {
|
||||||
|
|
Loading…
Reference in a new issue