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
07e04484
Unverified
Commit
07e04484
authored
Mar 10, 2021
by
Darren Austin
Committed by
GitHub
Mar 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed PaginatedDataTable accentColor dependency. (#77744)
parent
8c05c0a9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
14 deletions
+62
-14
paginated_data_table.dart
packages/flutter/lib/src/material/paginated_data_table.dart
+1
-1
paginated_data_table_test.dart
...ages/flutter/test/material/paginated_data_table_test.dart
+61
-13
No files found.
packages/flutter/lib/src/material/paginated_data_table.dart
View file @
07e04484
...
...
@@ -488,7 +488,7 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
// These typographic styles aren't quite the regular ones. We pick the closest ones from the regular
// list and then tweak them appropriately.
// See https://material.io/design/components/data-tables.html#tables-within-cards
style:
_selectedRowCount
>
0
?
themeData
.
textTheme
.
subtitle1
!.
copyWith
(
color:
themeData
.
accentColor
)
style:
_selectedRowCount
>
0
?
themeData
.
textTheme
.
subtitle1
!.
copyWith
(
color:
themeData
.
colorScheme
.
secondary
)
:
themeData
.
textTheme
.
headline6
!.
copyWith
(
fontWeight:
FontWeight
.
w400
),
child:
IconTheme
.
merge
(
data:
const
IconThemeData
(
...
...
packages/flutter/test/material/paginated_data_table_test.dart
View file @
07e04484
...
...
@@ -3,6 +3,7 @@
// found in the LICENSE file.
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/gestures.dart'
show
DragStartBehavior
;
...
...
@@ -10,10 +11,10 @@ import 'data_table_test_utils.dart';
class
TestDataSource
extends
DataTableSource
{
TestDataSource
({
this
.
onSelectChanged
,
this
.
allowSelection
=
false
,
});
final
void
Function
(
bool
?)?
onSelectChanged
;
final
bool
allowSelection
;
int
get
generation
=>
_generation
;
int
_generation
=
0
;
...
...
@@ -24,18 +25,30 @@ class TestDataSource extends DataTableSource {
notifyListeners
();
}
final
Set
<
int
>
_selectedRows
=
<
int
>{};
void
_handleSelected
(
int
index
,
bool
?
selected
)
{
if
(
selected
==
true
)
{
_selectedRows
.
add
(
index
);
}
else
{
_selectedRows
.
remove
(
index
);
}
notifyListeners
();
}
@override
DataRow
getRow
(
int
index
)
{
final
Dessert
dessert
=
kDesserts
[
index
%
kDesserts
.
length
];
final
int
page
=
index
~/
kDesserts
.
length
;
return
DataRow
.
byIndex
(
index:
index
,
selected:
_selectedRows
.
contains
(
index
),
cells:
<
DataCell
>[
DataCell
(
Text
(
'
${dessert.name}
(
$page
)'
)),
DataCell
(
Text
(
'
${dessert.calories}
'
)),
DataCell
(
Text
(
'
$generation
'
)),
],
onSelectChanged:
onSelectChanged
,
onSelectChanged:
allowSelection
?
(
bool
?
selected
)
=>
_handleSelected
(
index
,
selected
)
:
null
,
);
}
...
...
@@ -46,7 +59,7 @@ class TestDataSource extends DataTableSource {
bool
get
isRowCountApproximate
=>
false
;
@override
int
get
selectedRowCount
=>
0
;
int
get
selectedRowCount
=>
_selectedRows
.
length
;
}
void
main
(
)
{
...
...
@@ -276,7 +289,7 @@ void main() {
home:
PaginatedDataTable
(
header:
header
!=
null
?
Text
(
header
)
:
null
,
actions:
actions
,
source
:
TestDataSource
(
onSelectChanged:
(
bool
?
value
)
{}
),
source
:
TestDataSource
(
allowSelection:
true
),
showCheckboxColumn:
true
,
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'Name'
)),
...
...
@@ -469,9 +482,7 @@ void main() {
// much, resulting in our custom margin being ignored.
await
binding
.
setSurfaceSize
(
const
Size
(
_width
,
_height
));
final
TestDataSource
source
=
TestDataSource
(
onSelectChanged:
(
bool
?
value
)
{},
);
final
TestDataSource
source
=
TestDataSource
(
allowSelection:
true
);
Finder
cellContent
;
Finder
checkbox
;
Finder
padding
;
...
...
@@ -807,7 +818,7 @@ void main() {
Widget
buildTable
(
bool
checkbox
)
=>
MaterialApp
(
home:
PaginatedDataTable
(
header:
const
Text
(
'Test table'
),
source
:
TestDataSource
(
onSelectChanged:
(
bool
?
value
)
{}
),
source
:
TestDataSource
(
allowSelection:
true
),
showCheckboxColumn:
checkbox
,
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'Name'
)),
...
...
@@ -837,7 +848,7 @@ void main() {
),
home:
PaginatedDataTable
(
header:
const
Text
(
'Test table'
),
source
:
TestDataSource
(
onSelectChanged:
(
bool
?
value
)
{}
),
source
:
TestDataSource
(
allowSelection:
true
),
showCheckboxColumn:
true
,
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'Name'
)),
...
...
@@ -869,9 +880,7 @@ void main() {
// much, resulting in our custom margin being ignored.
await
binding
.
setSurfaceSize
(
const
Size
(
_width
,
_height
));
final
TestDataSource
source
=
TestDataSource
(
onSelectChanged:
(
bool
?
value
)
{},
);
final
TestDataSource
source
=
TestDataSource
(
allowSelection:
true
);
Finder
cellContent
;
Finder
checkbox
;
Finder
padding
;
...
...
@@ -923,4 +932,43 @@ void main() {
// Reset the surface size.
await
binding
.
setSurfaceSize
(
originalSize
);
});
testWidgets
(
'Items selected text uses secondary color'
,
(
WidgetTester
tester
)
async
{
const
Color
selectedTextColor
=
Color
(
0xff00ddff
);
final
ColorScheme
colors
=
const
ColorScheme
.
light
().
copyWith
(
secondary:
selectedTextColor
);
final
ThemeData
theme
=
ThemeData
.
from
(
colorScheme:
colors
);
Widget
buildTable
()
{
return
MaterialApp
(
theme:
theme
,
home:
PaginatedDataTable
(
header:
const
Text
(
'Test table'
),
source
:
TestDataSource
(
allowSelection:
true
),
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'Name'
)),
DataColumn
(
label:
Text
(
'Calories'
),
numeric:
true
),
DataColumn
(
label:
Text
(
'Generation'
)),
],
),
);
}
await
binding
.
setSurfaceSize
(
const
Size
(
800
,
800
));
await
tester
.
pumpWidget
(
buildTable
());
expect
(
find
.
text
(
'Test table'
),
findsOneWidget
);
// Select a row with yogurt
await
tester
.
tap
(
find
.
text
(
'Frozen yogurt (0)'
));
await
tester
.
pumpAndSettle
();
// The header should be replace with a selected text item
expect
(
find
.
text
(
'Test table'
),
findsNothing
);
expect
(
find
.
text
(
'1 item selected'
),
findsOneWidget
);
// The color of the selected text item should be the colorScheme.secondary
final
TextStyle
selectedTextStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'1 item selected'
)).
text
.
style
!;
expect
(
selectedTextStyle
.
color
,
equals
(
selectedTextColor
));
await
binding
.
setSurfaceSize
(
null
);
});
}
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