Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
a5a34d97
Commit
a5a34d97
authored
Apr 14, 2016
by
Ian Hickson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AnimatedDefaultTextStyle (#3324)
parent
c40f4cfe
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
81 additions
and
9 deletions
+81
-9
button.dart
packages/flutter/lib/src/material/button.dart
+3
-1
drawer_item.dart
packages/flutter/lib/src/material/drawer_item.dart
+3
-1
list_item.dart
packages/flutter/lib/src/material/list_item.dart
+5
-2
material.dart
packages/flutter/lib/src/material/material.dart
+2
-1
popup_menu.dart
packages/flutter/lib/src/material/popup_menu.dart
+3
-1
tabs.dart
packages/flutter/lib/src/material/tabs.dart
+3
-3
implicit_animations.dart
packages/flutter/lib/src/widgets/implicit_animations.dart
+62
-0
No files found.
packages/flutter/lib/src/material/button.dart
View file @
a5a34d97
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'colors.dart'
;
import
'colors.dart'
;
import
'constants.dart'
;
import
'debug.dart'
;
import
'debug.dart'
;
import
'ink_well.dart'
;
import
'ink_well.dart'
;
import
'material.dart'
;
import
'material.dart'
;
...
@@ -190,8 +191,9 @@ abstract class MaterialButtonState<T extends MaterialButton> extends State<T> {
...
@@ -190,8 +191,9 @@ abstract class MaterialButtonState<T extends MaterialButton> extends State<T> {
child:
contents
child:
contents
);
);
}
else
{
}
else
{
contents
=
new
DefaultTextStyle
(
contents
=
new
Animated
DefaultTextStyle
(
style:
style
,
style:
style
,
duration:
kThemeChangeDuration
,
child:
contents
child:
contents
);
);
}
}
...
...
packages/flutter/lib/src/material/drawer_item.dart
View file @
a5a34d97
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'colors.dart'
;
import
'colors.dart'
;
import
'constants.dart'
;
import
'debug.dart'
;
import
'debug.dart'
;
import
'icon.dart'
;
import
'icon.dart'
;
import
'icons.dart'
;
import
'icons.dart'
;
...
@@ -102,8 +103,9 @@ class DrawerItem extends StatelessWidget {
...
@@ -102,8 +103,9 @@ class DrawerItem extends StatelessWidget {
new
Flexible
(
new
Flexible
(
child:
new
Padding
(
child:
new
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
16.0
),
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
16.0
),
child:
new
DefaultTextStyle
(
child:
new
Animated
DefaultTextStyle
(
style:
_getTextStyle
(
themeData
),
style:
_getTextStyle
(
themeData
),
duration:
kThemeChangeDuration
,
child:
child
child:
child
)
)
)
)
...
...
packages/flutter/lib/src/material/list_item.dart
View file @
a5a34d97
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'constants.dart'
;
import
'debug.dart'
;
import
'debug.dart'
;
import
'ink_well.dart'
;
import
'ink_well.dart'
;
import
'theme.dart'
;
import
'theme.dart'
;
...
@@ -166,8 +167,9 @@ class ListItem extends StatelessWidget {
...
@@ -166,8 +167,9 @@ class ListItem extends StatelessWidget {
));
));
}
}
final
Widget
primaryLine
=
new
DefaultTextStyle
(
final
Widget
primaryLine
=
new
Animated
DefaultTextStyle
(
style:
_primaryTextStyle
(
context
),
style:
_primaryTextStyle
(
context
),
duration:
kThemeChangeDuration
,
child:
title
??
new
Container
()
child:
title
??
new
Container
()
);
);
Widget
center
=
primaryLine
;
Widget
center
=
primaryLine
;
...
@@ -177,8 +179,9 @@ class ListItem extends StatelessWidget {
...
@@ -177,8 +179,9 @@ class ListItem extends StatelessWidget {
crossAxisAlignment:
CrossAxisAlignment
.
start
,
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
<
Widget
>[
children:
<
Widget
>[
primaryLine
,
primaryLine
,
new
DefaultTextStyle
(
new
Animated
DefaultTextStyle
(
style:
_secondaryTextStyle
(
context
),
style:
_secondaryTextStyle
(
context
),
duration:
kThemeChangeDuration
,
child:
subtitle
child:
subtitle
)
)
]
]
...
...
packages/flutter/lib/src/material/material.dart
View file @
a5a34d97
...
@@ -202,8 +202,9 @@ class _MaterialState extends State<Material> {
...
@@ -202,8 +202,9 @@ class _MaterialState extends State<Material> {
Color
backgroundColor
=
_getBackgroundColor
(
context
);
Color
backgroundColor
=
_getBackgroundColor
(
context
);
Widget
contents
=
config
.
child
;
Widget
contents
=
config
.
child
;
if
(
contents
!=
null
)
{
if
(
contents
!=
null
)
{
contents
=
new
DefaultTextStyle
(
contents
=
new
Animated
DefaultTextStyle
(
style:
config
.
textStyle
??
Theme
.
of
(
context
).
textTheme
.
body1
,
style:
config
.
textStyle
??
Theme
.
of
(
context
).
textTheme
.
body1
,
duration:
kThemeChangeDuration
,
child:
contents
child:
contents
);
);
}
}
...
...
packages/flutter/lib/src/material/popup_menu.dart
View file @
a5a34d97
...
@@ -6,6 +6,7 @@ import 'dart:async';
...
@@ -6,6 +6,7 @@ import 'dart:async';
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'constants.dart'
;
import
'divider.dart'
;
import
'divider.dart'
;
import
'icon.dart'
;
import
'icon.dart'
;
import
'icons.dart'
;
import
'icons.dart'
;
...
@@ -90,8 +91,9 @@ class _PopupMenuItemState<T extends PopupMenuItem<dynamic>> extends State<T> {
...
@@ -90,8 +91,9 @@ class _PopupMenuItemState<T extends PopupMenuItem<dynamic>> extends State<T> {
if
(!
config
.
enabled
)
if
(!
config
.
enabled
)
style
=
style
.
copyWith
(
color:
theme
.
disabledColor
);
style
=
style
.
copyWith
(
color:
theme
.
disabledColor
);
Widget
item
=
new
DefaultTextStyle
(
Widget
item
=
new
Animated
DefaultTextStyle
(
style:
style
,
style:
style
,
duration:
kThemeChangeDuration
,
child:
new
Baseline
(
child:
new
Baseline
(
baseline:
config
.
height
-
_kBaselineOffsetFromBottom
,
baseline:
config
.
height
-
_kBaselineOffsetFromBottom
,
child:
buildChild
()
child:
buildChild
()
...
...
packages/flutter/lib/src/material/tabs.dart
View file @
a5a34d97
...
@@ -851,9 +851,9 @@ class _TabBarState<T> extends ScrollableState<TabBar<T>> implements TabBarSelect
...
@@ -851,9 +851,9 @@ class _TabBarState<T> extends ScrollableState<TabBar<T>> implements TabBarSelect
indicatorColor
=
Colors
.
white
;
indicatorColor
=
Colors
.
white
;
}
}
TextStyle
textStyle
=
themeData
.
primaryTextTheme
.
body2
;
final
TextStyle
textStyle
=
themeData
.
primaryTextTheme
.
body2
;
IconThemeData
iconTheme
=
themeData
.
primaryIconTheme
;
final
IconThemeData
iconTheme
=
themeData
.
primaryIconTheme
;
Color
textColor
=
themeData
.
primaryTextTheme
.
body2
.
color
.
withAlpha
(
0xB2
);
// 70% alpha
final
Color
textColor
=
themeData
.
primaryTextTheme
.
body2
.
color
.
withAlpha
(
0xB2
);
// 70% alpha
List
<
Widget
>
tabs
=
<
Widget
>[];
List
<
Widget
>
tabs
=
<
Widget
>[];
bool
textAndIcons
=
false
;
bool
textAndIcons
=
false
;
...
...
packages/flutter/lib/src/widgets/implicit_animations.dart
View file @
a5a34d97
...
@@ -48,6 +48,16 @@ class Matrix4Tween extends Tween<Matrix4> {
...
@@ -48,6 +48,16 @@ class Matrix4Tween extends Tween<Matrix4> {
}
}
}
}
/// An interpolation between two [TextStyle]s.
///
/// This will not work well if the styles don't set the same fields.
class
TextStyleTween
extends
Tween
<
TextStyle
>
{
TextStyleTween
({
TextStyle
begin
,
TextStyle
end
})
:
super
(
begin:
begin
,
end:
end
);
@override
TextStyle
lerp
(
double
t
)
=>
TextStyle
.
lerp
(
begin
,
end
,
t
);
}
/// An abstract widget for building widgets that gradually change their
/// An abstract widget for building widgets that gradually change their
/// values over a period of time.
/// values over a period of time.
abstract
class
ImplicitlyAnimatedWidget
extends
StatefulWidget
{
abstract
class
ImplicitlyAnimatedWidget
extends
StatefulWidget
{
...
@@ -504,3 +514,55 @@ class _AnimatedOpacityState extends AnimatedWidgetBaseState<AnimatedOpacity> {
...
@@ -504,3 +514,55 @@ class _AnimatedOpacityState extends AnimatedWidgetBaseState<AnimatedOpacity> {
);
);
}
}
}
}
/// Animated version of [DefaultTextStyle] which automatically
/// transitions the default text style (the text style to apply to
/// descendant [Text] widgets without explicit style) over a given
/// duration whenever the given style changes.
class
AnimatedDefaultTextStyle
extends
ImplicitlyAnimatedWidget
{
AnimatedDefaultTextStyle
({
Key
key
,
this
.
child
,
this
.
style
,
Curve
curve:
Curves
.
linear
,
Duration
duration
})
:
super
(
key:
key
,
curve:
curve
,
duration:
duration
)
{
assert
(
style
!=
null
);
assert
(
child
!=
null
);
}
/// The widget below this widget in the tree.
final
Widget
child
;
/// The target text style.
///
/// The text style must not be null.
final
TextStyle
style
;
@override
_AnimatedDefaultTextStyleState
createState
()
=>
new
_AnimatedDefaultTextStyleState
();
@override
void
debugFillDescription
(
List
<
String
>
description
)
{
super
.
debugFillDescription
(
description
);
'
$style
'
.
split
(
'
\n
'
).
forEach
(
description
.
add
);
}
}
class
_AnimatedDefaultTextStyleState
extends
AnimatedWidgetBaseState
<
AnimatedDefaultTextStyle
>
{
TextStyleTween
_style
;
@override
void
forEachTween
(
TweenVisitor
<
dynamic
>
visitor
)
{
// TODO(ianh): Use constructor tear-offs when it becomes possible
_style
=
visitor
(
_style
,
config
.
style
,
(
dynamic
value
)
=>
new
TextStyleTween
(
begin:
value
));
}
@override
Widget
build
(
BuildContext
context
)
{
return
new
DefaultTextStyle
(
style:
_style
.
evaluate
(
animation
),
child:
config
.
child
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment