followers/following paynym lists

This commit is contained in:
julian 2023-01-04 15:28:48 -06:00
parent 21cc545251
commit 3069ebeae9
3 changed files with 282 additions and 29 deletions

View file

@ -8,6 +8,8 @@ import 'package:stackwallet/notifications/show_flush_bar.dart';
import 'package:stackwallet/pages/paynym/add_new_paynym_follow_view.dart'; import 'package:stackwallet/pages/paynym/add_new_paynym_follow_view.dart';
import 'package:stackwallet/pages/paynym/dialogs/paynym_qr_popup.dart'; import 'package:stackwallet/pages/paynym/dialogs/paynym_qr_popup.dart';
import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart';
import 'package:stackwallet/pages/paynym/subwidgets/paynym_followers_list.dart';
import 'package:stackwallet/pages/paynym/subwidgets/paynym_following_list.dart';
import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; import 'package:stackwallet/providers/wallet/my_paynym_account_state_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';
@ -41,7 +43,7 @@ class PaynymHomeView extends ConsumerStatefulWidget {
} }
class _PaynymHomeViewState extends ConsumerState<PaynymHomeView> { class _PaynymHomeViewState extends ConsumerState<PaynymHomeView> {
bool showFollowing = false; bool showFollowers = false;
int secretCount = 0; int secretCount = 0;
Timer? timer; Timer? timer;
@ -521,15 +523,17 @@ class _PaynymHomeViewState extends ConsumerState<PaynymHomeView> {
width: isDesktop ? 490 : null, width: isDesktop ? 490 : null,
child: Toggle( child: Toggle(
onColor: Theme.of(context).extension<StackColors>()!.popupBG, onColor: Theme.of(context).extension<StackColors>()!.popupBG,
onText: "Following", onText:
"Following (${ref.watch(myPaynymAccountStateProvider.state).state?.following.length ?? 0})",
offColor: Theme.of(context) offColor: Theme.of(context)
.extension<StackColors>()! .extension<StackColors>()!
.textFieldDefaultBG, .textFieldDefaultBG,
offText: "Followers", offText:
isOn: showFollowing, "Followers (${ref.watch(myPaynymAccountStateProvider.state).state?.followers.length ?? 0})",
isOn: showFollowers,
onValueChanged: (value) { onValueChanged: (value) {
setState(() { setState(() {
showFollowing = value; showFollowers = value;
}); });
}, },
decoration: BoxDecoration( decoration: BoxDecoration(
@ -544,7 +548,8 @@ class _PaynymHomeViewState extends ConsumerState<PaynymHomeView> {
SizedBox( SizedBox(
height: isDesktop ? 20 : 16, height: isDesktop ? 20 : 16,
), ),
ConditionalParent( Expanded(
child: ConditionalParent(
condition: isDesktop, condition: isDesktop,
builder: (child) => Padding( builder: (child) => Padding(
padding: const EdgeInsets.only(left: 24), padding: const EdgeInsets.only(left: 24),
@ -553,22 +558,18 @@ class _PaynymHomeViewState extends ConsumerState<PaynymHomeView> {
child: child, child: child,
), ),
), ),
child: RoundedWhiteContainer( child: ConditionalParent(
child: Row( condition: !isDesktop,
mainAxisAlignment: MainAxisAlignment.center, builder: (child) => Container(
children: [ child: child,
Text( ),
"Your PayNym contacts will appear here", child: !showFollowers
style: isDesktop ? PaynymFollowingList(
? STextStyles.desktopTextExtraExtraSmall(context) walletId: widget.walletId,
.copyWith( )
color: Theme.of(context) : PaynymFollowersList(
.extension<StackColors>()! walletId: widget.walletId,
.textSubtitle1,
)
: STextStyles.label(context),
), ),
],
), ),
), ),
), ),

View file

@ -0,0 +1,126 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/pages/paynym/subwidgets/paynym_card.dart';
import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.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/utilities/util.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart';
class PaynymFollowersList extends ConsumerStatefulWidget {
const PaynymFollowersList({
Key? key,
required this.walletId,
}) : super(key: key);
final String walletId;
@override
ConsumerState<PaynymFollowersList> createState() =>
_PaynymFollowersListState();
}
class _PaynymFollowersListState extends ConsumerState<PaynymFollowersList> {
final isDesktop = Util.isDesktop;
BorderRadius get _borderRadiusFirst {
return BorderRadius.only(
topLeft: Radius.circular(
Constants.size.circularBorderRadius,
),
topRight: Radius.circular(
Constants.size.circularBorderRadius,
),
);
}
BorderRadius get _borderRadiusLast {
return BorderRadius.only(
bottomLeft: Radius.circular(
Constants.size.circularBorderRadius,
),
bottomRight: Radius.circular(
Constants.size.circularBorderRadius,
),
);
}
@override
Widget build(BuildContext context) {
final count =
ref.watch(myPaynymAccountStateProvider.state).state?.followers.length ??
0;
if (count == 0) {
return Column(
children: [
RoundedWhiteContainer(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Your PayNym followers will appear here",
style: isDesktop
? STextStyles.desktopTextExtraExtraSmall(context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textSubtitle1,
)
: STextStyles.label(context),
),
],
),
),
],
);
} else {
final followers =
ref.watch(myPaynymAccountStateProvider.state).state!.followers;
if (count == 1) {
return Column(
children: [
RoundedWhiteContainer(
padding: const EdgeInsets.all(0),
child: PaynymCard(
walletId: widget.walletId,
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;
} else if (index == count - 1) {
borderRadius = _borderRadiusLast;
}
return Container(
key: Key("paynymCardKey_${followers[index].nymId}"),
decoration: BoxDecoration(
borderRadius: borderRadius,
color: Theme.of(context).extension<StackColors>()!.popupBG,
),
child: PaynymCard(
walletId: widget.walletId,
label: followers[index].nymName,
paymentCodeString: followers[index].code,
),
);
},
);
}
}
}
}

View file

@ -0,0 +1,126 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/pages/paynym/subwidgets/paynym_card.dart';
import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.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/utilities/util.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart';
class PaynymFollowingList extends ConsumerStatefulWidget {
const PaynymFollowingList({
Key? key,
required this.walletId,
}) : super(key: key);
final String walletId;
@override
ConsumerState<PaynymFollowingList> createState() =>
_PaynymFollowingListState();
}
class _PaynymFollowingListState extends ConsumerState<PaynymFollowingList> {
final isDesktop = Util.isDesktop;
BorderRadius get _borderRadiusFirst {
return BorderRadius.only(
topLeft: Radius.circular(
Constants.size.circularBorderRadius,
),
topRight: Radius.circular(
Constants.size.circularBorderRadius,
),
);
}
BorderRadius get _borderRadiusLast {
return BorderRadius.only(
bottomLeft: Radius.circular(
Constants.size.circularBorderRadius,
),
bottomRight: Radius.circular(
Constants.size.circularBorderRadius,
),
);
}
@override
Widget build(BuildContext context) {
final count =
ref.watch(myPaynymAccountStateProvider.state).state?.following.length ??
0;
if (count == 0) {
return Column(
children: [
RoundedWhiteContainer(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Your PayNym contacts will appear here",
style: isDesktop
? STextStyles.desktopTextExtraExtraSmall(context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textSubtitle1,
)
: STextStyles.label(context),
),
],
),
),
],
);
} else {
final following =
ref.watch(myPaynymAccountStateProvider.state).state!.following;
if (count == 1) {
return Column(
children: [
RoundedWhiteContainer(
padding: const EdgeInsets.all(0),
child: PaynymCard(
walletId: widget.walletId,
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;
} else if (index == count - 1) {
borderRadius = _borderRadiusLast;
}
return Container(
key: Key("paynymCardKey_${following[index].nymId}"),
decoration: BoxDecoration(
borderRadius: borderRadius,
color: Theme.of(context).extension<StackColors>()!.popupBG,
),
child: PaynymCard(
walletId: widget.walletId,
label: following[index].nymName,
paymentCodeString: following[index].code,
),
);
},
);
}
}
}
}