Skip to content

Commit

Permalink
0.8.4 - se changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
ReinBentdal committed Nov 16, 2019
1 parent e9403c2 commit 8927833
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.8.4
* Added animation support for `fontSize`, `textColor`, `maxLines`, `letterSpacing` and `wordSpacing`
* Addedd `textDirection` method to `TxtStyle`

## 0.8.3+1
* [fix] `isTap` not working correctly

## 0.8.3
* Added `isTap` method to `GestureClass`
* Other minor improvements
Expand Down
Empty file removed example/examples.md
Empty file.
64 changes: 64 additions & 0 deletions lib/src/animated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,67 @@ class _ParentAnimatedState extends AnimatedWidgetBaseState<ParentAnimated> {
);
}
}

class TxtAnimated extends ImplicitlyAnimatedWidget {
TxtAnimated({
@required this.textModel,
@required Curve curve,
@required Duration duration,
@required this.text,
}) : super(curve: curve, duration: duration);

final String text;

final TextModel textModel;

@override
_TxtAnimatedState createState() => _TxtAnimatedState();
}

class _TxtAnimatedState extends AnimatedWidgetBaseState<TxtAnimated> {
Tween<double> _fontSize;
ColorTween _textColor;
Tween<int> _maxLines;
Tween<double> _letterSpacing;
Tween<double> _wordSpacing;

@override
void forEachTween(TweenVisitor<dynamic> visitor) {
_fontSize = visitor(_fontSize, widget.textModel?.fontSize,
(dynamic value) => Tween<double>(begin: value));
_textColor = visitor(_textColor, widget.textModel?.textColor,
(dynamic value) => ColorTween(begin: value));
_maxLines = visitor(_maxLines, widget.textModel?.maxLines,
(dynamic value) => Tween<int>(begin: value));
_letterSpacing = visitor(_letterSpacing, widget.textModel?.letterSpacing,
(dynamic value) => Tween<double>(begin: value));
_wordSpacing = visitor(_wordSpacing, widget.textModel?.wordSpacing,
(dynamic value) => Tween<double>(begin: value));
}

@override
Widget build(BuildContext context) {
TextModel _textModel = widget.textModel;

if (_textModel != null) {
_textModel
..fontSize = _fontSize?.evaluate(animation)
..textColor = _textColor?.evaluate(animation)
..maxLines = _maxLines?.evaluate(animation)
..letterSpacing = _letterSpacing?.evaluate(animation)
..wordSpacing = _wordSpacing?.evaluate(animation);
}

if (_textModel?.editable != null && _textModel?.editable == true) {
return TxtBuildEditable(
text: widget.text,
textModel: _textModel,
);
} else {
return TxtBuild(
text: widget.text,
textModel: _textModel,
);
}
}
}
4 changes: 3 additions & 1 deletion lib/src/build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ class TxtBuild extends StatelessWidget {
style: textModel?.textStyle,
textAlign: textModel?.textAlign ?? TextAlign.center,
maxLines: textModel?.maxLines,
textDirection: textModel?.textDirection,
);

return widgetTree;
Expand Down Expand Up @@ -277,8 +278,9 @@ class _TxtBuildEditableState extends State<TxtBuildEditable> {
obscureText: _placeholder ? false : widget.textModel?.obscureText,
cursorOpacityAnimates: true,
style: _placeholderStyle ?? widget.textModel?.textStyle,
textAlign: widget.textModel?.textAlign ?? TextAlign.left,
textAlign: widget.textModel?.textAlign ?? TextAlign.center,
maxLines: widget.textModel?.maxLines,
textDirection: widget.textModel?.textDirection,
controller: _placehodlerController ?? _controller,
focusNode: _focusNode,
backgroundCursorColor: Colors.grey,
Expand Down
2 changes: 2 additions & 0 deletions lib/src/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ class TextModel {
double letterSpacing;
double wordSpacing;
TextDecoration textDecoration;
TextDirection textDirection;

//editable
bool editable;
Expand Down Expand Up @@ -427,6 +428,7 @@ class TextModel {
wordSpacing = _replace(wordSpacing, textModel?.wordSpacing, override);
textDecoration =
_replace(textDecoration, textModel?.textDecoration, override);
textDirection = _replace(textDirection, textModel?.textDirection, override);

editable = _replace(editable, textModel?.editable, override);
keyboardType = _replace(keyboardType, textModel?.keyboardType, override);
Expand Down
3 changes: 3 additions & 0 deletions lib/src/style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,9 @@ class TxtStyle extends StyleClass {
void textDecoration(TextDecoration decoration) =>
_textModel?.textDecoration = decoration;

void textDirection(TextDirection textDirection) =>
_textModel?.textDirection = textDirection;

/// Make the widget editable just like a TextField.
///
/// If `focusNode` isnt spesified an internal `focusNode` will be created.
Expand Down
9 changes: 8 additions & 1 deletion lib/src/widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ class Txt extends StatelessWidget {
TextModel textModel = style?.exportTextStyle;
GestureModel gestureModel = gesture?.exportGesture;

if (textModel?.editable != null && textModel?.editable == true) {
if (styleModel?.duration != null) {
widgetTree = TxtAnimated(
text: text,
textModel: textModel,
curve: styleModel?.curve,
duration: styleModel?.duration,
);
} else if (textModel?.editable != null && textModel?.editable == true) {
widgetTree = TxtBuildEditable(
text: text,
textModel: textModel,
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: division
description: A simple to use yet powerfull styling widget with syntax inspired by CSS.
version: 0.8.3
description: A simple to use yet powerfull style widget with syntax inspired by CSS.
version: 0.8.4

author: Rein Gundersen Bentdal<[email protected]>
homepage: https://github.com/ReinBentdal/division
Expand Down

0 comments on commit 8927833

Please sign in to comment.