@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
2
2
import 'package:xdag/common/color.dart' ;
3
3
import 'package:flutter_gen/gen_l10n/app_localizations.dart' ;
4
4
import 'package:xdag/common/helper.dart' ;
5
+ import 'package:xdag/widget/desktop.dart' ;
5
6
6
7
class Dot extends StatelessWidget {
7
8
final double size;
@@ -60,6 +61,7 @@ class HomeMain extends StatefulWidget {
60
61
61
62
class _HomeMainState extends State <HomeMain > {
62
63
int index = 0 ;
64
+ final pageController = PageController ();
63
65
@override
64
66
Widget build (BuildContext context) {
65
67
var config = [
@@ -79,39 +81,100 @@ class _HomeMainState extends State<HomeMain> {
79
81
"subTitle" : AppLocalizations .of (context).welcomeDesc_3,
80
82
}
81
83
];
82
- return Stack (
83
- fit: StackFit .expand,
84
- children: [
85
- PageView .builder (
86
- itemCount: config.length,
87
- itemBuilder: (context, index) {
88
- return HomeMainContent (
89
- image: config[index]["image" ]! ,
90
- title: config[index]["title" ]! ,
91
- subTitle: config[index]["subTitle" ]! ,
92
- );
93
- },
94
- onPageChanged: (index) {
95
- setState (() {
96
- this .index = index;
97
- });
98
- },
99
- ),
100
- Positioned (
101
- bottom: 25 ,
102
- left: 0 ,
103
- right: 0 ,
104
- child: Row (
105
- mainAxisAlignment: MainAxisAlignment .center,
106
- children: [
107
- Dot (color: index == 0 ? DarkColors .mainColor : Colors .white),
108
- const SizedBox (width: 18 ),
109
- Dot (color: index == 1 ? DarkColors .mainColor : Colors .white),
110
- const SizedBox (width: 18 ),
111
- Dot (color: index == 2 ? DarkColors .mainColor : Colors .white),
112
- ],
113
- )),
114
- ],
84
+ return LayoutBuilder (
85
+ builder: (BuildContext context, BoxConstraints constraints) {
86
+ double screenHeight = MediaQuery .of (context).size.height;
87
+ double contentHeight = ScreenHelper .topPadding + 55 + 20 + (ScreenHelper .bottomPadding > 0 ? ScreenHelper .bottomPadding : 20 ) + 50 + 20 + 50 ;
88
+ double h = (screenHeight - contentHeight) / 2 ;
89
+ print (screenHeight);
90
+ return Stack (
91
+ fit: StackFit .expand,
92
+ children: [
93
+ PageView .builder (
94
+ itemCount: config.length,
95
+ controller: pageController,
96
+ itemBuilder: (context, index) {
97
+ return HomeMainContent (
98
+ image: config[index]["image" ]! ,
99
+ title: config[index]["title" ]! ,
100
+ subTitle: config[index]["subTitle" ]! ,
101
+ );
102
+ },
103
+ onPageChanged: (index) {
104
+ setState (() {
105
+ this .index = index;
106
+ });
107
+ },
108
+ ),
109
+ if (Helper .isDesktop)
110
+ Positioned (
111
+ top: h - 25 ,
112
+ left: 10 ,
113
+ width: 50 ,
114
+ height: 50 ,
115
+ child: MyCupertinoButton (
116
+ padding: const EdgeInsets .all (0 ),
117
+ onPressed: index != 0
118
+ ? () {
119
+ if (index > 0 ) {
120
+ pageController.previousPage (duration: const Duration (milliseconds: 300 ), curve: Curves .ease);
121
+ }
122
+ }
123
+ : null ,
124
+ child: SizedBox (
125
+ width: 50 ,
126
+ height: 50 ,
127
+ child: Center (
128
+ child: Icon (
129
+ Icons .arrow_back_ios,
130
+ color: index != 0 ? Colors .white : Colors .white54,
131
+ )),
132
+ ),
133
+ ),
134
+ ),
135
+ if (Helper .isDesktop)
136
+ Positioned (
137
+ top: h - 25 ,
138
+ right: 10 ,
139
+ width: 50 ,
140
+ height: 50 ,
141
+ child: MyCupertinoButton (
142
+ padding: const EdgeInsets .all (0 ),
143
+ onPressed: index != 2
144
+ ? () {
145
+ if (index < config.length - 1 ) {
146
+ pageController.nextPage (duration: const Duration (milliseconds: 300 ), curve: Curves .ease);
147
+ }
148
+ }
149
+ : null ,
150
+ child: SizedBox (
151
+ width: 50 ,
152
+ height: 50 ,
153
+ child: Center (
154
+ child: Icon (
155
+ Icons .arrow_forward_ios,
156
+ color: index != 2 ? Colors .white : Colors .white54,
157
+ )),
158
+ ),
159
+ ),
160
+ ),
161
+ Positioned (
162
+ bottom: 25 ,
163
+ left: 0 ,
164
+ right: 0 ,
165
+ child: Row (
166
+ mainAxisAlignment: MainAxisAlignment .center,
167
+ children: [
168
+ Dot (color: index == 0 ? DarkColors .mainColor : Colors .white),
169
+ const SizedBox (width: 18 ),
170
+ Dot (color: index == 1 ? DarkColors .mainColor : Colors .white),
171
+ const SizedBox (width: 18 ),
172
+ Dot (color: index == 2 ? DarkColors .mainColor : Colors .white),
173
+ ],
174
+ )),
175
+ ],
176
+ );
177
+ },
115
178
);
116
179
}
117
180
}
0 commit comments