Skip to content
Merged

Test #13

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docs/widget/regular/aspectratio/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## **AspectRatio**

>
将子控件调整为特定宽高比的控件
* AspectRatio 首先会尝试布局约束的最大宽度,widget的高度是通过给定的宽度和宽高比率来决定的
* 对于需要缩放调整位置的,一般是对图片的处理

### 构造方法
``` dart
AspectRatio({
Key key,
@required this.aspectRatio,
Widget child
})
```

### 属性介绍
* aspectRatio: 宽高比,如1.5,宽度是高度的1.5倍
* child: AspectRatio中的内容widget
20 changes: 20 additions & 0 deletions docs/widget/regular/constrainedbox/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## **ConstrainedBox**

>
一个基础布局控件,添加额外的限制条件(constraints)到child上

### 构造方法
``` dart
ConstrainedBox({
Key key,
@required this.constraints,
Widget child
})
```

### 属性介绍
* constraints: 添加到child上的额外限制条件,其类型为BoxConstraints,限制各种最大最小宽高
* child: ConstrainedBox中的内容Widget

### 其他用法
* constraints值为BoxConstraints.expand时,提供width或者height,那么限制(Constraints)将严格使用给出的width或者height值
23 changes: 23 additions & 0 deletions docs/widget/regular/flow/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## **Flow**

>
实现优化流式布局以使用流布局的控件
* 实现较为复杂,一般可通过Wrap来替换实现

### 构造方法
``` dart
Flow({
Key key,
@required this.delegate,
List<Widget> children = const <Widget>[],
})
```

### 属性介绍
* delegeate: 影响布局的FlowDelegate,包含方法如下:
* paintChildren: child的绘制控制代码,可以调整尺寸位置
* shouldPepaint:是否需要重绘
* shouldRelayout:是否需要重新布局
* getConstraintsForChild:设置每个child的约束条件,会覆盖已有
* getSize: 设置Flow的尺寸
* children: Flow中的内容widget
31 changes: 31 additions & 0 deletions docs/widget/regular/stack/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## **Stack**

>
该Widget将子控件相对于其边框进行定位
* Stack的布局行为,根据child是positioned节点还是non-positioned节点来区分
* 对于positioned的子节点,它们的位置会根据所设置的top、bottom、right以及left属性来确定,这几个值都是相对于Stack的左上角;
* 对于non-positioned的子节点,它们会根据Stack的aligment来设置位置。
* 对应child的顺序,第一个child会被绘制在最低端

### 构造方法
``` dart
Stack({
Key key,
this.alignment = AlignmentDirectional.topStart,
this.textDirection,
this.fit = StackFit.loose,
this.overflow = Overflow.clip,
List<Widget> children = const <Widget>[],
})
```

### 属性介绍
* alignment: 对齐方式,默认是topLeft
* textDirection:文本方向,不常用
* fit: 默认loose
* loose:子节点尺寸可以从min到max
* expand:子节点尽可能占用空间
* passthrough: 不改变子节点约束
* overflow:超过部分是否裁切,Overflow.clip/visible
* children: Stack中的内容Widget

35 changes: 35 additions & 0 deletions docs/widget/regular/table/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## **Table**

>
该控件为其子控件进行table布局的Widget

### 构造方法
``` dart
Table({
Key key,
this.children = const <TableRow>[],
this.columnWidths,
this.defaultColumnWidth = const FlexColumnWidth(1.0),
this.textDirection,
this.border,
this.defaultVerticalAlignment = TableCellVerticalAlignment.top,
this.textBaseline,
})
```

### 属性介绍
>
该Widget适用于多行多列,若只有一行或者一列,选择Row或Column会更合适一些

* columnWidths:设置每一列的宽度
* defaultColumnWidth:默认的每一列宽度值,默认情况下均分,通过FixedColumnWidth设置
* textDirection:文字显示方向
* border:表格边框
* defaultVerticalAlignment:每一个cell的垂直方向的对齐方式, 包含5种:
* top:放置在的顶部;
* middle:垂直居中;
* bottom:放置在底部;
* baseline:文本baseline对齐;
* fill:充满整个cell。
* textBaseline:defaultVerticalAlignment为baseline的时候,会用到这个属性。
* children: Table的中的内容widget
32 changes: 32 additions & 0 deletions docs/widget/regular/wrap/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## **Wrap**

