feat(mobile-app): 引荐列表支持展开/收拢功能

- 初始只显示前10条引荐记录
- 超过10人时显示"..."按钮可点击展开全部
- 展开后显示"收起"按钮可点击收拢
- 加载更多时显示loading指示器

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-09 08:59:03 -08:00
parent 4ee355a7cd
commit 8eb5b410cc
1 changed files with 91 additions and 1 deletions

View File

@ -66,6 +66,9 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
// referral-service
List<Map<String, dynamic>> _referrals = [];
int _totalReferralCount = 0; //
bool _isReferralListExpanded = false; //
bool _isLoadingMoreReferrals = false; //
//
TeamTreeNode? _teamTreeRootNode;
@ -401,6 +404,8 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
'personal': r.personalPlantingCount, //
'team': r.teamPlantingCount, //
}).toList();
_totalReferralCount = directReferrals.total; //
_isReferralListExpanded = false; //
});
}
} catch (e, stackTrace) {
@ -422,6 +427,46 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
}
}
///
Future<void> _expandReferralList() async {
if (_isLoadingMoreReferrals) return;
setState(() {
_isLoadingMoreReferrals = true;
});
try {
final referralService = ref.read(referralServiceProvider);
final response = await referralService.getDirectReferrals(limit: 200);
if (mounted) {
setState(() {
_referrals = response.referrals.map((r) => <String, dynamic>{
'serial': r.accountSequence,
'personal': r.personalPlantingCount,
'team': r.teamPlantingCount,
}).toList();
_isReferralListExpanded = true;
_isLoadingMoreReferrals = false;
});
}
} catch (e) {
debugPrint('[ProfilePage] 加载更多引荐失败: $e');
if (mounted) {
setState(() {
_isLoadingMoreReferrals = false;
});
}
}
}
/// 10
void _collapseReferralList() {
setState(() {
_isReferralListExpanded = false;
});
}
/// (from authorization-service)
/// [isRefresh]
Future<void> _loadAuthorizationData({bool isRefresh = false}) async {
@ -3349,6 +3394,11 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
///
Widget _buildReferralList() {
//
final displayList = _isReferralListExpanded
? _referrals
: _referrals.take(10).toList();
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -3366,7 +3416,7 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
),
),
const SizedBox(height: 8),
..._referrals.map((referral) => Padding(
...displayList.map((referral) => Padding(
padding: const EdgeInsets.only(bottom: 4),
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
@ -3399,6 +3449,46 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
),
),
)),
// /
if (_totalReferralCount > 10)
Padding(
padding: const EdgeInsets.only(top: 4),
child: GestureDetector(
onTap: _isLoadingMoreReferrals
? null
: (_isReferralListExpanded
? _collapseReferralList
: _expandReferralList),
child: Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(vertical: 8),
decoration: BoxDecoration(
color: const Color(0xCCFFF5E6),
borderRadius: BorderRadius.circular(8),
),
child: Center(
child: _isLoadingMoreReferrals
? const SizedBox(
width: 16,
height: 16,
child: CircularProgressIndicator(
strokeWidth: 2,
color: Color(0xFF5D4037),
),
)
: Text(
_isReferralListExpanded ? '收起' : '...',
style: const TextStyle(
fontSize: 14,
fontFamily: 'Inter',
fontWeight: FontWeight.w500,
color: Color(0xFF5D4037),
),
),
),
),
),
),
],
);
}