@@ -83,22 +83,25 @@ class _CopyLinkButton extends StatelessWidget {
8383 }
8484}
8585
86- class _LightboxPage extends StatefulWidget {
87- const _LightboxPage ({
86+ class _LightboxPageLayout extends StatefulWidget {
87+ const _LightboxPageLayout ({
8888 required this .routeEntranceAnimation,
8989 required this .message,
90- required this .src,
90+ required this .buildBottomAppBar,
91+ required this .child,
9192 });
9293
9394 final Animation routeEntranceAnimation;
9495 final Message message;
95- final Uri src;
96+ final Widget ? Function (
97+ BuildContext context, Color appBarBackgroundColor, double appBarElevation) buildBottomAppBar;
98+ final Widget child;
9699
97100 @override
98- State <_LightboxPage > createState () => _LightboxPageState ();
101+ State <_LightboxPageLayout > createState () => _LightboxPageLayoutState ();
99102}
100103
101- class _LightboxPageState extends State <_LightboxPage > {
104+ class _LightboxPageLayoutState extends State <_LightboxPageLayout > {
102105 // TODO(#38): Animate entrance/exit of header and footer
103106 bool _headerFooterVisible = false ;
104107
@@ -168,14 +171,8 @@ class _LightboxPageState extends State<_LightboxPage> {
168171
169172 Widget ? bottomAppBar;
170173 if (_headerFooterVisible) {
171- bottomAppBar = BottomAppBar (
172- color: appBarBackgroundColor,
173- elevation: appBarElevation,
174- child: Row (children: [
175- _CopyLinkButton (url: widget.src),
176- // TODO(#43): Share image
177- // TODO(#42): Download image
178- ]));
174+ bottomAppBar = widget.buildBottomAppBar (
175+ context, appBarBackgroundColor, appBarElevation);
179176 }
180177
181178 return Theme (
@@ -186,6 +183,7 @@ class _LightboxPageState extends State<_LightboxPage> {
186183 extendBody: true , // For the BottomAppBar
187184 extendBodyBehindAppBar: true , // For the AppBar
188185 appBar: appBar,
186+ bottomNavigationBar: bottomAppBar,
189187 body: MediaQuery (
190188 // Clobber the MediaQueryData prepared by Scaffold with one that's not
191189 // affected by the app bars. On this screen, the app bars are
@@ -197,14 +195,46 @@ class _LightboxPageState extends State<_LightboxPage> {
197195 child: GestureDetector (
198196 behavior: HitTestBehavior .translucent,
199197 onTap: _handleTap,
200- child: SizedBox .expand (
201- child: InteractiveViewer (
202- child: SafeArea (
203- child: LightboxHero (
204- message: widget.message,
205- src: widget.src,
206- child: RealmContentNetworkImage (widget.src, filterQuality: FilterQuality .medium))))))),
207- bottomNavigationBar: bottomAppBar));
198+ child: widget.child))));
199+ }
200+ }
201+
202+ class _ImageLightboxPage extends StatefulWidget {
203+ const _ImageLightboxPage ({
204+ required this .routeEntranceAnimation,
205+ required this .message,
206+ required this .src,
207+ });
208+
209+ final Animation routeEntranceAnimation;
210+ final Message message;
211+ final Uri src;
212+
213+ @override
214+ State <_ImageLightboxPage > createState () => _ImageLightboxPageState ();
215+ }
216+
217+ class _ImageLightboxPageState extends State <_ImageLightboxPage > {
218+ @override
219+ Widget build (BuildContext context) {
220+ return _LightboxPageLayout (
221+ routeEntranceAnimation: widget.routeEntranceAnimation,
222+ message: widget.message,
223+ buildBottomAppBar: (context, color, elevation) => BottomAppBar (
224+ color: color,
225+ elevation: elevation,
226+ child: Row (children: [
227+ _CopyLinkButton (url: widget.src),
228+ // TODO(#43): Share image
229+ // TODO(#42): Download image
230+ ])),
231+ child: SizedBox .expand (
232+ child: InteractiveViewer (
233+ child: SafeArea (
234+ child: LightboxHero (
235+ message: widget.message,
236+ src: widget.src,
237+ child: RealmContentNetworkImage (widget.src, filterQuality: FilterQuality .medium))))));
208238 }
209239}
210240
@@ -224,7 +254,7 @@ Route getLightboxRoute({
224254 Animation <double > secondaryAnimation,
225255 ) {
226256 // TODO(#40): Drag down to close?
227- return _LightboxPage (routeEntranceAnimation: animation, message: message, src: src);
257+ return _ImageLightboxPage (routeEntranceAnimation: animation, message: message, src: src);
228258 },
229259 transitionsBuilder: (
230260 BuildContext context,
0 commit comments