mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 20:19:25 +00:00
refactor: collapsible_standart_list improvements
This commit is contained in:
parent
8c7685c01b
commit
7d55092704
3 changed files with 41 additions and 56 deletions
|
@ -54,18 +54,13 @@ class ContactListPage extends BasePage {
|
|||
|
||||
@override
|
||||
Widget body(BuildContext context) {
|
||||
|
||||
return Container(
|
||||
padding: EdgeInsets.only(top: 20.0, bottom: 20.0),
|
||||
child: Observer(
|
||||
builder: (_) {
|
||||
padding: EdgeInsets.all(24),
|
||||
child: Observer(builder: (_) {
|
||||
final contacts = contactListViewModel.contactsToShow;
|
||||
final walletContacts = contactListViewModel.walletContactsToShow;
|
||||
return CollapsibleSectionList(
|
||||
sectionCount: 2,
|
||||
themeColor: Theme.of(context).primaryTextTheme!.titleLarge!.color!,
|
||||
dividerThemeColor:
|
||||
Theme.of(context).primaryTextTheme!.bodySmall!.decorationColor!,
|
||||
sectionTitleBuilder: (int sectionIndex) {
|
||||
var title = S.current.contact_list_contacts;
|
||||
|
||||
|
@ -75,11 +70,15 @@ class ContactListPage extends BasePage {
|
|||
|
||||
return Container(
|
||||
padding: EdgeInsets.only(bottom: 10),
|
||||
child: Text(title, style: TextStyle(fontSize: 36)));
|
||||
child: Text(title, style: TextStyle(
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.titleLarge!
|
||||
.color!,
|
||||
fontSize: 36)));
|
||||
},
|
||||
itemCounter: (int sectionIndex) => sectionIndex == 0
|
||||
? walletContacts.length
|
||||
: contacts.length,
|
||||
itemCounter: (int sectionIndex) =>
|
||||
sectionIndex == 0 ? walletContacts.length : contacts.length,
|
||||
itemBuilder: (sectionIndex, index) {
|
||||
if (sectionIndex == 0) {
|
||||
final walletInfo = walletContacts[index];
|
||||
|
@ -96,8 +95,8 @@ class ContactListPage extends BasePage {
|
|||
)
|
||||
: content;
|
||||
},
|
||||
);})
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
Widget generateRaw(BuildContext context, ContactBase contact) {
|
||||
|
|
|
@ -6,8 +6,6 @@ class CollapsibleSectionList extends SectionStandardList {
|
|||
{required int sectionCount,
|
||||
required int Function(int sectionIndex) itemCounter,
|
||||
required Widget Function(int sectionIndex, int itemIndex) itemBuilder,
|
||||
Color? themeColor,
|
||||
Color? dividerThemeColor,
|
||||
Widget Function(int sectionIndex)? sectionTitleBuilder,
|
||||
bool hasTopSeparator = false})
|
||||
: super(
|
||||
|
@ -15,9 +13,7 @@ class CollapsibleSectionList extends SectionStandardList {
|
|||
sectionCount: sectionCount,
|
||||
itemCounter: itemCounter,
|
||||
itemBuilder: itemBuilder,
|
||||
sectionTitleBuilder: sectionTitleBuilder,
|
||||
themeColor: themeColor,
|
||||
dividerThemeColor: dividerThemeColor);
|
||||
sectionTitleBuilder: sectionTitleBuilder);
|
||||
|
||||
@override
|
||||
Widget buildTitle(List<Widget> items, int sectionIndex) {
|
||||
|
|
|
@ -18,7 +18,7 @@ class StandardListRow extends StatelessWidget {
|
|||
return InkWell(
|
||||
onTap: () => onTap?.call(context),
|
||||
child: Container(
|
||||
color: _backgroundColor(context),
|
||||
color: Theme.of(context).colorScheme.background,
|
||||
height: 56,
|
||||
padding: EdgeInsets.only(left: 24, right: 24),
|
||||
child: Row(
|
||||
|
@ -54,11 +54,7 @@ class StandardListRow extends StatelessWidget {
|
|||
|
||||
Color titleColor(BuildContext context) => isSelected
|
||||
? Palette.blueCraiola
|
||||
: Theme.of(context).primaryTextTheme!.titleLarge!.color!;
|
||||
|
||||
Color _backgroundColor(BuildContext context) {
|
||||
return Theme.of(context).colorScheme.background;
|
||||
}
|
||||
: Theme.of(context).primaryTextTheme.titleLarge!.color!;
|
||||
}
|
||||
|
||||
class SectionHeaderListRow extends StatelessWidget {
|
||||
|
@ -123,8 +119,6 @@ class SectionStandardList extends StatelessWidget {
|
|||
required this.itemBuilder,
|
||||
required this.sectionCount,
|
||||
this.dividerPadding = const EdgeInsets.only(left: 24),
|
||||
this.themeColor,
|
||||
this.dividerThemeColor,
|
||||
this.sectionTitleBuilder,
|
||||
this.hasTopSeparator = false,
|
||||
}) : totalRows = [];
|
||||
|
@ -135,8 +129,6 @@ class SectionStandardList extends StatelessWidget {
|
|||
final Widget Function(int sectionIndex, int itemIndex) itemBuilder;
|
||||
final Widget Function(int sectionIndex)? sectionTitleBuilder;
|
||||
final List<Widget> totalRows;
|
||||
final Color? themeColor;
|
||||
final Color? dividerThemeColor;
|
||||
final EdgeInsets dividerPadding;
|
||||
|
||||
List<Widget> transform(
|
||||
|
@ -144,9 +136,7 @@ class SectionStandardList extends StatelessWidget {
|
|||
int sectionCount,
|
||||
int Function(int sectionIndex) itemCounter,
|
||||
Widget Function(int sectionIndex, int itemIndex) itemBuilder,
|
||||
Widget Function(int sectionIndex)? sectionTitleBuilder,
|
||||
Color? themeColor,
|
||||
Color? dividerThemeColor) {
|
||||
Widget Function(int sectionIndex)? sectionTitleBuilder) {
|
||||
final items = <Widget>[];
|
||||
|
||||
for (var sectionIndex = 0; sectionIndex < sectionCount; sectionIndex++) {
|
||||
|
@ -193,7 +183,7 @@ class SectionStandardList extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
totalRows.addAll(transform(hasTopSeparator, sectionCount, itemCounter,
|
||||
itemBuilder, sectionTitleBuilder, themeColor, dividerThemeColor));
|
||||
itemBuilder, sectionTitleBuilder));
|
||||
|
||||
return ListView.separated(
|
||||
separatorBuilder: (_, index) {
|
||||
|
|
Loading…
Reference in a new issue