From 557e7fe2a6ba5a4775b1fc507c58c6470a12ff81 Mon Sep 17 00:00:00 2001 From: sidhdhi canopas Date: Fri, 18 Oct 2024 13:01:13 +0530 Subject: [PATCH] height of sheet as per content --- .../verification_team_list_sheet.dart | 118 ++++++++++-------- .../team_selection/team_selection_screen.dart | 34 ++--- 2 files changed, 82 insertions(+), 70 deletions(-) diff --git a/khelo/lib/ui/flow/tournament/team_selection/component/verification_team_list_sheet.dart b/khelo/lib/ui/flow/tournament/team_selection/component/verification_team_list_sheet.dart index 0ac5210c..87415cb1 100644 --- a/khelo/lib/ui/flow/tournament/team_selection/component/verification_team_list_sheet.dart +++ b/khelo/lib/ui/flow/tournament/team_selection/component/verification_team_list_sheet.dart @@ -63,69 +63,77 @@ class _VerificationTeamListSheetState extends State { @override Widget build(BuildContext context) { - return SizedBox( - height: context.mediaQuerySize.height * 0.8, - child: Stack( - children: [ - dragHandle(context), - Padding( - padding: context.mediaQueryPadding + - BottomStickyOverlay.padding + - EdgeInsets.only(top: 44, left: 16, right: 16), - child: ListView( - children: [ - Text( - context.l10n.team_selection_verify_team_to_add_title, - style: AppTextStyle.header3 - .copyWith(color: context.colorScheme.textPrimary), + return ConstrainedBox( + constraints: + BoxConstraints(maxHeight: context.mediaQuerySize.height * 0.8), + child: IntrinsicHeight( + child: Stack( + children: [ + Padding( + padding: context.mediaQueryPadding + + BottomStickyOverlay.padding + + EdgeInsets.only(top: 44, left: 16, right: 16), + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + context.l10n.team_selection_verify_team_to_add_title, + style: AppTextStyle.header3 + .copyWith(color: context.colorScheme.textPrimary), + ), + SizedBox(height: 24), + ..._buildList(context), + SizedBox(height: 40), + ], ), - SizedBox(height: 24), - ..._buildList(context), - SizedBox(height: 16), - ], + ), ), - ), - BottomStickyOverlay( - child: PrimaryButton(context.l10n.common_select_title, - enabled: verified.isNotEmpty, - onPressed: () => context.pop(verified.toSet().toList())), - ), - ], + dragHandle(context), + BottomStickyOverlay( + child: PrimaryButton(context.l10n.common_select_title, + enabled: verified.isNotEmpty, + onPressed: () => context.pop(verified.toSet().toList())), + ), + ], + ), ), ); } List _buildList(BuildContext context) { - final List children = []; - for (int index = 0; index < widget.allTeams.length; index++) { - final team = widget.allTeams[index]; - final isVerified = verified.map((e) => e.id).contains(team.id); - children.add(TeamProfileCell( - team: team, - trailing: SecondaryButton( - isVerified - ? context.l10n.common_verified_title - : context.l10n.common_verify_title, - enabled: !isVerified, - onPressed: () async { - final res = await TeamMemberSheet.show( - context, - team: team, - isForVerification: true, - ); + if (widget.allTeams.isEmpty) { + return []; + } + return List.generate((widget.allTeams.length * 2) - 1, (index) { + if (index.isOdd) { + return Divider(color: context.colorScheme.outline); + } else { + final team = widget.allTeams[index ~/ 2]; + final isVerified = verified.map((e) => e.id).contains(team.id); + return TeamProfileCell( + team: team, + trailing: SecondaryButton( + isVerified + ? context.l10n.common_verified_title + : context.l10n.common_verify_title, + enabled: !isVerified, + onPressed: () async { + final res = await TeamMemberSheet.show( + context, + team: team, + isForVerification: true, + ); - if (res == true && context.mounted) { - verified.add(team); - setState(() {}); - } - }, - ), - onTap: () => TeamMemberSheet.show(context, team: team), - )); - if (index != widget.allTeams.length - 1) { - children.add(Divider(color: context.colorScheme.outline)); + if (res == true && context.mounted) { + verified.add(team); + setState(() {}); + } + }, + ), + onTap: () => TeamMemberSheet.show(context, team: team), + ); } - } - return children; + }); } } diff --git a/khelo/lib/ui/flow/tournament/team_selection/team_selection_screen.dart b/khelo/lib/ui/flow/tournament/team_selection/team_selection_screen.dart index 03ddb163..cfafa536 100644 --- a/khelo/lib/ui/flow/tournament/team_selection/team_selection_screen.dart +++ b/khelo/lib/ui/flow/tournament/team_selection/team_selection_screen.dart @@ -156,22 +156,26 @@ class _TeamSelectionScreenState extends ConsumerState { required List teams, bool showDividerAtLast = false, }) { - final List children = []; - for (int index = 0; index < teams.length; index++) { - final team = teams[index]; - children.add(TeamProfileCell( - team: team, - onTap: () => notifier.onTeamCellTap(team), - onLongTap: () => TeamMemberSheet.show(context, team: team), - trailing: RoundedCheckBox( - isSelected: state.selectedTeams.map((e) => e.id).contains(team.id), - onTap: (_) => notifier.onTeamCellTap(team)), - )); - if (index != teams.length - 1 || showDividerAtLast) { - children.add(Divider(color: context.colorScheme.outline)); - } + if (teams.isEmpty) { + return []; } - return children; + final listLength = (teams.length * 2) - (showDividerAtLast ? 0 : 1); + return List.generate(listLength, (index) { + if (index.isOdd) { + return Divider(color: context.colorScheme.outline); + } else { + final team = teams[index ~/ 2]; + return TeamProfileCell( + team: team, + onTap: () => notifier.onTeamCellTap(team), + onLongTap: () => TeamMemberSheet.show(context, team: team), + trailing: RoundedCheckBox( + isSelected: + state.selectedTeams.map((e) => e.id).contains(team.id), + onTap: (_) => notifier.onTeamCellTap(team)), + ); + } + }); } void _observeActionError() {