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
f5dea932
Unverified
Commit
f5dea932
authored
Feb 05, 2018
by
Hans Muller
Committed by
GitHub
Feb 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Material button update (#14410)
parent
5b46e0a4
Changes
20
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1165 additions
and
376 deletions
+1165
-376
material.dart
packages/flutter/lib/material.dart
+1
-0
button.dart
packages/flutter/lib/src/material/button.dart
+211
-191
button_bar.dart
packages/flutter/lib/src/material/button_bar.dart
+1
-1
button_theme.dart
packages/flutter/lib/src/material/button_theme.dart
+254
-0
colors.dart
packages/flutter/lib/src/material/colors.dart
+12
-0
date_picker.dart
packages/flutter/lib/src/material/date_picker.dart
+1
-1
dialog.dart
packages/flutter/lib/src/material/dialog.dart
+1
-1
flat_button.dart
packages/flutter/lib/src/material/flat_button.dart
+197
-87
ink_ripple.dart
packages/flutter/lib/src/material/ink_ripple.dart
+3
-2
material.dart
packages/flutter/lib/src/material/material.dart
+11
-1
paginated_data_table.dart
packages/flutter/lib/src/material/paginated_data_table.dart
+1
-1
raised_button.dart
packages/flutter/lib/src/material/raised_button.dart
+267
-75
scaffold.dart
packages/flutter/lib/src/material/scaffold.dart
+1
-1
snack_bar.dart
packages/flutter/lib/src/material/snack_bar.dart
+1
-1
stepper.dart
packages/flutter/lib/src/material/stepper.dart
+1
-1
theme_data.dart
packages/flutter/lib/src/material/theme_data.dart
+17
-3
time_picker.dart
packages/flutter/lib/src/material/time_picker.dart
+1
-1
button_theme_test.dart
packages/flutter/test/material/button_theme_test.dart
+176
-0
buttons_test.dart
packages/flutter/test/material/buttons_test.dart
+5
-4
debug_test.dart
packages/flutter/test/material/debug_test.dart
+3
-5
No files found.
packages/flutter/lib/material.dart
View file @
f5dea932
...
...
@@ -24,6 +24,7 @@ export 'src/material/bottom_navigation_bar.dart';
export
'src/material/bottom_sheet.dart'
;
export
'src/material/button.dart'
;
export
'src/material/button_bar.dart'
;
export
'src/material/button_theme.dart'
;
export
'src/material/card.dart'
;
export
'src/material/checkbox.dart'
;
export
'src/material/checkbox_list_tile.dart'
;
...
...
packages/flutter/lib/src/material/button.dart
View file @
f5dea932
This diff is collapsed.
Click to expand it.
packages/flutter/lib/src/material/button_bar.dart
View file @
f5dea932
...
...
@@ -4,7 +4,7 @@
import
'package:flutter/widgets.dart'
;
import
'button.dart'
;
import
'button
_theme
.dart'
;
import
'dialog.dart'
;
import
'flat_button.dart'
;
import
'raised_button.dart'
;
...
...
packages/flutter/lib/src/material/button_theme.dart
0 → 100644
View file @
f5dea932
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/foundation.dart'
;
import
'package:flutter/widgets.dart'
;
import
'theme.dart'
;
/// Used with [ButtonTheme] and [ButtonThemeData] to define a button's base
/// colors, and the defaults for the button's minimum size, internal padding,
/// and shape.
///
/// See also:
///
/// * [RaisedButton], which styles itself based on the ambient [ButtonTheme].
/// * [FlatButton], which styles itself based on the ambient [ButtonTheme].
enum
ButtonTextTheme
{
/// Button text is black or white depending on [ThemeData.brightness].
normal
,
/// Button text is [ThemeData.accentColor].
accent
,
/// Button text is based on [ThemeData.primaryColor].
primary
,
}
/// Used with [ButtonThemeData] to configure the color and geometry of buttons.
///
/// A button theme can be specified as part of the overall Material theme
/// using [ThemeData.buttomTheme]. The Material theme's button theme data
/// can be overridden with [ButtonTheme].
///
/// The actual appearance of buttons depends on the button theme, the
/// button's enabled state, its elevation (if any) and the overall Material
/// theme.
///
/// See also:
///
/// * [FlatButton] and [RaisedButton], which are styled based on the
/// ambient button theme.
/// * [ThemeData.textTheme], `button` is the default text style for button labels.
/// * [ThemeData.buttonColor], the fill color for [RaisedButton]s unless the
/// button theme's text theme is [ButtonTextTheme.primary].
/// * [ThemeData.primaryColor], the fill or text color if a button theme's text
/// theme is [ButtonTextTheme.primary].
/// * [ThemeData.accentColor], the text color for buttons when button theme's
/// text theme is [ButtonTextTheme.accent].
/// * [ThemeData.disabled], the default text color for disabled buttons.
/// * [ThemeData.brightness], used to select contrasting text and fill colors.
/// * [ThemeData.highlightColor], a button [InkWell]'s default highlight color.
/// * [ThemeData.splashColor], a button [InkWell]'s default splash color.
/// * [RawMaterialButton], which can be used to configure a button that doesn't
/// depend on any inherited themes.
class
ButtonTheme
extends
InheritedWidget
{
/// Creates a button theme.
///
/// The [textTheme], [minWidth], and [height] arguments must not be null.
ButtonTheme
({
Key
key
,
ButtonTextTheme
textTheme:
ButtonTextTheme
.
normal
,
double
minWidth:
88.0
,
double
height:
36.0
,
EdgeInsetsGeometry
padding
,
ShapeBorder
shape
,
Widget
child
,
})
:
assert
(
textTheme
!=
null
),
assert
(
minWidth
!=
null
&&
minWidth
>=
0.0
),
assert
(
height
!=
null
&&
height
>=
0.0
),
data
=
new
ButtonThemeData
(
textTheme:
textTheme
,
minWidth:
minWidth
,
height:
height
,
padding:
padding
,
shape:
shape
,
),
super
(
key:
key
,
child:
child
);
/// Creates a button theme that is appropriate for button bars, as used in
/// dialog footers and in the headers of data tables.
///
/// This theme is denser, with a smaller [minWidth] and [padding], than the
/// default theme. Also, this theme uses [ButtonTextTheme.accent] rather than
/// [ButtonTextTheme.normal].
///
/// For best effect, the label of the button at the edge of the container
/// should have text that ends up wider than 64.0 pixels. This ensures that
/// the alignment of the text matches the alignment of the edge of the
/// container.
///
/// For example, buttons at the bottom of [Dialog] or [Card] widgets use this
/// button theme.
ButtonTheme
.
bar
({
Key
key
,
ButtonTextTheme
textTheme:
ButtonTextTheme
.
accent
,
double
minWidth:
64.0
,
double
height:
36.0
,
EdgeInsetsGeometry
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
8.0
),
ShapeBorder
shape
,
Widget
child
,
})
:
assert
(
textTheme
!=
null
),
assert
(
minWidth
!=
null
&&
minWidth
>=
0.0
),
assert
(
height
!=
null
&&
height
>=
0.0
),
data
=
new
ButtonThemeData
(
textTheme:
textTheme
,
minWidth:
minWidth
,
height:
height
,
padding:
padding
,
shape:
shape
,
),
super
(
key:
key
,
child:
child
);
/// Specifies the color and geometry of buttons.
final
ButtonThemeData
data
;
/// The closest instance of this class that encloses the given context.
///
/// Typical usage is as follows:
///
/// ```dart
/// ButtonThemeData theme = ButtonTheme.of(context);
/// ```
static
ButtonThemeData
of
(
BuildContext
context
)
{
final
ButtonTheme
result
=
context
.
inheritFromWidgetOfExactType
(
ButtonTheme
);
return
result
?.
data
??
Theme
.
of
(
context
).
buttonTheme
;
}
@override
bool
updateShouldNotify
(
ButtonTheme
oldTheme
)
=>
data
!=
oldTheme
.
data
;
}
/// Used with [ButtonTheme] to configure the color and geometry of buttons.
///
/// A button theme can be specified as part of the overall Material theme
/// using [ThemeData.buttomTheme]. The Material theme's button theme data
/// can be overridden with [ButtonTheme].
class
ButtonThemeData
{
/// Create a button theme object that can be used with [ButtonTheme]
/// or [ThemeData].
///
/// The [textTheme], [minWidth], and [height] parameters must not be null.
const
ButtonThemeData
({
this
.
textTheme
:
ButtonTextTheme
.
normal
,
this
.
minWidth
:
88.0
,
this
.
height
:
36.0
,
EdgeInsetsGeometry
padding
,
ShapeBorder
shape
,
})
:
assert
(
textTheme
!=
null
),
assert
(
minWidth
!=
null
&&
minWidth
>=
0.0
),
assert
(
height
!=
null
&&
height
>=
0.0
),
_padding
=
padding
,
_shape
=
shape
;
/// The minimum width for buttons.
///
/// The actual horizontal space allocated for a button's child is
/// at least this value less the theme's horizontal [padding].
///
/// Defaults to 88.0 logical pixels.
final
double
minWidth
;
/// The minimum height for buttons.
///
/// Defaults to 36.0 logical pixels.
final
double
height
;
/// Defines a button's base colors, and the defaults for the button's minimum
/// size, internal padding, and shape.
final
ButtonTextTheme
textTheme
;
/// Simply a convenience that returns [minWidth] and [height] as a
/// [BoxConstraints] object:
/// ```dart
/// return new BoxConstraints(
/// minWidth: minWidth,
/// minHeight: height,
/// );
/// ```
BoxConstraints
get
constraints
{
return
new
BoxConstraints
(
minWidth:
minWidth
,
minHeight:
height
,
);
}
/// Padding for a button's child (typically the button's label).
///
/// Defaults to 24.0 on the left and right if [textTheme] is
/// [ButtonTextTheme.primary], 16.0 on the left and right otherwise.
EdgeInsetsGeometry
get
padding
{
if
(
_padding
!=
null
)
return
_padding
;
switch
(
textTheme
)
{
case
ButtonTextTheme
.
normal
:
case
ButtonTextTheme
.
accent
:
return
const
EdgeInsets
.
symmetric
(
horizontal:
16.0
);
case
ButtonTextTheme
.
primary
:
return
const
EdgeInsets
.
symmetric
(
horizontal:
24.0
);
}
return
EdgeInsets
.
zero
;
}
final
EdgeInsetsGeometry
_padding
;
/// The shape of a button's material.
///
/// The button's highlight and splash are clipped to this shape. If the
/// button has an elevation, then its drop shadow is defined by this
/// shape as well.
///
/// Defaults to a rounded rectangle with circular corner radii of 4.0 if
/// [textTheme] is [ButtonTextTheme.primary], a rounded rectangle with
/// circular corner radii of 2.0 otherwise.
ShapeBorder
get
shape
{
if
(
_shape
!=
null
)
return
_shape
;
switch
(
textTheme
)
{
case
ButtonTextTheme
.
normal
:
case
ButtonTextTheme
.
accent
:
return
const
RoundedRectangleBorder
(
borderRadius:
const
BorderRadius
.
all
(
const
Radius
.
circular
(
2.0
)),
);
case
ButtonTextTheme
.
primary
:
return
const
RoundedRectangleBorder
(
borderRadius:
const
BorderRadius
.
all
(
const
Radius
.
circular
(
4.0
)),
);
}
return
const
RoundedRectangleBorder
();
}
final
ShapeBorder
_shape
;
@override
bool
operator
==(
dynamic
other
)
{
if
(
other
.
runtimeType
!=
runtimeType
)
return
false
;
final
ButtonThemeData
typedOther
=
other
;
return
textTheme
==
typedOther
.
textTheme
&&
minWidth
==
typedOther
.
minWidth
&&
height
==
typedOther
.
height
&&
padding
==
typedOther
.
padding
&&
shape
==
typedOther
.
shape
;
}
@override
int
get
hashCode
{
return
hashValues
(
textTheme
,
minWidth
,
height
,
padding
,
shape
,
);
}
}
packages/flutter/lib/src/material/colors.dart
View file @
f5dea932
...
...
@@ -336,6 +336,18 @@ class Colors {
/// but with different opacities.
static
const
Color
white30
=
const
Color
(
0x4DFFFFFF
);
/// White with 24% opacity.
///
/// 
///
/// Used for the splash color for filled buttons.
///
/// See also:
///
/// * [white, white70, white30, white10], which are variants on this color
/// but with different opacities.
static
const
Color
white24
=
const
Color
(
0x3DFFFFFF
);
/// White with 12% opacity.
///
/// 
...
...
packages/flutter/lib/src/material/date_picker.dart
View file @
f5dea932
...
...
@@ -10,8 +10,8 @@ import 'package:flutter/rendering.dart';
import
'package:flutter/services.dart'
;
import
'package:flutter/widgets.dart'
;
import
'button.dart'
;
import
'button_bar.dart'
;
import
'button_theme.dart'
;
import
'colors.dart'
;
import
'debug.dart'
;
import
'dialog.dart'
;
...
...
packages/flutter/lib/src/material/dialog.dart
View file @
f5dea932
...
...
@@ -7,8 +7,8 @@ import 'dart:async';
import
'package:flutter/foundation.dart'
;
import
'package:flutter/widgets.dart'
;
import
'button.dart'
;
import
'button_bar.dart'
;
import
'button_theme.dart'
;
import
'colors.dart'
;
import
'ink_well.dart'
;
import
'material.dart'
;
...
...
packages/flutter/lib/src/material/flat_button.dart
View file @
f5dea932
This diff is collapsed.
Click to expand it.
packages/flutter/lib/src/material/ink_ripple.dart
View file @
f5dea932
...
...
@@ -202,9 +202,10 @@ class InkRipple extends InteractiveInkFeature {
// Watch out: setting _fadeOutController's value to 1.0 would
// trigger a call to _handleAlphaStatusChanged() which would
// dispose _fadeOutController.
if
(
_fadeInController
.
value
>
0.0
)
{
final
double
_fadeOutValue
=
1.0
-
_fadeInController
.
value
;
if
(
_fadeOutValue
<
1.0
)
{
_fadeOutController
..
value
=
1.0
-
_fadeInController
.
v
alue
..
value
=
_fadeOutV
alue
..
animateTo
(
1.0
,
duration:
_kCancelDuration
);
}
}
...
...
packages/flutter/lib/src/material/material.dart
View file @
f5dea932
...
...
@@ -186,7 +186,7 @@ class Material extends StatefulWidget {
/// The z-coordinate at which to place this material. This controls the size
/// of the shadow below the material.
///
/// If this is non-zero, the contents of the
card
are clipped, because the
/// If this is non-zero, the contents of the
material
are clipped, because the
/// widget conceptually defines an independent printed piece of material.
///
/// Defaults to 0. Changing this value will cause the shadow to animate over
...
...
@@ -209,12 +209,21 @@ class Material extends StatefulWidget {
/// The typographical style to use for text within this material.
final
TextStyle
textStyle
;
/// Defines the material's shape as well its shadow.
///
/// If shape is non null, the [borderRadius] is ignored and the material's
/// clip boundary and shadow are defined by the shape.
///
/// A shadow is only displayed if the [elevation] is greater than
/// zero.
final
ShapeBorder
shape
;
/// If non-null, the corners of this box are rounded by this [BorderRadius].
/// Otherwise, the corners specified for the current [type] of material are
/// used.
///
/// If [shape] is non null then the border radius is ignored.
///
/// Must be null if [type] is [MaterialType.circle].
final
BorderRadius
borderRadius
;
...
...
@@ -242,6 +251,7 @@ class Material extends StatefulWidget {
description
.
add
(
new
DiagnosticsProperty
<
Color
>(
'color'
,
color
,
defaultValue:
null
));
description
.
add
(
new
DiagnosticsProperty
<
Color
>(
'shadowColor'
,
shadowColor
,
defaultValue:
const
Color
(
0xFF000000
)));
textStyle
?.
debugFillProperties
(
description
,
prefix:
'textStyle.'
);
description
.
add
(
new
DiagnosticsProperty
<
ShapeBorder
>(
'shape'
,
shape
,
defaultValue:
null
));
description
.
add
(
new
EnumProperty
<
BorderRadius
>(
'borderRadius'
,
borderRadius
,
defaultValue:
null
));
}
...
...
packages/flutter/lib/src/material/paginated_data_table.dart
View file @
f5dea932
...
...
@@ -8,8 +8,8 @@ import 'package:flutter/foundation.dart';
import
'package:flutter/widgets.dart'
;
import
'package:flutter/rendering.dart'
;
import
'button.dart'
;
import
'button_bar.dart'
;
import
'button_theme.dart'
;
import
'card.dart'
;
import
'data_table.dart'
;
import
'data_table_source.dart'
;
...
...
packages/flutter/lib/src/material/raised_button.dart
View file @
f5dea932
This diff is collapsed.
Click to expand it.
packages/flutter/lib/src/material/scaffold.dart
View file @
f5dea932
...
...
@@ -11,8 +11,8 @@ import 'package:flutter/widgets.dart';
import
'app_bar.dart'
;
import
'bottom_sheet.dart'
;
import
'button.dart'
;
import
'button_bar.dart'
;
import
'button_theme.dart'
;
import
'drawer.dart'
;
import
'flexible_space_bar.dart'
;
import
'material.dart'
;
...
...
packages/flutter/lib/src/material/snack_bar.dart
View file @
f5dea932
...
...
@@ -5,7 +5,7 @@
import
'package:flutter/foundation.dart'
;
import
'package:flutter/widgets.dart'
;
import
'button.dart'
;
import
'button
_theme
.dart'
;
import
'flat_button.dart'
;
import
'material.dart'
;
import
'scaffold.dart'
;
...
...
packages/flutter/lib/src/material/stepper.dart
View file @
f5dea932
...
...
@@ -5,7 +5,7 @@
import
'package:flutter/foundation.dart'
;
import
'package:flutter/widgets.dart'
;
import
'button.dart'
;
import
'button
_theme
.dart'
;
import
'colors.dart'
;
import
'debug.dart'
;
import
'flat_button.dart'
;
...
...
packages/flutter/lib/src/material/theme_data.dart
View file @
f5dea932
...
...
@@ -7,6 +7,7 @@ import 'dart:ui' show Color, hashValues;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/widgets.dart'
;
import
'button_theme.dart'
;
import
'colors.dart'
;
import
'ink_splash.dart'
;
import
'ink_well.dart'
show
InteractiveInkFeatureFactory
;
...
...
@@ -90,6 +91,7 @@ class ThemeData {
Color
unselectedWidgetColor
,
Color
disabledColor
,
Color
buttonColor
,
ButtonThemeData
buttonTheme
,
Color
secondaryHeaderColor
,
Color
textSelectionColor
,
Color
textSelectionHandleColor
,
...
...
@@ -128,6 +130,7 @@ class ThemeData {
unselectedWidgetColor
??=
isDark
?
Colors
.
white70
:
Colors
.
black54
;
disabledColor
??=
isDark
?
Colors
.
white30
:
Colors
.
black26
;
buttonColor
??=
isDark
?
primarySwatch
[
600
]
:
Colors
.
grey
[
300
];
buttonTheme
??=
const
ButtonThemeData
();
// Spec doesn't specify a dark theme secondaryHeaderColor, this is a guess.
secondaryHeaderColor
??=
isDark
?
Colors
.
grey
[
700
]
:
primarySwatch
[
50
];
textSelectionColor
??=
isDark
?
accentColor
:
primarySwatch
[
200
];
...
...
@@ -168,6 +171,7 @@ class ThemeData {
unselectedWidgetColor:
unselectedWidgetColor
,
disabledColor:
disabledColor
,
buttonColor:
buttonColor
,
buttonTheme:
buttonTheme
,
secondaryHeaderColor:
secondaryHeaderColor
,
textSelectionColor:
textSelectionColor
,
textSelectionHandleColor:
textSelectionHandleColor
,
...
...
@@ -210,6 +214,7 @@ class ThemeData {
@required
this
.
unselectedWidgetColor
,
@required
this
.
disabledColor
,
@required
this
.
buttonColor
,
@required
this
.
buttonTheme
,
@required
this
.
secondaryHeaderColor
,
@required
this
.
textSelectionColor
,
@required
this
.
textSelectionHandleColor
,
...
...
@@ -241,7 +246,7 @@ class ThemeData {
assert
(
selectedRowColor
!=
null
),
assert
(
unselectedWidgetColor
!=
null
),
assert
(
disabledColor
!=
null
),
assert
(
button
Color
!=
null
),
assert
(
button
Theme
!=
null
),
assert
(
secondaryHeaderColor
!=
null
),
assert
(
textSelectionColor
!=
null
),
assert
(
textSelectionHandleColor
!=
null
),
...
...
@@ -353,9 +358,13 @@ class ThemeData {
/// checked or unchecked).
final
Color
disabledColor
;
/// The default color of the [Material] used in [RaisedButton]s.
/// The default
fill
color of the [Material] used in [RaisedButton]s.
final
Color
buttonColor
;
/// Defines the default configuration of button widgets, like [RaisedButton]
/// and [FlatButton].
final
ButtonThemeData
buttonTheme
;
/// The color of the header of a [PaginatedDataTable] when there are selected rows.
// According to the spec for data tables:
// https://material.google.com/components/data-tables.html#data-tables-tables-within-cards
...
...
@@ -432,6 +441,7 @@ class ThemeData {
Color
unselectedWidgetColor
,
Color
disabledColor
,
Color
buttonColor
,
Color
buttonTheme
,
Color
secondaryHeaderColor
,
Color
textSelectionColor
,
Color
textSelectionHandleColor
,
...
...
@@ -466,6 +476,7 @@ class ThemeData {
unselectedWidgetColor:
unselectedWidgetColor
??
this
.
unselectedWidgetColor
,
disabledColor:
disabledColor
??
this
.
disabledColor
,
buttonColor:
buttonColor
??
this
.
buttonColor
,
buttonTheme:
buttonTheme
??
this
.
buttonTheme
,
secondaryHeaderColor:
secondaryHeaderColor
??
this
.
secondaryHeaderColor
,
textSelectionColor:
textSelectionColor
??
this
.
textSelectionColor
,
textSelectionHandleColor:
textSelectionHandleColor
??
this
.
textSelectionHandleColor
,
...
...
@@ -583,6 +594,7 @@ class ThemeData {
unselectedWidgetColor:
Color
.
lerp
(
a
.
unselectedWidgetColor
,
b
.
unselectedWidgetColor
,
t
),
disabledColor:
Color
.
lerp
(
a
.
disabledColor
,
b
.
disabledColor
,
t
),
buttonColor:
Color
.
lerp
(
a
.
buttonColor
,
b
.
buttonColor
,
t
),
buttonTheme:
t
<
0.5
?
a
.
buttonTheme
:
b
.
buttonTheme
,
secondaryHeaderColor:
Color
.
lerp
(
a
.
secondaryHeaderColor
,
b
.
secondaryHeaderColor
,
t
),
textSelectionColor:
Color
.
lerp
(
a
.
textSelectionColor
,
b
.
textSelectionColor
,
t
),
textSelectionHandleColor:
Color
.
lerp
(
a
.
textSelectionHandleColor
,
b
.
textSelectionHandleColor
,
t
),
...
...
@@ -623,6 +635,7 @@ class ThemeData {
(
otherData
.
unselectedWidgetColor
==
unselectedWidgetColor
)
&&
(
otherData
.
disabledColor
==
disabledColor
)
&&
(
otherData
.
buttonColor
==
buttonColor
)
&&
(
otherData
.
buttonTheme
==
buttonTheme
)
&&
(
otherData
.
secondaryHeaderColor
==
secondaryHeaderColor
)
&&
(
otherData
.
textSelectionColor
==
textSelectionColor
)
&&
(
otherData
.
textSelectionHandleColor
==
textSelectionHandleColor
)
&&
...
...
@@ -660,12 +673,13 @@ class ThemeData {
unselectedWidgetColor
,
disabledColor
,
buttonColor
,
buttonTheme
,
secondaryHeaderColor
,
textSelectionColor
,
textSelectionHandleColor
,
backgroundColor
,
accentColor
,
hashValues
(
// Too many values.
accentColor
,
accentColorBrightness
,
indicatorColor
,
dialogBackgroundColor
,
...
...
packages/flutter/lib/src/material/time_picker.dart
View file @
f5dea932
...
...
@@ -10,8 +10,8 @@ import 'package:flutter/rendering.dart';
import
'package:flutter/services.dart'
;
import
'package:flutter/widgets.dart'
;
import
'button.dart'
;
import
'button_bar.dart'
;
import
'button_theme.dart'
;
import
'colors.dart'
;
import
'dialog.dart'
;
import
'feedback.dart'
;
...
...
packages/flutter/test/material/button_theme_test.dart
0 → 100644
View file @
f5dea932
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
test
(
'ButtonThemeData defaults'
,
()
{
final
ButtonThemeData
theme
=
const
ButtonThemeData
();
expect
(
theme
.
textTheme
,
ButtonTextTheme
.
normal
);
expect
(
theme
.
constraints
,
const
BoxConstraints
(
minWidth:
88.0
,
minHeight:
36.0
));
expect
(
theme
.
padding
,
const
EdgeInsets
.
symmetric
(
horizontal:
16.0
));
expect
(
theme
.
shape
,
const
RoundedRectangleBorder
(
borderRadius:
const
BorderRadius
.
all
(
const
Radius
.
circular
(
2.0
)),
));
});
test
(
'ButtonThemeData default overrides'
,
()
{
final
ButtonThemeData
theme
=
const
ButtonThemeData
(
textTheme:
ButtonTextTheme
.
primary
,
minWidth:
100.0
,
height:
200.0
,
padding:
EdgeInsets
.
zero
,
shape:
const
RoundedRectangleBorder
(),
);
expect
(
theme
.
textTheme
,
ButtonTextTheme
.
primary
);
expect
(
theme
.
constraints
,
const
BoxConstraints
(
minWidth:
100.0
,
minHeight:
200.0
));
expect
(
theme
.
padding
,
EdgeInsets
.
zero
);
expect
(
theme
.
shape
,
const
RoundedRectangleBorder
());
});
testWidgets
(
'ButtonTheme defaults'
,
(
WidgetTester
tester
)
async
{
ButtonTextTheme
textTheme
;
BoxConstraints
constraints
;
EdgeInsets
padding
;
ShapeBorder
shape
;
await
tester
.
pumpWidget
(
new
ButtonTheme
(
child:
new
Builder
(
builder:
(
BuildContext
context
)
{
final
ButtonThemeData
theme
=
ButtonTheme
.
of
(
context
);
textTheme
=
theme
.
textTheme
;
constraints
=
theme
.
constraints
;
padding
=
theme
.
padding
;
shape
=
theme
.
shape
;
return
new
Container
(
alignment:
Alignment
.
topLeft
,
child:
const
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
const
FlatButton
(
onPressed:
null
,
child:
const
Text
(
'b'
),
// intrinsic width < minimum width
),
),
);
},
),
),
);
expect
(
textTheme
,
ButtonTextTheme
.
normal
);
expect
(
constraints
,
const
BoxConstraints
(
minWidth:
88.0
,
minHeight:
36.0
));
expect
(
padding
,
const
EdgeInsets
.
symmetric
(
horizontal:
16.0
));
expect
(
shape
,
const
RoundedRectangleBorder
(
borderRadius:
const
BorderRadius
.
all
(
const
Radius
.
circular
(
2.0
)),
));
expect
(
tester
.
widget
<
Material
>(
find
.
byType
(
Material
)).
shape
,
shape
);
expect
(
tester
.
getSize
(
find
.
byType
(
Material
)),
const
Size
(
88.0
,
36.0
));
});
testWidgets
(
'Theme buttonTheme defaults'
,
(
WidgetTester
tester
)
async
{
final
ThemeData
lightTheme
=
new
ThemeData
.
light
();
ButtonTextTheme
textTheme
;
BoxConstraints
constraints
;
EdgeInsets
padding
;
ShapeBorder
shape
;
await
tester
.
pumpWidget
(
new
Theme
(
data:
lightTheme
.
copyWith
(
disabledColor:
const
Color
(
0xFF00FF00
),
// disabled RaisedButton fill color
textTheme:
lightTheme
.
textTheme
.
copyWith
(
button:
lightTheme
.
textTheme
.
button
.
copyWith
(
// The button's height will match because there's no
// vertical padding by default
fontSize:
48.0
,
),
),
),
child:
new
Builder
(
builder:
(
BuildContext
context
)
{
final
ButtonThemeData
theme
=
ButtonTheme
.
of
(
context
);
textTheme
=
theme
.
textTheme
;
constraints
=
theme
.
constraints
;
padding
=
theme
.
padding
;
shape
=
theme
.
shape
;
return
new
Container
(
alignment:
Alignment
.
topLeft
,
child:
const
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
const
RaisedButton
(
onPressed:
null
,
child:
const
Text
(
'b'
),
// intrinsic width < minimum width
),
),
);
},
),
),
);
expect
(
textTheme
,
ButtonTextTheme
.
normal
);
expect
(
constraints
,
const
BoxConstraints
(
minWidth:
88.0
,
minHeight:
36.0
));
expect
(
padding
,
const
EdgeInsets
.
symmetric
(
horizontal:
16.0
));
expect
(
shape
,
const
RoundedRectangleBorder
(
borderRadius:
const
BorderRadius
.
all
(
const
Radius
.
circular
(
2.0
)),
));
expect
(
tester
.
widget
<
Material
>(
find
.
byType
(
Material
)).
shape
,
shape
);
expect
(
tester
.
widget
<
Material
>(
find
.
byType
(
Material
)).
color
,
const
Color
(
0xFF00FF00
));
expect
(
tester
.
getSize
(
find
.
byType
(
Material
)),
const
Size
(
88.0
,
48.0
));
});
testWidgets
(
'Theme buttonTheme ButtonTheme overrides'
,
(
WidgetTester
tester
)
async
{
ButtonTextTheme
textTheme
;
BoxConstraints
constraints
;
EdgeInsets
padding
;
ShapeBorder
shape
;
await
tester
.
pumpWidget
(
new
Theme
(
data:
new
ThemeData
.
light
().
copyWith
(
buttonColor:
const
Color
(
0xFF00FF00
),
// enabled RaisedButton fill color
),
child:
new
ButtonTheme
(
textTheme:
ButtonTextTheme
.
primary
,
minWidth:
100.0
,
height:
200.0
,
padding:
EdgeInsets
.
zero
,
shape:
const
RoundedRectangleBorder
(),
child:
new
Builder
(
builder:
(
BuildContext
context
)
{
final
ButtonThemeData
theme
=
ButtonTheme
.
of
(
context
);
textTheme
=
theme
.
textTheme
;
constraints
=
theme
.
constraints
;
padding
=
theme
.
padding
;
shape
=
theme
.
shape
;
return
new
Container
(
alignment:
Alignment
.
topLeft
,
child:
new
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
new
RaisedButton
(
onPressed:
()
{
},
child:
const
Text
(
'b'
),
// intrinsic width < minimum width
),
),
);
},
),
),
),
);
expect
(
textTheme
,
ButtonTextTheme
.
primary
);
expect
(
constraints
,
const
BoxConstraints
(
minWidth:
100.0
,
minHeight:
200.0
));
expect
(
padding
,
EdgeInsets
.
zero
);
expect
(
shape
,
const
RoundedRectangleBorder
());
expect
(
tester
.
widget
<
Material
>(
find
.
byType
(
Material
)).
shape
,
shape
);
expect
(
tester
.
widget
<
Material
>(
find
.
byType
(
Material
)).
color
,
const
Color
(
0xFF00FF00
));
expect
(
tester
.
getSize
(
find
.
byType
(
Material
)),
const
Size
(
100.0
,
200.0
));
});
}
packages/flutter/test/material/buttons_test.dart
View file @
f5dea932
...
...
@@ -203,8 +203,9 @@ void main() {
expect
(
Material
.
of
(
tester
.
element
(
find
.
byType
(
MaterialButton
))),
paints
..
clipRRect
(
rrect:
new
RRect
.
fromLTRBR
(
356.0
,
282.0
,
444.0
,
318.0
,
const
Radius
.
circular
(
2.0
)))
..
circle
(
color:
directSplashColor
)
..
r
r
ect
(
color:
directHighlightColor
)
..
rect
(
color:
directHighlightColor
)
);
const
Color
themeSplashColor1
=
const
Color
(
0xFF001100
);
...
...
@@ -234,8 +235,9 @@ void main() {
expect
(
Material
.
of
(
tester
.
element
(
find
.
byType
(
MaterialButton
))),
paints
..
clipRRect
(
rrect:
new
RRect
.
fromLTRBR
(
356.0
,
282.0
,
444.0
,
318.0
,
const
Radius
.
circular
(
2.0
)))
..
circle
(
color:
themeSplashColor1
)
..
r
r
ect
(
color:
themeHighlightColor1
)
..
rect
(
color:
themeHighlightColor1
)
);
const
Color
themeSplashColor2
=
const
Color
(
0xFF002200
);
...
...
@@ -258,7 +260,7 @@ void main() {
Material
.
of
(
tester
.
element
(
find
.
byType
(
MaterialButton
))),
paints
..
circle
(
color:
themeSplashColor2
)
..
r
r
ect
(
color:
themeHighlightColor2
)
..
rect
(
color:
themeHighlightColor2
)
);
await
gesture
.
up
();
...
...
@@ -342,5 +344,4 @@ void main() {
semantics
.
dispose
();
});
}
packages/flutter/test/material/debug_test.dart
View file @
f5dea932
...
...
@@ -7,12 +7,10 @@ import 'package:flutter_test/flutter_test.dart';
void
main
(
)
{
testWidgets
(
'debugCheckHasMaterial control test'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
FlatButton
(
onPressed:
null
,
child:
const
Text
(
'Go'
),
));
await
tester
.
pumpWidget
(
const
ListTile
());
final
dynamic
exception
=
tester
.
takeException
();
expect
(
exception
,
isFlutterError
);
expect
(
exception
.
toString
(),
endsWith
(
':
\n
FlatButton(disabled)
\n
[root]'
));
expect
(
exception
.
toString
(),
startsWith
(
'No Material widget found.'
));
expect
(
exception
.
toString
(),
endsWith
(
':
\n
ListTile
\n
The ancestors of this widget were:
\n
[root]'
));
});
}
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