Skip to content

Commit

Permalink
Fixed scroll containers padding
Browse files Browse the repository at this point in the history
  • Loading branch information
Loic-Vanden-Bossche committed Jul 9, 2024
1 parent 32ac37d commit 0b46d52
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class EventDetailsInfos extends StatelessWidget {
EventStatusFeed(eventDetails: eventDetails),
const SizedBox(height: 13),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
children: [
Row(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ class _EventCandidatesScreenState extends State<EventCandidatesScreen> {
),
floatingActionButton: floatingActionButton,
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: [
const SizedBox(height: 32),
const SizedBox(height: 16),
TextField(
decoration: InputDecoration(
border: OutlineInputBorder(
Expand All @@ -141,6 +141,7 @@ class _EventCandidatesScreenState extends State<EventCandidatesScreen> {
),
onChanged: _onSearchCandidates,
),
const SizedBox(height: 16),
BlocBuilder<EventCandidatesBloc, EventCandidatesState>(
builder: (context, state) {
final isLoading =
Expand Down Expand Up @@ -186,30 +187,33 @@ class _EventCandidatesScreenState extends State<EventCandidatesScreen> {
state.candidates.length + (state.hasMore ? 1 : 0);

return Expanded(
child: ListView.separated(
controller: _scrollController,
padding: const EdgeInsets.symmetric(vertical: 10),
itemCount: totalCandidates,
separatorBuilder: (context, index) =>
const SizedBox(height: 10),
itemBuilder: (context, index) {
if (state.hasMore && index == totalCandidates - 1) {
return const Center(
child: CircularProgressIndicator(),
);
}
child: ClipRRect(
borderRadius: BorderRadius.circular(10),
child: ListView.separated(
controller: _scrollController,
padding: const EdgeInsets.only(bottom: 80),
itemCount: totalCandidates,
separatorBuilder: (context, index) =>
const SizedBox(height: 6),
itemBuilder: (context, index) {
if (state.hasMore && index == totalCandidates - 1) {
return const Center(
child: CircularProgressIndicator(),
);
}

final candidate = state.candidates[index];
final candidate = state.candidates[index];

return EventCandidateCard(
candidate: candidate,
alreadyParticipating: candidate.eventRole != null,
isSelected:
_selectedCandidates.contains(candidate.id) ||
candidate.eventRole != null,
onTap: () => _onCandidateSelected(candidate.id),
);
},
return EventCandidateCard(
candidate: candidate,
alreadyParticipating: candidate.eventRole != null,
isSelected:
_selectedCandidates.contains(candidate.id) ||
candidate.eventRole != null,
onTap: () => _onCandidateSelected(candidate.id),
);
},
),
),
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class _EventParticipationsScreenState extends State<EventParticipationsScreen> {
child: Container(
color: Theme.of(context).scaffoldBackgroundColor,
child: Padding(
padding: const EdgeInsets.only(top: 16, left: 8, right: 8),
padding: const EdgeInsets.only(top: 16, left: 16, right: 16),
child:
BlocBuilder<EventParticipationBloc, EventParticipationsState>(
builder: (context, state) {
Expand Down Expand Up @@ -159,46 +159,47 @@ class _EventParticipationsScreenState extends State<EventParticipationsScreen> {
Widget _buildList(List<EventParticipation> participants, bool isLoading) {
final totalCount = participants.length + (isLoading ? 1 : 0);

return ListView.separated(
controller: _scrollController,
padding: const EdgeInsets.symmetric(vertical: 10),
itemCount: totalCount,
separatorBuilder: (context, index) => const SizedBox(height: 10),
physics: const AlwaysScrollableScrollPhysics(
parent: BouncingScrollPhysics(),
),
itemBuilder: (context, index) {
if (isLoading && index == totalCount - 1) {
return const Center(
child: CircularProgressIndicator(),
);
}
return ClipRRect(
borderRadius: BorderRadius.circular(10),
child: ListView.separated(
controller: _scrollController,
padding: const EdgeInsets.only(bottom: 80),
itemCount: totalCount,
separatorBuilder: (context, index) => const SizedBox(height: 6),
physics: const AlwaysScrollableScrollPhysics(),
itemBuilder: (context, index) {
if (isLoading && index == totalCount - 1) {
return const Center(
child: CircularProgressIndicator(),
);
}

final participation = participants[index];

return TweenAnimationBuilder(
tween: Tween<double>(begin: 0, end: 1),
duration: const Duration(milliseconds: 250),
curve: Curves.ease,
builder: (context, double value, child) {
return Transform.translate(
offset: Offset(30 * (1 - value), 0),
child: Opacity(
opacity: value,
child: EventParticipationCard(
eventId: widget.eventDetails.event.id,
participation: participation,
isOwner: widget.eventDetails.event.owner.id ==
participation.user.id,
isCurrentUser: participation.user.id ==
widget.eventDetails.callerParticipation?.userId,
isCurrentUserOrganizer: widget.eventDetails.isOrganizer,
final participation = participants[index];

return TweenAnimationBuilder(
tween: Tween<double>(begin: 0, end: 1),
duration: const Duration(milliseconds: 250),
curve: Curves.ease,
builder: (context, double value, child) {
return Transform.translate(
offset: Offset(30 * (1 - value), 0),
child: Opacity(
opacity: value,
child: EventParticipationCard(
eventId: widget.eventDetails.event.id,
participation: participation,
isOwner: widget.eventDetails.event.owner.id ==
participation.user.id,
isCurrentUser: participation.user.id ==
widget.eventDetails.callerParticipation?.userId,
isCurrentUserOrganizer: widget.eventDetails.isOrganizer,
),
),
),
);
},
);
},
);
},
);
},
),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class EventCandidateCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Card(
margin: const EdgeInsets.symmetric(vertical: 5),
child: CheckboxListTile(
value: isSelected,
enabled: !alreadyParticipating,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class EventPositionSwitch extends StatelessWidget {
width: double.infinity,
color: Theme.of(context).colorScheme.primary,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 6),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
child: SizedBox(
child: SwitchWithText(
alignment: SwitchAlignment.right,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class EventParticipationCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Card(
margin: const EdgeInsets.symmetric(vertical: 5),
child: ListTile(
onTap: () {
_onOpenParticipationModal(context);
Expand Down

0 comments on commit 0b46d52

Please sign in to comment.