-
Notifications
You must be signed in to change notification settings - Fork 633
feat: customizable Scrollbars #6282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ndonkoHenri
wants to merge
12
commits into
main
Choose a base branch
from
scroll
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+596
−49
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9076135
initial commit
ndonkoHenri 80a87e1
Refactor ScrollbarConfiguration to improve reusability and simplify S…
ndonkoHenri 47ae785
example
ndonkoHenri 97100b9
Extract ScrollbarConfiguration into a dedicated utility file for impr…
ndonkoHenri ad5bd35
improvements
ndonkoHenri 512aa47
Refactor ScrollableControl to enhance scrollbar configuration handlin…
ndonkoHenri 8879ede
Add documentation for Scrollbar and ScrollbarOrientation classes
ndonkoHenri 852b2ee
Refactor ScrollableControl and ScrollbarConfiguration to remove `Scro…
ndonkoHenri 0c409c8
Add showcase for ScrollbarOrientation with example usage and document…
ndonkoHenri d479015
Merge branch 'main' into scroll
ndonkoHenri 504e4ef
improve example
ndonkoHenri fe78563
delete test leftovers
ndonkoHenri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| import 'package:flutter/material.dart'; | ||
|
|
||
| import '../models/control.dart'; | ||
| import 'borders.dart'; | ||
| import 'enums.dart'; | ||
| import 'numbers.dart'; | ||
| import 'platform.dart'; | ||
|
|
||
| enum ScrollMode { auto, adaptive, always, hidden } | ||
|
|
||
| ScrollMode? parseScrollMode(String? value, [ScrollMode? defaultValue]) { | ||
| return parseEnum(ScrollMode.values, value, defaultValue); | ||
| } | ||
|
|
||
| class ScrollbarConfiguration { | ||
| final bool? thumbVisibility; | ||
| final bool? trackVisibility; | ||
| final double? thickness; | ||
| final Radius? radius; | ||
| final bool? interactive; | ||
| final ScrollbarOrientation? orientation; | ||
|
|
||
| const ScrollbarConfiguration({ | ||
| this.thumbVisibility, | ||
| this.trackVisibility, | ||
| this.thickness, | ||
| this.radius, | ||
| this.interactive, | ||
| this.orientation, | ||
| }); | ||
|
|
||
| factory ScrollbarConfiguration.fromScrollMode(ScrollMode mode) { | ||
| final defaultThickness = isMobilePlatform() ? 4.0 : null; | ||
|
|
||
| switch (mode) { | ||
| case ScrollMode.auto: | ||
| return ScrollbarConfiguration(thickness: defaultThickness); | ||
| case ScrollMode.adaptive: | ||
| return ScrollbarConfiguration( | ||
| thumbVisibility: !isMobilePlatform(), thickness: defaultThickness); | ||
| case ScrollMode.always: | ||
| return ScrollbarConfiguration( | ||
| thumbVisibility: true, thickness: defaultThickness); | ||
| case ScrollMode.hidden: | ||
| return const ScrollbarConfiguration(thickness: 0); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| ScrollbarOrientation? parseScrollbarOrientation(String? value, | ||
| [ScrollbarOrientation? defaultValue]) { | ||
| return parseEnum(ScrollbarOrientation.values, value, defaultValue); | ||
| } | ||
|
|
||
| ScrollbarConfiguration? parseScrollbarConfiguration(dynamic value, | ||
| [ScrollbarConfiguration? defaultValue]) { | ||
| if (value == null) return defaultValue; | ||
| if (value is! Map) { | ||
| final mode = parseScrollMode(value); | ||
| return mode == null | ||
| ? defaultValue | ||
| : ScrollbarConfiguration.fromScrollMode(mode); | ||
| } | ||
|
|
||
| final baseConfiguration = ScrollbarConfiguration.fromScrollMode( | ||
| parseScrollMode(value["mode"], ScrollMode.auto)!); | ||
|
|
||
| return ScrollbarConfiguration( | ||
| thumbVisibility: | ||
| parseBool(value["thumb_visibility"], baseConfiguration.thumbVisibility), | ||
| trackVisibility: | ||
| parseBool(value["track_visibility"], baseConfiguration.trackVisibility), | ||
| thickness: parseDouble(value["thickness"], baseConfiguration.thickness), | ||
| radius: parseRadius(value["radius"], baseConfiguration.radius), | ||
| interactive: parseBool(value["interactive"], baseConfiguration.interactive), | ||
| orientation: parseScrollbarOrientation( | ||
| value["orientation"], baseConfiguration.orientation), | ||
| ); | ||
| } | ||
|
|
||
| extension ScrollbarParsers on Control { | ||
| ScrollMode? getScrollMode(String propertyName, [ScrollMode? defaultValue]) { | ||
| return parseScrollMode(get(propertyName), defaultValue); | ||
| } | ||
|
|
||
| ScrollbarConfiguration? getScrollbarConfiguration(String propertyName, | ||
| [ScrollbarConfiguration? defaultValue]) { | ||
| return parseScrollbarConfiguration(get(propertyName), defaultValue); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This workflow change comments out the
controls/typesintegration test suite, which reduces CI coverage exactly where this PR introduces new types and golden updates. Please re-enablecontrols/types(and update/refresh the golden baselines as needed) rather than disabling the suite.