After refonte for the options of Profile3
This commit is contained in:
parent
0198b60c24
commit
3e18a4df25
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import '../../../core/di/injection.dart';
|
import '../../../core/di/injection.dart';
|
||||||
@ -9,9 +11,10 @@ import '../../../l10n/app_strings.dart';
|
|||||||
import '../../../shared/widgets/pred_skeleton.dart';
|
import '../../../shared/widgets/pred_skeleton.dart';
|
||||||
import '../../../shared/widgets/section_error.dart';
|
import '../../../shared/widgets/section_error.dart';
|
||||||
import '../../../shared/widgets/tloto_gradient_app_bar.dart';
|
import '../../../shared/widgets/tloto_gradient_app_bar.dart';
|
||||||
|
import '../utils/referral_display.dart';
|
||||||
import 'widgets/referral_member_card.dart';
|
import 'widgets/referral_member_card.dart';
|
||||||
|
|
||||||
const _pageSize = 15;
|
const _pageSize = 20;
|
||||||
|
|
||||||
/// Full list of the user's direct (level-1) referrals.
|
/// Full list of the user's direct (level-1) referrals.
|
||||||
class ReferralDirectsScreen extends StatefulWidget {
|
class ReferralDirectsScreen extends StatefulWidget {
|
||||||
@ -23,11 +26,17 @@ class ReferralDirectsScreen extends StatefulWidget {
|
|||||||
|
|
||||||
class _ReferralDirectsScreenState extends State<ReferralDirectsScreen> {
|
class _ReferralDirectsScreenState extends State<ReferralDirectsScreen> {
|
||||||
final _repo = sl<ReferralRepository>();
|
final _repo = sl<ReferralRepository>();
|
||||||
|
final _searchController = TextEditingController();
|
||||||
|
final _searchFocus = FocusNode();
|
||||||
|
|
||||||
bool _loading = true;
|
bool _loading = true;
|
||||||
bool _retrying = false;
|
bool _retrying = false;
|
||||||
String? _error;
|
String? _error;
|
||||||
List<ReferralNetworkMember> _members = [];
|
List<ReferralNetworkMember> _members = [];
|
||||||
|
List<ReferralNetworkMember> _filtered = [];
|
||||||
int _visibleCount = _pageSize;
|
int _visibleCount = _pageSize;
|
||||||
|
String _query = '';
|
||||||
|
Timer? _debounce;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -35,11 +44,50 @@ class _ReferralDirectsScreenState extends State<ReferralDirectsScreen> {
|
|||||||
final cached = _repo.peekLastDashboard(maxDepth: 1);
|
final cached = _repo.peekLastDashboard(maxDepth: 1);
|
||||||
if (cached != null) {
|
if (cached != null) {
|
||||||
_members = cached.directMembers;
|
_members = cached.directMembers;
|
||||||
|
_filtered = _members;
|
||||||
_loading = false;
|
_loading = false;
|
||||||
}
|
}
|
||||||
|
_searchController.addListener(_onSearchChanged);
|
||||||
_load();
|
_load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_debounce?.cancel();
|
||||||
|
_searchController.removeListener(_onSearchChanged);
|
||||||
|
_searchController.dispose();
|
||||||
|
_searchFocus.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onSearchChanged() {
|
||||||
|
_debounce?.cancel();
|
||||||
|
_debounce = Timer(const Duration(milliseconds: 120), () {
|
||||||
|
if (!mounted) return;
|
||||||
|
_applyFilter(_searchController.text);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _applyFilter(String raw) {
|
||||||
|
final s = context.strings;
|
||||||
|
final next = filterReferralMembers(_members, raw, strings: s);
|
||||||
|
setState(() {
|
||||||
|
_query = raw;
|
||||||
|
_filtered = next;
|
||||||
|
_visibleCount = _pageSize;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _clearSearch() {
|
||||||
|
_debounce?.cancel();
|
||||||
|
_searchController.clear();
|
||||||
|
setState(() {
|
||||||
|
_query = '';
|
||||||
|
_filtered = _members;
|
||||||
|
_visibleCount = _pageSize;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _load({bool force = false}) async {
|
Future<void> _load({bool force = false}) async {
|
||||||
final keep = _members.isNotEmpty && !force;
|
final keep = _members.isNotEmpty && !force;
|
||||||
if (!keep) {
|
if (!keep) {
|
||||||
@ -60,6 +108,11 @@ class _ReferralDirectsScreenState extends State<ReferralDirectsScreen> {
|
|||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
_members = dashboard.directMembers;
|
_members = dashboard.directMembers;
|
||||||
|
_filtered = filterReferralMembers(
|
||||||
|
_members,
|
||||||
|
_searchController.text,
|
||||||
|
strings: context.strings,
|
||||||
|
);
|
||||||
_visibleCount = _pageSize;
|
_visibleCount = _pageSize;
|
||||||
_loading = false;
|
_loading = false;
|
||||||
_error = null;
|
_error = null;
|
||||||
@ -84,8 +137,8 @@ class _ReferralDirectsScreenState extends State<ReferralDirectsScreen> {
|
|||||||
final s = context.strings;
|
final s = context.strings;
|
||||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||||
final bottomInset = MediaQuery.paddingOf(context).bottom;
|
final bottomInset = MediaQuery.paddingOf(context).bottom;
|
||||||
final visible = _members.take(_visibleCount).toList();
|
final visible = _filtered.take(_visibleCount).toList();
|
||||||
final remaining = _members.length - visible.length;
|
final remaining = _filtered.length - visible.length;
|
||||||
|
|
||||||
return AnnotatedRegion<SystemUiOverlayStyle>(
|
return AnnotatedRegion<SystemUiOverlayStyle>(
|
||||||
value: TlotoGradientAppBar.overlayStyle,
|
value: TlotoGradientAppBar.overlayStyle,
|
||||||
@ -97,6 +150,17 @@ class _ReferralDirectsScreenState extends State<ReferralDirectsScreen> {
|
|||||||
title: s.directReferrals,
|
title: s.directReferrals,
|
||||||
showBack: true,
|
showBack: true,
|
||||||
),
|
),
|
||||||
|
if (!_loading || _members.isNotEmpty)
|
||||||
|
_SearchBar(
|
||||||
|
controller: _searchController,
|
||||||
|
focusNode: _searchFocus,
|
||||||
|
hasQuery: _query.trim().isNotEmpty,
|
||||||
|
onClear: _clearSearch,
|
||||||
|
hint: s.searchDirectReferrals,
|
||||||
|
resultCount: _members.isEmpty
|
||||||
|
? null
|
||||||
|
: s.directSearchCount(_filtered.length, _members.length),
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: RefreshIndicator(
|
child: RefreshIndicator(
|
||||||
onRefresh: () => _load(force: true),
|
onRefresh: () => _load(force: true),
|
||||||
@ -125,13 +189,15 @@ class _ReferralDirectsScreenState extends State<ReferralDirectsScreen> {
|
|||||||
physics: const AlwaysScrollableScrollPhysics(
|
physics: const AlwaysScrollableScrollPhysics(
|
||||||
parent: BouncingScrollPhysics(),
|
parent: BouncingScrollPhysics(),
|
||||||
),
|
),
|
||||||
padding: EdgeInsets.fromLTRB(20, 16, 20, 24 + bottomInset),
|
padding: EdgeInsets.fromLTRB(16, 12, 16, 24 + bottomInset),
|
||||||
children: const [
|
children: const [
|
||||||
PredSkeletonCard(height: 88),
|
PredSkeletonCard(height: 72),
|
||||||
SizedBox(height: 10),
|
SizedBox(height: 8),
|
||||||
PredSkeletonCard(height: 88),
|
PredSkeletonCard(height: 72),
|
||||||
SizedBox(height: 10),
|
SizedBox(height: 8),
|
||||||
PredSkeletonCard(height: 88),
|
PredSkeletonCard(height: 72),
|
||||||
|
SizedBox(height: 8),
|
||||||
|
PredSkeletonCard(height: 72),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -140,7 +206,7 @@ class _ReferralDirectsScreenState extends State<ReferralDirectsScreen> {
|
|||||||
physics: const AlwaysScrollableScrollPhysics(
|
physics: const AlwaysScrollableScrollPhysics(
|
||||||
parent: BouncingScrollPhysics(),
|
parent: BouncingScrollPhysics(),
|
||||||
),
|
),
|
||||||
padding: EdgeInsets.fromLTRB(20, 16, 20, 24 + bottomInset),
|
padding: EdgeInsets.fromLTRB(16, 12, 16, 24 + bottomInset),
|
||||||
children: [
|
children: [
|
||||||
SectionError(
|
SectionError(
|
||||||
message: _error!,
|
message: _error!,
|
||||||
@ -169,27 +235,131 @@ class _ReferralDirectsScreenState extends State<ReferralDirectsScreen> {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (_filtered.isEmpty) {
|
||||||
|
return ListView(
|
||||||
|
physics: const AlwaysScrollableScrollPhysics(
|
||||||
|
parent: BouncingScrollPhysics(),
|
||||||
|
),
|
||||||
|
padding: EdgeInsets.fromLTRB(40, 40, 40, 40 + bottomInset),
|
||||||
|
children: [
|
||||||
|
Icon(Icons.search_off_rounded, size: 48, color: muted),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
Text(
|
||||||
|
s.noDirectSearchResults,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||||
|
color: secondary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
Center(
|
||||||
|
child: TextButton(
|
||||||
|
onPressed: _clearSearch,
|
||||||
|
child: Text(s.clearDirectSearch),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return ListView.separated(
|
return ListView.separated(
|
||||||
physics: const AlwaysScrollableScrollPhysics(
|
physics: const AlwaysScrollableScrollPhysics(
|
||||||
parent: BouncingScrollPhysics(),
|
parent: BouncingScrollPhysics(),
|
||||||
),
|
),
|
||||||
padding: EdgeInsets.fromLTRB(20, 16, 20, 24 + bottomInset),
|
padding: EdgeInsets.fromLTRB(16, 8, 16, 24 + bottomInset),
|
||||||
itemCount: visible.length + (remaining > 0 ? 1 : 0),
|
itemCount: visible.length + (remaining > 0 ? 1 : 0),
|
||||||
separatorBuilder: (_, __) => const SizedBox(height: 10),
|
separatorBuilder: (_, __) => const SizedBox(height: 8),
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
if (index >= visible.length) {
|
if (index >= visible.length) {
|
||||||
return TextButton(
|
return TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
_visibleCount =
|
_visibleCount =
|
||||||
(_visibleCount + _pageSize).clamp(0, _members.length);
|
(_visibleCount + _pageSize).clamp(0, _filtered.length);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: Text(s.loadMoreRemaining(remaining)),
|
child: Text(s.loadMoreRemaining(remaining)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return ReferralMemberCard(member: visible[index]);
|
return ReferralMemberCard(
|
||||||
|
key: ValueKey(visible[index].userId),
|
||||||
|
member: visible[index],
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _SearchBar extends StatelessWidget {
|
||||||
|
const _SearchBar({
|
||||||
|
required this.controller,
|
||||||
|
required this.focusNode,
|
||||||
|
required this.hasQuery,
|
||||||
|
required this.onClear,
|
||||||
|
required this.hint,
|
||||||
|
this.resultCount,
|
||||||
|
});
|
||||||
|
|
||||||
|
final TextEditingController controller;
|
||||||
|
final FocusNode focusNode;
|
||||||
|
final bool hasQuery;
|
||||||
|
final VoidCallback onClear;
|
||||||
|
final String hint;
|
||||||
|
final String? resultCount;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 10, 16, 4),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
TextField(
|
||||||
|
key: const Key('referral_directs_search'),
|
||||||
|
controller: controller,
|
||||||
|
focusNode: focusNode,
|
||||||
|
textInputAction: TextInputAction.search,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: hint,
|
||||||
|
isDense: true,
|
||||||
|
filled: true,
|
||||||
|
fillColor: isDark
|
||||||
|
? AppColors.surfaceElevated
|
||||||
|
: const Color(0xFFF1F5F9),
|
||||||
|
prefixIcon: const Icon(Icons.search_rounded, size: 22),
|
||||||
|
suffixIcon: hasQuery
|
||||||
|
? IconButton(
|
||||||
|
key: const Key('referral_directs_search_clear'),
|
||||||
|
tooltip: MaterialLocalizations.of(context)
|
||||||
|
.deleteButtonTooltip,
|
||||||
|
onPressed: onClear,
|
||||||
|
icon: const Icon(Icons.close_rounded, size: 20),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
borderSide: BorderSide.none,
|
||||||
|
),
|
||||||
|
contentPadding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 12,
|
||||||
|
vertical: 10,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (resultCount != null) ...[
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
Text(
|
||||||
|
resultCount!,
|
||||||
|
style: Theme.of(context).textTheme.labelSmall?.copyWith(
|
||||||
|
color: isDark
|
||||||
|
? AppColors.textMuted
|
||||||
|
: const Color(0xFF64748B),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -5,112 +5,199 @@ import '../../../../l10n/app_strings.dart';
|
|||||||
import '../../../../shared/widgets/pred_card.dart';
|
import '../../../../shared/widgets/pred_card.dart';
|
||||||
import '../../utils/referral_display.dart';
|
import '../../utils/referral_display.dart';
|
||||||
|
|
||||||
/// Detailed card for one network member (direct list + tree leaves).
|
/// Compact expandable card for one direct referral.
|
||||||
class ReferralMemberCard extends StatelessWidget {
|
class ReferralMemberCard extends StatefulWidget {
|
||||||
const ReferralMemberCard({
|
const ReferralMemberCard({
|
||||||
super.key,
|
super.key,
|
||||||
required this.member,
|
required this.member,
|
||||||
this.compact = false,
|
this.initiallyExpanded = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
final ReferralNetworkMember member;
|
final ReferralNetworkMember member;
|
||||||
final bool compact;
|
final bool initiallyExpanded;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ReferralMemberCard> createState() => _ReferralMemberCardState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ReferralMemberCardState extends State<ReferralMemberCard> {
|
||||||
|
late bool _expanded = widget.initiallyExpanded;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final s = context.strings;
|
final s = context.strings;
|
||||||
|
final member = widget.member;
|
||||||
final statusColor = referralStatusColor(member.status);
|
final statusColor = referralStatusColor(member.status);
|
||||||
|
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||||
|
|
||||||
return PredCard(
|
return PredCard(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: EdgeInsets.zero,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
InkWell(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
onTap: () => setState(() => _expanded = !_expanded),
|
||||||
children: [
|
borderRadius: BorderRadius.circular(20),
|
||||||
CircleAvatar(
|
child: Padding(
|
||||||
radius: 20,
|
padding: const EdgeInsets.fromLTRB(12, 12, 8, 12),
|
||||||
backgroundColor: AppColors.primary.withValues(alpha: 0.18),
|
child: Row(
|
||||||
child: Text(
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
member.displayName.isNotEmpty
|
children: [
|
||||||
? member.displayName.characters.first.toUpperCase()
|
CircleAvatar(
|
||||||
: '?',
|
radius: 18,
|
||||||
style: const TextStyle(
|
backgroundColor: AppColors.primary.withValues(alpha: 0.18),
|
||||||
fontWeight: FontWeight.w800,
|
child: Text(
|
||||||
color: AppColors.primary,
|
member.displayName.isNotEmpty
|
||||||
),
|
? member.displayName.characters.first.toUpperCase()
|
||||||
),
|
: '?',
|
||||||
),
|
style: const TextStyle(
|
||||||
const SizedBox(width: 12),
|
fontWeight: FontWeight.w800,
|
||||||
Expanded(
|
color: AppColors.primary,
|
||||||
child: Column(
|
),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
member.displayName,
|
|
||||||
style: const TextStyle(fontWeight: FontWeight.w800, fontSize: 16),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 6),
|
),
|
||||||
Wrap(
|
const SizedBox(width: 10),
|
||||||
spacing: 6,
|
Expanded(
|
||||||
runSpacing: 6,
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
_Chip(
|
Text(
|
||||||
label: s.referralLevelLabel(member.levelNumber),
|
member.displayName,
|
||||||
color: AppColors.info,
|
maxLines: 1,
|
||||||
),
|
overflow: TextOverflow.ellipsis,
|
||||||
_Chip(
|
style: const TextStyle(
|
||||||
label: referralStatusLabel(member.status, s),
|
fontWeight: FontWeight.w800,
|
||||||
color: statusColor,
|
fontSize: 15,
|
||||||
),
|
|
||||||
if (member.generatesCommissions)
|
|
||||||
_Chip(
|
|
||||||
label: s.generatesCommissions,
|
|
||||||
color: AppColors.accentGold,
|
|
||||||
),
|
),
|
||||||
if (member.directReferralsCount > 0)
|
),
|
||||||
_Chip(
|
const SizedBox(height: 4),
|
||||||
label: s.directCountLabel(member.directReferralsCount),
|
Wrap(
|
||||||
color: AppColors.primary,
|
spacing: 6,
|
||||||
|
runSpacing: 4,
|
||||||
|
children: [
|
||||||
|
_Chip(
|
||||||
|
label: referralStatusLabel(member.status, s),
|
||||||
|
color: statusColor,
|
||||||
|
),
|
||||||
|
if (member.directReferralsCount > 0)
|
||||||
|
_Chip(
|
||||||
|
label: s.directCountLabel(
|
||||||
|
member.directReferralsCount,
|
||||||
|
),
|
||||||
|
color: AppColors.primary,
|
||||||
|
),
|
||||||
|
if (!_expanded)
|
||||||
|
_Chip(
|
||||||
|
label: formatReferralDate(member.registeredAt),
|
||||||
|
color: isDark
|
||||||
|
? AppColors.textMuted
|
||||||
|
: const Color(0xFF64748B),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (!_expanded) ...[
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
[
|
||||||
|
if (member.referralCode != null &&
|
||||||
|
member.referralCode!.isNotEmpty)
|
||||||
|
member.referralCode!,
|
||||||
|
formatUsdt(member.commissionsPaidRaw),
|
||||||
|
].join(' · '),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 11,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: isDark
|
||||||
|
? AppColors.textMuted
|
||||||
|
: const Color(0xFF64748B),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
AnimatedRotation(
|
||||||
|
turns: _expanded ? 0.5 : 0,
|
||||||
|
duration: const Duration(milliseconds: 180),
|
||||||
|
child: Icon(
|
||||||
|
Icons.expand_more_rounded,
|
||||||
|
color: isDark
|
||||||
|
? AppColors.textMuted
|
||||||
|
: const Color(0xFF64748B),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
if (!compact) ...[
|
AnimatedCrossFade(
|
||||||
const SizedBox(height: 14),
|
firstChild: const SizedBox.shrink(),
|
||||||
_InfoRow(
|
secondChild: Padding(
|
||||||
label: s.registeredAt,
|
padding: const EdgeInsets.fromLTRB(12, 0, 12, 12),
|
||||||
value: formatReferralDate(member.registeredAt),
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
Divider(
|
||||||
|
height: 1,
|
||||||
|
color: (isDark ? Colors.white : Colors.black)
|
||||||
|
.withValues(alpha: 0.08),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
_InfoRow(
|
||||||
|
label: s.registeredAt,
|
||||||
|
value: formatReferralDate(member.registeredAt),
|
||||||
|
),
|
||||||
|
_InfoRow(
|
||||||
|
label: s.email,
|
||||||
|
value: (member.email?.trim().isNotEmpty ?? false)
|
||||||
|
? member.email!.trim()
|
||||||
|
: '—',
|
||||||
|
),
|
||||||
|
_InfoRow(
|
||||||
|
label: s.memberCountry,
|
||||||
|
value: () {
|
||||||
|
final n = member.countryName?.trim();
|
||||||
|
final c = member.countryOfResidence?.trim();
|
||||||
|
if (n != null && n.isNotEmpty) return n;
|
||||||
|
if (c != null && c.isNotEmpty) return c;
|
||||||
|
return '—';
|
||||||
|
}(),
|
||||||
|
),
|
||||||
|
_InfoRow(
|
||||||
|
label: s.memberReferralCode,
|
||||||
|
value: (member.referralCode?.trim().isNotEmpty ?? false)
|
||||||
|
? member.referralCode!.trim()
|
||||||
|
: '—',
|
||||||
|
),
|
||||||
|
_InfoRow(
|
||||||
|
label: s.predictionsCount,
|
||||||
|
value: '${member.realPredictionsCount}',
|
||||||
|
),
|
||||||
|
_InfoRow(
|
||||||
|
label: s.commissionsGenerated,
|
||||||
|
value: formatUsdt(member.commissionsGeneratedRaw),
|
||||||
|
),
|
||||||
|
_InfoRow(
|
||||||
|
label: s.commissionsPaidLabel,
|
||||||
|
value: formatUsdt(member.commissionsPaidRaw),
|
||||||
|
valueColor: AppColors.success,
|
||||||
|
),
|
||||||
|
_InfoRow(
|
||||||
|
label: s.commissionsPendingLabel,
|
||||||
|
value: formatUsdt(member.commissionsPendingRaw),
|
||||||
|
valueColor: AppColors.warning,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
if (member.email != null && member.email!.isNotEmpty)
|
crossFadeState: _expanded
|
||||||
_InfoRow(label: s.email, value: member.email!),
|
? CrossFadeState.showSecond
|
||||||
if (member.countryName != null && member.countryName!.isNotEmpty)
|
: CrossFadeState.showFirst,
|
||||||
_InfoRow(label: s.countryOfResidence.replaceAll(' *', ''), value: member.countryName!),
|
duration: const Duration(milliseconds: 200),
|
||||||
if (member.referralCode != null && member.referralCode!.isNotEmpty)
|
sizeCurve: Curves.easeOutCubic,
|
||||||
_InfoRow(label: s.yourReferralCode, value: member.referralCode!),
|
),
|
||||||
_InfoRow(
|
|
||||||
label: s.predictionsCount,
|
|
||||||
value: '${member.realPredictionsCount}',
|
|
||||||
),
|
|
||||||
_InfoRow(
|
|
||||||
label: s.commissionsGenerated,
|
|
||||||
value: formatUsdt(member.commissionsGeneratedRaw),
|
|
||||||
),
|
|
||||||
_InfoRow(
|
|
||||||
label: s.commissionsPaidLabel,
|
|
||||||
value: formatUsdt(member.commissionsPaidRaw),
|
|
||||||
valueColor: AppColors.success,
|
|
||||||
),
|
|
||||||
_InfoRow(
|
|
||||||
label: s.commissionsPendingLabel,
|
|
||||||
value: formatUsdt(member.commissionsPendingRaw),
|
|
||||||
valueColor: AppColors.warning,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -125,7 +212,7 @@ class _Chip extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: color.withValues(alpha: 0.15),
|
color: color.withValues(alpha: 0.15),
|
||||||
borderRadius: BorderRadius.circular(999),
|
borderRadius: BorderRadius.circular(999),
|
||||||
@ -162,6 +249,7 @@ class _InfoRow extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
|
flex: 2,
|
||||||
child: Text(
|
child: Text(
|
||||||
label,
|
label,
|
||||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
@ -170,7 +258,8 @@ class _InfoRow extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Flexible(
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
child: Text(
|
child: Text(
|
||||||
value,
|
value,
|
||||||
textAlign: TextAlign.end,
|
textAlign: TextAlign.end,
|
||||||
|
|||||||
@ -45,3 +45,47 @@ Map<String, List<ReferralNetworkMember>> buildReferralChildMap(
|
|||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String _norm(String? value) => (value ?? '').trim().toLowerCase();
|
||||||
|
|
||||||
|
/// Client-side filter for direct referrals (no phone field in API).
|
||||||
|
/// Matches partial tokens against name, ids, email, code, country, status, dates.
|
||||||
|
List<ReferralNetworkMember> filterReferralMembers(
|
||||||
|
List<ReferralNetworkMember> members,
|
||||||
|
String query, {
|
||||||
|
required AppStrings strings,
|
||||||
|
}) {
|
||||||
|
final q = query.trim().toLowerCase();
|
||||||
|
if (q.isEmpty) return members;
|
||||||
|
|
||||||
|
final tokens = q.split(RegExp(r'\s+')).where((t) => t.isNotEmpty).toList();
|
||||||
|
if (tokens.isEmpty) return members;
|
||||||
|
|
||||||
|
return members.where((m) {
|
||||||
|
final registered = DateTime.tryParse(m.registeredAt)?.toLocal();
|
||||||
|
final registeredFmt =
|
||||||
|
registered != null ? DateFormat('dd/MM/yyyy').format(registered) : '';
|
||||||
|
final registeredIso = registered != null
|
||||||
|
? DateFormat('yyyy-MM-dd').format(registered)
|
||||||
|
: '';
|
||||||
|
final haystack = [
|
||||||
|
m.displayName,
|
||||||
|
m.userId,
|
||||||
|
m.email,
|
||||||
|
m.referralCode,
|
||||||
|
m.countryName,
|
||||||
|
m.countryOfResidence,
|
||||||
|
m.status.name,
|
||||||
|
referralStatusLabel(m.status, strings),
|
||||||
|
registeredFmt,
|
||||||
|
registeredIso,
|
||||||
|
registered?.year.toString(),
|
||||||
|
'level ${m.levelNumber}',
|
||||||
|
'niveau ${m.levelNumber}',
|
||||||
|
m.levelNumber.toString(),
|
||||||
|
if (m.directReferralsCount > 0) '${m.directReferralsCount} direct',
|
||||||
|
].map(_norm).join(' ');
|
||||||
|
|
||||||
|
return tokens.every((token) => haystack.contains(token));
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
|||||||
@ -560,6 +560,19 @@ class AppStrings {
|
|||||||
String get viewNetworkTree => t('Explore network tree', 'Explorer l’arbre du réseau');
|
String get viewNetworkTree => t('Explore network tree', 'Explorer l’arbre du réseau');
|
||||||
String get yourReferrer => t('Your referrer', 'Votre parrain');
|
String get yourReferrer => t('Your referrer', 'Votre parrain');
|
||||||
String get noDirectReferrals => t('No direct referrals yet', 'Aucun filleul direct');
|
String get noDirectReferrals => t('No direct referrals yet', 'Aucun filleul direct');
|
||||||
|
String get searchDirectReferrals => t(
|
||||||
|
'Search by name, email, code, country, status…',
|
||||||
|
'Rechercher par nom, e-mail, code, pays, statut…',
|
||||||
|
);
|
||||||
|
String get noDirectSearchResults => t(
|
||||||
|
'No referrals match your search.',
|
||||||
|
'Aucun filleul ne correspond à votre recherche.',
|
||||||
|
);
|
||||||
|
String get clearDirectSearch => t('Clear search', 'Effacer la recherche');
|
||||||
|
String directSearchCount(int shown, int total) => t(
|
||||||
|
'$shown of $total',
|
||||||
|
'$shown sur $total',
|
||||||
|
);
|
||||||
String get noNetworkMembers => t(
|
String get noNetworkMembers => t(
|
||||||
'Your network is empty. Share your invite link to grow your team.',
|
'Your network is empty. Share your invite link to grow your team.',
|
||||||
'Votre réseau est vide. Partagez votre lien d’invitation pour grandir.',
|
'Votre réseau est vide. Partagez votre lien d’invitation pour grandir.',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user