Skip to content

Commit f9ccfb4

Browse files
authored
Merge pull request #44 from efoxTeam/dev
v1.0.1
2 parents c72e6e8 + 95433de commit f9ccfb4

File tree

20 files changed

+877
-74
lines changed

20 files changed

+877
-74
lines changed

android/app/build.gradle

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if (keystorePropertiesFile.exists()) {
3232
}
3333

3434
android {
35-
compileSdkVersion 27
35+
compileSdkVersion 28
3636

3737
lintOptions {
3838
disable 'InvalidPackage'
@@ -42,10 +42,10 @@ android {
4242
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
4343
applicationId "com.flutter.beer"
4444
minSdkVersion 16
45-
targetSdkVersion 27
45+
targetSdkVersion 28
4646
versionCode flutterVersionCode.toInteger()
4747
versionName flutterVersionName
48-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
48+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
4949
}
5050

5151
signingConfigs {
@@ -79,10 +79,14 @@ flutter {
7979

8080
dependencies {
8181
testImplementation 'junit:junit:4.12'
82-
androidTestImplementation 'com.android.support.test:runner:1.0.2'
83-
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
82+
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
83+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
8484
//firebase
85-
implementation 'com.google.firebase:firebase-core:16.0.7'
85+
implementation 'com.google.firebase:firebase-core:16.0.8'
86+
//Crashlytics SDK
87+
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9'
8688
}
8789
//firebase
88-
apply plugin: 'com.google.gms.google-services'
90+
apply plugin: 'com.google.gms.google-services'
91+
//Crashlytics SDK
92+
apply plugin: 'io.fabric'

android/build.gradle

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,29 @@ buildscript {
22
repositories {
33
google()
44
jcenter()
5+
//Crashlytics SDK
6+
maven {
7+
url 'https://maven.fabric.io/public'
8+
}
59
}
610

711
dependencies {
8-
classpath 'com.android.tools.build:gradle:3.2.1'
12+
classpath 'com.android.tools.build:gradle:3.3.2'
913
//firebase
1014
classpath 'com.google.gms:google-services:4.2.0'
15+
//Crashlytics SDK
16+
classpath 'io.fabric.tools:gradle:1.26.1'
1117
}
1218
}
1319

1420
allprojects {
1521
repositories {
1622
google()
1723
jcenter()
24+
//Crashlytics SDK
25+
maven {
26+
url 'https://maven.google.com/'
27+
}
1828
}
1929
}
2030

android/gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
org.gradle.jvmargs=-Xmx1536M
2+
android.useAndroidX=true
3+
android.enableJetifier=true
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## **PageView**
2+
> 创建一个整屏滚动的滚动列表,逐页滚动
3+
4+
5+
### 构造函数
6+
```
7+
PageView({
8+
Key key,
9+
Axis scrollDirection: Axis.horizontal,
10+
bool reverse: false,
11+
PageController controller,
12+
ScrollPhysics physics,
13+
bool pageSnapping: true,
14+
ValueChanged<int> onPageChanged,
15+
List<Widget> children: const [],
16+
DragStartBehavior dragStartBehavior: DragStartBehavior.down
17+
})
18+
```
19+
20+
### 属性介绍
21+
- children:页面列表,每个子元素对应一个当前页。
22+
- scrollDirection: Axis.horizontal/Axis.vertical, 默认是水平方向,可选择垂直方向滚动
23+
- reverse: 滚动方向取反操作
24+
- controller: 操作页面滚动行为类,可以通过PageController实例后的对象进行指定页面跳转,可携带特效跳转等。PageController.jumpToPage(index)
25+
- physics: 滚动属性,可参考滚动类别中的gridview等相近属性介绍
26+
- pageSnapping: 默认true,切换时,自动逐页跳转。当自定义滚动行为时,可设置为false,禁止页面捕获。
27+
- onPageChanged: 页面切换时,回调函数,返回页面下标值
Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,34 @@
1-
## **文档完善中**
1+
## **PopupMenuButton**
2+
3+
### 构造函数
4+
```
5+
PopupMenuButton<T>({
6+
Key key,
7+
@required PopupMenuItemBuilder<T> itemBuilder,
8+
T initialValue,
9+
PopupMenuItemSelected<T> onSelected,
10+
PopupMenuCanceled onCanceled,
11+
String tooltip,
12+
double elevation: 8.0,
13+
EdgeInsetsGeometry padding: const EdgeInsets.all(8.0),
14+
Widget child,
15+
Icon icon,
16+
Offset offset: Offset.zero
17+
})
18+
```
19+
20+
### 属性介绍
21+
- itemBuilder: (_) => { return [PopupMenuItem(), PopupMenuItem(),]}
22+
> PopupMenuItem: 菜单子组件
23+
```
24+
PopupMenuItem<T>({
25+
Key key,
26+
T value,
27+
bool enabled: true,
28+
double height: _kMenuItemHeight,
29+
@required Widget child
30+
})
31+
```
32+
- onSelected: 选中后返回PopupMenuItem中value的值
33+
- child: 有默认图标,可以修改为其它显示内容。
34+

lib/components/widgetComp.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ class IndexState extends State<Index> {
6464
this._bodyList.length = 0;
6565
String mdText = await this.getMdFile(this.mdUrl);
6666
if (mdText.length > 30 || !this.model.config.state.isPro) {
67-
this
68-
._bodyList
69-
.add(await MarkDownComp.Index(mdText));
67+
this._bodyList.add(await MarkDownComp.Index(mdText));
7068
// demo
7169
if (this.demoChild != null && this.demoChild.length > 0) {
7270
this.demoChild.forEach((Widget item) {
@@ -87,9 +85,9 @@ class IndexState extends State<Index> {
8785
this.model = model;
8886
return Scaffold(
8987
appBar: AppBar(
90-
title: Header.Index(
88+
/* title: Header.Index(
9189
this.title,
92-
),
90+
), */
9391
actions: this.getActions(
9492
context,
9593
),

lib/config/theme.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ class AppTheme {
66
static int thirdColor = 0xFFFAFAFA;
77
static int greyColor = 0x8A000000;
88
static int blackColor = 0xFF000000;
9+
static int lineColor = 0xFFEEEEEE;
910
static ThemeData themData = ThemeData(
1011
textTheme: TextTheme(
1112
body1: TextStyle(
1213
// color: Colors.black,
1314
// fontWeight: FontWeight.bold,
1415
),
1516
),
16-
platform: TargetPlatform.iOS,
17+
//platform: TargetPlatform.iOS,
1718
iconTheme: IconThemeData(
1819
size: 32,
1920
color: Color(thirdColor),
@@ -25,6 +26,6 @@ class AppTheme {
2526
),
2627
accentColor: Colors.grey, // 选中颜色
2728
primaryColor: Color(mainColor), // appbar背景
28-
scaffoldBackgroundColor: Color(thirdColor), // 整体的scaffold背景颜色
29+
scaffoldBackgroundColor: Color(secondColor), // 整体的scaffold背景颜色
2930
);
3031
}

lib/page/component/tabs.dart

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:efox_flutter/store/models/main_state_model.dart'
3+
show MainStateModel;
4+
import 'package:efox_flutter/config/theme.dart' show AppTheme;
5+
import 'package:efox_flutter/widget/index.dart' as WidgetRoot;
6+
import 'package:efox_flutter/router/index.dart' show FluroRouter;
7+
import 'package:efox_flutter/lang/index.dart' show AppLocalizations;
8+
import 'package:efox_flutter/components/headerComp.dart' as Header;
9+
10+
class Index extends StatefulWidget {
11+
final MainStateModel model;
12+
Index({Key key, this.model}) : super(key: key);
13+
@override
14+
_IndexState createState() => new _IndexState();
15+
}
16+
17+
class _IndexState extends State<Index>
18+
with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin {
19+
List _mapList = WidgetRoot.getAllWidgets();
20+
int _currentIndex = -1;
21+
TabController _tabController;
22+
23+
@override
24+
bool get wantKeepAlive => true;
25+
26+
@override
27+
initState() {
28+
super.initState();
29+
_tabController = new TabController(vsync: this, length: _mapList.length);
30+
_tabController.addListener(() {
31+
if (_currentIndex != _tabController.index) {
32+
_currentIndex = _tabController.index;
33+
}
34+
});
35+
}
36+
37+
@override
38+
void dispose() {
39+
_tabController.dispose();
40+
super.dispose();
41+
}
42+
43+
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
44+
45+
Widget build(BuildContext context) {
46+
return Scaffold(
47+
key: _scaffoldKey,
48+
/* appBar: AppBar(
49+
title: Header.Index(
50+
AppLocalizations.$t('nav_title_0'),
51+
),
52+
actions: appBarActions(),
53+
), */
54+
appBar: PreferredSize(
55+
preferredSize: Size.fromHeight(kToolbarHeight),
56+
child: Container(
57+
color: Color(AppTheme.mainColor),
58+
child: SafeArea(
59+
child: this._TabBar(),
60+
),
61+
),
62+
),
63+
body: Column(
64+
children: <Widget>[
65+
//this._TabBar(),
66+
this._TabView()
67+
],
68+
));
69+
}
70+
71+
Widget _TabBar() {
72+
return TabBar(
73+
indicatorColor: Color(AppTheme.secondColor),
74+
controller: _tabController,
75+
isScrollable: true,
76+
tabs: _mapList.map((v) {
77+
return new Tab(
78+
text: AppLocalizations.$t(v.typeName),
79+
/* icon: Icon(
80+
IconData(
81+
v.code,
82+
fontFamily: 'MaterialIcons',
83+
matchTextDirection: true,
84+
),
85+
), */
86+
);
87+
}).toList());
88+
}
89+
90+
Widget _TabView() {
91+
return Expanded(
92+
child: new TabBarView(
93+
controller: _tabController,
94+
children: List.generate(_mapList.length, (index) {
95+
return this.Grids(_mapList[index], index);
96+
})),
97+
);
98+
}
99+
100+
Widget Grids(widgetsItem, index) {
101+
String nameSpaces = widgetsItem.nameSpaces;
102+
List _tmpWidgetList = widgetsItem.widgetList;
103+
104+
return Container(
105+
child: GridView.count(
106+
childAspectRatio: 1.3,
107+
padding: EdgeInsets.fromLTRB(4, 0, 4, 0),
108+
shrinkWrap: true,
109+
physics: ScrollPhysics(),
110+
crossAxisCount: 3,
111+
children: List.generate(
112+
_tmpWidgetList.length,
113+
(index) {
114+
return Container(
115+
decoration: BoxDecoration(
116+
border:
117+
Border.all(color: Color(AppTheme.lineColor), width: 0.5)),
118+
child: FlatButton(
119+
color: Color(AppTheme.secondColor),
120+
splashColor: Color(AppTheme.mainColor),
121+
child: Column(
122+
crossAxisAlignment: CrossAxisAlignment.center,
123+
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
124+
children: [
125+
Icon(
126+
IconData(
127+
_tmpWidgetList[index].code,
128+
fontFamily: 'MaterialIcons',
129+
matchTextDirection: true,
130+
),
131+
color: Color(AppTheme.mainColor),
132+
size: 32,
133+
),
134+
Text(
135+
'${_tmpWidgetList[index].title}',
136+
//overflow: TextOverflow.ellipsis,
137+
style:
138+
TextStyle(fontSize: 14, fontWeight: FontWeight.w300),
139+
)
140+
],
141+
),
142+
onPressed: () {
143+
FluroRouter.router.navigateTo(
144+
context,
145+
nameSpaces + _tmpWidgetList[index].title,
146+
);
147+
},
148+
),
149+
);
150+
},
151+
),
152+
),
153+
);
154+
}
155+
156+
List<Widget> appBarActions() {
157+
return [
158+
PopupMenuButton(
159+
icon: Icon(
160+
Icons.more_vert,
161+
),
162+
onSelected: (local) {
163+
AppLocalizations.changeLanguage(Locale(local));
164+
print('local=$local');
165+
},
166+
itemBuilder: (context) => [
167+
PopupMenuItem(
168+
child: Row(
169+
children: <Widget>[
170+
Text('中文'),
171+
],
172+
),
173+
value: 'zh',
174+
),
175+
PopupMenuItem(
176+
child: Row(
177+
children: <Widget>[
178+
Text('english'),
179+
],
180+
),
181+
value: 'en',
182+
),
183+
],
184+
),
185+
];
186+
}
187+
}

0 commit comments

Comments
 (0)