>
该控件以多个水平或垂直方向显示其子控件
* 单行的Wrap和Row表现几乎一致,单列的Wrap和Column表现几乎一致,但是Row同Column系单行单列的,Wrap中行或列空间不足时,会自动换行

### 构造方法
``` dart
Wrap({
Key key,
this.direction = Axis.horizontal,
this.alignment = WrapAlignment.start,
this.spacing = 0.0,
this.runAlignment = WrapAlignment.start,
this.runSpacing = 0.0,
this.crossAxisAlignment = WrapCrossAlignment.start,
this.textDirection,
this.verticalDirection = VerticalDirection.down,
List<Widget> children = const <Widget>[],
})
```

### 属性介绍
* direction:主轴的方向,默认为水平,值:Axis.horizontal/vertical
* alignment:主轴方向上的对齐方式,默认为start, 值: WrapAlignment.start/center/end/spaceAround/spaceBetween/spaceEvenly
* spacing:主轴方向上的间距。
* runAlignment:run的对齐方式, 值: WrapAlignment.start/center/end/spaceAround/spaceBetween/spaceEvenly
* runSpacing:run的间距。
* crossAxisAlignment:交叉轴(crossAxis)方向上的对齐方式,值: WrapCrossAlignment.start/center/end
* textDirection:文本方向, 值:TextDirection.ltr/rtl
* verticalDirection:定义了children摆放顺序,默认是down,值: VerticalDirection.down/up
* children: Table的中的内容widget
9 changes: 9 additions & 0 deletions git.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# git使用规范
## 提交规范
+ feat:新功能(feature)
+ fix:修补bug
+ docs:文档(documentation)
+ style: 格式(不影响代码运行的变动)
+ refactor:重构(即不是新增功能,也不是修改bug的代码变动)
+ test:增加测试
+ chore:构建过程或辅助工具的变动
13 changes: 6 additions & 7 deletions lib/components/exampleComp.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import 'package:flutter/material.dart';
import 'package:efox_flutter/store/models/main_state_model.dart' show MainStateModel;
import 'package:efox_flutter/store/models/main_state_model.dart'
show MainStateModel;
import 'package:efox_flutter/store/store.dart' show Store;
import 'package:efox_flutter/config/theme.dart' show AppTheme;

class Index extends StatelessWidget {
final Widget child;

Index({Key key, this.child}):super(key: key);
Index({Key key, this.child}) : super(key: key);

@override
Widget build(BuildContext context) {
Expand All @@ -15,14 +17,11 @@ class Index extends StatelessWidget {
height: 420.0,
margin: EdgeInsets.fromLTRB(50, 40, 50, 40),
decoration: BoxDecoration(
border: Border.all(
color: Color(model.theme.mainColor),
width: 1.0
),
border: Border.all(color: Color(AppTheme.mainColor), width: 1.0),
),
child: this.child,
);
},
);
}
}
}
8 changes: 4 additions & 4 deletions lib/components/widgetComp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:efox_flutter/components/exampleComp.dart' as ExampleComp;
import 'package:efox_flutter/utils/file.dart' as FileUtils;
import 'package:efox_flutter/utils/loadAsset.dart' as LoadAssetUtils;
import 'package:efox_flutter/router/index.dart' show FluroRouter;
import 'package:efox_flutter/config/theme.dart' show AppTheme;

