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
500981fe
Commit
500981fe
authored
Jan 03, 2017
by
lequem
Committed by
Adam Barth
Jan 03, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make dialog background color configurable (#7320) (#7323)
parent
2bb93db2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
9 deletions
+56
-9
AUTHORS
AUTHORS
+1
-0
dialog.dart
packages/flutter/lib/src/material/dialog.dart
+1
-9
theme_data.dart
packages/flutter/lib/src/material/theme_data.dart
+13
-0
dialog_test.dart
packages/flutter/test/material/dialog_test.dart
+41
-0
No files found.
AUTHORS
View file @
500981fe
...
@@ -13,3 +13,4 @@ Raju Bitter <rajubitter@gmail.com>
...
@@ -13,3 +13,4 @@ Raju Bitter <rajubitter@gmail.com>
Michael Beckler <mcbeckler@gmail.com>
Michael Beckler <mcbeckler@gmail.com>
Alexandre Ardhuin <alexandre.ardhuin@gmail.com>
Alexandre Ardhuin <alexandre.ardhuin@gmail.com>
Luke Freeman <luke@goposse.com>
Luke Freeman <luke@goposse.com>
Vincent Le Quéméner <eu.lequem@gmail.com>
packages/flutter/lib/src/material/dialog.dart
View file @
500981fe
...
@@ -37,15 +37,7 @@ class Dialog extends StatelessWidget {
...
@@ -37,15 +37,7 @@ class Dialog extends StatelessWidget {
final
Widget
child
;
final
Widget
child
;
Color
_getColor
(
BuildContext
context
)
{
Color
_getColor
(
BuildContext
context
)
{
Brightness
brightness
=
Theme
.
of
(
context
).
brightness
;
return
Theme
.
of
(
context
).
dialogBackgroundColor
;
assert
(
brightness
!=
null
);
switch
(
brightness
)
{
case
Brightness
.
light
:
return
Colors
.
white
;
case
Brightness
.
dark
:
return
Colors
.
grey
[
800
];
}
return
null
;
}
}
@override
@override
...
...
packages/flutter/lib/src/material/theme_data.dart
View file @
500981fe
...
@@ -89,6 +89,7 @@ class ThemeData {
...
@@ -89,6 +89,7 @@ class ThemeData {
Color
textSelectionColor
,
Color
textSelectionColor
,
Color
textSelectionHandleColor
,
Color
textSelectionHandleColor
,
Color
backgroundColor
,
Color
backgroundColor
,
Color
dialogBackgroundColor
,
Color
indicatorColor
,
Color
indicatorColor
,
Color
hintColor
,
Color
hintColor
,
Color
errorColor
,
Color
errorColor
,
...
@@ -124,6 +125,7 @@ class ThemeData {
...
@@ -124,6 +125,7 @@ class ThemeData {
textSelectionColor
??=
isDark
?
accentColor
:
primarySwatch
[
200
];
textSelectionColor
??=
isDark
?
accentColor
:
primarySwatch
[
200
];
textSelectionHandleColor
??=
isDark
?
Colors
.
tealAccent
[
400
]
:
primarySwatch
[
300
];
textSelectionHandleColor
??=
isDark
?
Colors
.
tealAccent
[
400
]
:
primarySwatch
[
300
];
backgroundColor
??=
isDark
?
Colors
.
grey
[
700
]
:
primarySwatch
[
200
];
backgroundColor
??=
isDark
?
Colors
.
grey
[
700
]
:
primarySwatch
[
200
];
dialogBackgroundColor
??=
isDark
?
Colors
.
grey
[
800
]
:
Colors
.
white
;
indicatorColor
??=
accentColor
==
primaryColor
?
Colors
.
white
:
accentColor
;
indicatorColor
??=
accentColor
==
primaryColor
?
Colors
.
white
:
accentColor
;
hintColor
??=
isDark
?
const
Color
(
0x42FFFFFF
)
:
const
Color
(
0x4C000000
);
hintColor
??=
isDark
?
const
Color
(
0x42FFFFFF
)
:
const
Color
(
0x4C000000
);
errorColor
??=
Colors
.
red
[
700
];
errorColor
??=
Colors
.
red
[
700
];
...
@@ -155,6 +157,7 @@ class ThemeData {
...
@@ -155,6 +157,7 @@ class ThemeData {
textSelectionColor:
textSelectionColor
,
textSelectionColor:
textSelectionColor
,
textSelectionHandleColor:
textSelectionHandleColor
,
textSelectionHandleColor:
textSelectionHandleColor
,
backgroundColor:
backgroundColor
,
backgroundColor:
backgroundColor
,
dialogBackgroundColor:
dialogBackgroundColor
,
indicatorColor:
indicatorColor
,
indicatorColor:
indicatorColor
,
hintColor:
hintColor
,
hintColor:
hintColor
,
errorColor:
errorColor
,
errorColor:
errorColor
,
...
@@ -194,6 +197,7 @@ class ThemeData {
...
@@ -194,6 +197,7 @@ class ThemeData {
this
.
textSelectionColor
,
this
.
textSelectionColor
,
this
.
textSelectionHandleColor
,
this
.
textSelectionHandleColor
,
this
.
backgroundColor
,
this
.
backgroundColor
,
this
.
dialogBackgroundColor
,
this
.
indicatorColor
,
this
.
indicatorColor
,
this
.
hintColor
,
this
.
hintColor
,
this
.
errorColor
,
this
.
errorColor
,
...
@@ -212,6 +216,7 @@ class ThemeData {
...
@@ -212,6 +216,7 @@ class ThemeData {
assert
(
accentColorBrightness
!=
null
);
assert
(
accentColorBrightness
!=
null
);
assert
(
canvasColor
!=
null
);
assert
(
canvasColor
!=
null
);
assert
(
scaffoldBackgroundColor
!=
null
);
assert
(
scaffoldBackgroundColor
!=
null
);
assert
(
dialogBackgroundColor
!=
null
);
assert
(
cardColor
!=
null
);
assert
(
cardColor
!=
null
);
assert
(
dividerColor
!=
null
);
assert
(
dividerColor
!=
null
);
assert
(
highlightColor
!=
null
);
assert
(
highlightColor
!=
null
);
...
@@ -327,6 +332,9 @@ class ThemeData {
...
@@ -327,6 +332,9 @@ class ThemeData {
/// remaining part of a progress bar.
/// remaining part of a progress bar.
final
Color
backgroundColor
;
final
Color
backgroundColor
;
/// The background color of [Dialog] elements.
final
Color
dialogBackgroundColor
;
/// The color of the selected tab indicator in a tab bar.
/// The color of the selected tab indicator in a tab bar.
final
Color
indicatorColor
;
final
Color
indicatorColor
;
...
@@ -381,6 +389,7 @@ class ThemeData {
...
@@ -381,6 +389,7 @@ class ThemeData {
Color
textSelectionColor
,
Color
textSelectionColor
,
Color
textSelectionHandleColor
,
Color
textSelectionHandleColor
,
Color
backgroundColor
,
Color
backgroundColor
,
Color
dialogBackgroundColor
,
Color
indicatorColor
,
Color
indicatorColor
,
Color
hintColor
,
Color
hintColor
,
Color
errorColor
,
Color
errorColor
,
...
@@ -412,6 +421,7 @@ class ThemeData {
...
@@ -412,6 +421,7 @@ class ThemeData {
textSelectionColor:
textSelectionColor
??
this
.
textSelectionColor
,
textSelectionColor:
textSelectionColor
??
this
.
textSelectionColor
,
textSelectionHandleColor:
textSelectionHandleColor
??
this
.
textSelectionHandleColor
,
textSelectionHandleColor:
textSelectionHandleColor
??
this
.
textSelectionHandleColor
,
backgroundColor:
backgroundColor
??
this
.
backgroundColor
,
backgroundColor:
backgroundColor
??
this
.
backgroundColor
,
dialogBackgroundColor:
dialogBackgroundColor
??
this
.
dialogBackgroundColor
,
indicatorColor:
indicatorColor
??
this
.
indicatorColor
,
indicatorColor:
indicatorColor
??
this
.
indicatorColor
,
hintColor:
hintColor
??
this
.
hintColor
,
hintColor:
hintColor
??
this
.
hintColor
,
errorColor:
errorColor
??
this
.
errorColor
,
errorColor:
errorColor
??
this
.
errorColor
,
...
@@ -445,6 +455,7 @@ class ThemeData {
...
@@ -445,6 +455,7 @@ class ThemeData {
textSelectionColor:
Color
.
lerp
(
begin
.
textSelectionColor
,
end
.
textSelectionColor
,
t
),
textSelectionColor:
Color
.
lerp
(
begin
.
textSelectionColor
,
end
.
textSelectionColor
,
t
),
textSelectionHandleColor:
Color
.
lerp
(
begin
.
textSelectionHandleColor
,
end
.
textSelectionHandleColor
,
t
),
textSelectionHandleColor:
Color
.
lerp
(
begin
.
textSelectionHandleColor
,
end
.
textSelectionHandleColor
,
t
),
backgroundColor:
Color
.
lerp
(
begin
.
backgroundColor
,
end
.
backgroundColor
,
t
),
backgroundColor:
Color
.
lerp
(
begin
.
backgroundColor
,
end
.
backgroundColor
,
t
),
dialogBackgroundColor:
Color
.
lerp
(
begin
.
dialogBackgroundColor
,
end
.
dialogBackgroundColor
,
t
),
accentColor:
Color
.
lerp
(
begin
.
accentColor
,
end
.
accentColor
,
t
),
accentColor:
Color
.
lerp
(
begin
.
accentColor
,
end
.
accentColor
,
t
),
accentColorBrightness:
t
<
0.5
?
begin
.
accentColorBrightness
:
end
.
accentColorBrightness
,
accentColorBrightness:
t
<
0.5
?
begin
.
accentColorBrightness
:
end
.
accentColorBrightness
,
indicatorColor:
Color
.
lerp
(
begin
.
indicatorColor
,
end
.
indicatorColor
,
t
),
indicatorColor:
Color
.
lerp
(
begin
.
indicatorColor
,
end
.
indicatorColor
,
t
),
...
@@ -482,6 +493,7 @@ class ThemeData {
...
@@ -482,6 +493,7 @@ class ThemeData {
(
otherData
.
textSelectionColor
==
textSelectionColor
)
&&
(
otherData
.
textSelectionColor
==
textSelectionColor
)
&&
(
otherData
.
textSelectionHandleColor
==
textSelectionHandleColor
)
&&
(
otherData
.
textSelectionHandleColor
==
textSelectionHandleColor
)
&&
(
otherData
.
backgroundColor
==
backgroundColor
)
&&
(
otherData
.
backgroundColor
==
backgroundColor
)
&&
(
otherData
.
dialogBackgroundColor
==
dialogBackgroundColor
)
&&
(
otherData
.
accentColor
==
accentColor
)
&&
(
otherData
.
accentColor
==
accentColor
)
&&
(
otherData
.
accentColorBrightness
==
accentColorBrightness
)
&&
(
otherData
.
accentColorBrightness
==
accentColorBrightness
)
&&
(
otherData
.
indicatorColor
==
indicatorColor
)
&&
(
otherData
.
indicatorColor
==
indicatorColor
)
&&
...
@@ -520,6 +532,7 @@ class ThemeData {
...
@@ -520,6 +532,7 @@ class ThemeData {
accentColorBrightness
,
accentColorBrightness
,
hashValues
(
// Too many values.
hashValues
(
// Too many values.
indicatorColor
,
indicatorColor
,
dialogBackgroundColor
,
hintColor
,
hintColor
,
errorColor
,
errorColor
,
textTheme
,
textTheme
,
...
...
packages/flutter/test/material/dialog_test.dart
View file @
500981fe
...
@@ -55,4 +55,45 @@ void main() {
...
@@ -55,4 +55,45 @@ void main() {
await
tester
.
tap
(
find
.
text
(
'OK'
));
await
tester
.
tap
(
find
.
text
(
'OK'
));
expect
(
didPressOk
,
true
);
expect
(
didPressOk
,
true
);
});
});
testWidgets
(
'Dialog background color'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
new
MaterialApp
(
theme:
new
ThemeData
(
brightness:
Brightness
.
dark
),
home:
new
Material
(
child:
new
Builder
(
builder:
(
BuildContext
context
)
{
return
new
Center
(
child:
new
RaisedButton
(
child:
new
Text
(
'X'
),
onPressed:
()
{
showDialog
(
context:
context
,
child:
new
AlertDialog
(
content:
new
Text
(
'Y'
),
actions:
<
Widget
>[
]
)
);
}
)
);
}
)
)
)
);
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pump
();
// start animation
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
StatefulElement
widget
=
tester
.
element
(
find
.
byType
(
Material
).
last
);
Material
materialconfig
=
widget
.
state
.
config
;
//first and second expect check that the material is the dialog's one
expect
(
materialconfig
.
type
,
MaterialType
.
card
);
expect
(
materialconfig
.
elevation
,
24
);
expect
(
materialconfig
.
color
,
Colors
.
grey
[
800
]);
});
}
}
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