followers/following paynym lists clean up

This commit is contained in:
julian 2023-01-04 16:01:26 -06:00
parent 3069ebeae9
commit 8c0366904a
4 changed files with 95 additions and 115 deletions

View file

@ -165,7 +165,7 @@ class _AddNewPaynymFollowViewState
),
titleSpacing: 0,
title: Text(
"Add new",
"New follow",
style: STextStyles.navBarTitle(context),
overflow: TextOverflow.ellipsis,
),
@ -201,7 +201,7 @@ class _AddNewPaynymFollowViewState
Padding(
padding: const EdgeInsets.only(left: 32),
child: Text(
"Add new",
"New follow",
style: STextStyles.desktopH3(context),
),
),

View file

@ -138,7 +138,7 @@ class _PaynymHomeViewState extends ConsumerState<PaynymHomeView> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Add new",
"Follow",
style:
STextStyles.desktopButtonSecondaryEnabled(
context)

View file

@ -1,3 +1,5 @@
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/pages/paynym/subwidgets/paynym_card.dart';
@ -48,13 +50,19 @@ class _PaynymFollowersListState extends ConsumerState<PaynymFollowersList> {
@override
Widget build(BuildContext context) {
final count =
ref.watch(myPaynymAccountStateProvider.state).state?.followers.length ??
0;
final followers =
ref.watch(myPaynymAccountStateProvider.state).state?.followers;
final count = followers?.length ?? 0;
return ListView.separated(
itemCount: max(count, 1),
separatorBuilder: (BuildContext context, int index) => Container(
height: 1.5,
color: Colors.transparent,
),
itemBuilder: (BuildContext context, int index) {
if (count == 0) {
return Column(
children: [
RoundedWhiteContainer(
return RoundedWhiteContainer(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
@ -71,34 +79,17 @@ class _PaynymFollowersListState extends ConsumerState<PaynymFollowersList> {
),
],
),
),
],
);
} else {
final followers =
ref.watch(myPaynymAccountStateProvider.state).state!.followers;
if (count == 1) {
return Column(
children: [
RoundedWhiteContainer(
} else if (count == 1) {
return RoundedWhiteContainer(
padding: const EdgeInsets.all(0),
child: PaynymCard(
walletId: widget.walletId,
label: followers[0].nymName,
label: followers![0].nymName,
paymentCodeString: followers[0].code,
),
),
],
);
} else {
return ListView.separated(
itemCount: count,
separatorBuilder: (BuildContext context, int index) => Container(
height: 1.5,
color: Colors.transparent,
),
itemBuilder: (BuildContext context, int index) {
BorderRadius? borderRadius;
if (index == 0) {
borderRadius = _borderRadiusFirst;
@ -107,7 +98,7 @@ class _PaynymFollowersListState extends ConsumerState<PaynymFollowersList> {
}
return Container(
key: Key("paynymCardKey_${followers[index].nymId}"),
key: Key("paynymCardKey_${followers![index].nymId}"),
decoration: BoxDecoration(
borderRadius: borderRadius,
color: Theme.of(context).extension<StackColors>()!.popupBG,
@ -118,9 +109,8 @@ class _PaynymFollowersListState extends ConsumerState<PaynymFollowersList> {
paymentCodeString: followers[index].code,
),
);
}
},
);
}
}
}
}

View file

@ -1,3 +1,5 @@
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/pages/paynym/subwidgets/paynym_card.dart';
@ -48,13 +50,19 @@ class _PaynymFollowingListState extends ConsumerState<PaynymFollowingList> {
@override
Widget build(BuildContext context) {
final count =
ref.watch(myPaynymAccountStateProvider.state).state?.following.length ??
0;
final following =
ref.watch(myPaynymAccountStateProvider.state).state?.following;
final count = following?.length ?? 0;
return ListView.separated(
itemCount: max(count, 1),
separatorBuilder: (BuildContext context, int index) => Container(
height: 1.5,
color: Colors.transparent,
),
itemBuilder: (BuildContext context, int index) {
if (count == 0) {
return Column(
children: [
RoundedWhiteContainer(
return RoundedWhiteContainer(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
@ -71,34 +79,17 @@ class _PaynymFollowingListState extends ConsumerState<PaynymFollowingList> {
),
],
),
),
],
);
} else {
final following =
ref.watch(myPaynymAccountStateProvider.state).state!.following;
if (count == 1) {
return Column(
children: [
RoundedWhiteContainer(
} else if (count == 1) {
return RoundedWhiteContainer(
padding: const EdgeInsets.all(0),
child: PaynymCard(
walletId: widget.walletId,
label: following[0].nymName,
label: following![0].nymName,
paymentCodeString: following[0].code,
),
),
],
);
} else {
return ListView.separated(
itemCount: count,
separatorBuilder: (BuildContext context, int index) => Container(
height: 1.5,
color: Colors.transparent,
),
itemBuilder: (BuildContext context, int index) {
BorderRadius? borderRadius;
if (index == 0) {
borderRadius = _borderRadiusFirst;
@ -107,7 +98,7 @@ class _PaynymFollowingListState extends ConsumerState<PaynymFollowingList> {
}
return Container(
key: Key("paynymCardKey_${following[index].nymId}"),
key: Key("paynymCardKey_${following![index].nymId}"),
decoration: BoxDecoration(
borderRadius: borderRadius,
color: Theme.of(context).extension<StackColors>()!.popupBG,
@ -118,9 +109,8 @@ class _PaynymFollowingListState extends ConsumerState<PaynymFollowingList> {
paymentCodeString: following[index].code,
),
);
}
},
);
}
}
}
}