@@ -48,9 +48,7 @@ class CommonUtils {
4848 static String getDateStr (DateTime ? date) {
4949 if (date == null || date.toString () == "" ) {
5050 return "" ;
51- } else if (date
52- .toString ()
53- .length < 10 ) {
51+ } else if (date.toString ().length < 10 ) {
5452 return date.toString ();
5553 }
5654 return date.toString ().substring (0 , 10 );
@@ -66,33 +64,41 @@ class CommonUtils {
6664 ///日期格式转换
6765 static String getNewsTimeStr (DateTime date) {
6866 int subTimes =
69- DateTime
70- .now ()
71- .millisecondsSinceEpoch - date.millisecondsSinceEpoch;
67+ DateTime .now ().millisecondsSinceEpoch - date.millisecondsSinceEpoch;
7268
7369 if (subTimes < MILLIS_LIMIT ) {
7470 return (curLocale != null )
75- ? (curLocale! .languageCode != "zh" ) ? "right now" : "刚刚"
71+ ? (curLocale! .languageCode != "zh" )
72+ ? "right now"
73+ : "刚刚"
7674 : "刚刚" ;
7775 } else if (subTimes < SECONDS_LIMIT ) {
7876 return (subTimes / MILLIS_LIMIT ).round ().toString () +
7977 ((curLocale != null )
80- ? (curLocale! .languageCode != "zh" ) ? " seconds ago" : " 秒前"
78+ ? (curLocale! .languageCode != "zh" )
79+ ? " seconds ago"
80+ : " 秒前"
8181 : " 秒前" );
8282 } else if (subTimes < MINUTES_LIMIT ) {
8383 return (subTimes / SECONDS_LIMIT ).round ().toString () +
8484 ((curLocale != null )
85- ? (curLocale! .languageCode != "zh" ) ? " min ago" : " 分钟前"
85+ ? (curLocale! .languageCode != "zh" )
86+ ? " min ago"
87+ : " 分钟前"
8688 : " 分钟前" );
8789 } else if (subTimes < HOURS_LIMIT ) {
8890 return (subTimes / MINUTES_LIMIT ).round ().toString () +
8991 ((curLocale != null )
90- ? (curLocale! .languageCode != "zh" ) ? " hours ago" : " 小时前"
92+ ? (curLocale! .languageCode != "zh" )
93+ ? " hours ago"
94+ : " 小时前"
9195 : " 小时前" );
9296 } else if (subTimes < DAYS_LIMIT ) {
9397 return (subTimes / HOURS_LIMIT ).round ().toString () +
9498 ((curLocale != null )
95- ? (curLocale! .languageCode != "zh" ) ? " days ago" : " 天前"
99+ ? (curLocale! .languageCode != "zh" )
100+ ? " days ago"
101+ : " 天前"
96102 : " 天前" );
97103 } else {
98104 return getDateStr (date);
@@ -197,31 +203,33 @@ class CommonUtils {
197203 }
198204
199205 static getThemeData (Color color) {
200- return ThemeData (primarySwatch: color as MaterialColor ? ,
201- platform: TargetPlatform .android,
202- appBarTheme: AppBarTheme (systemOverlayStyle: SystemUiOverlayStyle .light),
203- // 如果需要去除对应的水波纹效果
204- // splashFactory: NoSplash.splashFactory,
205- // textButtonTheme: TextButtonThemeData(
206- // style: ButtonStyle(splashFactory: NoSplash.splashFactory),
207- // ),
208- // elevatedButtonTheme: ElevatedButtonThemeData(
209- // style: ButtonStyle(splashFactory: NoSplash.splashFactory),
210- // ),
206+ return ThemeData (
207+ primarySwatch: color as MaterialColor ? ,
208+ platform: TargetPlatform .android,
209+ appBarTheme: AppBarTheme (
210+ systemOverlayStyle: SystemUiOverlayStyle .light.copyWith (
211+ systemNavigationBarContrastEnforced: true ,
212+ systemStatusBarContrastEnforced: true ,
213+ systemNavigationBarColor: color,
214+ systemNavigationBarDividerColor: color.withAlpha (199 ),
215+ ),
216+ ),
217+ // 如果需要去除对应的水波纹效果
218+ // splashFactory: NoSplash.splashFactory,
219+ // textButtonTheme: TextButtonThemeData(
220+ // style: ButtonStyle(splashFactory: NoSplash.splashFactory),
221+ // ),
222+ // elevatedButtonTheme: ElevatedButtonThemeData(
223+ // style: ButtonStyle(splashFactory: NoSplash.splashFactory),
224+ // ),
211225 );
212226 }
213227
214228 static showLanguageDialog (BuildContext context) {
215229 StringList list = [
216- GSYLocalizations
217- .i18n (context)!
218- .home_language_default,
219- GSYLocalizations
220- .i18n (context)!
221- .home_language_zh,
222- GSYLocalizations
223- .i18n (context)!
224- .home_language_en,
230+ GSYLocalizations .i18n (context)! .home_language_default,
231+ GSYLocalizations .i18n (context)! .home_language_zh,
232+ GSYLocalizations .i18n (context)! .home_language_en,
225233 ];
226234 CommonUtils .showCommitOptionDialog (context, list, (index) {
227235 CommonUtils .changeLocale (StoreProvider .of <GSYState >(context), index);
@@ -286,9 +294,7 @@ class CommonUtils {
286294 static copy (String ? data, BuildContext context) {
287295 Clipboard .setData (new ClipboardData (text: data));
288296 Fluttertoast .showToast (
289- msg: GSYLocalizations
290- .i18n (context)!
291- .option_share_copy_success);
297+ msg: GSYLocalizations .i18n (context)! .option_share_copy_success);
292298 }
293299
294300 static launchUrl (context, String ? url) {
@@ -303,8 +309,7 @@ class CommonUtils {
303309 return ;
304310 }
305311
306- if (parseUrl.host == "github.com" &&
307- parseUrl.path.length > 0 ) {
312+ if (parseUrl.host == "github.com" && parseUrl.path.length > 0 ) {
308313 StringList pathnames = parseUrl.path.split ("/" );
309314 if (pathnames.length == 2 ) {
310315 //解析人
@@ -332,7 +337,7 @@ class CommonUtils {
332337 NavigatorUtils .goGSYWebView (
333338 context,
334339 new Uri .dataFromString (url,
335- mimeType: 'text/html' , encoding: Encoding .getByName ("utf-8" ))
340+ mimeType: 'text/html' , encoding: Encoding .getByName ("utf-8" ))
336341 .toString (),
337342 title);
338343 }
@@ -343,9 +348,7 @@ class CommonUtils {
343348 await launch (url);
344349 } else {
345350 Fluttertoast .showToast (
346- msg: GSYLocalizations
347- .i18n (context)!
348- .option_web_launcher_error +
351+ msg: GSYLocalizations .i18n (context)! .option_web_launcher_error +
349352 ": " +
350353 (url ?? "" ));
351354 }
@@ -377,9 +380,7 @@ class CommonUtils {
377380 new Container (height: 10.0 ),
378381 new Container (
379382 child: new Text (
380- GSYLocalizations
381- .i18n (context)!
382- .loading_text,
383+ GSYLocalizations .i18n (context)! .loading_text,
383384 style: GSYConstant .normalTextWhite)),
384385 ],
385386 ),
@@ -389,15 +390,16 @@ class CommonUtils {
389390 });
390391 }
391392
392- static Future <Null > showEditDialog (BuildContext context,
393- String dialogTitle,
394- ValueChanged <String >? onTitleChanged,
395- ValueChanged <String > onContentChanged,
396- VoidCallback onPressed, {
397- TextEditingController ? titleController,
398- TextEditingController ? valueController,
399- bool needTitle = true ,
400- }) {
393+ static Future <Null > showEditDialog (
394+ BuildContext context,
395+ String dialogTitle,
396+ ValueChanged <String >? onTitleChanged,
397+ ValueChanged <String > onContentChanged,
398+ VoidCallback onPressed, {
399+ TextEditingController ? titleController,
400+ TextEditingController ? valueController,
401+ bool needTitle = true ,
402+ }) {
401403 return NavigatorUtils .showGSYDialog (
402404 context: context,
403405 builder: (BuildContext context) {
@@ -416,13 +418,14 @@ class CommonUtils {
416418 }
417419
418420 ///列表item dialog
419- static Future <Null > showCommitOptionDialog (BuildContext context,
420- StringList ? commitMaps,
421- ValueChanged <int > onTap, {
422- width = 250.0 ,
423- height = 400.0 ,
424- List <Color >? colorList,
425- }) {
421+ static Future <Null > showCommitOptionDialog (
422+ BuildContext context,
423+ StringList ? commitMaps,
424+ ValueChanged <int > onTap, {
425+ width = 250.0 ,
426+ height = 400.0 ,
427+ List <Color >? colorList,
428+ }) {
426429 return NavigatorUtils .showGSYDialog (
427430 context: context,
428431 builder: (BuildContext context) {
@@ -446,9 +449,7 @@ class CommonUtils {
446449 fontSize: 14.0 ,
447450 color: colorList != null
448451 ? colorList[index]
449- : Theme
450- .of (context)
451- .primaryColor,
452+ : Theme .of (context).primaryColor,
452453 text: commitMaps[index],
453454 textColor: GSYColors .white,
454455 onPress: () {
@@ -463,32 +464,26 @@ class CommonUtils {
463464 }
464465
465466 ///版本更新
466- static Future <Null > showUpdateDialog (BuildContext context,
467- String contentMsg) {
467+ static Future <Null > showUpdateDialog (
468+ BuildContext context, String contentMsg) {
468469 return NavigatorUtils .showGSYDialog (
469470 context: context,
470471 builder: (BuildContext context) {
471472 return AlertDialog (
472- title: new Text (GSYLocalizations
473- .i18n (context)!
474- .app_version_title),
473+ title: new Text (GSYLocalizations .i18n (context)! .app_version_title),
475474 content: new Text (contentMsg),
476475 actions: < Widget > [
477476 new TextButton (
478477 onPressed: () {
479478 Navigator .pop (context);
480479 },
481- child: new Text (GSYLocalizations
482- .i18n (context)!
483- .app_cancel)),
480+ child: new Text (GSYLocalizations .i18n (context)! .app_cancel)),
484481 new TextButton (
485482 onPressed: () {
486483 launch (Address .updateUrl);
487484 Navigator .pop (context);
488485 },
489- child: new Text (GSYLocalizations
490- .i18n (context)!
491- .app_ok)),
486+ child: new Text (GSYLocalizations .i18n (context)! .app_ok)),
492487 ],
493488 );
494489 });
0 commit comments