Browse Source

修改

null_safety
哈哈哈 4 years ago
parent
commit
9f24573d67
  1. 16
      lib/home/guide_page.dart
  2. 106
      lib/home/home_page.dart
  3. 7
      lib/main.dart
  4. 8
      lib/union/store_details_page.dart
  5. 4
      lib/view_widget/login_tips.dart

16
lib/home/guide_page.dart

@ -1,6 +1,7 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:huixiang/view_widget/border_text.dart'; import 'package:huixiang/view_widget/border_text.dart';
import 'package:shared_preferences/shared_preferences.dart';
class GuidePage extends StatefulWidget { class GuidePage extends StatefulWidget {
@override @override
@ -328,7 +329,7 @@ class _GuidePage extends State<GuidePage> {
), ),
GestureDetector( GestureDetector(
onTap: (){ onTap: (){
Navigator.of(context).popAndPushNamed('/router/login_page'); toNext();
}, },
child:Container( child:Container(
margin: EdgeInsets.only(left: 71,right: 71), margin: EdgeInsets.only(left: 71,right: 71),
@ -353,4 +354,17 @@ class _GuidePage extends State<GuidePage> {
), ),
); );
} }
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');
}
});
}
} }

106
lib/home/home_page.dart

@ -26,7 +26,9 @@ import 'package:shared_preferences/shared_preferences.dart';
class HomePage extends StatefulWidget { class HomePage extends StatefulWidget {
final GestureTapCallback callback; final GestureTapCallback callback;
HomePage(this.callback); HomePage(this.callback);
@override @override
State<StatefulWidget> createState() { State<StatefulWidget> createState() {
return _HomePage(callback); return _HomePage(callback);
@ -36,6 +38,7 @@ class HomePage extends StatefulWidget {
class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin { class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
ApiService apiService; ApiService apiService;
final GestureTapCallback callback; final GestureTapCallback callback;
_HomePage(this.callback); _HomePage(this.callback);
@override @override
@ -219,8 +222,8 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
), ),
brands(), brands(),
Container( Container(
margin: EdgeInsets.only(left:16.5,right: 16.5,bottom: 40), margin: EdgeInsets.only(left: 16.5.w, right: 16.5.w, bottom: 40.h),
padding: EdgeInsets.only(bottom: 10), padding: EdgeInsets.only(bottom: 10.h),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.all( borderRadius: BorderRadius.all(
Radius.circular(4), Radius.circular(4),
@ -233,32 +236,40 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
spreadRadius: 0, spreadRadius: 0,
) )
], ],
color: Colors.white), color: Colors.white,
),
child: Column( child: Column(
children: [ children: [
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Expanded(flex: 1,child:ItemTitle( Expanded(
flex: 1,
child: ItemTitle(
text: S.of(context).jifenshangcheng, text: S.of(context).jifenshangcheng,
imgPath: "assets/image/icon_points_mall.png", imgPath: "assets/image/icon_points_mall.png",
)), )),
GestureDetector( GestureDetector(
onTap: callback, onTap: callback,
child: Container( child: Container(
padding: EdgeInsets.only(left:8,right: 8,top:3,bottom: 3), padding: EdgeInsets.only(
margin:EdgeInsets.only(right: 16), left: 8.w, right: 8.w, top: 3.h, bottom: 3.h),
margin: EdgeInsets.only(right: 16.w),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.all( borderRadius: BorderRadius.circular(11.5),
Radius.circular(11.5), color: Color(0xFF32A060),
), ),
color: Color(0xFF32A060)),
child: Row( child: Row(
children: [ children: [
Text("GO",style: TextStyle( Text(
fontSize: 14,fontWeight: FontWeight.bold,color: Colors.white "GO",
),), style: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
Icon( Icon(
Icons.chevron_right, Icons.chevron_right,
color: Colors.white, color: Colors.white,
@ -275,11 +286,10 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
thickness: 1, thickness: 1,
color: Color(0xffF2F2F2), color: Color(0xffF2F2F2),
), ),
points(), integralStore(),
], ],
), ),
), ),
// integralStore(), // integralStore(),
], ],
), ),
@ -288,7 +298,6 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
); );
} }
Widget hotList() { Widget hotList() {
return AspectRatio( return AspectRatio(
aspectRatio: 2.47, aspectRatio: 2.47,
@ -358,8 +367,7 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
textBaseline: TextBaseline.alphabetic, textBaseline: TextBaseline.alphabetic,
children: [ children: [
Expanded( Expanded(
child: child: Row(
Row(
children: [ children: [
Text( Text(
"创始人的故事-", "创始人的故事-",
@ -407,32 +415,11 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
); );
} }
Widget points() { // Widget points() {
return Container( // return Container(
child: Column( // child: integralStore(),
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 integralStore() { Widget integralStore() {
return GridView.builder( return GridView.builder(
@ -448,13 +435,13 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
//Widget之间间距 //Widget之间间距
mainAxisSpacing: 16, mainAxisSpacing: 16,
//Widget宽高比例 //Widget宽高比例
childAspectRatio: 0.67, childAspectRatio: 0.88,
), ),
itemBuilder: (contetx, index) { itemBuilder: (contetx, index) {
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
// Navigator.of(context).pushNamed('/router/integral_store_page', Navigator.of(context).pushNamed('/router/integral_store_page',
// arguments: {"goodsId": gooods[index].id}); arguments: {"goodsId": gooods[index].id});
}, },
child: buildItem(gooods[index]), child: buildItem(gooods[index]),
); );
@ -465,19 +452,6 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
Widget buildItem(Goods goods) { Widget buildItem(Goods goods) {
return Container( return Container(
alignment: Alignment.center, 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( child: Column(
children: [ children: [
MImage( MImage(
@ -502,10 +476,14 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
SizedBox(height: 14,), SizedBox(
height: 14,
),
Row( Row(
children: [ children: [
Expanded(flex: 1,child:Text( Expanded(
flex: 1,
child: Text(
goods.name, goods.name,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
@ -513,8 +491,7 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 14.sp, fontSize: 14.sp,
), ),
) ) )),
,
BorderText( BorderText(
padding: EdgeInsets.all(2.h), padding: EdgeInsets.all(2.h),
text: S.of(context).haowu, text: S.of(context).haowu,
@ -535,8 +512,7 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
style: TextStyle( style: TextStyle(
color: Color(0xFF727272), color: Color(0xFF727272),
fontSize: 12.sp, fontSize: 12.sp,
fontWeight: FontWeight.w500 fontWeight: FontWeight.w500),
),
), ),
], ],
), ),

7
lib/main.dart

@ -82,7 +82,7 @@ void main() async {
initSdk(); initSdk();
runApp(MyApp(locale)); runApp(MyApp(locale, sharedPreferences.getBool("isFirst")));
} }
XgFlutterPlugin xgFlutterPlugin = XgFlutterPlugin(); XgFlutterPlugin xgFlutterPlugin = XgFlutterPlugin();
@ -107,8 +107,9 @@ EventBus eventBus = EventBus(sync: true);
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
final Locale appLocale; final Locale appLocale;
final bool isFirst;
MyApp(this.appLocale); MyApp(this.appLocale, this.isFirst);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -142,7 +143,7 @@ class MyApp extends StatelessWidget {
return appLocale ?? locales[0]; return appLocale ?? locales[0];
}, },
supportedLocales: S.delegate.supportedLocales, supportedLocales: S.delegate.supportedLocales,
home: GuidePage(), home: (isFirst ?? true) ? GuidePage() : LoginPage(),
// home: MainPage(), // home: MainPage(),
builder: (context, widget) { builder: (context, widget) {
return MediaQuery( return MediaQuery(

8
lib/union/store_details_page.dart

@ -211,7 +211,6 @@ class _StoreDetailsPage extends State<StoreDetailsPage> {
networkSourceMatcher(extension: "svg"): networkSourceMatcher(extension: "svg"):
svgNetworkImageRender(), svgNetworkImageRender(),
networkSourceMatcher(): networkImageRender(loadingWidget: () { networkSourceMatcher(): networkImageRender(loadingWidget: () {
// return Image.asset("assets/image/default_1.png",);
return Container(); return Container();
}), }),
}, },
@ -222,4 +221,11 @@ class _StoreDetailsPage extends State<StoreDetailsPage> {
), ),
); );
} }
@override
void dispose() {
super.dispose();
}
} }

4
lib/view_widget/login_tips.dart

@ -1,3 +1,5 @@
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
@ -20,7 +22,7 @@ class LoginTips extends StatelessWidget {
child: Center( child: Center(
child: Container( child: Container(
width: 0.7867.sw, 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), padding: EdgeInsets.symmetric(vertical: 20.h, horizontal: 24.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,

Loading…
Cancel
Save