desktop address book filter dialog

This commit is contained in:
ryleedavis 2022-11-12 11:10:46 -07:00
parent 7798ed39a0
commit ca6578d367
2 changed files with 229 additions and 148 deletions

View file

@ -5,7 +5,12 @@ import 'package:stackwallet/providers/ui/address_book_providers/address_book_fil
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/conditional_parent.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
import 'package:stackwallet/widgets/desktop/primary_button.dart';
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart';
class AddressBookFilterView extends ConsumerStatefulWidget {
@ -41,10 +46,16 @@ class _AddressBookFilterViewState extends ConsumerState<AddressBookFilterView> {
@override
Widget build(BuildContext context) {
final isDesktop = Util.isDesktop;
return ConditionalParent(
condition: !isDesktop,
builder: (child) {
return Scaffold(
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
backgroundColor:
Theme.of(context).extension<StackColors>()!.background,
appBar: AppBar(
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
backgroundColor:
Theme.of(context).extension<StackColors>()!.background,
leading: AppBarBackButton(
onPressed: () async {
Navigator.of(context).pop();
@ -85,7 +96,93 @@ class _AddressBookFilterViewState extends ConsumerState<AddressBookFilterView> {
const SizedBox(
height: 12,
),
RoundedWhiteContainer(
child,
],
),
),
),
),
);
}),
),
);
},
child: ConditionalParent(
condition: isDesktop,
builder: (child) {
return Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.all(32),
child: Text(
"Select cryptocurrency",
style: STextStyles.desktopH3(context),
textAlign: TextAlign.center,
),
),
const DesktopDialogCloseButton(),
],
),
Expanded(
child: LayoutBuilder(
builder: (context, constraints) {
return SingleChildScrollView(
scrollDirection: Axis.vertical,
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: constraints.maxHeight,
),
child: IntrinsicHeight(
child: Column(
children: [
Padding(
padding:
const EdgeInsets.symmetric(horizontal: 32),
child: child,
),
],
),
),
),
);
},
),
),
Padding(
padding:
const EdgeInsets.symmetric(horizontal: 32, vertical: 32),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SecondaryButton(
width: 248,
desktopMed: true,
enabled: true,
label: "Cancel",
onPressed: () {
Navigator.of(context).pop();
},
),
// const SizedBox(width: 16),
PrimaryButton(
width: 248,
desktopMed: true,
enabled: true,
label: "Apply",
onPressed: () {
Navigator.of(context).pop();
},
),
],
),
),
],
);
},
child: RoundedWhiteContainer(
padding: const EdgeInsets.all(0),
child: Wrap(
children: [
@ -102,9 +199,7 @@ class _AddressBookFilterViewState extends ConsumerState<AddressBookFilterView> {
.read(addressBookFilterProvider)
.remove(coin, true);
} else {
ref
.read(addressBookFilterProvider)
.add(coin, true);
ref.read(addressBookFilterProvider).add(coin, true);
}
setState(() {});
},
@ -113,30 +208,25 @@ class _AddressBookFilterViewState extends ConsumerState<AddressBookFilterView> {
child: Padding(
padding: const EdgeInsets.all(12),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 20,
width: 20,
child: Checkbox(
value: ref
.watch(
addressBookFilterProvider
.select((value) =>
value.coins))
.watch(addressBookFilterProvider
.select((value) => value.coins))
.contains(coin),
onChanged: (value) {
if (value is bool) {
if (value) {
ref
.read(
addressBookFilterProvider)
.read(addressBookFilterProvider)
.add(coin, true);
} else {
ref
.read(
addressBookFilterProvider)
.read(addressBookFilterProvider)
.remove(coin, true);
}
setState(() {});
@ -148,23 +238,18 @@ class _AddressBookFilterViewState extends ConsumerState<AddressBookFilterView> {
width: 12,
),
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
coin.prettyName,
style:
STextStyles.largeMedium14(
context),
style: STextStyles.largeMedium14(context),
),
const SizedBox(
height: 2,
),
Text(
coin.ticker,
style:
STextStyles.itemSubtitle(
context),
style: STextStyles.itemSubtitle(context),
),
],
)
@ -179,29 +264,6 @@ class _AddressBookFilterViewState extends ConsumerState<AddressBookFilterView> {
],
),
),
const Spacer(),
// Row(
// children: [
// TextButton(
// onPressed: () {},
// child: Text("Cancel"),
// ),
// SizedBox(
// width: 16,
// ),
// TextButton(
// onPressed: () {},
// child: Text("Cancel"),
// ),
// ],
// )
],
),
),
),
),
);
}),
),
);
}

View file

@ -2,12 +2,14 @@ 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/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';
import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
import 'package:stackwallet/widgets/icon_widgets/x_icon.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart';
import 'package:stackwallet/widgets/stack_text_field.dart';
@ -34,6 +36,21 @@ class _DesktopAddressBook extends ConsumerState<DesktopAddressBook> {
String filter = "";
Future<void> selectCryptocurrency() async {
await showDialog<dynamic>(
context: context,
useSafeArea: false,
barrierDismissible: true,
builder: (context) {
return DesktopDialog(
maxHeight: 609,
maxWidth: 576,
child: AddressBookFilterView(),
);
},
);
}
@override
void initState() {
_searchController = TextEditingController();
@ -141,7 +158,9 @@ class _DesktopAddressBook extends ConsumerState<DesktopAddressBook> {
style: Theme.of(context)
.extension<StackColors>()!
.getDesktopMenuButtonColorSelected(context),
onPressed: () {},
onPressed: () {
selectCryptocurrency();
},
child: SizedBox(
width: 200,
height: 56,