Skip to content

Commit

Permalink
add some demos and update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
xuyisheng committed Feb 29, 2020
1 parent 79eefc6 commit d2c10ed
Show file tree
Hide file tree
Showing 27 changed files with 1,908 additions and 149 deletions.
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# flutter_dojo

[![license](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Dojo,源自日语「道場」。

flutter_dojo项目的主要目的是为了帮助Flutter初学者快速入门Flutter开发,并借助该项目快速建立起Flutter的知识体系架构。
Expand Down Expand Up @@ -44,65 +46,65 @@ Back-end Util这部分主要是针对Flutter中的非UI场景知识点进行的

所有的展示界面,都以演示效果为目的,展示该Widget最主要的属性,并通过实例演示更改属性后的效果,举例如下。

![](resource/6.png)
<img src="resource/6.png" width="240px"/>

修改对应的属性后,可以直接展示修改效果,从而了解到该属性的作用。

同时,Demo代码可以直接查看。

![](resource/61.png)
<img src="resource/61.png" width="240px"/>

而且代码也可以直接分享出来,分享出来的代码几乎是可以直接Copy使用的代码。

## Widgets

Widgets部分包含了Flutter官方Category中的几乎所有Widget,是的你没看错,按照官网的Category划分,穷举了官方列出的所有Widget,同时也新增了一些未出现在Category中,但却很常用的Widget。

![](resource/1.png)
<img src="resource/1.png" width="240px"/>

在每个Category中,都按照A-Z的顺序展示Widget。

![](resource/11.png)
<img src="resource/11.png" width="240px"/>

## UI Pattern

UI Pattern部分包含了APP中常用的界面开发模板元素,例如APPBar、Banner、Login、Setting等等,在UI Pattern中,开发者可以找到各自分解的UI元素,了解如何使用Flutter来构建这些UI组件。

![](resource/2.png)
<img src="resource/2.png" width="240px"/>

在UI Pattern中,我分类列举了很多不同的模板类型。

![](resource/21.png)
<img src="resource/21.png" width="240px"/>

## Develop UI Kit

Develop UI Kit列举了UI开发中的一些常用工具类和开发模板代码,开发者可以使用这些工具类来完成一些UI功能开发。

![](resource/3.png)
<img src="resource/3.png" width="240px"/>

在Develop UI Kit中,按照A-Z对相关代码进行了排列。

![](resource/31.png)
<img src="resource/31.png" width="240px"/>

## Animations

由于动画在APP开发中的重要性,这里特地将Animations作为一项单独列出。开发者可以在这里找到不同的Animation开发模式,了解不同的Animation使用方法。

![](resource/4.png)
<img src="resource/4.png" width="240px"/>

在Animations中,同样是根据不同的功能进行了划分。

![](resource/41.png)
<img src="resource/41.png" width="240px"/>

## Back-end Util

Back-end Util中列举了非UI的一些Flutter知识点。

![](resource/5.png)
<img src="resource/5.png" width="240px"/>

Flutter不仅仅是一个UI跨平台框架,同样是一个完整的APP开发框架,所以,这里列举了除了UI开发之外的一些功能。

![](resource/51.png)
<img src="resource/51.png" width="240px"/>

## 协作

Expand All @@ -112,11 +114,11 @@ Flutter不仅仅是一个UI跨平台框架,同样是一个完整的APP开发

有兴趣一起协作的开发者可以添加我的微信。

![](resource/7.jpeg)
<img src="resource/7.jpeg" width="240px"/>

或者感兴趣的开发者可以加入我的Flutter修仙群,加我微信我拉你进群。

## 打赏

![](resource/8.png)
<img src="resource/8.png" width="400px"/>

170 changes: 170 additions & 0 deletions lib/animation/animation/curveline.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter_dojo/common/main_title_widget.dart';
import 'package:flutter_dojo/common/subtitle_widget.dart';

class CurveLineWidget extends StatefulWidget {
@override
_CurveLineWidgetState createState() => _CurveLineWidgetState();
}

class _CurveLineWidgetState extends State<CurveLineWidget> with SingleTickerProviderStateMixin {
AnimationController _controller;
Animation _animation;
double _fraction = 0.0;
int _seconds = 3;
Path _path;
GlobalKey customPaintKey = GlobalKey();

@override
void initState() {
_controller = AnimationController(
vsync: this,
duration: Duration(seconds: _seconds),
);
super.initState();
}

@override
void dispose() {
_controller.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
MainTitleWidget('通过PathMetrics计算Path上的坐标'),
SubtitleWidget('通过getTangentForOffset获取点的Position'),
Expanded(
child: Container(
constraints: BoxConstraints.expand(),
child: CustomPaint(
key: customPaintKey,
painter: PathPainter(_path, _fraction),
),
),
),
RaisedButton(
onPressed: startPathMotion,
child: Text('Start'),
),
SubtitleWidget('通过extractPath截取Path片段'),
Expanded(
child: Container(
constraints: BoxConstraints.expand(),
child: CustomPaint(
painter: PathSegmentPainter(_path, _fraction),
),
),
),
RaisedButton(
onPressed: startPathMotion,
child: Text('Start'),
),
],
);
}

Path _getPath(Size size) {
Path path = Path();
path.moveTo(20, 20);
path.cubicTo(
size.width / 4,
size.height / 2,
size.width / 4 * 3,
size.height / 2,
size.width - 20,
size.height - 20,
);
return path;
}

startPathMotion() {
_controller.reset();
RenderBox renderBox = customPaintKey.currentContext.findRenderObject();
Size s = renderBox.size;
_path = _getPath(s);
PathMetrics pms = _path.computeMetrics();
PathMetric pm = pms.elementAt(0);
double len = pm.length;
_animation = Tween(begin: 0.0, end: len).animate(_controller)
..addListener(() {
setState(() => _fraction = _animation.value);
})
..addStatusListener((status) {
if (status == AnimationStatus.completed) {
_controller.stop();
}
});
_controller.forward();
}
}

