mirror of
https://github.com/alibaba/flutter-go.git
synced 2025-06-20 12:32:25 +08:00
add file
This commit is contained in:
67
lib/widgets/elements/Frame/Align/Align/demo.dart
Normal file
67
lib/widgets/elements/Frame/Align/Align/demo.dart
Normal file
@ -0,0 +1,67 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
/**
|
||||
* Author: xiaojia.dxj
|
||||
* Date: 2018/11/22
|
||||
* Email: xiaojia.dxj@alibaba-inc.com
|
||||
* LastUpdateTime: 2018/11/22
|
||||
* LastUpdateBy: xj.deng
|
||||
*
|
||||
* Describle:Align描述
|
||||
*/
|
||||
|
||||
class AlignAlignment extends StatelessWidget {
|
||||
final Alignment status;
|
||||
final String dec;
|
||||
|
||||
const AlignAlignment(Alignment this.status, String this.dec) : super();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Container(
|
||||
color: Color(0xffd81b60),
|
||||
width: 90.0,
|
||||
height: 50.0,
|
||||
child: new Align(
|
||||
alignment: status,
|
||||
child: new Text(
|
||||
dec,
|
||||
style: TextStyle(fontSize: 12.0, color: Color(0xffffffff)),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AlignFactor extends StatelessWidget {
|
||||
final Alignment status;
|
||||
final double wFactor;
|
||||
final double hFactor;
|
||||
final String dec;
|
||||
|
||||
const AlignFactor(Alignment this.status, double this.wFactor,
|
||||
double this.hFactor, String this.dec)
|
||||
: super();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Container(
|
||||
margin: new EdgeInsets.only(top: 10.0, bottom: 10.0),
|
||||
color: Color(0xffd81b60),
|
||||
child: new Align(
|
||||
alignment: status,
|
||||
widthFactor: wFactor,
|
||||
heightFactor: hFactor,
|
||||
child: Container(
|
||||
color: Color(0xfff06292),
|
||||
width: 100.0,
|
||||
height: 50.0,
|
||||
child: Text(
|
||||
dec,
|
||||
style: TextStyle(color: Color(0xffffffff)),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
100
lib/widgets/elements/Frame/Align/Align/index.dart
Normal file
100
lib/widgets/elements/Frame/Align/Align/index.dart
Normal file
@ -0,0 +1,100 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||
import '../../../../../common/widget_demo.dart';
|
||||
import './demo.dart' ;
|
||||
|
||||
|
||||
const String _flatText0 = """
|
||||
### **简介**
|
||||
> Align控件即对齐控件,能将子控件所指定方式对齐,并根据子控件的大小调整自己的大小。
|
||||
- 根据自己需求,进行控件对齐
|
||||
### **基本用法**
|
||||
> alignment → AlignmentGeometry
|
||||
- 要对齐右下方的框,您将通过此框一个比子的自然大小更大的严格约束,并且对齐Alignment.bottomRight
|
||||
- 同理:Alignment.center,Alignment.bottomLeft,Alignment.topLeft等
|
||||
""";
|
||||
|
||||
const String _flatText1 = """
|
||||
> widthFactor / heightFactor → double
|
||||
- 如果widthFactor / heightFactor 为空,并且外部无任何约束,孩子控件大小默认,那么这个控件将根据自身尺寸最大化
|
||||
|
||||
- 如果widthFactor / heightFactor 不为空,并且外部无约束,align将匹配对应的孩子尺寸
|
||||
- ex:widthFactor/ heightFactor 为2.0;那么widget的宽高为孩子宽高的两倍
|
||||
- 如果widthFactor / heightFactor 为空,并且外部无约束,孩子控件设置自身大小
|
||||
- Alignment部分标签失效
|
||||
""";
|
||||
|
||||
class Demo extends StatefulWidget {
|
||||
static const String routeName = '/element/Frame/Align/Align';
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _DemoState();
|
||||
}
|
||||
|
||||
class _DemoState extends State<Demo> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WidgetDemo(
|
||||
title: 'Align',
|
||||
codeUrl:"elements/Frame/Align/Align/demo.dart",
|
||||
docUrl: 'https://docs.flutter.io/flutter/widgets/Align-class.html',
|
||||
contentList: [
|
||||
_flatText0,
|
||||
_flatText1,
|
||||
_AlignCreate()
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Column _AlignCreate() {
|
||||
return new Column(
|
||||
children: <Widget>[
|
||||
SizedBox(height: 10.0),
|
||||
new Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: <Widget>[
|
||||
AlignAlignment(Alignment.center, 'center'),
|
||||
AlignAlignment(Alignment.centerLeft, 'centerLeft'),
|
||||
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10.0),
|
||||
new Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: <Widget>[
|
||||
AlignAlignment(Alignment.centerRight, 'centerRight'),
|
||||
AlignAlignment(Alignment.bottomCenter, 'btCenter'),
|
||||
AlignAlignment(Alignment.topCenter, 'topCenter'),
|
||||
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10.0),
|
||||
new Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: <Widget>[
|
||||
AlignAlignment(Alignment.topLeft, 'topLeft'),
|
||||
AlignAlignment(Alignment.topRight, 'topRight'),
|
||||
AlignAlignment(Alignment.bottomLeft, 'bottomLeft'),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10.0),
|
||||
MarkdownBody(data: _flatText1),
|
||||
Container(
|
||||
margin: new EdgeInsets.only(top: 20.0, bottom: 20.0),
|
||||
color: Color(0xffe91e63),
|
||||
child: new Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: new Text("Align",style:
|
||||
TextStyle(color: Color(0xffffffff)),),
|
||||
),
|
||||
),
|
||||
|
||||
AlignFactor(Alignment.topLeft, 2.0, 2.0, 'topleft'),
|
||||
|
||||
AlignFactor(Alignment.topRight, null, null, 'topleft'),
|
||||
AlignFactor(Alignment.center, null, null, 'center'),
|
||||
AlignFactor(Alignment.bottomLeft, null, null, 'bottomLeft'),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
@ -1 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_rookie_book/model/widget.dart';
|
||||
|
||||
import './Align/index.dart' as Align;
|
||||
|
||||
List<WidgetPoint> widgetPoints = [
|
||||
WidgetPoint(
|
||||
name: 'Align',
|
||||
routerName: Align.Demo.routeName,
|
||||
buildRouter: (BuildContext context) => Align.Demo(),
|
||||
),
|
||||
];
|
||||
|
Reference in New Issue
Block a user