mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-10 20:54:33 +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';
|
||||
|
||||
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";
|
||||
|
||||
final Coin? coin;
|
||||
final String? filterTerm;
|
||||
|
||||
@override
|
||||
ConsumerState<AddressBookView> createState() => _AddressBookViewState();
|
||||
|
@ -37,9 +42,6 @@ class _AddressBookViewState extends ConsumerState<AddressBookView> {
|
|||
late TextEditingController _searchController;
|
||||
|
||||
final _searchFocusNode = FocusNode();
|
||||
//
|
||||
// List<Contact>? _cache;
|
||||
// List<Contact>? _cacheFav;
|
||||
|
||||
String _searchTerm = "";
|
||||
|
||||
|
@ -198,20 +200,21 @@ class _AddressBookViewState extends ConsumerState<AddressBookView> {
|
|||
child: IntrinsicHeight(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
minHeight: MediaQuery.of(context).size.height - 271,
|
||||
),
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
minHeight: MediaQuery.of(context).size.height - 271,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
|
@ -285,15 +288,14 @@ class _AddressBookViewState extends ConsumerState<AddressBookView> {
|
|||
children: [
|
||||
...contacts
|
||||
.where((element) => element.addresses
|
||||
.where((e) => ref.watch(
|
||||
addressBookFilterProvider.select(
|
||||
(value) => value.coins.contains(e.coin))))
|
||||
.where((e) => ref.watch(addressBookFilterProvider
|
||||
.select((value) => value.coins.contains(e.coin))))
|
||||
.isNotEmpty)
|
||||
.where((e) =>
|
||||
e.isFavorite &&
|
||||
ref
|
||||
.read(addressBookServiceProvider)
|
||||
.matches(_searchTerm, e))
|
||||
.matches(widget.filterTerm ?? _searchTerm, e))
|
||||
.where((element) => element.isFavorite)
|
||||
.map(
|
||||
(e) => AddressBookCard(
|
||||
|
@ -335,13 +337,12 @@ class _AddressBookViewState extends ConsumerState<AddressBookView> {
|
|||
...contacts
|
||||
.where((element) => element.addresses
|
||||
.where((e) => ref.watch(
|
||||
addressBookFilterProvider.select(
|
||||
(value) =>
|
||||
addressBookFilterProvider.select((value) =>
|
||||
value.coins.contains(e.coin))))
|
||||
.isNotEmpty)
|
||||
.where((e) => ref
|
||||
.read(addressBookServiceProvider)
|
||||
.matches(_searchTerm, e))
|
||||
.matches(widget.filterTerm ?? _searchTerm, e))
|
||||
.map(
|
||||
(e) => AddressBookCard(
|
||||
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_riverpod/flutter_riverpod.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/subviews/add_address_book_entry_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/constants.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
|
@ -34,11 +32,6 @@ class _DesktopAddressBook extends ConsumerState<DesktopAddressBook> {
|
|||
|
||||
late final FocusNode _searchFocusNode;
|
||||
|
||||
List<Contact>? _cache;
|
||||
List<Contact>? _cacheFav;
|
||||
|
||||
late bool hasContacts = false;
|
||||
|
||||
String _searchTerm = "";
|
||||
|
||||
Future<void> selectCryptocurrency() async {
|
||||
|
@ -90,7 +83,6 @@ class _DesktopAddressBook extends ConsumerState<DesktopAddressBook> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
debugPrint("BUILD: $runtimeType");
|
||||
final hasWallets = ref.watch(walletsChangeNotifierProvider).hasWallets;
|
||||
|
||||
return DesktopScaffold(
|
||||
appBar: DesktopAppBar(
|
||||
|
@ -171,7 +163,11 @@ class _DesktopAddressBook extends ConsumerState<DesktopAddressBook> {
|
|||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
const AddressBookView(),
|
||||
Expanded(
|
||||
child: AddressBookView(
|
||||
filterTerm: _searchTerm,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue