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,7 +200,12 @@ class _AddressBookViewState extends ConsumerState<AddressBookView> {
|
||||||
child: IntrinsicHeight(
|
child: IntrinsicHeight(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(4),
|
padding: const EdgeInsets.all(4),
|
||||||
child: child,
|
child: ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
minHeight: MediaQuery.of(context).size.height - 271,
|
||||||
|
),
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -208,163 +215,156 @@ class _AddressBookViewState extends ConsumerState<AddressBookView> {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: ConstrainedBox(
|
child: Column(
|
||||||
constraints: BoxConstraints(
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
minHeight: MediaQuery.of(context).size.height - 271,
|
children: [
|
||||||
),
|
ClipRRect(
|
||||||
child: Column(
|
borderRadius: BorderRadius.circular(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
Constants.size.circularBorderRadius,
|
||||||
children: [
|
),
|
||||||
ClipRRect(
|
child: !isDesktop
|
||||||
borderRadius: BorderRadius.circular(
|
? TextField(
|
||||||
Constants.size.circularBorderRadius,
|
autocorrect: Util.isDesktop ? false : true,
|
||||||
),
|
enableSuggestions: Util.isDesktop ? false : true,
|
||||||
child: !isDesktop
|
controller: _searchController,
|
||||||
? TextField(
|
focusNode: _searchFocusNode,
|
||||||
autocorrect: Util.isDesktop ? false : true,
|
onChanged: (value) {
|
||||||
enableSuggestions: Util.isDesktop ? false : true,
|
setState(() {
|
||||||
controller: _searchController,
|
_searchTerm = value;
|
||||||
focusNode: _searchFocusNode,
|
});
|
||||||
onChanged: (value) {
|
},
|
||||||
setState(() {
|
style: STextStyles.field(context),
|
||||||
_searchTerm = value;
|
decoration: standardInputDecoration(
|
||||||
});
|
"Search",
|
||||||
},
|
_searchFocusNode,
|
||||||
style: STextStyles.field(context),
|
context,
|
||||||
decoration: standardInputDecoration(
|
).copyWith(
|
||||||
"Search",
|
prefixIcon: Padding(
|
||||||
_searchFocusNode,
|
padding: const EdgeInsets.symmetric(
|
||||||
context,
|
horizontal: 10,
|
||||||
).copyWith(
|
vertical: 16,
|
||||||
prefixIcon: Padding(
|
),
|
||||||
padding: const EdgeInsets.symmetric(
|
child: SvgPicture.asset(
|
||||||
horizontal: 10,
|
Assets.svg.search,
|
||||||
vertical: 16,
|
width: 16,
|
||||||
),
|
height: 16,
|
||||||
child: SvgPicture.asset(
|
|
||||||
Assets.svg.search,
|
|
||||||
width: 16,
|
|
||||||
height: 16,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
suffixIcon: _searchController.text.isNotEmpty
|
|
||||||
? Padding(
|
|
||||||
padding: const EdgeInsets.only(right: 0),
|
|
||||||
child: UnconstrainedBox(
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
TextFieldIconButton(
|
|
||||||
child: const XIcon(),
|
|
||||||
onTap: () async {
|
|
||||||
setState(() {
|
|
||||||
_searchController.text = "";
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
),
|
),
|
||||||
)
|
suffixIcon: _searchController.text.isNotEmpty
|
||||||
: null,
|
? Padding(
|
||||||
),
|
padding: const EdgeInsets.only(right: 0),
|
||||||
if (!isDesktop) const SizedBox(height: 16),
|
child: UnconstrainedBox(
|
||||||
Text(
|
child: Row(
|
||||||
"Favorites",
|
children: [
|
||||||
style: STextStyles.smallMed12(context),
|
TextFieldIconButton(
|
||||||
),
|
child: const XIcon(),
|
||||||
const SizedBox(
|
onTap: () async {
|
||||||
height: 12,
|
setState(() {
|
||||||
),
|
_searchController.text = "";
|
||||||
if (contacts.isNotEmpty)
|
});
|
||||||
RoundedWhiteContainer(
|
},
|
||||||
padding: EdgeInsets.all(!isDesktop ? 0 : 15),
|
),
|
||||||
child: Column(
|
],
|
||||||
children: [
|
|
||||||
...contacts
|
|
||||||
.where((element) => element.addresses
|
|
||||||
.where((e) => ref.watch(
|
|
||||||
addressBookFilterProvider.select(
|
|
||||||
(value) => value.coins.contains(e.coin))))
|
|
||||||
.isNotEmpty)
|
|
||||||
.where((e) =>
|
|
||||||
e.isFavorite &&
|
|
||||||
ref
|
|
||||||
.read(addressBookServiceProvider)
|
|
||||||
.matches(_searchTerm, e))
|
|
||||||
.where((element) => element.isFavorite)
|
|
||||||
.map(
|
|
||||||
(e) => AddressBookCard(
|
|
||||||
key: Key("favContactCard_${e.id}_key"),
|
|
||||||
contactId: e.id,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (contacts.isEmpty)
|
|
||||||
RoundedWhiteContainer(
|
|
||||||
child: Center(
|
|
||||||
child: Text(
|
|
||||||
"Your favorite contacts will appear here",
|
|
||||||
style: STextStyles.itemSubtitle(context),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 16,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
"All contacts",
|
|
||||||
style: STextStyles.smallMed12(context),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 12,
|
|
||||||
),
|
|
||||||
if (contacts.isNotEmpty)
|
|
||||||
Column(
|
|
||||||
children: [
|
|
||||||
RoundedWhiteContainer(
|
|
||||||
padding: EdgeInsets.all(!isDesktop ? 0 : 15),
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
...contacts
|
|
||||||
.where((element) => element.addresses
|
|
||||||
.where((e) => ref.watch(
|
|
||||||
addressBookFilterProvider.select(
|
|
||||||
(value) =>
|
|
||||||
value.coins.contains(e.coin))))
|
|
||||||
.isNotEmpty)
|
|
||||||
.where((e) => ref
|
|
||||||
.read(addressBookServiceProvider)
|
|
||||||
.matches(_searchTerm, e))
|
|
||||||
.map(
|
|
||||||
(e) => AddressBookCard(
|
|
||||||
key: Key("desktopContactCard_${e.id}_key"),
|
|
||||||
contactId: e.id,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
)
|
||||||
),
|
: null,
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
if (!isDesktop) const SizedBox(height: 16),
|
||||||
|
Text(
|
||||||
|
"Favorites",
|
||||||
|
style: STextStyles.smallMed12(context),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 12,
|
||||||
|
),
|
||||||
|
if (contacts.isNotEmpty)
|
||||||
|
RoundedWhiteContainer(
|
||||||
|
padding: EdgeInsets.all(!isDesktop ? 0 : 15),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
...contacts
|
||||||
|
.where((element) => element.addresses
|
||||||
|
.where((e) => ref.watch(addressBookFilterProvider
|
||||||
|
.select((value) => value.coins.contains(e.coin))))
|
||||||
|
.isNotEmpty)
|
||||||
|
.where((e) =>
|
||||||
|
e.isFavorite &&
|
||||||
|
ref
|
||||||
|
.read(addressBookServiceProvider)
|
||||||
|
.matches(widget.filterTerm ?? _searchTerm, e))
|
||||||
|
.where((element) => element.isFavorite)
|
||||||
|
.map(
|
||||||
|
(e) => AddressBookCard(
|
||||||
|
key: Key("favContactCard_${e.id}_key"),
|
||||||
|
contactId: e.id,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (contacts.isEmpty)
|
),
|
||||||
RoundedWhiteContainer(
|
if (contacts.isEmpty)
|
||||||
child: Center(
|
RoundedWhiteContainer(
|
||||||
child: Text(
|
child: Center(
|
||||||
"Your contacts will appear here",
|
child: Text(
|
||||||
style: STextStyles.itemSubtitle(context),
|
"Your favorite contacts will appear here",
|
||||||
),
|
style: STextStyles.itemSubtitle(context),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
const SizedBox(
|
||||||
|
height: 16,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"All contacts",
|
||||||
|
style: STextStyles.smallMed12(context),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 12,
|
||||||
|
),
|
||||||
|
if (contacts.isNotEmpty)
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
RoundedWhiteContainer(
|
||||||
|
padding: EdgeInsets.all(!isDesktop ? 0 : 15),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
...contacts
|
||||||
|
.where((element) => element.addresses
|
||||||
|
.where((e) => ref.watch(
|
||||||
|
addressBookFilterProvider.select((value) =>
|
||||||
|
value.coins.contains(e.coin))))
|
||||||
|
.isNotEmpty)
|
||||||
|
.where((e) => ref
|
||||||
|
.read(addressBookServiceProvider)
|
||||||
|
.matches(widget.filterTerm ?? _searchTerm, e))
|
||||||
|
.map(
|
||||||
|
(e) => AddressBookCard(
|
||||||
|
key: Key("desktopContactCard_${e.id}_key"),
|
||||||
|
contactId: e.id,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (contacts.isEmpty)
|
||||||
|
RoundedWhiteContainer(
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
"Your contacts will appear here",
|
||||||
|
style: STextStyles.itemSubtitle(context),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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