class PathPainter extends CustomPainter {
double _fraction;
Path _path;

PathPainter(this._path, this._fraction);

Paint _paint = Paint()
..color = Colors.blue
..style = PaintingStyle.stroke
..strokeWidth = 4.0;

Paint _paint2 = Paint()
..color = Colors.red
..style = PaintingStyle.fill;

@override
void paint(Canvas canvas, Size size) {
if (_path == null) {
return;
}
PathMetrics pms = _path.computeMetrics();
PathMetric pm = pms.elementAt(0);
Tangent t = pm.getTangentForOffset(_fraction);
canvas.drawPath(_path, _paint);
canvas.drawCircle(t.position, 10, _paint2);
}

@override
bool shouldRepaint(CustomPainter oldDelegate) {
return true;
}
}

class PathSegmentPainter extends CustomPainter {
double _fraction;
Path _path;

PathSegmentPainter(this._path, this._fraction);

Paint _paint = Paint()
..color = Colors.blue
..style = PaintingStyle.stroke
..strokeWidth = 4.0;

@override
void paint(Canvas canvas, Size size) {
if (_path == null) {
return;
}
Path segmentPath = Path();

PathMetrics pms = _path.computeMetrics();
PathMetric pm = pms.elementAt(0);

var extractPath = pm.extractPath(0.0, _fraction);
segmentPath.addPath(extractPath, Offset(0, 0));

canvas.drawPath(segmentPath, _paint);
}

@override
bool shouldRepaint(CustomPainter oldDelegate) {
return true;
}
}
11 changes: 10 additions & 1 deletion lib/modle/animation/animation_category.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_dojo/animation/animation/bouncing.dart';
import 'package:flutter_dojo/animation/animation/curve.dart';
import 'package:flutter_dojo/animation/animation/curveline.dart';
import 'package:flutter_dojo/animation/animation/focus.dart';
import 'package:flutter_dojo/animation/animation/sequence.dart';
import 'package:flutter_dojo/animation/animation/showup.dart';
Expand All @@ -19,6 +20,7 @@ import 'package:flutter_dojo/animation/scrollanimation/listtopbottom.dart';
import 'package:flutter_dojo/animation/scrollanimation/scrollinganimation1.dart';
import 'package:flutter_dojo/animation/scrollanimation/scrollinganimation2.dart';
import 'package:flutter_dojo/animation/scrollanimation/scrollinganimation3.dart';
import 'package:flutter_dojo/animation/scrollanimation/scrollparallax.dart';
import 'package:flutter_dojo/animation/tween/slidecard.dart';
import 'package:flutter_dojo/animation/tween/testanim1.dart';
import 'package:flutter_dojo/animation/tween/testanim2.dart';
Expand All @@ -27,7 +29,6 @@ import 'package:flutter_dojo/animation/tween/tweenanimationbuilder.dart';
import 'package:flutter_dojo/common/base_widget.dart';
import 'package:flutter_dojo/common/demo_item.dart';
import 'package:flutter_dojo/pages/pattern/pattern_mainpage.dart';
import 'package:flutter_dojo/animation/scrollanimation/scrollparallax.dart';

var codePath = 'lib/animation/';

Expand Down Expand Up @@ -120,6 +121,13 @@ List<DemoItem> buildAnimationDemoItems(String codePath) {
documentationUrl: '',
buildRoute: (context) => BaseWidget('Curve', codePath, CurveWidget()),
),
DemoItem(
icon: Icons.date_range,
title: 'CurveLine',
subtitle: 'CurveLine',
documentationUrl: '',
buildRoute: (context) => BaseWidget('CurveLine', codePath, CurveLineWidget()),
),
DemoItem(
icon: Icons.date_range,
title: 'Focus',
Expand Down Expand Up @@ -247,6 +255,7 @@ List<DemoItem> buildBarChatDemoItems(String codePath) {
),
];
}

List<DemoItem> buildScrollAnimationDemoItems(String codePath) {
return [
DemoItem(
Expand Down

0 comments on commit d2c10ed

Please sign in to comment.