Skip to content

Commit 2c88732

Browse files
authored
Do not show carousel topBar if no images in report (#642)
1 parent 221e724 commit 2c88732

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

lib/pages/my_reports_pages/detail/shared_report_widgets.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,13 @@ class ReportDetailWidgets {
5757
);
5858
}
5959

60-
static Widget buildPhotoCarousel({
60+
static Widget? buildPhotoCarousel({
6161
required dynamic report,
6262
}) {
63+
if (report.photos.isEmpty) {
64+
return null;
65+
}
66+
6367
return CarouselView(
6468
scrollDirection: Axis.horizontal,
6569
itemExtent: double.infinity,

lib/pages/my_reports_pages/widgets/report_detail_page.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class ReportDetailPage extends StatelessWidget {
1212
final Text title;
1313
final Future<void> Function(dynamic report) onTapDelete;
1414
final Map<IconData, String>? extraListTileMap;
15-
final Widget Function(dynamic report)? topBarBackgroundBuilder;
15+
final Widget? Function(dynamic report)? topBarBackgroundBuilder;
1616
final Widget Function()? cardBuilder;
1717

1818
const ReportDetailPage({
@@ -84,13 +84,14 @@ class ReportDetailPage extends StatelessWidget {
8484
report.location.point.latitude,
8585
report.location.point.longitude,
8686
);
87+
final topBarBackground = topBarBackgroundBuilder?.call(report);
8788
return Scaffold(
8889
body: SafeArea(
8990
top: false,
9091
child: CustomScrollView(slivers: [
9192
SliverAppBar(
9293
titleSpacing: 0,
93-
expandedHeight: topBarBackgroundBuilder != null ? 250.0 : 0.0,
94+
expandedHeight: topBarBackground != null ? 250.0 : 0.0,
9495
floating: true,
9596
pinned: true,
9697
snap: true,
@@ -131,10 +132,10 @@ class ReportDetailPage extends StatelessWidget {
131132
color: Colors.white,
132133
) ??
133134
const TextStyle(color: Colors.white)),
134-
background: topBarBackgroundBuilder == null
135+
background: topBarBackground == null
135136
? null
136137
: Stack(fit: StackFit.expand, children: [
137-
topBarBackgroundBuilder!.call(report),
138+
topBarBackground,
138139
Positioned(
139140
bottom: 0,
140141
left: 0,

0 commit comments

Comments
 (0)