forked from CarGuo/gsy_github_app_flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomePage.dart
More file actions
83 lines (78 loc) · 2.83 KB
/
HomePage.dart
File metadata and controls
83 lines (78 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:gsy_github_app_flutter/common/localization/DefaultLocalizations.dart';
import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart';
import 'package:gsy_github_app_flutter/common/utils/CommonUtils.dart';
import 'package:gsy_github_app_flutter/common/utils/NavigatorUtils.dart';
import 'package:gsy_github_app_flutter/page/DynamicPage.dart';
import 'package:gsy_github_app_flutter/page/MyPage.dart';
import 'package:gsy_github_app_flutter/page/TrendPage.dart';
import 'package:gsy_github_app_flutter/widget/GSYTabBarWidget.dart';
import 'package:gsy_github_app_flutter/widget/GSYTitleBar.dart';
import 'package:gsy_github_app_flutter/widget/HomeDrawer.dart';
/**
* 主页
* Created by guoshuyu
* Date: 2018-07-16
*/
class HomePage extends StatelessWidget {
static final String sName = "home";
/// 单击提示退出
Future<bool> _dialogExitApp(BuildContext context) {
return showDialog(
context: context,
builder: (context) => new AlertDialog(
content: new Text(CommonUtils.getLocale(context).app_back_tip),
actions: <Widget>[
new FlatButton(onPressed: () => Navigator.of(context).pop(false), child: new Text(CommonUtils.getLocale(context).app_cancel)),
new FlatButton(
onPressed: () {
Navigator.of(context).pop(true);
},
child: new Text(CommonUtils.getLocale(context).app_ok))
],
));
}
_renderTab(icon, text) {
return new Tab(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[new Icon(icon, size: 16.0), new Text(text)],
),
);
}
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
List<Widget> tabs = [
_renderTab(GSYICons.MAIN_DT, CommonUtils.getLocale(context).home_dynamic),
_renderTab(GSYICons.MAIN_QS, CommonUtils.getLocale(context).home_trend),
_renderTab(GSYICons.MAIN_MY, CommonUtils.getLocale(context).home_my),
];
return WillPopScope(
onWillPop: () {
return _dialogExitApp(context);
},
child: new GSYTabBarWidget(
drawer: new HomeDrawer(),
type: GSYTabBarWidget.BOTTOM_TAB,
tabItems: tabs,
tabViews: [
new DynamicPage(),
new TrendPage(),
new MyPage(),
],
backgroundColor: GSYColors.primarySwatch,
indicatorColor: Color(GSYColors.white),
title: GSYTitleBar(
GSYLocalizations.of(context).currentLocalized.app_name,
iconData: GSYICons.MAIN_SEARCH,
needRightLocalIcon: true,
onPressed: () {
NavigatorUtils.goSearchPage(context);
},
),
),
);
}
}