parent
8ce0e17cba
commit
c60e5b5a99
@ -1,7 +1,10 @@
|
|||||||
library aku_ui;
|
library aku_ui;
|
||||||
|
|
||||||
/// A Calculator.
|
//animated widgets
|
||||||
class Calculator {
|
export 'animated_widgets/animated.dart';
|
||||||
/// Returns [value] plus 1.
|
|
||||||
int addOne(int value) => value + 1;
|
//common widgets
|
||||||
}
|
export 'common_widgets/aku_common_widgets.dart';
|
||||||
|
|
||||||
|
//mixins
|
||||||
|
export 'mixins/aku_mixins.dart';
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
export 'animated_color_icon.dart';
|
||||||
|
export 'animated_image_revert.dart';
|
||||||
|
export 'animated_rotate.dart';
|
@ -0,0 +1,45 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
///动态变化图标
|
||||||
|
///
|
||||||
|
class AnimatedColorIcon extends ImplicitlyAnimatedWidget {
|
||||||
|
final IconData icon;
|
||||||
|
final Color color;
|
||||||
|
final double size;
|
||||||
|
|
||||||
|
AnimatedColorIcon({
|
||||||
|
this.icon,
|
||||||
|
this.color,
|
||||||
|
this.size,
|
||||||
|
Duration duration = const Duration(milliseconds: 300),
|
||||||
|
Curve curve = Curves.easeInOutCubic,
|
||||||
|
}) : super(
|
||||||
|
duration: duration,
|
||||||
|
curve: curve,
|
||||||
|
);
|
||||||
|
@override
|
||||||
|
ImplicitlyAnimatedWidgetState<ImplicitlyAnimatedWidget> createState() =>
|
||||||
|
_AniamtedColorIconState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AniamtedColorIconState
|
||||||
|
extends AnimatedWidgetBaseState<AnimatedColorIcon> {
|
||||||
|
ColorTween _colorTween;
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Icon(
|
||||||
|
widget.icon,
|
||||||
|
color: _colorTween.evaluate(animation),
|
||||||
|
size: widget.size,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void forEachTween(context) {
|
||||||
|
_colorTween = context(
|
||||||
|
_colorTween,
|
||||||
|
widget.color,
|
||||||
|
(dynamic value) => ColorTween(begin: value),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
///动态颜色混合
|
||||||
|
class AnimatedColorRevert extends ImplicitlyAnimatedWidget {
|
||||||
|
final Widget child;
|
||||||
|
final Color color;
|
||||||
|
|
||||||
|
AnimatedColorRevert({
|
||||||
|
this.child,
|
||||||
|
this.color,
|
||||||
|
Duration duration = const Duration(milliseconds: 300),
|
||||||
|
Curve curve = Curves.easeInOutCubic,
|
||||||
|
}) : super(
|
||||||
|
duration: duration,
|
||||||
|
curve: curve,
|
||||||
|
);
|
||||||
|
@override
|
||||||
|
ImplicitlyAnimatedWidgetState<ImplicitlyAnimatedWidget> createState() =>
|
||||||
|
_AnimatedColorRevertState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AnimatedColorRevertState
|
||||||
|
extends AnimatedWidgetBaseState<AnimatedColorRevert> {
|
||||||
|
ColorTween _colorTween;
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ColorFiltered(
|
||||||
|
colorFilter: ColorFilter.mode(
|
||||||
|
_colorTween.evaluate(animation),
|
||||||
|
BlendMode.modulate,
|
||||||
|
),
|
||||||
|
child: widget.child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void forEachTween(context) {
|
||||||
|
_colorTween = context(
|
||||||
|
_colorTween,
|
||||||
|
widget.color,
|
||||||
|
(dynamic value) => ColorTween(begin: value),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
///动态旋转
|
||||||
|
class AnimatedRotate extends ImplicitlyAnimatedWidget {
|
||||||
|
final Widget child;
|
||||||
|
final Duration duration;
|
||||||
|
final Curve curve;
|
||||||
|
final double angle;
|
||||||
|
|
||||||
|
AnimatedRotate({
|
||||||
|
Key key,
|
||||||
|
@required this.child,
|
||||||
|
this.duration = const Duration(milliseconds: 400),
|
||||||
|
this.curve = Curves.easeInOutCubic,
|
||||||
|
@required this.angle,
|
||||||
|
}) : super(
|
||||||
|
key: key,
|
||||||
|
duration: duration,
|
||||||
|
curve: curve,
|
||||||
|
);
|
||||||
|
@override
|
||||||
|
ImplicitlyAnimatedWidgetState<ImplicitlyAnimatedWidget> createState() =>
|
||||||
|
_AnimatedRoateState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AnimatedRoateState extends AnimatedWidgetBaseState<AnimatedRotate> {
|
||||||
|
Tween<double> _rotateTween;
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Transform.rotate(
|
||||||
|
angle: _rotateTween.evaluate(animation),
|
||||||
|
child: widget.child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void forEachTween(visitor) {
|
||||||
|
_rotateTween = visitor(
|
||||||
|
_rotateTween,
|
||||||
|
widget.angle,
|
||||||
|
(dynamic value) => Tween<double>(begin: value),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
import 'package:aku_ui/common_widgets/aku_cupertino_button.dart';
|
||||||
|
import 'package:aku_ui/common_widgets/aku_material_button.dart';
|
||||||
|
import 'package:aku_ui/mixins/aku_mixins.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
///按钮
|
||||||
|
class AkuButton extends StatefulWidget {
|
||||||
|
@required
|
||||||
|
final Widget child;
|
||||||
|
final double height;
|
||||||
|
final double radius;
|
||||||
|
final EdgeInsets padding;
|
||||||
|
@required
|
||||||
|
final VoidCallback onPressed;
|
||||||
|
AkuButton({
|
||||||
|
Key key,
|
||||||
|
this.child,
|
||||||
|
this.height = 0,
|
||||||
|
this.radius = 0,
|
||||||
|
this.onPressed,
|
||||||
|
this.padding = EdgeInsets.zero,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_AkuButtonState createState() => _AkuButtonState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AkuButtonState extends State<AkuButton> with PlatformMixin {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return isIOS
|
||||||
|
? AkuCupertinoButton(
|
||||||
|
onPressed: widget.onPressed,
|
||||||
|
child: widget.child,
|
||||||
|
radius: widget.radius,
|
||||||
|
minHeight: widget.height,
|
||||||
|
padding: widget.padding,
|
||||||
|
)
|
||||||
|
: AkuMaterialButton(
|
||||||
|
onPressed: widget.onPressed,
|
||||||
|
child: widget.child,
|
||||||
|
radius: widget.radius,
|
||||||
|
height: widget.height,
|
||||||
|
padding: widget.padding,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
export 'aku_button.dart';
|
@ -0,0 +1,32 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class AkuCupertinoButton extends CupertinoButton {
|
||||||
|
final VoidCallback onPressed;
|
||||||
|
final Widget child;
|
||||||
|
final Color color;
|
||||||
|
final EdgeInsetsGeometry padding;
|
||||||
|
final double radius;
|
||||||
|
final double minHeight;
|
||||||
|
final Color nullColor;
|
||||||
|
|
||||||
|
AkuCupertinoButton({
|
||||||
|
Key key,
|
||||||
|
@required this.onPressed,
|
||||||
|
@required this.child,
|
||||||
|
this.color = Colors.transparent,
|
||||||
|
this.padding = EdgeInsets.zero,
|
||||||
|
this.radius = 0,
|
||||||
|
this.minHeight = 0,
|
||||||
|
this.nullColor,
|
||||||
|
}) : super(
|
||||||
|
key: key,
|
||||||
|
child: child,
|
||||||
|
color: color,
|
||||||
|
onPressed: onPressed,
|
||||||
|
padding: padding,
|
||||||
|
borderRadius: BorderRadius.circular(radius),
|
||||||
|
minSize: minHeight,
|
||||||
|
disabledColor: nullColor ?? color.withAlpha(170),
|
||||||
|
);
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class AkuMaterialButton extends MaterialButton {
|
||||||
|
final VoidCallback onPressed;
|
||||||
|
final double elevation;
|
||||||
|
final double disabledElevation;
|
||||||
|
final double focusElevation;
|
||||||
|
final double highlightElevation;
|
||||||
|
final double hoverElevation;
|
||||||
|
final double height;
|
||||||
|
final double minWidth;
|
||||||
|
final double radius;
|
||||||
|
final EdgeInsets padding;
|
||||||
|
|
||||||
|
final Widget child;
|
||||||
|
AkuMaterialButton({
|
||||||
|
Key key,
|
||||||
|
@required this.onPressed,
|
||||||
|
this.elevation = 0,
|
||||||
|
this.disabledElevation = 0,
|
||||||
|
this.focusElevation = 0,
|
||||||
|
this.highlightElevation = 0,
|
||||||
|
this.hoverElevation = 0,
|
||||||
|
this.height = 48,
|
||||||
|
this.minWidth = 0,
|
||||||
|
this.radius = 0,
|
||||||
|
this.padding = EdgeInsets.zero,
|
||||||
|
@required this.child,
|
||||||
|
}) : super(
|
||||||
|
key: key,
|
||||||
|
onPressed: onPressed,
|
||||||
|
elevation: elevation,
|
||||||
|
disabledElevation: disabledElevation,
|
||||||
|
focusElevation: focusElevation,
|
||||||
|
highlightElevation: highlightElevation,
|
||||||
|
hoverElevation: hoverElevation,
|
||||||
|
height: height,
|
||||||
|
minWidth: minWidth,
|
||||||
|
padding: padding,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(radius),
|
||||||
|
),
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
import 'package:aku_ui/aku_ui.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
///圆角按钮
|
||||||
|
class AkuRoundButton extends AkuButton {
|
||||||
|
final double height;
|
||||||
|
final VoidCallback onPressed;
|
||||||
|
final Widget child;
|
||||||
|
final EdgeInsets padding;
|
||||||
|
AkuRoundButton({
|
||||||
|
Key key,
|
||||||
|
this.height,
|
||||||
|
@required this.child,
|
||||||
|
@required this.onPressed,
|
||||||
|
this.padding = EdgeInsets.zero,
|
||||||
|
}) : super(
|
||||||
|
key: key,
|
||||||
|
height: height,
|
||||||
|
radius: height / 2,
|
||||||
|
onPressed: onPressed,
|
||||||
|
child: child,
|
||||||
|
padding: padding,
|
||||||
|
);
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
export 'platform_mixin.dart';
|
@ -0,0 +1,6 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
class PlatformMixin {
|
||||||
|
bool get isIOS => Platform.isIOS;
|
||||||
|
bool get isAndroid => Platform.isAndroid;
|
||||||
|
}
|
Reference in new issue