From 97b2d53b627ff9ca41314a7a852bf39ed5d18b8f Mon Sep 17 00:00:00 2001 From: guoshuyu <359369982@qq.com> Date: Wed, 16 Jan 2019 13:45:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=B1=E4=BA=8E=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E4=B8=BB=E9=A2=98=E5=AF=BC=E8=87=B4=E7=9A=84=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=A1=86=E9=95=BF=E6=8C=89=E5=BC=B9=E5=87=BA=E9=BB=8F?= =?UTF-8?q?=E8=B4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/common/utils/CommonUtils.dart | 7 ++++++- lib/main.dart | 8 ++------ lib/page/LoginPage.dart | 1 + 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/common/utils/CommonUtils.dart b/lib/common/utils/CommonUtils.dart index a8405e26..5f0e5c1a 100644 --- a/lib/common/utils/CommonUtils.dart +++ b/lib/common/utils/CommonUtils.dart @@ -137,10 +137,15 @@ class CommonUtils { static pushTheme(Store store, int index) { ThemeData themeData; List colors = getThemeListColor(); - themeData = new ThemeData(primarySwatch: colors[index], platform: TargetPlatform.iOS); + themeData = getThemeData(colors[index]); store.dispatch(new RefreshThemeDataAction(themeData)); } + + static getThemeData(Color color) { + return ThemeData(primarySwatch: color, platform: TargetPlatform.android); + } + /** * 切换语言 */ diff --git a/lib/main.dart b/lib/main.dart index 0b9a80b6..eefc268c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,9 +1,7 @@ import 'dart:async'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:event_bus/event_bus.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:gsy_github_app_flutter/common/event/HttpErrorEvent.dart'; @@ -34,10 +32,7 @@ class FlutterReduxApp extends StatelessWidget { userInfo: User.empty(), eventList: new List(), trendList: new List(), - themeData: new ThemeData( - primarySwatch: GSYColors.primarySwatch, - platform: TargetPlatform.android,//fix #192 - ), + themeData: CommonUtils.getThemeData(GSYColors.primarySwatch), locale: Locale('zh', 'CH')), ); @@ -99,6 +94,7 @@ class _GSYLocalizations extends State { @override Widget build(BuildContext context) { + return new StoreBuilder(builder: (context, store) { ///通过 StoreBuilder 和 Localizations 实现实时多语言切换 return new Localizations.override( diff --git a/lib/page/LoginPage.dart b/lib/page/LoginPage.dart index 60046924..60181bff 100644 --- a/lib/page/LoginPage.dart +++ b/lib/page/LoginPage.dart @@ -61,6 +61,7 @@ class _LoginPageState extends State { body: new Container( color: Theme.of(context).primaryColor, child: new Center( + //防止overFlow的现象 child: SafeArea( child: SingleChildScrollView( child: new Card(