class Index extends StatefulWidget {
final List<Widget> demoChild;
Expand Down Expand Up @@ -149,7 +150,7 @@ class IndexState extends State<Index> {
child: Row(children: [
Icon(
Icons.home,
color: Color(model.theme.greyColor),
color: Color(AppTheme.greyColor),
),
Text(" "),
Text('Flutter-UI'),
Expand All @@ -160,7 +161,7 @@ class IndexState extends State<Index> {
child: Row(children: [
Icon(
Icons.code,
color: Color(model.theme.greyColor),
color: Color(AppTheme.greyColor),
),
Text(" "),
Text(this.title),
Expand Down Expand Up @@ -205,8 +206,7 @@ class IndexState extends State<Index> {
child: Text(
AppTranslations.of(context).t('loading'),
style: TextStyle(
color: Color(this.model.theme.secondColor),
fontSize: 20.0),
color: Color(AppTheme.secondColor), fontSize: 20.0),
),
)
],
Expand Down
30 changes: 30 additions & 0 deletions lib/config/theme.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'package:flutter/material.dart';

class AppTheme {
static int mainColor = 0xFFD32F2F;
static int secondColor = 0xFFFFFFFF;
static int thirdColor = 0xFFFAFAFA;
static int greyColor = 0x8A000000;
static int blackColor = 0xFF000000;
static ThemeData themData = ThemeData(
textTheme: TextTheme(
body1: TextStyle(
// color: Colors.black,
// fontWeight: FontWeight.bold,
),
),
platform: TargetPlatform.iOS,
iconTheme: IconThemeData(
size: 32,
color: Color(thirdColor),
opacity: 0.85,
),
// primaryIconTheme 导航栏按钮颜色
primaryIconTheme: IconThemeData(
color: Color(secondColor),
),
accentColor: Colors.grey, // 选中颜色
primaryColor: Color(mainColor), // appbar背景
scaffoldBackgroundColor: Color(thirdColor), // 整体的scaffold背景颜色
);
}
25 changes: 4 additions & 21 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import 'package:efox_flutter/lang/app_translations_delegate.dart';
import 'package:efox_flutter/store/store.dart' show model, Store;
//路由
import 'package:efox_flutter/router/index.dart';
//主题
import 'package:efox_flutter/config/theme.dart' show AppTheme;

void main() => runApp(MainApp());

class MainApp extends StatefulWidget {
Expand Down Expand Up @@ -56,27 +59,7 @@ class MainAppState extends State<MainApp> {
const Locale('zh'),
],
title: 'Flutter Demo',
theme: ThemeData(
textTheme: TextTheme(
body1: TextStyle(
// color: Colors.black,
// fontWeight: FontWeight.bold,
),
),
platform: TargetPlatform.iOS,
iconTheme: IconThemeData(
size: 32,
color: Color(model.theme.thirdColor),
opacity: 0.85,
),
// primaryIconTheme 导航栏按钮颜色
primaryIconTheme: IconThemeData(
color: Color(model.theme.secondColor),
),
accentColor: Colors.grey, // 选中颜色
primaryColor: Color(model.theme.mainColor), // appbar背景
scaffoldBackgroundColor: Color(model.theme.thirdColor), // 整体的scaffold背景颜色
),
theme: AppTheme.themData,
onGenerateRoute: FluroRouter.router.generator,
),
);
Expand Down
5 changes: 3 additions & 2 deletions lib/page/component/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:efox_flutter/router/index.dart';
import 'package:efox_flutter/store/models/main_state_model.dart';
import 'package:efox_flutter/widget/index.dart' as WidgetRoot;
import 'package:efox_flutter/config/theme.dart' show AppTheme;

class Index extends StatefulWidget {
final MainStateModel model;
Expand Down Expand Up @@ -43,7 +44,7 @@ class _IndexState extends State<Index> {
fontFamily: 'MaterialIcons',
matchTextDirection: true,
),
// color: Color(model.theme.mainColor),
// color: Color(AppTheme.mainColor),
),
backgroundColor: Colors.white,
children: [
Expand Down Expand Up @@ -74,7 +75,7 @@ class _IndexState extends State<Index> {
fontFamily: 'MaterialIcons',
matchTextDirection: true,
),
color: Color(model.theme.mainColor),
color: Color(AppTheme.mainColor),
),
onPressed: () {
FluroRouter.router.navigateTo(
Expand Down
Loading