-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathlarge.dart
85 lines (80 loc) · 2.67 KB
/
large.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import 'package:ensemble_device_preview/src/state/store.dart';
import 'package:ensemble_device_preview/src/views/theme.dart';
import 'package:ensemble_device_preview/src/views/tool_panel/tool_panel.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:provider/provider.dart';
/// The tool layout when the screen is large.
class DervicePreviewLargeLayout extends StatefulWidget {
/// Create a new panel from the given tools grouped as [slivers].
const DervicePreviewLargeLayout({
Key? key,
required this.slivers,
}) : super(key: key);
/// The sections containing the tools.
///
/// They must be [Sliver]s.
final List<Widget> slivers;
@override
_DervicePreviewLargeLayoutState createState() =>
_DervicePreviewLargeLayoutState();
}
class _DervicePreviewLargeLayoutState extends State<DervicePreviewLargeLayout> {
@override
void initState() {
// Forcing rebuild to update absolute postion in `_overlayKey`
WidgetsBinding.instance.addPostFrameCallback(
(timeStamp) => setState(() {}),
);
super.initState();
}
@override
Widget build(BuildContext context) {
final mediaQuery = MediaQuery.of(context);
final toolbarTheme = context.select(
(DevicePreviewStore store) => store.settings.toolbarTheme,
);
return Theme(
data: toolbarTheme.asThemeData(),
child: Directionality(
textDirection: TextDirection.ltr,
child: Localizations(
locale: const Locale('en', 'US'),
delegates: const [
GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
child: Stack(
children: [
Positioned(
top: 0,
right: 0,
bottom: 0,
width: ToolPanel.panelWidth,
child: MediaQuery(
data: mediaQuery.copyWith(
padding: mediaQuery.padding.copyWith(left: 0) +
const EdgeInsets.only(left: 40),
),
child: Navigator(
onGenerateInitialRoutes: (navigator, initialRoute) {
return [
MaterialPageRoute(
builder: (context) => ToolPanel(
slivers: widget.slivers,
),
),
];
},
),
),
),
],
),
),
),
);
}
}