@@ -33,6 +33,9 @@ class MyHomePage extends StatefulWidget {
33
33
}
34
34
35
35
class _MyHomePageState extends State <MyHomePage > with SingleTickerProviderStateMixin {
36
+ static const _pageCount = 20 ;
37
+ static const _naturalPageSizeInInches = Size (8.5 , 11 );
38
+
36
39
late final PageListViewportController _controller;
37
40
38
41
@override
@@ -50,51 +53,81 @@ class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateM
50
53
@override
51
54
Widget build (BuildContext context) {
52
55
return Scaffold (
53
- body: PageListViewportGestures (
56
+ body: Row (
57
+ crossAxisAlignment: CrossAxisAlignment .stretch,
58
+ children: [
59
+ SizedBox (
60
+ width: 125 ,
61
+ child: _buildThumbnailList (),
62
+ ),
63
+ Expanded (
64
+ child: _buildViewport (),
65
+ ),
66
+ ],
67
+ ),
68
+ );
69
+ }
70
+
71
+ Widget _buildViewport () {
72
+ return PageListViewportGestures (
73
+ controller: _controller,
74
+ lockPanAxis: true ,
75
+ child: PageListViewport (
54
76
controller: _controller,
55
- lockPanAxis : true ,
56
- child : PageListViewport (
57
- controller : _controller ,
58
- pageCount : 60 , //_pageCount ,
59
- naturalPageSize : const Size ( 8.5 , 11 ) * 72 * MediaQuery . of (context).devicePixelRatio,
60
- pageLayoutCacheCount : 3 ,
61
- pagePaintCacheCount : 3 ,
62
- builder : ( BuildContext context, int pageIndex) {
63
- return Stack (
64
- children : [
65
- Positioned . fill (
66
- child: Image . asset (
67
- "assets/test-image.jpeg" ,
68
- fit : BoxFit .cover ,
69
- ),
77
+ pageCount : _pageCount ,
78
+ naturalPageSize : _naturalPageSizeInInches * 72 * MediaQuery . of (context).devicePixelRatio,
79
+ pageLayoutCacheCount : 3 ,
80
+ pagePaintCacheCount : 3 ,
81
+ builder : ( BuildContext context, int pageIndex) {
82
+ return Stack (
83
+ children : [
84
+ Positioned . fill (
85
+ child : _buildPage (pageIndex),
86
+ ),
87
+ Center (
88
+ child: Container (
89
+ padding : const EdgeInsets . all ( 32 ) ,
90
+ color : Colors .white ,
91
+ child : Text ( "Page: $ pageIndex " ),
70
92
),
71
- Center (
72
- child: Container (
73
- padding: const EdgeInsets .all (32 ),
74
- color: Colors .white,
75
- child: Text ("Page: $pageIndex " ),
76
- ),
77
- )
78
- ],
79
- );
93
+ )
94
+ ],
95
+ );
96
+ },
97
+ ),
98
+ );
99
+ }
80
100
81
- // return RepaintBoundary(
82
- // key: ValueKey(pageIndex),
83
- // child: Container(
84
- // width: double.infinity,
85
- // height: double.infinity,
86
- // decoration: const BoxDecoration(
87
- // gradient: LinearGradient(
88
- // colors: [Colors.red, Colors.blue],
89
- // begin: Alignment.topLeft,
90
- // end: Alignment.bottomRight,
91
- // ),
92
- // ),
93
- // ),
94
- // );
101
+ Widget _buildThumbnailList () {
102
+ return RepaintBoundary (
103
+ child: ColoredBox (
104
+ color: Colors .grey.shade800,
105
+ child: ListView .builder (
106
+ padding: const EdgeInsets .all (16 ),
107
+ itemCount: _pageCount,
108
+ itemBuilder: (context, index) {
109
+ return Padding (
110
+ padding: const EdgeInsets .symmetric (vertical: 8 ),
111
+ child: GestureDetector (
112
+ onTap: () {
113
+ _controller.animateToPage (index, const Duration (milliseconds: 250 ));
114
+ },
115
+ child: AspectRatio (
116
+ aspectRatio: _naturalPageSizeInInches.aspectRatio,
117
+ child: _buildPage (index),
118
+ ),
119
+ ),
120
+ );
95
121
},
96
122
),
97
123
),
98
124
);
99
125
}
126
+
127
+ Widget _buildPage (int pageIndex) {
128
+ return Image .asset (
129
+ "assets/test-image.jpeg" ,
130
+ fit: BoxFit .cover,
131
+ );
132
+ }
100
133
}
0 commit comments