@@ -22,10 +22,11 @@ import 'package:flutter_wechat/utils/service/zone_code_service.dart';
2222
2323/// 闪屏跳转模式
2424enum MHSplashSkipMode {
25- newFeature, // 新特性
25+ newFeature, // 新特性(引导页)
2626 login, // 登陆
2727 currentLogin, // 账号登陆
2828 homePage, // 主页
29+ ad, // 广告页
2930}
3031
3132/// 闪屏界面主要用来中转(新特性界面、登陆界面、主页面)
@@ -77,7 +78,10 @@ class _SplashPageState extends State<SplashPage> {
7778 _skipMode = MHSplashSkipMode .newFeature;
7879 });
7980 } else {
80- _switchRootView ();
81+ // _switchRootView();
82+ setState (() {
83+ _skipMode = MHSplashSkipMode .ad;
84+ });
8185 }
8286 });
8387 }
@@ -133,12 +137,15 @@ class _SplashPageState extends State<SplashPage> {
133137
134138 /// If you use a dependent context-free method to obtain screen parameters and adaptions, you need to call this method.
135139 MediaQuery .of (context);
136-
137- return Material (
138- child: _skipMode == MHSplashSkipMode .newFeature
139- ? _buildNewFeatureWidget ()
140- : _buildDefaultLaunchImage (),
141- );
140+ Widget child;
141+ if (_skipMode == MHSplashSkipMode .newFeature) {
142+ child = _buildNewFeatureWidget ();
143+ } else if (_skipMode == MHSplashSkipMode .ad) {
144+ child = _buildAdWidget ();
145+ } else {
146+ child = _buildDefaultLaunchImage ();
147+ }
148+ return Material (child: child);
142149 }
143150
144151 /// 默认情况是一个启动页 1200x530
@@ -151,7 +158,7 @@ class _SplashPageState extends State<SplashPage> {
151158 // 这里设置颜色 跟启动页一致的背景色,以免发生白屏闪烁
152159 color: Color .fromRGBO (0 , 10 , 24 , 1 ),
153160 image: DecorationImage (
154- // 启动页 别搞太大 以免加载慢
161+ // 注意: 启动页 别搞太大 以免加载慢
155162 image: AssetImage (Constant .assetsImages + 'LaunchImage.png' ),
156163 fit: BoxFit .cover,
157164 ),
@@ -167,7 +174,6 @@ class _SplashPageState extends State<SplashPage> {
167174 itemBuilder: (_, index) {
168175 final String name =
169176 Constant .assetsImagesNewFeature + 'intro_page_${index + 1 }.png' ;
170- print (name);
171177 Widget widget = Image .asset (
172178 name,
173179 fit: BoxFit .cover,
@@ -203,4 +209,72 @@ class _SplashPageState extends State<SplashPage> {
203209 },
204210 );
205211 }
212+
213+ /// 广告页
214+ Widget _buildAdWidget () {
215+ return Container (
216+ child: _buildAdChildWidget (),
217+ width: double .infinity,
218+ height: double .infinity,
219+ decoration: BoxDecoration (
220+ image: DecorationImage (
221+ image: AssetImage (Constant .assetsImagesBg + 'SkyBg01_320x490.png' ),
222+ fit: BoxFit .cover,
223+ ),
224+ ),
225+ );
226+ }
227+
228+ Widget _buildAdChildWidget () {
229+ final double horizontal =
230+ FlutterScreenUtil .ScreenUtil .getInstance ().setWidth (30.0 );
231+ final double vertical =
232+ FlutterScreenUtil .ScreenUtil .getInstance ().setHeight (9.0 );
233+ final double fontSize =
234+ FlutterScreenUtil .ScreenUtil .getInstance ().setSp (42.0 );
235+ final lineHeight =
236+ FlutterScreenUtil .ScreenUtil .getInstance ().setHeight (20.0 * 3 / 14.0 );
237+ final radius = FlutterScreenUtil .ScreenUtil .getInstance ().setWidth (108.0 );
238+ return Stack (
239+ children: < Widget > [
240+ Swiper (
241+ onTap: (idx) {
242+ print ('onTap $idx ' );
243+ // 跳转到Web
244+ },
245+ itemCount: 4 ,
246+ loop: true ,
247+ autoplay: true ,
248+ itemBuilder: (_, index) {
249+ return Center (
250+ child: Image .asset (
251+ Constant .assetsImagesAds + '121-bigskin-${index + 1 }.jpg' ,
252+ fit: BoxFit .cover,
253+ ),
254+ );
255+ },
256+ ),
257+ Positioned (
258+ top: FlutterScreenUtil .ScreenUtil .getInstance ().setWidth (60.0 ),
259+ right: FlutterScreenUtil .ScreenUtil .getInstance ().setWidth (60.0 ),
260+ child: Container (
261+ padding: EdgeInsets .symmetric (
262+ horizontal: horizontal, vertical: vertical),
263+ alignment: Alignment .center,
264+ decoration: BoxDecoration (
265+ color: Colors .white10,
266+ border: Border .all (color: Colors .white, width: 0 ),
267+ borderRadius: BorderRadius .all (Radius .circular (radius)),
268+ ),
269+ child: Text (
270+ '跳过 5' ,
271+ textAlign: TextAlign .center,
272+ style: TextStyle (
273+ color: Colors .white, fontSize: fontSize, height: lineHeight),
274+ ),
275+ ),
276+ )
277+ ],
278+ );
279+ }
206280}
0 commit comments