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
f1c8723a
Unverified
Commit
f1c8723a
authored
May 30, 2023
by
Matheus Kirchesch
Committed by
GitHub
May 30, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added option to disable [NavigationRailDestination]s (#127113)
parent
a6ef86a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
3 deletions
+58
-3
navigation_rail.dart
packages/flutter/lib/src/material/navigation_rail.dart
+14
-3
navigation_rail_test.dart
packages/flutter/test/material/navigation_rail_test.dart
+44
-0
No files found.
packages/flutter/lib/src/material/navigation_rail.dart
View file @
f1c8723a
...
@@ -467,6 +467,7 @@ class _NavigationRailState extends State<NavigationRail> with TickerProviderStat
...
@@ -467,6 +467,7 @@ class _NavigationRailState extends State<NavigationRail> with TickerProviderStat
tabIndex:
i
+
1
,
tabIndex:
i
+
1
,
tabCount:
widget
.
destinations
.
length
,
tabCount:
widget
.
destinations
.
length
,
),
),
disabled:
widget
.
destinations
[
i
].
disabled
,
),
),
if
(
widget
.
trailing
!=
null
)
if
(
widget
.
trailing
!=
null
)
widget
.
trailing
!,
widget
.
trailing
!,
...
@@ -545,6 +546,7 @@ class _RailDestination extends StatelessWidget {
...
@@ -545,6 +546,7 @@ class _RailDestination extends StatelessWidget {
required
this
.
useIndicator
,
required
this
.
useIndicator
,
this
.
indicatorColor
,
this
.
indicatorColor
,
this
.
indicatorShape
,
this
.
indicatorShape
,
this
.
disabled
=
false
,
})
:
_positionAnimation
=
CurvedAnimation
(
})
:
_positionAnimation
=
CurvedAnimation
(
parent:
ReverseAnimation
(
destinationAnimation
),
parent:
ReverseAnimation
(
destinationAnimation
),
curve:
Curves
.
easeInOut
,
curve:
Curves
.
easeInOut
,
...
@@ -567,6 +569,7 @@ class _RailDestination extends StatelessWidget {
...
@@ -567,6 +569,7 @@ class _RailDestination extends StatelessWidget {
final
bool
useIndicator
;
final
bool
useIndicator
;
final
Color
?
indicatorColor
;
final
Color
?
indicatorColor
;
final
ShapeBorder
?
indicatorShape
;
final
ShapeBorder
?
indicatorShape
;
final
bool
disabled
;
final
Animation
<
double
>
_positionAnimation
;
final
Animation
<
double
>
_positionAnimation
;
...
@@ -577,12 +580,16 @@ class _RailDestination extends StatelessWidget {
...
@@ -577,12 +580,16 @@ class _RailDestination extends StatelessWidget {
'[NavigationRail.indicatorColor] does not have an effect when [NavigationRail.useIndicator] is false'
,
'[NavigationRail.indicatorColor] does not have an effect when [NavigationRail.useIndicator] is false'
,
);
);
final
bool
material3
=
Theme
.
of
(
context
).
useMaterial3
;
final
ThemeData
theme
=
Theme
.
of
(
context
);
final
bool
material3
=
theme
.
useMaterial3
;
final
EdgeInsets
destinationPadding
=
(
padding
??
EdgeInsets
.
zero
).
resolve
(
Directionality
.
of
(
context
));
final
EdgeInsets
destinationPadding
=
(
padding
??
EdgeInsets
.
zero
).
resolve
(
Directionality
.
of
(
context
));
Offset
indicatorOffset
;
Offset
indicatorOffset
;
final
Widget
themedIcon
=
IconTheme
(
final
Widget
themedIcon
=
IconTheme
(
data:
iconTheme
,
data:
disabled
?
iconTheme
.
copyWith
(
color:
theme
.
colorScheme
.
onSurface
.
withOpacity
(
0.38
))
:
iconTheme
,
child:
icon
,
child:
icon
,
);
);
final
Widget
styledLabel
=
DefaultTextStyle
(
final
Widget
styledLabel
=
DefaultTextStyle
(
...
@@ -761,7 +768,7 @@ class _RailDestination extends StatelessWidget {
...
@@ -761,7 +768,7 @@ class _RailDestination extends StatelessWidget {
Material
(
Material
(
type:
MaterialType
.
transparency
,
type:
MaterialType
.
transparency
,
child:
_IndicatorInkWell
(
child:
_IndicatorInkWell
(
onTap:
onTap
,
onTap:
disabled
?
null
:
onTap
,
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
minWidth
/
2.0
)),
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
minWidth
/
2.0
)),
customBorder:
indicatorShape
,
customBorder:
indicatorShape
,
splashColor:
colors
.
primary
.
withOpacity
(
0.12
),
splashColor:
colors
.
primary
.
withOpacity
(
0.12
),
...
@@ -909,6 +916,7 @@ class NavigationRailDestination {
...
@@ -909,6 +916,7 @@ class NavigationRailDestination {
this
.
indicatorShape
,
this
.
indicatorShape
,
required
this
.
label
,
required
this
.
label
,
this
.
padding
,
this
.
padding
,
this
.
disabled
=
false
,
})
:
selectedIcon
=
selectedIcon
??
icon
;
})
:
selectedIcon
=
selectedIcon
??
icon
;
/// The icon of the destination.
/// The icon of the destination.
...
@@ -954,6 +962,9 @@ class NavigationRailDestination {
...
@@ -954,6 +962,9 @@ class NavigationRailDestination {
/// The amount of space to inset the destination item.
/// The amount of space to inset the destination item.
final
EdgeInsetsGeometry
?
padding
;
final
EdgeInsetsGeometry
?
padding
;
/// Indicates that this destination is inaccessible.
final
bool
disabled
;
}
}
class
_ExtendedNavigationRailAnimation
extends
InheritedWidget
{
class
_ExtendedNavigationRailAnimation
extends
InheritedWidget
{
...
...
packages/flutter/test/material/navigation_rail_test.dart
View file @
f1c8723a
...
@@ -3136,6 +3136,50 @@ void main() {
...
@@ -3136,6 +3136,50 @@ void main() {
expect
(
_getIndicatorDecoration
(
tester
)?.
shape
,
shape
);
expect
(
_getIndicatorDecoration
(
tester
)?.
shape
,
shape
);
});
});
testWidgets
(
"Destination's respect their disabled state"
,
(
WidgetTester
tester
)
async
{
late
int
selectedIndex
;
await
_pumpNavigationRail
(
tester
,
navigationRail:
NavigationRail
(
selectedIndex:
0
,
destinations:
const
<
NavigationRailDestination
>[
NavigationRailDestination
(
icon:
Icon
(
Icons
.
favorite_border
),
selectedIcon:
Icon
(
Icons
.
favorite
),
label:
Text
(
'Abc'
),
),
NavigationRailDestination
(
icon:
Icon
(
Icons
.
star_border
),
selectedIcon:
Icon
(
Icons
.
star
),
label:
Text
(
'Bcd'
),
),
NavigationRailDestination
(
icon:
Icon
(
Icons
.
bookmark_border
),
selectedIcon:
Icon
(
Icons
.
bookmark
),
label:
Text
(
'Cde'
),
disabled:
true
,
),
],
onDestinationSelected:
(
int
index
)
{
selectedIndex
=
index
;
},
labelType:
NavigationRailLabelType
.
all
,
),
);
await
tester
.
tap
(
find
.
text
(
'Abc'
));
expect
(
selectedIndex
,
0
);
await
tester
.
tap
(
find
.
text
(
'Bcd'
));
expect
(
selectedIndex
,
1
);
await
tester
.
tap
(
find
.
text
(
'Cde'
));
expect
(
selectedIndex
,
1
);
// Wait for any pending shader compilation.
tester
.
pumpAndSettle
();
});
group
(
'Material 2'
,
()
{
group
(
'Material 2'
,
()
{
// These tests are only relevant for Material 2. Once Material 2
// These tests are only relevant for Material 2. Once Material 2
// support is deprecated and the APIs are removed, these tests
// support is deprecated and the APIs are removed, these tests
...
...
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