mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-11 05:04:35 +00:00
desktop addressbook search
This commit is contained in:
parent
e0ef78685d
commit
7cc3c71b0d
2 changed files with 158 additions and 162 deletions
|
@ -23,11 +23,16 @@ import 'package:stackwallet/widgets/stack_text_field.dart';
|
||||||
import 'package:stackwallet/widgets/textfield_icon_button.dart';
|
import 'package:stackwallet/widgets/textfield_icon_button.dart';
|
||||||
|
|
||||||
class AddressBookView extends ConsumerStatefulWidget {
|
class AddressBookView extends ConsumerStatefulWidget {
|
||||||
const AddressBookView({Key? key, this.coin}) : super(key: key);
|
const AddressBookView({
|
||||||
|
Key? key,
|
||||||
|
this.coin,
|
||||||
|
this.filterTerm,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
static const String routeName = "/addressBook";
|
static const String routeName = "/addressBook";
|
||||||
|
|
||||||
final Coin? coin;
|
final Coin? coin;
|
||||||
|
final String? filterTerm;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ConsumerState<AddressBookView> createState() => _AddressBookViewState();
|
ConsumerState<AddressBookView> createState() => _AddressBookViewState();
|
||||||
|
@ -37,9 +42,6 @@ class _AddressBookViewState extends ConsumerState<AddressBookView> {
|
||||||
late TextEditingController _searchController;
|
late TextEditingController _searchController;
|
||||||
|
|
||||||
final _searchFocusNode = FocusNode();
|
final _searchFocusNode = FocusNode();
|
||||||
//
|
|
||||||
// List<Contact>? _cache;
|
|
||||||
// List<Contact>? _cacheFav;
|
|
||||||
|
|
||||||
String _searchTerm = "";
|
String _searchTerm = "";
|
||||||
|
|
||||||
|
@ -198,20 +200,21 @@ class _AddressBookViewState extends ConsumerState<AddressBookView> {
|
||||||
child: IntrinsicHeight(
|
child: IntrinsicHeight(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(4),
|
padding: const EdgeInsets.all(4),
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
minHeight: MediaQuery.of(context).size.height - 271,
|
||||||
|
),
|
||||||
child: child,
|
child: child,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: ConstrainedBox(
|
|
||||||
constraints: BoxConstraints(
|
|
||||||
minHeight: MediaQuery.of(context).size.height - 271,
|
|
||||||
),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
|
@ -285,15 +288,14 @@ class _AddressBookViewState extends ConsumerState<AddressBookView> {
|
||||||
children: [
|
children: [
|
||||||
...contacts
|
...contacts
|
||||||
.where((element) => element.addresses
|
.where((element) => element.addresses
|
||||||
.where((e) => ref.watch(
|
.where((e) => ref.watch(addressBookFilterProvider
|
||||||
addressBookFilterProvider.select(
|
.select((value) => value.coins.contains(e.coin))))
|
||||||
(value) => value.coins.contains(e.coin))))
|
|
||||||
.isNotEmpty)
|
.isNotEmpty)
|
||||||
.where((e) =>
|
.where((e) =>
|
||||||
e.isFavorite &&
|
e.isFavorite &&
|
||||||
ref
|
ref
|
||||||
.read(addressBookServiceProvider)
|
.read(addressBookServiceProvider)
|
||||||
.matches(_searchTerm, e))
|
.matches(widget.filterTerm ?? _searchTerm, e))
|
||||||
.where((element) => element.isFavorite)
|
.where((element) => element.isFavorite)
|
||||||
.map(
|
.map(
|
||||||
(e) => AddressBookCard(
|
(e) => AddressBookCard(
|
||||||
|
@ -335,13 +337,12 @@ class _AddressBookViewState extends ConsumerState<AddressBookView> {
|
||||||
...contacts
|
...contacts
|
||||||
.where((element) => element.addresses
|
.where((element) => element.addresses
|
||||||
.where((e) => ref.watch(
|
.where((e) => ref.watch(
|
||||||
addressBookFilterProvider.select(
|
addressBookFilterProvider.select((value) =>
|
||||||
(value) =>
|
|
||||||
value.coins.contains(e.coin))))
|
value.coins.contains(e.coin))))
|
||||||
.isNotEmpty)
|
.isNotEmpty)
|
||||||
.where((e) => ref
|
.where((e) => ref
|
||||||
.read(addressBookServiceProvider)
|
.read(addressBookServiceProvider)
|
||||||
.matches(_searchTerm, e))
|
.matches(widget.filterTerm ?? _searchTerm, e))
|
||||||
.map(
|
.map(
|
||||||
(e) => AddressBookCard(
|
(e) => AddressBookCard(
|
||||||
key: Key("desktopContactCard_${e.id}_key"),
|
key: Key("desktopContactCard_${e.id}_key"),
|
||||||
|
@ -365,7 +366,6 @@ class _AddressBookViewState extends ConsumerState<AddressBookView> {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
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:stackwallet/models/contact.dart';
|
|
||||||
import 'package:stackwallet/pages/address_book_views/address_book_view.dart';
|
import 'package:stackwallet/pages/address_book_views/address_book_view.dart';
|
||||||
import 'package:stackwallet/pages/address_book_views/subviews/add_address_book_entry_view.dart';
|
import 'package:stackwallet/pages/address_book_views/subviews/add_address_book_entry_view.dart';
|
||||||
import 'package:stackwallet/pages/address_book_views/subviews/address_book_filter_view.dart';
|
import 'package:stackwallet/pages/address_book_views/subviews/address_book_filter_view.dart';
|
||||||
import 'package:stackwallet/providers/global/wallets_provider.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';
|
||||||
|
@ -34,11 +32,6 @@ class _DesktopAddressBook extends ConsumerState<DesktopAddressBook> {
|
||||||
|
|
||||||
late final FocusNode _searchFocusNode;
|
late final FocusNode _searchFocusNode;
|
||||||
|
|
||||||
List<Contact>? _cache;
|
|
||||||
List<Contact>? _cacheFav;
|
|
||||||
|
|
||||||
late bool hasContacts = false;
|
|
||||||
|
|
||||||
String _searchTerm = "";
|
String _searchTerm = "";
|
||||||
|
|
||||||
Future<void> selectCryptocurrency() async {
|
Future<void> selectCryptocurrency() async {
|
||||||
|
@ -90,7 +83,6 @@ class _DesktopAddressBook extends ConsumerState<DesktopAddressBook> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
debugPrint("BUILD: $runtimeType");
|
debugPrint("BUILD: $runtimeType");
|
||||||
final hasWallets = ref.watch(walletsChangeNotifierProvider).hasWallets;
|
|
||||||
|
|
||||||
return DesktopScaffold(
|
return DesktopScaffold(
|
||||||
appBar: DesktopAppBar(
|
appBar: DesktopAppBar(
|
||||||
|
@ -171,7 +163,11 @@ class _DesktopAddressBook extends ConsumerState<DesktopAddressBook> {
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 24,
|
height: 24,
|
||||||
),
|
),
|
||||||
const AddressBookView(),
|
Expanded(
|
||||||
|
child: AddressBookView(
|
||||||
|
filterTerm: _searchTerm,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue