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
0e7b2bef
Unverified
Commit
0e7b2bef
authored
May 12, 2020
by
rami-a
Committed by
GitHub
May 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use titleTextStyle from dialog theme for SimpleDialog (#56895)
parent
1bb9f3f7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
20 deletions
+75
-20
dialog.dart
packages/flutter/lib/src/material/dialog.dart
+8
-1
dialog_theme_test.dart
packages/flutter/test/material/dialog_theme_test.dart
+67
-19
No files found.
packages/flutter/lib/src/material/dialog.dart
View file @
0e7b2bef
...
...
@@ -712,6 +712,7 @@ class SimpleDialog extends StatelessWidget {
Key
key
,
this
.
title
,
this
.
titlePadding
=
const
EdgeInsets
.
fromLTRB
(
24.0
,
24.0
,
24.0
,
0.0
),
this
.
titleTextStyle
,
this
.
children
,
this
.
contentPadding
=
const
EdgeInsets
.
fromLTRB
(
0.0
,
12.0
,
0.0
,
16.0
),
this
.
backgroundColor
,
...
...
@@ -739,6 +740,12 @@ class SimpleDialog extends StatelessWidget {
/// [title] and the [children].
final
EdgeInsetsGeometry
titlePadding
;
/// Style for the text in the [title] of this [SimpleDialog].
///
/// If null, [DialogTheme.titleTextStyle] is used, if that's null, defaults to
/// [ThemeData.textTheme.headline6].
final
TextStyle
titleTextStyle
;
/// The (optional) content of the dialog is displayed in a
/// [SingleChildScrollView] underneath the title.
///
...
...
@@ -814,7 +821,7 @@ class SimpleDialog extends StatelessWidget {
Padding
(
padding:
titlePadding
,
child:
DefaultTextStyle
(
style:
theme
.
textTheme
.
headline6
,
style:
t
itleTextStyle
??
DialogTheme
.
of
(
context
).
titleTextStyle
??
t
heme
.
textTheme
.
headline6
,
child:
Semantics
(
namesRoute:
true
,
child:
title
),
),
),
...
...
packages/flutter/test/material/dialog_theme_test.dart
View file @
0e7b2bef
...
...
@@ -6,7 +6,7 @@ import 'package:flutter/material.dart';
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
MaterialApp
_appWith
AlertDialog
(
WidgetTester
tester
,
AlertDialog
dialog
,
{
ThemeData
theme
})
{
MaterialApp
_appWith
Dialog
(
WidgetTester
tester
,
Widget
dialog
,
{
ThemeData
theme
})
{
return
MaterialApp
(
theme:
theme
,
home:
Material
(
...
...
@@ -37,8 +37,8 @@ Material _getMaterialFromDialog(WidgetTester tester) {
return
tester
.
widget
<
Material
>(
find
.
descendant
(
of:
find
.
byType
(
AlertDialog
),
matching:
find
.
byType
(
Material
)));
}
RenderParagraph
_getTextRenderObject
FromDialog
(
WidgetTester
tester
,
String
text
)
{
return
tester
.
element
<
StatelessElement
>(
find
.
descendant
(
of:
find
.
byType
(
AlertDialog
),
matching:
find
.
text
(
text
)
)).
renderObject
as
RenderParagraph
;
RenderParagraph
_getTextRenderObject
(
WidgetTester
tester
,
String
text
)
{
return
tester
.
element
<
StatelessElement
>(
find
.
text
(
text
)).
renderObject
as
RenderParagraph
;
}
void
main
(
)
{
...
...
@@ -70,7 +70,7 @@ void main() {
);
final
ThemeData
theme
=
ThemeData
(
dialogTheme:
const
DialogTheme
(
backgroundColor:
customColor
));
await
tester
.
pumpWidget
(
_appWith
Alert
Dialog
(
tester
,
dialog
,
theme:
theme
));
await
tester
.
pumpWidget
(
_appWithDialog
(
tester
,
dialog
,
theme:
theme
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
...
...
@@ -87,7 +87,7 @@ void main() {
final
ThemeData
theme
=
ThemeData
(
dialogTheme:
const
DialogTheme
(
elevation:
customElevation
));
await
tester
.
pumpWidget
(
_appWith
Alert
Dialog
(
tester
,
dialog
,
theme:
theme
)
_appWithDialog
(
tester
,
dialog
,
theme:
theme
)
);
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
...
...
@@ -106,7 +106,7 @@ void main() {
final
ThemeData
theme
=
ThemeData
(
dialogTheme:
const
DialogTheme
(
shape:
customBorder
));
await
tester
.
pumpWidget
(
_appWith
Alert
Dialog
(
tester
,
dialog
,
theme:
theme
)
_appWithDialog
(
tester
,
dialog
,
theme:
theme
)
);
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
...
...
@@ -124,7 +124,7 @@ void main() {
);
final
ThemeData
theme
=
ThemeData
(
dialogTheme:
const
DialogTheme
(
shape:
customBorder
));
await
tester
.
pumpWidget
(
_appWith
Alert
Dialog
(
tester
,
dialog
,
theme:
theme
));
await
tester
.
pumpWidget
(
_appWithDialog
(
tester
,
dialog
,
theme:
theme
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
...
...
@@ -143,11 +143,11 @@ void main() {
actions:
<
Widget
>[
],
);
await
tester
.
pumpWidget
(
_appWith
Alert
Dialog
(
tester
,
dialog
));
await
tester
.
pumpWidget
(
_appWithDialog
(
tester
,
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
final
RenderParagraph
title
=
_getTextRenderObject
FromDialog
(
tester
,
titleText
);
final
RenderParagraph
title
=
_getTextRenderObject
(
tester
,
titleText
);
expect
(
title
.
text
.
style
,
titleTextStyle
);
});
...
...
@@ -160,11 +160,11 @@ void main() {
);
final
ThemeData
theme
=
ThemeData
(
dialogTheme:
const
DialogTheme
(
titleTextStyle:
titleTextStyle
));
await
tester
.
pumpWidget
(
_appWith
Alert
Dialog
(
tester
,
dialog
,
theme:
theme
));
await
tester
.
pumpWidget
(
_appWithDialog
(
tester
,
dialog
,
theme:
theme
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
final
RenderParagraph
title
=
_getTextRenderObject
FromDialog
(
tester
,
titleText
);
final
RenderParagraph
title
=
_getTextRenderObject
(
tester
,
titleText
);
expect
(
title
.
text
.
style
,
titleTextStyle
);
});
...
...
@@ -177,11 +177,59 @@ void main() {
);
final
ThemeData
theme
=
ThemeData
(
textTheme:
const
TextTheme
(
headline6:
titleTextStyle
));
await
tester
.
pumpWidget
(
_appWith
Alert
Dialog
(
tester
,
dialog
,
theme:
theme
));
await
tester
.
pumpWidget
(
_appWithDialog
(
tester
,
dialog
,
theme:
theme
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
final
RenderParagraph
title
=
_getTextRenderObjectFromDialog
(
tester
,
titleText
);
final
RenderParagraph
title
=
_getTextRenderObject
(
tester
,
titleText
);
expect
(
title
.
text
.
style
.
color
,
titleTextStyle
.
color
);
});
testWidgets
(
'Simple Dialog - Custom Title Text Style - Constructor Param'
,
(
WidgetTester
tester
)
async
{
const
String
titleText
=
'Title'
;
const
TextStyle
titleTextStyle
=
TextStyle
(
color:
Colors
.
pink
);
const
SimpleDialog
dialog
=
SimpleDialog
(
title:
Text
(
titleText
),
titleTextStyle:
titleTextStyle
,
);
await
tester
.
pumpWidget
(
_appWithDialog
(
tester
,
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
final
RenderParagraph
title
=
_getTextRenderObject
(
tester
,
titleText
);
expect
(
title
.
text
.
style
,
titleTextStyle
);
});
testWidgets
(
'Simple Dialog - Custom Title Text Style - Dialog Theme'
,
(
WidgetTester
tester
)
async
{
const
String
titleText
=
'Title'
;
const
TextStyle
titleTextStyle
=
TextStyle
(
color:
Colors
.
pink
);
const
SimpleDialog
dialog
=
SimpleDialog
(
title:
Text
(
titleText
),
);
final
ThemeData
theme
=
ThemeData
(
dialogTheme:
const
DialogTheme
(
titleTextStyle:
titleTextStyle
));
await
tester
.
pumpWidget
(
_appWithDialog
(
tester
,
dialog
,
theme:
theme
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
final
RenderParagraph
title
=
_getTextRenderObject
(
tester
,
titleText
);
expect
(
title
.
text
.
style
,
titleTextStyle
);
});
testWidgets
(
'Simple Dialog - Custom Title Text Style - Theme'
,
(
WidgetTester
tester
)
async
{
const
String
titleText
=
'Title'
;
const
TextStyle
titleTextStyle
=
TextStyle
(
color:
Colors
.
pink
);
const
SimpleDialog
dialog
=
SimpleDialog
(
title:
Text
(
titleText
),
);
final
ThemeData
theme
=
ThemeData
(
textTheme:
const
TextTheme
(
headline6:
titleTextStyle
));
await
tester
.
pumpWidget
(
_appWithDialog
(
tester
,
dialog
,
theme:
theme
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
final
RenderParagraph
title
=
_getTextRenderObject
(
tester
,
titleText
);
expect
(
title
.
text
.
style
.
color
,
titleTextStyle
.
color
);
});
...
...
@@ -194,11 +242,11 @@ void main() {
actions:
<
Widget
>[
],
);
await
tester
.
pumpWidget
(
_appWith
Alert
Dialog
(
tester
,
dialog
));
await
tester
.
pumpWidget
(
_appWithDialog
(
tester
,
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
final
RenderParagraph
content
=
_getTextRenderObject
FromDialog
(
tester
,
contentText
);
final
RenderParagraph
content
=
_getTextRenderObject
(
tester
,
contentText
);
expect
(
content
.
text
.
style
,
contentTextStyle
);
});
...
...
@@ -211,11 +259,11 @@ void main() {
);
final
ThemeData
theme
=
ThemeData
(
dialogTheme:
const
DialogTheme
(
contentTextStyle:
contentTextStyle
));
await
tester
.
pumpWidget
(
_appWith
Alert
Dialog
(
tester
,
dialog
,
theme:
theme
));
await
tester
.
pumpWidget
(
_appWithDialog
(
tester
,
dialog
,
theme:
theme
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
final
RenderParagraph
content
=
_getTextRenderObject
FromDialog
(
tester
,
contentText
);
final
RenderParagraph
content
=
_getTextRenderObject
(
tester
,
contentText
);
expect
(
content
.
text
.
style
,
contentTextStyle
);
});
...
...
@@ -228,11 +276,11 @@ void main() {
);
final
ThemeData
theme
=
ThemeData
(
textTheme:
const
TextTheme
(
subtitle1:
contentTextStyle
));
await
tester
.
pumpWidget
(
_appWith
Alert
Dialog
(
tester
,
dialog
,
theme:
theme
));
await
tester
.
pumpWidget
(
_appWithDialog
(
tester
,
dialog
,
theme:
theme
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
final
RenderParagraph
content
=
_getTextRenderObject
FromDialog
(
tester
,
contentText
);
final
RenderParagraph
content
=
_getTextRenderObject
(
tester
,
contentText
);
expect
(
content
.
text
.
style
.
color
,
contentTextStyle
.
color
);
});
}
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