-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from efoxTeam/dev
v1.0.1
- Loading branch information
Showing
20 changed files
with
877 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
org.gradle.jvmargs=-Xmx1536M | ||
android.useAndroidX=true | ||
android.enableJetifier=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
## **PageView** | ||
> 创建一个整屏滚动的滚动列表,逐页滚动 | ||
|
||
### 构造函数 | ||
``` | ||
PageView({ | ||
Key key, | ||
Axis scrollDirection: Axis.horizontal, | ||
bool reverse: false, | ||
PageController controller, | ||
ScrollPhysics physics, | ||
bool pageSnapping: true, | ||
ValueChanged<int> onPageChanged, | ||
List<Widget> children: const [], | ||
DragStartBehavior dragStartBehavior: DragStartBehavior.down | ||
}) | ||
``` | ||
|
||
### 属性介绍 | ||
- children:页面列表,每个子元素对应一个当前页。 | ||
- scrollDirection: Axis.horizontal/Axis.vertical, 默认是水平方向,可选择垂直方向滚动 | ||
- reverse: 滚动方向取反操作 | ||
- controller: 操作页面滚动行为类,可以通过PageController实例后的对象进行指定页面跳转,可携带特效跳转等。PageController.jumpToPage(index) | ||
- physics: 滚动属性,可参考滚动类别中的gridview等相近属性介绍 | ||
- pageSnapping: 默认true,切换时,自动逐页跳转。当自定义滚动行为时,可设置为false,禁止页面捕获。 | ||
- onPageChanged: 页面切换时,回调函数,返回页面下标值 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,34 @@ | ||
## **文档完善中** | ||
## **PopupMenuButton** | ||
|
||
### 构造函数 | ||
``` | ||
PopupMenuButton<T>({ | ||
Key key, | ||
@required PopupMenuItemBuilder<T> itemBuilder, | ||
T initialValue, | ||
PopupMenuItemSelected<T> onSelected, | ||
PopupMenuCanceled onCanceled, | ||
String tooltip, | ||
double elevation: 8.0, | ||
EdgeInsetsGeometry padding: const EdgeInsets.all(8.0), | ||
Widget child, | ||
Icon icon, | ||
Offset offset: Offset.zero | ||
}) | ||
``` | ||
|
||
### 属性介绍 | ||
- itemBuilder: (_) => { return [PopupMenuItem(), PopupMenuItem(),]} | ||
> PopupMenuItem: 菜单子组件 | ||
``` | ||
PopupMenuItem<T>({ | ||
Key key, | ||
T value, | ||
bool enabled: true, | ||
double height: _kMenuItemHeight, | ||
@required Widget child | ||
}) | ||
``` | ||
- onSelected: 选中后返回PopupMenuItem中value的值 | ||
- child: 有默认图标,可以修改为其它显示内容。 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:efox_flutter/store/models/main_state_model.dart' | ||
show MainStateModel; | ||
import 'package:efox_flutter/config/theme.dart' show AppTheme; | ||
import 'package:efox_flutter/widget/index.dart' as WidgetRoot; | ||
import 'package:efox_flutter/router/index.dart' show FluroRouter; | ||
import 'package:efox_flutter/lang/index.dart' show AppLocalizations; | ||
import 'package:efox_flutter/components/headerComp.dart' as Header; | ||
|
||
class Index extends StatefulWidget { | ||
final MainStateModel model; | ||
Index({Key key, this.model}) : super(key: key); | ||
@override | ||
_IndexState createState() => new _IndexState(); | ||
} | ||
|
||
class _IndexState extends State<Index> | ||
with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin { | ||
List _mapList = WidgetRoot.getAllWidgets(); | ||
int _currentIndex = -1; | ||
TabController _tabController; | ||
|
||
@override | ||
bool get wantKeepAlive => true; | ||
|
||
@override | ||
initState() { | ||
super.initState(); | ||
_tabController = new TabController(vsync: this, length: _mapList.length); | ||
_tabController.addListener(() { | ||
if (_currentIndex != _tabController.index) { | ||
_currentIndex = _tabController.index; | ||
} | ||
}); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
_tabController.dispose(); | ||
super.dispose(); | ||
} | ||
|
||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>(); | ||
|
||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
key: _scaffoldKey, | ||
/* appBar: AppBar( | ||
title: Header.Index( | ||
AppLocalizations.$t('nav_title_0'), | ||
), | ||
actions: appBarActions(), | ||
), */ | ||
appBar: PreferredSize( | ||
preferredSize: Size.fromHeight(kToolbarHeight), | ||
child: Container( | ||
color: Color(AppTheme.mainColor), | ||
child: SafeArea( | ||
child: this._TabBar(), | ||
), | ||
), | ||
), | ||
body: Column( | ||
children: <Widget>[ | ||
//this._TabBar(), | ||
this._TabView() | ||
], | ||
)); | ||
} | ||
|
||
Widget _TabBar() { | ||
return TabBar( | ||
indicatorColor: Color(AppTheme.secondColor), | ||
controller: _tabController, | ||
isScrollable: true, | ||
tabs: _mapList.map((v) { | ||
return new Tab( | ||
text: AppLocalizations.$t(v.typeName), | ||
/* icon: Icon( | ||
IconData( | ||
v.code, | ||
fontFamily: 'MaterialIcons', | ||
matchTextDirection: true, | ||
), | ||
), */ | ||
); | ||
}).toList()); | ||
} | ||
|
||
Widget _TabView() { | ||
return Expanded( | ||
child: new TabBarView( | ||
controller: _tabController, | ||
children: List.generate(_mapList.length, (index) { | ||
return this.Grids(_mapList[index], index); | ||
})), | ||
); | ||
} | ||
|
||
Widget Grids(widgetsItem, index) { | ||
String nameSpaces = widgetsItem.nameSpaces; | ||
List _tmpWidgetList = widgetsItem.widgetList; | ||
|
||
return Container( | ||
child: GridView.count( | ||
childAspectRatio: 1.3, | ||
padding: EdgeInsets.fromLTRB(4, 0, 4, 0), | ||
shrinkWrap: true, | ||
physics: ScrollPhysics(), | ||
crossAxisCount: 3, | ||
children: List.generate( | ||
_tmpWidgetList.length, | ||
(index) { | ||
return Container( | ||
decoration: BoxDecoration( | ||
border: | ||
Border.all(color: Color(AppTheme.lineColor), width: 0.5)), | ||
child: FlatButton( | ||
color: Color(AppTheme.secondColor), | ||
splashColor: Color(AppTheme.mainColor), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.center, | ||
mainAxisAlignment: MainAxisAlignment.spaceEvenly, | ||
children: [ | ||
Icon( | ||
IconData( | ||
_tmpWidgetList[index].code, | ||
fontFamily: 'MaterialIcons', | ||
matchTextDirection: true, | ||
), | ||
color: Color(AppTheme.mainColor), | ||
size: 32, | ||
), | ||
Text( | ||
'${_tmpWidgetList[index].title}', | ||
//overflow: TextOverflow.ellipsis, | ||
style: | ||
TextStyle(fontSize: 14, fontWeight: FontWeight.w300), | ||
) | ||
], | ||
), | ||
onPressed: () { | ||
FluroRouter.router.navigateTo( | ||
context, | ||
nameSpaces + _tmpWidgetList[index].title, | ||
); | ||
}, | ||
), | ||
); | ||
}, | ||
), | ||
), | ||
); | ||
} | ||
|
||
List<Widget> appBarActions() { | ||
return [ | ||
PopupMenuButton( | ||
icon: Icon( | ||
Icons.more_vert, | ||
), | ||
onSelected: (local) { | ||
AppLocalizations.changeLanguage(Locale(local)); | ||
print('local=$local'); | ||
}, | ||
itemBuilder: (context) => [ | ||
PopupMenuItem( | ||
child: Row( | ||
children: <Widget>[ | ||
Text('中文'), | ||
], | ||
), | ||
value: 'zh', | ||
), | ||
PopupMenuItem( | ||
child: Row( | ||
children: <Widget>[ | ||
Text('english'), | ||
], | ||
), | ||
value: 'en', | ||
), | ||
], | ||
), | ||
]; | ||
} | ||
} |
Oops, something went wrong.