2020-01-01 18:10:13 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
enum FocusPage { FIRST, SECOND }
|
|
|
|
|
|
|
|
class AdaptivePageLayout extends StatelessWidget {
|
|
|
|
final Widget firstScaffold;
|
|
|
|
final Widget secondScaffold;
|
|
|
|
final FocusPage primaryPage;
|
|
|
|
final double minWidth;
|
|
|
|
|
|
|
|
static const double defaultMinWidth = 400;
|
|
|
|
static bool columnMode(BuildContext context) =>
|
|
|
|
MediaQuery.of(context).size.width > 2 * defaultMinWidth;
|
|
|
|
|
|
|
|
AdaptivePageLayout(
|
|
|
|
{this.firstScaffold,
|
|
|
|
this.secondScaffold,
|
|
|
|
this.primaryPage = FocusPage.FIRST,
|
|
|
|
this.minWidth = defaultMinWidth,
|
|
|
|
Key key})
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return OrientationBuilder(builder: (context, orientation) {
|
2020-01-03 11:37:16 +00:00
|
|
|
if (orientation == Orientation.portrait || !columnMode(context)) {
|
2020-01-02 21:31:39 +00:00
|
|
|
if (primaryPage == FocusPage.FIRST) {
|
|
|
|
return firstScaffold;
|
|
|
|
} else {
|
|
|
|
return secondScaffold;
|
|
|
|
}
|
|
|
|
}
|
2020-01-01 18:10:13 +00:00
|
|
|
return Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
|
|
|
width: minWidth,
|
|
|
|
child: firstScaffold,
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
width: 1,
|
2020-02-16 19:11:39 +00:00
|
|
|
color: Theme.of(context).secondaryHeaderColor, //Color(0xFFE8E8E8),
|
2020-01-01 18:10:13 +00:00
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
child: secondScaffold,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|