Skip to content

Commit

Permalink
height of sheet as per content
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-sidhdhi-p committed Oct 18, 2024
1 parent 21004b1 commit 557e7fe
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,69 +63,77 @@ class _VerificationTeamListSheetState extends State<VerificationTeamListSheet> {

@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<Widget> _buildList(BuildContext context) {
final List<Widget> 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<bool>(
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<bool>(
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;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,22 +156,26 @@ class _TeamSelectionScreenState extends ConsumerState<TeamSelectionScreen> {
required List<TeamModel> teams,
bool showDividerAtLast = false,
}) {
final List<Widget> 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<bool>(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<bool>(context, team: team),
trailing: RoundedCheckBox(
isSelected:
state.selectedTeams.map((e) => e.id).contains(team.id),
onTap: (_) => notifier.onTeamCellTap(team)),
);
}
});
}

void _observeActionError() {
Expand Down

0 comments on commit 557e7fe

Please sign in to comment.