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
97d0247d
Unverified
Commit
97d0247d
authored
Nov 02, 2022
by
Taha Tesser
Committed by
GitHub
Nov 02, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Material 3 support for `Slider` - Part 1 (#114079)
parent
f10021b3
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
854 additions
and
57 deletions
+854
-57
gen_defaults.dart
dev/tools/gen_defaults/bin/gen_defaults.dart
+2
-0
slider_template.dart
dev/tools/gen_defaults/lib/slider_template.dart
+77
-0
slider.dart
packages/flutter/lib/src/material/slider.dart
+159
-24
slider_test.dart
packages/flutter/test/material/slider_test.dart
+255
-33
slider_theme_test.dart
packages/flutter/test/material/slider_theme_test.dart
+361
-0
No files found.
dev/tools/gen_defaults/bin/gen_defaults.dart
View file @
97d0247d
...
...
@@ -38,6 +38,7 @@ import 'package:gen_defaults/navigation_rail_template.dart';
import
'package:gen_defaults/popup_menu_template.dart'
;
import
'package:gen_defaults/progress_indicator_template.dart'
;
import
'package:gen_defaults/radio_template.dart'
;
import
'package:gen_defaults/slider_template.dart'
;
import
'package:gen_defaults/surface_tint.dart'
;
import
'package:gen_defaults/switch_template.dart'
;
import
'package:gen_defaults/text_field_template.dart'
;
...
...
@@ -144,6 +145,7 @@ Future<void> main(List<String> args) async {
PopupMenuTemplate
(
'PopupMenu'
,
'
$materialLib
/popup_menu.dart'
,
tokens
).
updateFile
();
ProgressIndicatorTemplate
(
'ProgressIndicator'
,
'
$materialLib
/progress_indicator.dart'
,
tokens
).
updateFile
();
RadioTemplate
(
'Radio<T>'
,
'
$materialLib
/radio.dart'
,
tokens
).
updateFile
();
SliderTemplate
(
'md.comp.slider'
,
'Slider'
,
'
$materialLib
/slider.dart'
,
tokens
).
updateFile
();
SurfaceTintTemplate
(
'SurfaceTint'
,
'
$materialLib
/elevation_overlay.dart'
,
tokens
).
updateFile
();
SwitchTemplate
(
'Switch'
,
'
$materialLib
/switch.dart'
,
tokens
).
updateFile
();
TextFieldTemplate
(
'TextField'
,
'
$materialLib
/text_field.dart'
,
tokens
).
updateFile
();
...
...
dev/tools/gen_defaults/lib/slider_template.dart
0 → 100644
View file @
97d0247d
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'template.dart'
;
class
SliderTemplate
extends
TokenTemplate
{
const
SliderTemplate
(
this
.
tokenGroup
,
super
.
blockName
,
super
.
fileName
,
super
.
tokens
,
{
super
.
colorSchemePrefix
=
'_colors.'
,
});
final
String
tokenGroup
;
@override
String
generate
()
=>
'''
class _
${blockName}
DefaultsM3 extends SliderThemeData {
_
${blockName}
DefaultsM3(this.context)
: _colors = Theme.of(context).colorScheme,
super(trackHeight:
${tokens['$tokenGroup.active.track.height']}
);
final BuildContext context;
final ColorScheme _colors;
@override
Color? get activeTrackColor =>
${componentColor('$tokenGroup.active.track')}
;
@override
Color? get inactiveTrackColor =>
${componentColor('$tokenGroup.inactive.track')}
;
@override
Color? get secondaryActiveTrackColor => _colors.primary.withOpacity(0.54);
@override
Color? get disabledActiveTrackColor =>
${componentColor('$tokenGroup.disabled.active.track')}
;
@override
Color? get disabledInactiveTrackColor =>
${componentColor('$tokenGroup.disabled.inactive.track')}
;
@override
Color? get disabledSecondaryActiveTrackColor => _colors.onSurface.withOpacity(0.12);
@override
Color? get activeTickMarkColor =>
${componentColor('$tokenGroup.with-tick-marks.active.container')}
;
@override
Color? get inactiveTickMarkColor =>
${componentColor('$tokenGroup.with-tick-marks.inactive.container')}
;
@override
Color? get disabledActiveTickMarkColor =>
${componentColor('$tokenGroup.with-tick-marks.disabled.container')}
;
@override
Color? get disabledInactiveTickMarkColor =>
${componentColor('$tokenGroup.with-tick-marks.disabled.container')}
;
@override
Color? get thumbColor =>
${componentColor('$tokenGroup.handle')}
;
@override
Color? get disabledThumbColor => Color.alphaBlend(
${componentColor('$tokenGroup.disabled.handle')}
, _colors.surface);
@override
Color? get overlayColor => MaterialStateColor.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.hovered)) {
return
${componentColor('$tokenGroup.hover.state-layer')}
;
}
if (states.contains(MaterialState.focused)) {
return
${componentColor('$tokenGroup.focus.state-layer')}
;
}
if (states.contains(MaterialState.dragged)) {
return
${componentColor('$tokenGroup.pressed.state-layer')}
;
}
return Colors.transparent;
});
}
'''
;
}
packages/flutter/lib/src/material/slider.dart
View file @
97d0247d
This diff is collapsed.
Click to expand it.
packages/flutter/test/material/slider_test.dart
View file @
97d0247d
This diff is collapsed.
Click to expand it.
packages/flutter/test/material/slider_theme_test.dart
View file @
97d0247d
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