Skip to content

Commit

Permalink
优化示例和图片
Browse files Browse the repository at this point in the history
  • Loading branch information
lizhuoyuan committed Nov 19, 2018
1 parent 9e2f2e9 commit e922908
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 266 deletions.
Binary file modified demo_en.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified demo_zh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class _MyHomePageState extends State<MyHomePage> {
'My width:${ScreenUtil().setWidth(375)}dp',
style: TextStyle(
color: Colors.white,
fontSize: ScreenUtil().setSp(12, false)),
fontSize: ScreenUtil().setSp(24, false)),
),
),
Container(
Expand All @@ -77,7 +77,7 @@ class _MyHomePageState extends State<MyHomePage> {
child: Text('My width:${ScreenUtil().setWidth(375)}dp',
style: TextStyle(
color: Colors.white,
fontSize: ScreenUtil().setSp(12, false))),
fontSize: ScreenUtil().setSp(24, false))),
),
],
),
Expand Down Expand Up @@ -110,16 +110,16 @@ class _MyHomePageState extends State<MyHomePage> {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'My font size is 14px on the design draft and will not change with the system.',
'My font size is 24px on the design draft and will not change with the system.',
style: TextStyle(
color: Colors.black,
fontSize: ScreenUtil().setSp(14, false),
fontSize: ScreenUtil().setSp(24, false),
)),
Text(
'My font size is 14px on the design draft and will change with the system.',
'My font size is 24px on the design draft and will change with the system.',
style: TextStyle(
color: Colors.black,
fontSize: ScreenUtil().setSp(14),
fontSize: ScreenUtil().setSp(24),
)),
],
)
Expand Down
16 changes: 7 additions & 9 deletions example/lib/main_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class MyHomePage extends StatefulWidget {
}

class _MyHomePageState extends State<MyHomePage> {

@override
Widget build(BuildContext context) {
//设置适配尺寸 (填入设计稿中设备的屏幕尺寸) 假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334)
Expand All @@ -46,8 +45,7 @@ class _MyHomePageState extends State<MyHomePage> {

print(
'宽度和字体相对于设计稿放大的比例:${ScreenUtil().scaleWidth * ScreenUtil.pixelRatio}');
print(
'高度相对于设计稿放大的比例:${ScreenUtil().scaleHeight * ScreenUtil.pixelRatio}');
print('高度相对于设计稿放大的比例:${ScreenUtil().scaleHeight * ScreenUtil.pixelRatio}');
print('系统的字体缩放比例:${ScreenUtil.textScaleFactory}');

return new Scaffold(
Expand All @@ -68,7 +66,7 @@ class _MyHomePageState extends State<MyHomePage> {
'我的宽度:${ScreenUtil().setWidth(375)}dp',
style: TextStyle(
color: Colors.white,
fontSize: ScreenUtil().setSp(12, false),
fontSize: ScreenUtil().setSp(24, false),
),
),
),
Expand All @@ -79,7 +77,7 @@ class _MyHomePageState extends State<MyHomePage> {
child: Text('我的宽度:${ScreenUtil().setWidth(375)}dp',
style: TextStyle(
color: Colors.white,
fontSize: ScreenUtil().setSp(12, false),
fontSize: ScreenUtil().setSp(24, false),
)),
),
],
Expand Down Expand Up @@ -112,13 +110,13 @@ class _MyHomePageState extends State<MyHomePage> {
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text('我的文字大小在设计稿上是14px,不会随着系统的文字缩放比例变化',
Text('我的文字大小在设计稿上是25px,不会随着系统的文字缩放比例变化',
style: TextStyle(
color: Colors.black,
fontSize: ScreenUtil().setSp(14, false))),
Text('我的文字大小在设计稿上是14px,会随着系统的文字缩放比例变化',
fontSize: ScreenUtil().setSp(24, false))),
Text('我的文字大小在设计稿上是25px,会随着系统的文字缩放比例变化',
style: TextStyle(
color: Colors.black, fontSize: ScreenUtil().setSp(14))),
color: Colors.black, fontSize: ScreenUtil().setSp(24))),
],
)
],
Expand Down
Loading

0 comments on commit e922908

Please sign in to comment.