diff --git a/lib/home/guide_page.dart b/lib/home/guide_page.dart index 17417bdd..50b8ab38 100644 --- a/lib/home/guide_page.dart +++ b/lib/home/guide_page.dart @@ -1,6 +1,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:huixiang/view_widget/border_text.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class GuidePage extends StatefulWidget { @override @@ -328,7 +329,7 @@ class _GuidePage extends State { ), GestureDetector( onTap: (){ - Navigator.of(context).popAndPushNamed('/router/login_page'); + toNext(); }, child:Container( margin: EdgeInsets.only(left: 71,right: 71), @@ -353,4 +354,17 @@ class _GuidePage extends State { ), ); } + + toNext() { + SharedPreferences.getInstance().then((value) { + value.setBool("isFirst", false); + String token = value.getString("token"); + if (token == null || token == "") { + Navigator.of(context).popAndPushNamed('/router/login_page'); + } else { + Navigator.of(context).popAndPushNamed('/router/main_page'); + } + }); + } + } diff --git a/lib/home/home_page.dart b/lib/home/home_page.dart index ebf47a64..29969e3f 100644 --- a/lib/home/home_page.dart +++ b/lib/home/home_page.dart @@ -26,7 +26,9 @@ import 'package:shared_preferences/shared_preferences.dart'; class HomePage extends StatefulWidget { final GestureTapCallback callback; + HomePage(this.callback); + @override State createState() { return _HomePage(callback); @@ -36,6 +38,7 @@ class HomePage extends StatefulWidget { class _HomePage extends State with AutomaticKeepAliveClientMixin { ApiService apiService; final GestureTapCallback callback; + _HomePage(this.callback); @override @@ -43,12 +46,12 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { super.initState(); SharedPreferences.getInstance().then((value) => { - apiService = ApiService(Dio(), - context: context, - token: value.getString('token'), - showLoading: false), - queryHome(), - }); + apiService = ApiService(Dio(), + context: context, + token: value.getString('token'), + showLoading: false), + queryHome(), + }); eventBus.on().listen((event) { if (event.type < 3) { @@ -219,46 +222,54 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { ), brands(), Container( - margin: EdgeInsets.only(left:16.5,right: 16.5,bottom: 40), - padding: EdgeInsets.only(bottom: 10), + margin: EdgeInsets.only(left: 16.5.w, right: 16.5.w, bottom: 40.h), + padding: EdgeInsets.only(bottom: 10.h), decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(4), - ), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(12), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ) - ], - color: Colors.white), + borderRadius: BorderRadius.all( + Radius.circular(4), + ), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ) + ], + color: Colors.white, + ), child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Expanded(flex: 1,child:ItemTitle( - text: S.of(context).jifenshangcheng, - imgPath: "assets/image/icon_points_mall.png", - )), + Expanded( + flex: 1, + child: ItemTitle( + text: S.of(context).jifenshangcheng, + imgPath: "assets/image/icon_points_mall.png", + )), GestureDetector( onTap: callback, - child:Container( - padding: EdgeInsets.only(left:8,right: 8,top:3,bottom: 3), - margin:EdgeInsets.only(right: 16), + child: Container( + padding: EdgeInsets.only( + left: 8.w, right: 8.w, top: 3.h, bottom: 3.h), + margin: EdgeInsets.only(right: 16.w), decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(11.5), - ), - color: Color(0xFF32A060)), + borderRadius: BorderRadius.circular(11.5), + color: Color(0xFF32A060), + ), child: Row( children: [ - Text("GO",style: TextStyle( - fontSize: 14,fontWeight: FontWeight.bold,color: Colors.white - ),), + Text( + "GO", + style: TextStyle( + fontSize: 14.sp, + fontWeight: FontWeight.bold, + color: Colors.white, + ), + ), Icon( Icons.chevron_right, color: Colors.white, @@ -272,14 +283,13 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { ), Divider( // indent: 0.0, - thickness:1, + thickness: 1, color: Color(0xffF2F2F2), ), - points(), + integralStore(), ], ), ), - // integralStore(), ], ), @@ -288,7 +298,6 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { ); } - Widget hotList() { return AspectRatio( aspectRatio: 2.47, @@ -358,8 +367,7 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { textBaseline: TextBaseline.alphabetic, children: [ Expanded( - child: - Row( + child: Row( children: [ Text( "创始人的故事-", @@ -407,32 +415,11 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { ); } - Widget points() { - return Container( - child: Column( - children: [ - Container( - height: 219.h, - child: Swiper( - key: UniqueKey(), - itemCount: articles != null ? articles.length : 0, - viewportFraction: 0.95, - scale: 1, - loop: false, - physics: BouncingScrollPhysics(), - itemBuilder: (context, position) { - return Container( - // margin: EdgeInsets.symmetric(vertical: 15.h, horizontal: 4.5.w), - child:integralStore(), - ); - }, - ), - ) - ], - - ), - ); - } + // Widget points() { + // return Container( + // child: integralStore(), + // ); + // } Widget integralStore() { return GridView.builder( @@ -448,13 +435,13 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { //垂直子Widget之间间距 mainAxisSpacing: 16, //子Widget宽高比例 - childAspectRatio: 0.67, + childAspectRatio: 0.88, ), itemBuilder: (contetx, index) { return GestureDetector( onTap: () { - // Navigator.of(context).pushNamed('/router/integral_store_page', - // arguments: {"goodsId": gooods[index].id}); + Navigator.of(context).pushNamed('/router/integral_store_page', + arguments: {"goodsId": gooods[index].id}); }, child: buildItem(gooods[index]), ); @@ -465,24 +452,11 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { Widget buildItem(Goods goods) { return Container( alignment: Alignment.center, - // decoration: BoxDecoration( - // borderRadius: BorderRadius.all( - // Radius.circular(4), - // ), - // boxShadow: [ - // BoxShadow( - // color: Colors.black.withAlpha(12), - // offset: Offset(0, 3), - // blurRadius: 14, - // spreadRadius: 0, - // ) - // ], - // color: Colors.white), child: Column( children: [ MImage( goods.mainImgPath, - aspectRatio: 5/3, + aspectRatio: 5 / 3, radius: BorderRadius.only( topLeft: Radius.circular(4), topRight: Radius.circular(4), @@ -502,19 +476,22 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.start, children: [ - SizedBox(height: 14,), + SizedBox( + height: 14, + ), Row( children: [ - Expanded(flex: 1,child:Text( - goods.name, - overflow: TextOverflow.ellipsis, - style: TextStyle( - color: Color(0xff353535), - fontWeight: FontWeight.bold, - fontSize: 14.sp, - ), - ) ) - , + Expanded( + flex: 1, + child: Text( + goods.name, + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: Color(0xff353535), + fontWeight: FontWeight.bold, + fontSize: 14.sp, + ), + )), BorderText( padding: EdgeInsets.all(2.h), text: S.of(context).haowu, @@ -535,8 +512,7 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { style: TextStyle( color: Color(0xFF727272), fontSize: 12.sp, - fontWeight: FontWeight.w500 - ), + fontWeight: FontWeight.w500), ), ], ), @@ -636,7 +612,7 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { ); }, itemCount: - (brandData != null && brandData.length > 0) ? brandData.length : 0, + (brandData != null && brandData.length > 0) ? brandData.length : 0, ), // child: AspectRatio( // aspectRatio: 4.16, diff --git a/lib/main.dart b/lib/main.dart index 225a2335..7662fd00 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -82,7 +82,7 @@ void main() async { initSdk(); - runApp(MyApp(locale)); + runApp(MyApp(locale, sharedPreferences.getBool("isFirst"))); } XgFlutterPlugin xgFlutterPlugin = XgFlutterPlugin(); @@ -107,8 +107,9 @@ EventBus eventBus = EventBus(sync: true); class MyApp extends StatelessWidget { final Locale appLocale; + final bool isFirst; - MyApp(this.appLocale); + MyApp(this.appLocale, this.isFirst); @override Widget build(BuildContext context) { @@ -142,7 +143,7 @@ class MyApp extends StatelessWidget { return appLocale ?? locales[0]; }, supportedLocales: S.delegate.supportedLocales, - home: GuidePage(), + home: (isFirst ?? true) ? GuidePage() : LoginPage(), // home: MainPage(), builder: (context, widget) { return MediaQuery( diff --git a/lib/union/store_details_page.dart b/lib/union/store_details_page.dart index a1299fa4..209a3829 100644 --- a/lib/union/store_details_page.dart +++ b/lib/union/store_details_page.dart @@ -211,7 +211,6 @@ class _StoreDetailsPage extends State { networkSourceMatcher(extension: "svg"): svgNetworkImageRender(), networkSourceMatcher(): networkImageRender(loadingWidget: () { - // return Image.asset("assets/image/default_1.png",); return Container(); }), }, @@ -222,4 +221,11 @@ class _StoreDetailsPage extends State { ), ); } + + @override + void dispose() { + super.dispose(); + + } + } diff --git a/lib/view_widget/login_tips.dart b/lib/view_widget/login_tips.dart index 8d39a840..7b90d4a5 100644 --- a/lib/view_widget/login_tips.dart +++ b/lib/view_widget/login_tips.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; @@ -20,7 +22,7 @@ class LoginTips extends StatelessWidget { child: Center( child: Container( width: 0.7867.sw, - height: 0.7867.sw / 0.86, + height: 0.7867.sw / (Platform.isAndroid ? 0.86 : 0.9), padding: EdgeInsets.symmetric(vertical: 20.h, horizontal: 24.w), decoration: BoxDecoration( color: Colors.white,