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
677f218e
Unverified
Commit
677f218e
authored
Jan 20, 2018
by
Hans Muller
Committed by
GitHub
Jan 20, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added InputDecorationTheme (#14177)
parent
38ce59f0
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
539 additions
and
61 deletions
+539
-61
input_border.dart
packages/flutter/lib/src/material/input_border.dart
+44
-0
input_decorator.dart
packages/flutter/lib/src/material/input_decorator.dart
+238
-41
text_field.dart
packages/flutter/lib/src/material/text_field.dart
+4
-2
text_form_field.dart
packages/flutter/lib/src/material/text_form_field.dart
+4
-1
theme_data.dart
packages/flutter/lib/src/material/theme_data.dart
+17
-0
input_decorator_test.dart
packages/flutter/test/material/input_decorator_test.dart
+232
-17
No files found.
packages/flutter/lib/src/material/input_border.dart
View file @
677f218e
...
...
@@ -28,6 +28,13 @@ import 'package:flutter/widgets.dart';
/// rounded rectangle around the input decorator's container.
/// * [InputDecoration], which is used to configure an [InputDecorator].
abstract
class
InputBorder
extends
ShapeBorder
{
/// No input border.
///
/// Use this value with [InputDecoration.border] to specify that no border
/// should be drawn. The [InputDecoration.collapsed] constructor sets
/// its border to this value.
static
const
InputBorder
none
=
const
_NoInputBorder
();
/// Creates a border for an [InputDecorator].
///
/// The [borderSide] parameter must not be null. Applications typically do
...
...
@@ -72,6 +79,43 @@ abstract class InputBorder extends ShapeBorder {
});
}
// Used to create the InputBorder.none singleton.
class
_NoInputBorder
extends
InputBorder
{
const
_NoInputBorder
()
:
super
(
borderSide:
BorderSide
.
none
);
@override
_NoInputBorder
copyWith
({
BorderSide
borderSide
})
=>
const
_NoInputBorder
();
@override
bool
get
isOutline
=>
false
;
@override
EdgeInsetsGeometry
get
dimensions
=>
EdgeInsets
.
zero
;
@override
_NoInputBorder
scale
(
double
t
)
=>
const
_NoInputBorder
();
@override
Path
getInnerPath
(
Rect
rect
,
{
TextDirection
textDirection
})
{
return
new
Path
()..
addRect
(
rect
);
}
@override
Path
getOuterPath
(
Rect
rect
,
{
TextDirection
textDirection
})
{
return
new
Path
()..
addRect
(
rect
);
}
@override
void
paint
(
Canvas
canvas
,
Rect
rect
,
{
double
gapStart
,
double
gapExtent:
0.0
,
double
gapPercentage:
0.0
,
TextDirection
textDirection
,
})
{
// Do not paint.
}
}
/// Draws a horizontal line at the bottom of an [InputDecorator]'s container.
///
/// The input decorator's "container" is the optionally filled area above the
...
...
packages/flutter/lib/src/material/input_decorator.dart
View file @
677f218e
This diff is collapsed.
Click to expand it.
packages/flutter/lib/src/material/text_field.dart
View file @
677f218e
...
...
@@ -296,10 +296,12 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
&&
widget
.
decoration
.
counterText
==
null
;
InputDecoration
_getEffectiveDecoration
()
{
final
InputDecoration
effectiveDecoration
=
(
widget
.
decoration
??
const
InputDecoration
())
.
applyDefaults
(
Theme
.
of
(
context
).
inputDecorationTheme
);
if
(!
needsCounter
)
return
widget
.
d
ecoration
;
return
effectiveD
ecoration
;
final
InputDecoration
effectiveDecoration
=
widget
?.
decoration
??
const
InputDecoration
();
final
String
counterText
=
'
${_effectiveController.value.text.runes.length}
/
${widget.maxLength}
'
;
if
(
_effectiveController
.
value
.
text
.
runes
.
length
>
widget
.
maxLength
)
{
final
ThemeData
themeData
=
Theme
.
of
(
context
);
...
...
packages/flutter/lib/src/material/text_form_field.dart
View file @
677f218e
...
...
@@ -7,6 +7,7 @@ import 'package:flutter/widgets.dart';
import
'input_decorator.dart'
;
import
'text_field.dart'
;
import
'theme.dart'
;
/// A [FormField] that contains a [TextField].
///
...
...
@@ -71,10 +72,12 @@ class TextFormField extends FormField<String> {
validator:
validator
,
builder:
(
FormFieldState
<
String
>
field
)
{
final
_TextFormFieldState
state
=
field
;
final
InputDecoration
effectiveDecoration
=
(
decoration
??
const
InputDecoration
())
.
applyDefaults
(
Theme
.
of
(
field
.
context
).
inputDecorationTheme
);
return
new
TextField
(
controller:
state
.
_effectiveController
,
focusNode:
focusNode
,
decoration:
d
ecoration
.
copyWith
(
errorText:
field
.
errorText
),
decoration:
effectiveD
ecoration
.
copyWith
(
errorText:
field
.
errorText
),
keyboardType:
keyboardType
,
style:
style
,
textAlign:
textAlign
,
...
...
packages/flutter/lib/src/material/theme_data.dart
View file @
677f218e
...
...
@@ -10,6 +10,7 @@ import 'package:flutter/widgets.dart';
import
'colors.dart'
;
import
'ink_splash.dart'
;
import
'ink_well.dart'
show
InteractiveInkFeatureFactory
;
import
'input_decorator.dart'
;
import
'typography.dart'
;
/// Describes the contrast needs of a color.
...
...
@@ -101,6 +102,7 @@ class ThemeData {
TextTheme
textTheme
,
TextTheme
primaryTextTheme
,
TextTheme
accentTextTheme
,
InputDecorationTheme
inputDecorationTheme
,
IconThemeData
iconTheme
,
IconThemeData
primaryIconTheme
,
IconThemeData
accentIconTheme
,
...
...
@@ -135,6 +137,7 @@ class ThemeData {
indicatorColor
??=
accentColor
==
primaryColor
?
Colors
.
white
:
accentColor
;
hintColor
??=
isDark
?
const
Color
(
0x42FFFFFF
)
:
const
Color
(
0x4C000000
);
errorColor
??=
Colors
.
red
[
700
];
inputDecorationTheme
??=
const
InputDecorationTheme
();
iconTheme
??=
isDark
?
const
IconThemeData
(
color:
Colors
.
white
)
:
const
IconThemeData
(
color:
Colors
.
black
);
primaryIconTheme
??=
primaryIsDark
?
const
IconThemeData
(
color:
Colors
.
white
)
:
const
IconThemeData
(
color:
Colors
.
black
);
accentIconTheme
??=
accentIsDark
?
const
IconThemeData
(
color:
Colors
.
white
)
:
const
IconThemeData
(
color:
Colors
.
black
);
...
...
@@ -176,6 +179,7 @@ class ThemeData {
textTheme:
textTheme
,
primaryTextTheme:
primaryTextTheme
,
accentTextTheme:
accentTextTheme
,
inputDecorationTheme:
inputDecorationTheme
,
iconTheme:
iconTheme
,
primaryIconTheme:
primaryIconTheme
,
accentIconTheme:
accentIconTheme
,
...
...
@@ -217,6 +221,7 @@ class ThemeData {
@required
this
.
textTheme
,
@required
this
.
primaryTextTheme
,
@required
this
.
accentTextTheme
,
@required
this
.
inputDecorationTheme
,
@required
this
.
iconTheme
,
@required
this
.
primaryIconTheme
,
@required
this
.
accentIconTheme
,
...
...
@@ -248,6 +253,7 @@ class ThemeData {
assert
(
textTheme
!=
null
),
assert
(
primaryTextTheme
!=
null
),
assert
(
accentTextTheme
!=
null
),
assert
(
inputDecorationTheme
!=
null
),
assert
(
iconTheme
!=
null
),
assert
(
primaryIconTheme
!=
null
),
assert
(
accentIconTheme
!=
null
),
...
...
@@ -388,6 +394,12 @@ class ThemeData {
/// A text theme that contrasts with the accent color.
final
TextTheme
accentTextTheme
;
/// The default [InputDecoration] values for [InputDecorator], [TextField],
/// and [TextFormField] are based on this theme.
///
/// See [InputDecoration.applyDefaults].
final
InputDecorationTheme
inputDecorationTheme
;
/// An icon theme that contrasts with the card and canvas colors.
final
IconThemeData
iconTheme
;
...
...
@@ -431,6 +443,7 @@ class ThemeData {
TextTheme
textTheme
,
TextTheme
primaryTextTheme
,
TextTheme
accentTextTheme
,
InputDecorationTheme
inputDecorationTheme
,
IconThemeData
iconTheme
,
IconThemeData
primaryIconTheme
,
IconThemeData
accentIconTheme
,
...
...
@@ -464,6 +477,7 @@ class ThemeData {
textTheme:
textTheme
??
this
.
textTheme
,
primaryTextTheme:
primaryTextTheme
??
this
.
primaryTextTheme
,
accentTextTheme:
accentTextTheme
??
this
.
accentTextTheme
,
inputDecorationTheme:
inputDecorationTheme
??
this
.
inputDecorationTheme
,
iconTheme:
iconTheme
??
this
.
iconTheme
,
primaryIconTheme:
primaryIconTheme
??
this
.
primaryIconTheme
,
accentIconTheme:
accentIconTheme
??
this
.
accentIconTheme
,
...
...
@@ -582,6 +596,7 @@ class ThemeData {
textTheme:
TextTheme
.
lerp
(
a
.
textTheme
,
b
.
textTheme
,
t
),
primaryTextTheme:
TextTheme
.
lerp
(
a
.
primaryTextTheme
,
b
.
primaryTextTheme
,
t
),
accentTextTheme:
TextTheme
.
lerp
(
a
.
accentTextTheme
,
b
.
accentTextTheme
,
t
),
inputDecorationTheme:
t
<
0.5
?
a
.
inputDecorationTheme
:
b
.
inputDecorationTheme
,
iconTheme:
IconThemeData
.
lerp
(
a
.
iconTheme
,
b
.
iconTheme
,
t
),
primaryIconTheme:
IconThemeData
.
lerp
(
a
.
primaryIconTheme
,
b
.
primaryIconTheme
,
t
),
accentIconTheme:
IconThemeData
.
lerp
(
a
.
accentIconTheme
,
b
.
accentIconTheme
,
t
),
...
...
@@ -621,6 +636,7 @@ class ThemeData {
(
otherData
.
textTheme
==
textTheme
)
&&
(
otherData
.
primaryTextTheme
==
primaryTextTheme
)
&&
(
otherData
.
accentTextTheme
==
accentTextTheme
)
&&
(
otherData
.
inputDecorationTheme
==
inputDecorationTheme
)
&&
(
otherData
.
iconTheme
==
iconTheme
)
&&
(
otherData
.
primaryIconTheme
==
primaryIconTheme
)
&&
(
otherData
.
accentIconTheme
==
accentIconTheme
)
&&
...
...
@@ -659,6 +675,7 @@ class ThemeData {
primaryTextTheme
,
accentTextTheme
,
iconTheme
,
inputDecorationTheme
,
primaryIconTheme
,
accentIconTheme
,
platform
,
...
...
packages/flutter/test/material/input_decorator_test.dart
View file @
677f218e
This diff is collapsed.
Click to expand it.
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