X Tutup
Skip to content

Commit 5ee7d5f

Browse files
committed
about dialog
1 parent 32d121b commit 5ee7d5f

File tree

6 files changed

+77
-16
lines changed

6 files changed

+77
-16
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@
8686
### 进行中:
8787

8888
* IOS未测试
89-
* 主页drawer:关于、个人信息
90-
* 仓库的: 动态的背景头像|版本|tag| 浏览器打开|下载、复制克隆间接|分享
89+
* 主页drawer:个人信息
90+
* 仓库的:|版本|tag|下载、克隆
9191
* 本地数据库
9292
* issue数据统计
9393

lib/common/style/GSYStyle.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ class GSYStrings {
186186
static const String app_ok = "确定";
187187
static const String app_cancel = "取消";
188188
static const String app_empty = "目前什么也没有哟";
189+
static const String app_licenses = "协议";
190+
static const String app_close = "关闭";
191+
static const String app_version = "版本";
189192

190193
static const String nothing_now = "目前什么都没有。";
191194
static const String loading_text = "加载中···";

lib/main.dart

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import 'dart:async';
2+
3+
import 'package:flutter/foundation.dart';
14
import 'package:flutter/material.dart';
25
import 'package:gsy_github_app_flutter/common/redux/GSYState.dart';
36
import 'package:gsy_github_app_flutter/common/model/User.dart';
47
import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart';
58
import 'package:gsy_github_app_flutter/page/HomePage.dart';
69
import 'package:gsy_github_app_flutter/page/LoginPage.dart';
7-
import 'package:gsy_github_app_flutter/page/PersonPage.dart';
810
import 'package:gsy_github_app_flutter/page/WelcomePage.dart';
911
import 'package:flutter_redux/flutter_redux.dart';
1012
import 'package:redux/redux.dart';
@@ -14,8 +16,7 @@ void main() {
1416
}
1517

1618
class FlutterReduxApp extends StatelessWidget {
17-
final store = new Store<GSYState>(appReducer,
18-
initialState: new GSYState(userInfo: User.empty(), eventList: new List()));
19+
final store = new Store<GSYState>(appReducer, initialState: new GSYState(userInfo: User.empty(), eventList: new List()));
1920

2021
FlutterReduxApp({Key key}) : super(key: key);
2122

@@ -24,6 +25,13 @@ class FlutterReduxApp extends StatelessWidget {
2425
return new StoreProvider(
2526
store: store,
2627
child: new MaterialApp(
28+
localizationsDelegates: [
29+
_MaterialLocalizationsDelegate(),
30+
],
31+
supportedLocales: [
32+
const Locale('zh', 'US'), // English
33+
// ... other locales the app supports
34+
],
2735
theme: new ThemeData(
2836
primarySwatch: GSYColors.primarySwatch,
2937
),
@@ -41,3 +49,27 @@ class FlutterReduxApp extends StatelessWidget {
4149
);
4250
}
4351
}
52+
53+
class GSYMaterialLocalizations extends DefaultMaterialLocalizations {
54+
const GSYMaterialLocalizations();
55+
56+
@override
57+
String get viewLicensesButtonLabel => GSYStrings.app_licenses;
58+
59+
String get closeButtonLabel => GSYStrings.app_close;
60+
}
61+
62+
class _MaterialLocalizationsDelegate extends LocalizationsDelegate<MaterialLocalizations> {
63+
const _MaterialLocalizationsDelegate();
64+
65+
@override
66+
bool isSupported(Locale locale) => locale.languageCode == 'zh';
67+
68+
@override
69+
Future<MaterialLocalizations> load(Locale locale) {
70+
return new SynchronousFuture<MaterialLocalizations>(const GSYMaterialLocalizations());
71+
}
72+
73+
@override
74+
bool shouldReload(_MaterialLocalizationsDelegate old) => false;
75+
}

lib/widget/HomeDrawer.dart

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import 'dart:io';
2+
3+
import 'package:get_version/get_version.dart';
14
import 'package:flutter/material.dart';
25
import 'package:flutter_redux/flutter_redux.dart';
36
import 'package:gsy_github_app_flutter/common/dao/EventDao.dart';
@@ -16,6 +19,20 @@ import 'package:gsy_github_app_flutter/widget/GSYFlexButton.dart';
1619
* Date: 2018-07-18
1720
*/
1821
class HomeDrawer extends StatelessWidget {
22+
showAboutDialog(BuildContext context, String versionName) {
23+
if(versionName == null) {
24+
versionName = "Null";
25+
}
26+
showDialog(
27+
context: context,
28+
builder: (BuildContext context) => AboutDialog(
29+
applicationName: GSYStrings.app_name,
30+
applicationVersion: GSYStrings.app_version + ": " + versionName,
31+
applicationIcon: new Image(image: new AssetImage('static/images/logo.png'), width: 50.0, height: 50.0),
32+
applicationLegalese: "http://github.com/CarGuo",
33+
));
34+
}
35+
1936
@override
2037
Widget build(BuildContext context) {
2138
return new StoreBuilder<GSYState>(
@@ -76,14 +93,9 @@ class HomeDrawer extends StatelessWidget {
7693
style: GSYConstant.normalText,
7794
),
7895
onTap: () {
79-
showDialog(
80-
context: context,
81-
builder: (BuildContext context) => AboutDialog(
82-
applicationName: GSYStrings.app_name,
83-
applicationVersion: "1.0.0",
84-
applicationIcon: new Image(image: new AssetImage('static/images/logo.png'), width: 50.0, height: 50.0),
85-
applicationLegalese: null,
86-
));
96+
GetVersion.projectVersion.then((value){
97+
showAboutDialog(context, value);
98+
});
8799
}),
88100
new ListTile(
89101
title: new GSYFlexButton(
@@ -96,8 +108,7 @@ class HomeDrawer extends StatelessWidget {
96108
NavigatorUtils.goLogin(context);
97109
},
98110
),
99-
onTap: () {
100-
}),
111+
onTap: () {}),
101112
],
102113
),
103114
);

pubspec.lock

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ packages:
147147
name: dart_style
148148
url: "https://pub.flutter-io.cn"
149149
source: hosted
150-
version: "1.0.14"
150+
version: "1.1.3"
151151
device_info:
152152
dependency: "direct main"
153153
description:
@@ -214,6 +214,13 @@ packages:
214214
url: "https://pub.flutter-io.cn"
215215
source: hosted
216216
version: "0.1.0-alpha.12"
217+
get_version:
218+
dependency: "direct main"
219+
description:
220+
name: get_version
221+
url: "https://pub.flutter-io.cn"
222+
source: hosted
223+
version: "0.0.5"
217224
glob:
218225
dependency: transitive
219226
description:
@@ -354,6 +361,13 @@ packages:
354361
url: "https://pub.flutter-io.cn"
355362
source: hosted
356363
version: "1.0.3"
364+
package_info:
365+
dependency: transitive
366+
description:
367+
name: package_info
368+
url: "https://pub.flutter-io.cn"
369+
source: hosted
370+
version: "0.3.2"
357371
package_resolver:
358372
dependency: transitive
359373
description:

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ dependencies:
1919
url_launcher: ^3.0.3
2020
share: ^0.5.2
2121
flutter_spinkit: ^2.0.0
22+
get_version: ^0.0.5
2223

2324
dev_dependencies:
2425
build_runner: ^0.7.6

0 commit comments

Comments
 (0)
X Tutup