mirror of
https://github.com/alibaba/flutter-go.git
synced 2025-07-15 03:04:25 +08:00
merge devlop
This commit is contained in:
49
lib/widgets/elements/Frame/Box/Fittedbox/demo.dart
Normal file
49
lib/widgets/elements/Frame/Box/Fittedbox/demo.dart
Normal file
@ -0,0 +1,49 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
/**
|
||||
* Author: xiaojia.dxj
|
||||
* Date: 2018/12/2
|
||||
* Email: xiaojia.dxj@alibaba-inc.com
|
||||
* LastUpdateTime: 2018/12/2
|
||||
* LastUpdateBy: xj.deng
|
||||
*
|
||||
* Describle:FittedBox
|
||||
*/
|
||||
|
||||
class FittedBoxDefault extends StatelessWidget {
|
||||
final BoxFit curfit;
|
||||
String dec;
|
||||
|
||||
FittedBoxDefault({Key key, BoxFit this.curfit, this.dec});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Column(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
//外部有位置约束,内部大小设定失效,保持和外部约束一致
|
||||
height: 100.0,
|
||||
width: 100.0,
|
||||
color: Colors.yellow,
|
||||
child: FittedBox(
|
||||
fit: curfit,
|
||||
// 修改child写入布局时期分配的空间
|
||||
alignment: Alignment.center,
|
||||
//alignment修改child于父空间对齐方式,默认:Alignment.center,
|
||||
child: Container(
|
||||
// height: 50.0,
|
||||
// width: 50.0,
|
||||
color: Colors.red,
|
||||
child: Text(
|
||||
'fittedBox',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(dec),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
108
lib/widgets/elements/Frame/Box/Fittedbox/index.dart
Normal file
108
lib/widgets/elements/Frame/Box/Fittedbox/index.dart
Normal file
@ -0,0 +1,108 @@
|
||||
|
||||
/**
|
||||
* Author: xiaojia.dxj
|
||||
* Date: 2019-01-08
|
||||
* Email: xiaojia.dxj@alibaba-inc.com
|
||||
* LastUpdateTime: 2019-01-08
|
||||
* LastUpdateBy: xj.deng
|
||||
*
|
||||
*/
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../../../common/widget_demo.dart';
|
||||
import './demo.dart' as fittedBox;
|
||||
|
||||
const String Text0 = """
|
||||
### **FittedBox**
|
||||
> 根据自己的需要,对child进行缩放和定位
|
||||
- 可以看看变换,在绘制时任意变换应用在子窗口的widget
|
||||
""";
|
||||
|
||||
const String Text1 = """
|
||||
### **基本用法**
|
||||
> 根据外部约束,调整child
|
||||
- 如果外部没有约束,按照child的大小。
|
||||
- 如果外部有约束,按照外部约束调整自身大小,然后缩放调整child,根据条件进行放置
|
||||
- BoxFix 属性,修改child写入布局时期分配的空间
|
||||
- alignment修改child于父空间对齐方式,默认:Alignment.center,
|
||||
""";
|
||||
|
||||
class Demo extends StatefulWidget {
|
||||
static const String routeName = '/element/Frame/Box/FittedBox';
|
||||
|
||||
_DemoState createState() => _DemoState();
|
||||
}
|
||||
|
||||
class _DemoState extends State<Demo> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WidgetDemo(
|
||||
title: 'FittedBox',
|
||||
codeUrl: 'elements/Frame/Box/Fittedbox/demo.dart',
|
||||
docUrl: 'https://docs.flutter.io/flutter/widgets/FittedBox-class.html',
|
||||
contentList: [
|
||||
Text0,
|
||||
Text1,
|
||||
_FittedBoxCreate(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Column _FittedBoxCreate() {
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: <Widget>[
|
||||
fittedBox.FittedBoxDefault(
|
||||
/**
|
||||
* 设置child写入布局期间分配空间
|
||||
*/
|
||||
curfit: BoxFit.contain,
|
||||
dec: 'contain',
|
||||
),
|
||||
fittedBox.FittedBoxDefault(
|
||||
curfit: BoxFit.fill,
|
||||
dec: 'fill',
|
||||
),
|
||||
fittedBox.FittedBoxDefault(
|
||||
curfit: BoxFit.cover,
|
||||
dec: 'cover',
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.0,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: <Widget>[
|
||||
fittedBox.FittedBoxDefault(
|
||||
curfit: BoxFit.fitHeight,
|
||||
dec: 'fitHeight',
|
||||
),
|
||||
fittedBox.FittedBoxDefault(
|
||||
curfit: BoxFit.fitWidth,
|
||||
dec: 'fitWidth',
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.0,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: <Widget>[
|
||||
fittedBox.FittedBoxDefault(
|
||||
curfit: BoxFit.none,
|
||||
dec: 'none',
|
||||
),
|
||||
fittedBox.FittedBoxDefault(
|
||||
curfit: BoxFit.scaleDown,
|
||||
dec: 'scaleDown',
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
22
lib/widgets/elements/Frame/Box/RenderBox/demo.dart
Normal file
22
lib/widgets/elements/Frame/Box/RenderBox/demo.dart
Normal file
@ -0,0 +1,22 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class RenderBoxDemo extends StatefulWidget {
|
||||
_RenderBoxDemoState createState() => _RenderBoxDemoState();
|
||||
}
|
||||
|
||||
class _RenderBoxDemoState extends State<RenderBoxDemo> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
// child: RenderFoo(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class RenderFoo extends RenderBox {
|
||||
@override
|
||||
bool get hasSize => super.hasSize;
|
||||
|
||||
@override
|
||||
BoxConstraints get constraints => super.constraints;
|
||||
}
|
63
lib/widgets/elements/Frame/Box/RenderBox/index.dart
Normal file
63
lib/widgets/elements/Frame/Box/RenderBox/index.dart
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* @Author: xiaojia.dxj
|
||||
* @Date: 2019-01-08 15:56:26
|
||||
* @Last Modified by: xiaojia.dxj
|
||||
* @Last Modified time: 2019-01-08 15:56:26
|
||||
*/
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../../../common/widget_demo.dart';
|
||||
import './demo.dart' as sizeBox;
|
||||
|
||||
const String _Text = '''
|
||||
### **简介**
|
||||
> BoxConstraints为抽象类,我们可以使用BoxConstraints,一个不可边的约束布局,renderBox布局
|
||||
- 一个尺寸尊重一个BoxConstraints,当且仅当,以下关系式的成立:
|
||||
minWidth <= Size.width <= maxWidth
|
||||
minHeight <= Size.height <= maxHeight
|
||||
约束本身必须满足这些关系:
|
||||
|
||||
0.0 <= minWidth <= maxWidth <= double.infinity
|
||||
0.0 <= minHeight <= maxHeight <= double.infinity
|
||||
double.infinity是每个约束的合法值。
|
||||
''';
|
||||
|
||||
class Demo extends StatefulWidget {
|
||||
static const String routeName = '/element/Frame/Box/RenderBox';
|
||||
|
||||
_DemoState createState() => _DemoState();
|
||||
}
|
||||
|
||||
class _DemoState extends State<Demo> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WidgetDemo(
|
||||
title: 'Table',
|
||||
codeUrl: 'elements/Frame/Box/RenderBox/demo.dart',
|
||||
contentList: [
|
||||
_Text,
|
||||
_SizeBoxCreate(),
|
||||
],
|
||||
docUrl: 'https://docs.flutter.io/flutter/widgets/RenderBox-class.html',
|
||||
);
|
||||
}
|
||||
|
||||
Column _SizeBoxCreate() {
|
||||
return new Column(
|
||||
children: <Widget>[
|
||||
/**
|
||||
* Immutable layout constraints for RenderBox layout.
|
||||
*/
|
||||
SizedBox(
|
||||
width: 900.0,
|
||||
height: 50.0,
|
||||
child: const Card(
|
||||
child: Text(
|
||||
'SizedBox',
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
color: Color(0xFFEF5350)),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
20
lib/widgets/elements/Frame/Box/SizeBox/demo.dart
Normal file
20
lib/widgets/elements/Frame/Box/SizeBox/demo.dart
Normal file
@ -0,0 +1,20 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
class SizeBoxDefault extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: 140.0,
|
||||
height: 80.0,
|
||||
child: const Card(
|
||||
child: Text(
|
||||
'SizedBox',
|
||||
textDirection: TextDirection.rtl,
|
||||
),
|
||||
margin: EdgeInsets.all(20.0),
|
||||
color: Color(0xFFEF9A9A),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
68
lib/widgets/elements/Frame/Box/SizeBox/index.dart
Normal file
68
lib/widgets/elements/Frame/Box/SizeBox/index.dart
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* @Author: xiaojia.dxj
|
||||
* @Date: 2019-01-08 15:55:46
|
||||
* @Last Modified by: xiaojia.dxj
|
||||
* @Last Modified time: 2019-01-08 15:55:46
|
||||
*/
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../../../common/widget_demo.dart';
|
||||
import './demo.dart' as sizeBox;
|
||||
|
||||
class Demo extends StatefulWidget {
|
||||
static const String routeName = '/element/Frame/Box/SizeBox';
|
||||
|
||||
_DemoState createState() => _DemoState();
|
||||
}
|
||||
|
||||
class _DemoState extends State<Demo> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WidgetDemo(
|
||||
title: 'Table',
|
||||
codeUrl: 'elements/Frame/Box/SizedBox/demo.dart',
|
||||
contentList: [
|
||||
_SizeBoxCreate(),
|
||||
],
|
||||
docUrl: 'https://docs.flutter.io/flutter/widgets/SizedBox-class.html',
|
||||
);
|
||||
}
|
||||
|
||||
Column _SizeBoxCreate() {
|
||||
return new Column(
|
||||
children: <Widget>[
|
||||
new Text("SizedBox",
|
||||
textAlign: TextAlign.right,
|
||||
style: TextStyle(
|
||||
fontSize: 28.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
)),
|
||||
new Row(
|
||||
children: <Widget>[
|
||||
sizeBox.SizeBoxDefault(),
|
||||
SizedBox(
|
||||
width: 130.0,
|
||||
height: 80.0,
|
||||
child: const Card(
|
||||
child: Text(
|
||||
'SizedBox',
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
margin: EdgeInsets.only(left: 20.0, right: 20.0, top: 20.0),
|
||||
color: Color(0xFFE57373)),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
width: 900.0,
|
||||
height: 50.0,
|
||||
child: const Card(
|
||||
child: Text(
|
||||
'SizedBox',
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
color: Color(0xFFEF5350)),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
1
lib/widgets/elements/Frame/Box/TextBox/demo.dart
Normal file
1
lib/widgets/elements/Frame/Box/TextBox/demo.dart
Normal file
@ -0,0 +1 @@
|
||||
|
50
lib/widgets/elements/Frame/Box/TextBox/index.dart
Normal file
50
lib/widgets/elements/Frame/Box/TextBox/index.dart
Normal file
@ -0,0 +1,50 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../../../common/widget_demo.dart';
|
||||
import './demo.dart' as TextBox;
|
||||
|
||||
const String _Text = """### **TextBox简介**
|
||||
> 是一个包含一段文本的矩形
|
||||
- 它与rect类似,不过包含一个固定的TextDirection。
|
||||
- sizebox的width,heigh为null,child自身设置
|
||||
### **属性**
|
||||
> width:宽
|
||||
> height:高
|
||||
- ex:200*50 sizebox
|
||||
""";
|
||||
|
||||
class Demo extends StatefulWidget {
|
||||
static const String routeName = '/element/Frame/Box/TextBox';
|
||||
|
||||
_DemoState createState() => _DemoState();
|
||||
}
|
||||
|
||||
class _DemoState extends State<Demo> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WidgetDemo(
|
||||
title: 'TextBox',
|
||||
codeUrl: 'elements/Frame/Box/TextBox/demo.dart',
|
||||
contentList: [
|
||||
_Text,
|
||||
_creatTexbox(),
|
||||
],
|
||||
docUrl: 'https://docs.flutter.io/flutter/dart-ui/TextBox-class.html',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Column _creatTexbox() {
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
// Text("TextBox ",textDirection: new TextBox.fo,),
|
||||
Container(
|
||||
// child: TextBox.fromLTRB(270.0, 180.0, 1360.0, 730.0,TextDirection.rtl),
|
||||
|
||||
)
|
||||
|
||||
// centerSlice: new Rect.fromLTRB(270.0, 180.0, 1360.0, 730.0),
|
||||
|
||||
|
||||
],
|
||||
);
|
||||
}
|
@ -1 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
Reference in New Issue
Block a user