@@ -83,22 +83,25 @@ class _CopyLinkButton extends StatelessWidget {
83
83
}
84
84
}
85
85
86
- class _LightboxPage extends StatefulWidget {
87
- const _LightboxPage ({
86
+ class _LightboxPageLayout extends StatefulWidget {
87
+ const _LightboxPageLayout ({
88
88
required this .routeEntranceAnimation,
89
89
required this .message,
90
- required this .src,
90
+ required this .buildBottomAppBar,
91
+ required this .child,
91
92
});
92
93
93
94
final Animation routeEntranceAnimation;
94
95
final Message message;
95
- final Uri src;
96
+ final Widget ? Function (
97
+ BuildContext context, Color appBarBackgroundColor, double appBarElevation) buildBottomAppBar;
98
+ final Widget child;
96
99
97
100
@override
98
- State <_LightboxPage > createState () => _LightboxPageState ();
101
+ State <_LightboxPageLayout > createState () => _LightboxPageLayoutState ();
99
102
}
100
103
101
- class _LightboxPageState extends State <_LightboxPage > {
104
+ class _LightboxPageLayoutState extends State <_LightboxPageLayout > {
102
105
// TODO(#38): Animate entrance/exit of header and footer
103
106
bool _headerFooterVisible = false ;
104
107
@@ -168,14 +171,8 @@ class _LightboxPageState extends State<_LightboxPage> {
168
171
169
172
Widget ? bottomAppBar;
170
173
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);
179
176
}
180
177
181
178
return Theme (
@@ -186,6 +183,7 @@ class _LightboxPageState extends State<_LightboxPage> {
186
183
extendBody: true , // For the BottomAppBar
187
184
extendBodyBehindAppBar: true , // For the AppBar
188
185
appBar: appBar,
186
+ bottomNavigationBar: bottomAppBar,
189
187
body: MediaQuery (
190
188
// Clobber the MediaQueryData prepared by Scaffold with one that's not
191
189
// affected by the app bars. On this screen, the app bars are
@@ -197,14 +195,46 @@ class _LightboxPageState extends State<_LightboxPage> {
197
195
child: GestureDetector (
198
196
behavior: HitTestBehavior .translucent,
199
197
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))))));
208
238
}
209
239
}
210
240
@@ -224,7 +254,7 @@ Route getLightboxRoute({
224
254
Animation <double > secondaryAnimation,
225
255
) {
226
256
// TODO(#40): Drag down to close?
227
- return _LightboxPage (routeEntranceAnimation: animation, message: message, src: src);
257
+ return _ImageLightboxPage (routeEntranceAnimation: animation, message: message, src: src);
228
258
},
229
259
transitionsBuilder: (
230
260
BuildContext context,
0 commit comments