Skip to content

Commit

Permalink
fix the UI issue with address book (#1803)
Browse files Browse the repository at this point in the history
  • Loading branch information
Serhii-Borodenko authored Nov 14, 2024
1 parent ed5e701 commit cf7f019
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
19 changes: 13 additions & 6 deletions lib/src/screens/contact/contact_list_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:cake_wallet/core/auth_service.dart';
import 'package:cake_wallet/entities/contact.dart';
import 'package:cake_wallet/entities/contact_base.dart';
import 'package:cake_wallet/entities/contact_record.dart';
import 'package:cake_wallet/entities/wallet_list_order_types.dart';
Expand All @@ -11,14 +12,12 @@ import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
import 'package:cake_wallet/src/widgets/standard_list.dart';
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
import 'package:cake_wallet/themes/extensions/exchange_page_theme.dart';
import 'package:cake_wallet/themes/extensions/filter_theme.dart';
import 'package:cake_wallet/utils/show_bar.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:cake_wallet/view_model/contact_list/contact_list_view_model.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_slidable/flutter_slidable.dart';

class ContactListPage extends BasePage {
Expand Down Expand Up @@ -92,16 +91,19 @@ class ContactPageBody extends StatefulWidget {

class _ContactPageBodyState extends State<ContactPageBody> with SingleTickerProviderStateMixin {
late TabController _tabController;
late ContactListViewModel contactListViewModel;

@override
void initState() {
super.initState();
_tabController = TabController(length: 2, vsync: this);
contactListViewModel = widget.contactListViewModel;
}

@override
void dispose() {
_tabController.dispose();
contactListViewModel.dispose();
super.dispose();
}

Expand Down Expand Up @@ -306,13 +308,17 @@ class _ContactListBodyState extends State<ContactListBody> {
@override
void dispose() {
widget.tabController.removeListener(_handleTabChange);
widget.contactListViewModel.dispose();
if (widget.contactListViewModel.settingsStore.contactListOrder == FilterListOrderType.Custom) {
widget.contactListViewModel.saveCustomOrder();
}
super.dispose();
}

@override
Widget build(BuildContext context) {
final contacts = widget.contactListViewModel.contactsToShow;
final contacts = widget.contactListViewModel.isEditable
? widget.contactListViewModel.contacts
: widget.contactListViewModel.contactsToShow;
return Scaffold(
body: Container(
child: FilteredList(
Expand Down Expand Up @@ -351,8 +357,9 @@ class _ContactListBodyState extends State<ContactListBody> {
},
),
),
floatingActionButton:
_isContactsTabActive ? filterButtonWidget(context, widget.contactListViewModel) : null,
floatingActionButton: _isContactsTabActive && widget.contactListViewModel.isEditable
? filterButtonWidget(context, widget.contactListViewModel)
: null,
);
}

Expand Down
7 changes: 4 additions & 3 deletions lib/view_model/contact_list/contact_list_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,11 @@ abstract class ContactListViewModelBase with Store {
_currency?.tag == element.type.toString();
}

void dispose() async {
_subscription?.cancel();
void dispose() => _subscription?.cancel();

void saveCustomOrder() {
final List<Contact> contactsSourceCopy = contacts.map((e) => e.original).toList();
await reorderContacts(contactsSourceCopy);
reorderContacts(contactsSourceCopy);
}

void reorderAccordingToContactList() =>
Expand Down

0 comments on commit cf7f019

Please sign in to comment.