Skip to content

Commit 32e0484

Browse files
Adaptive Scaffold Widget Package Code, Tests, and Examples (flutter#2406)
* move adaptive helper widgets from PR to package * Added some facing documentation * Added examples for adaptive_helper package * small formatting * fixed animation controller system in slotLayout * more polish and fixes to functionality * documentation * demo structure simplification * formatting * more simplifications to demo * adaptiveScaffold fix tests * documentation for examples * small changes and comments * update breakpoint values to m3 spec * fixed usage of custom breakpoints in adaptivescaffold * remove empty line * formatting * change focus to AdaptiveScaffold * Segmentation of PR * test change in pubsec.yaml version * change name to adaptive_scaffold and fix descriptions * template change * format * versioning and formatting * formatting * format * format * example update * license * format * format.. * format * format * add authors * formatting * format * publish to none * pubsec changes * [adaptive_scaffold] Add Code and Tests to AdaptiveScaffold package * license * format & analyze * animation duration fix * formatting * move breakpoint class * Several changes to documentation and some functionality changes * more documentation * format * Add documentation to examples and provide more breakpoints. * AdaptiveScaffold update breakpoint system * major refactor of main demo and added comments * format * license * AdaptiveLayout update documentation * more docs * AdaptiveScaffold documentation. * wrap at 80 lines * documentation and change horizontalBody to bodyOrientation with Axis * update isAnimating * Update notifier structure * builder configuration changes * notifiers .. notation * docs * Big refactor of SlotLayoutConfig -> SlotLayout.from. and some doc changes * Documentation revamp * format * example images and some updates to adaptiveScaffold * format * documentation * fix selectCard behavior * Some documentation changes * docs * docs * docs and some SlotLayoutConfig changes * docs * SlotLayoutConfig private constructor * use helper methods in internal AdaptiveScaffold slots * changes to adaptiveScaffold helper * fix helper * windows example * Icon theme fix and formatting * docs * add testing for the examples * license * remove extra analysis.yaml * docs * doc changes * main tests * test update * format * skip test temporarily * disable failing tests temporarily * format
1 parent c5e9167 commit 32e0484

File tree

79 files changed

+4494
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+4494
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
migrate_working_dir/
12+
13+
# IntelliJ related
14+
*.iml
15+
*.ipr
16+
*.iws
17+
.idea/
18+
19+
# The .vscode folder contains launch configuration and tasks you configure in
20+
# VS Code which you may wish to be included in version control, so this line
21+
# is commented out by default.
22+
#.vscode/
23+
24+
# Flutter/Dart/Pub related
25+
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
26+
/pubspec.lock
27+
**/doc/api/
28+
.dart_tool/
29+
.packages
30+
build/
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: 57f2ff0d286c95e6c2385abc29efc9e2d298797c
8+
channel: sliverQuickDocumentationFix
9+
10+
project_type: package

packages/adaptive_scaffold/AUTHORS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Below is a list of people and organizations that have contributed
2+
# to the Flutter project. Names should be added to the list like so:
3+
#
4+
# Name/Organization <email address>
5+
6+
Google Inc.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 0.0.1
2+
3+
* Initial release

packages/adaptive_scaffold/LICENSE

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Copyright 2013 The Flutter Authors. All rights reserved.
2+
3+
Redistribution and use in source and binary forms, with or without modification,
4+
are permitted provided that the following conditions are met:
5+
6+
* Redistributions of source code must retain the above copyright
7+
notice, this list of conditions and the following disclaimer.
8+
* Redistributions in binary form must reproduce the above
9+
copyright notice, this list of conditions and the following
10+
disclaimer in the documentation and/or other materials provided
11+
with the distribution.
12+
* Neither the name of Google Inc. nor the names of its
13+
contributors may be used to endorse or promote products derived
14+
from this software without specific prior written permission.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Helper Widgets for Making Adaptive Layouts in Flutter (AdaptiveScaffold)
2+
3+
This package contains some helper widgets that make the process of developing adaptive layouts easier, especially with navigational elements.
4+
5+
To see examples of using these helper widgets to make a simple but common adaptive layout:
6+
7+
```bash
8+
cd example/
9+
flutter run --release
10+
```
11+
## AdaptiveScaffold:
12+
AdaptiveScaffold implements the basic visual layout structure for Material Design 3 that adapts to a variety of screens. It provides a preset of layout, including positions and animations, by handling macro changes in navigational elements and bodies based on the current features of the screen, namely screen width and platform. For example, the navigational elements would be a BottomNavigationBar on a small mobile device and a NavigationRail on larger devices. The body is the primary screen that takes up the space left by the navigational elements. The secondaryBody acts as an option to split the space between two panes for purposes such as having a detail view. There is some automatic functionality with foldables to handle the split between panels properly. AdaptiveScaffold is much simpler to use but is not the best if you would like high customizability. Apps that would like more refined layout and/or animation should use AdaptiveLayout.
13+
### Example Usage:
14+
15+
<?code-excerpt ...>
16+
```dart
17+
AdaptiveScaffold(
18+
destinations: const [
19+
NavigationDestination(icon: Icon(Icons.inbox), label: 'Inbox'),
20+
NavigationDestination(icon: Icon(Icons.article), label: 'Articles'),
21+
NavigationDestination(icon: Icon(Icons.chat), label: 'Chat'),
22+
NavigationDestination(icon: Icon(Icons.video_call), label: 'Video'),
23+
],
24+
smallBody: (_) => ListView.builder(
25+
itemCount: children.length,
26+
itemBuilder: (_, idx) => children[idx]
27+
),
28+
body: (_) => GridView.count(crossAxisCount: 2, children: children),
29+
)
30+
```
31+
## The Background Widget Suite
32+
These are the set of widgets that are used on a lower level and offer more customizability at a cost of more lines of code.
33+
#### AdaptiveLayout:
34+
!["AdaptiveLayout's Assigned Slots Displayed on Screen"](example/demo_files/screenSlots.png)
35+
AdaptiveLayout is the top-level widget class that arranges the layout of the slots and their animation, similar to Scaffold. It takes in several LayoutSlots and returns an appropriate layout based on the diagram above. AdaptiveScaffold is built upon AdaptiveLayout internally but abstracts some of the complexity with presets based on the Material 3 Design specification.
36+
#### SlotLayout:
37+
SlotLayout handles the adaptivity or the changes between widgets at certain Breakpoints. It also holds the logic for animating between breakpoints. It takes SlotLayoutConfigs mapped to Breakpoints in a config and displays a widget based on that information.
38+
#### SlotLayout.from:
39+
SlotLayout.from creates a SlotLayoutConfig holds the actual widget to be displayed and the entrance animation and exit animation.
40+
### Example Usage:
41+
42+
<?code-excerpt ...>
43+
```dart
44+
AdaptiveLayout(
45+
primaryNavigation: SlotLayout(
46+
config: {
47+
Breakpoints.small: SlotLayout.from(key: const Key('pnav'), builder: (_) => const SizedBox.shrink()),
48+
Breakpoints.medium: SlotLayout.from(
49+
inAnimation: leftOutIn,
50+
key: const Key('pnav1'),
51+
builder: (_) => AdaptiveScaffold.toNavigationRail(destinations: destinations),
52+
),
53+
Breakpoints.large: SlotLayout.from(
54+
key: const Key('pnav2'),
55+
inAnimation: leftOutIn,
56+
builder: (_) => AdaptiveScaffold.toNavigationRail(extended: true, destinations: destinations),
57+
),
58+
},
59+
),
60+
body: SlotLayout(
61+
config: {
62+
Breakpoints.small: SlotLayout.from(
63+
key: const Key('body'),
64+
builder: (_) => ListView.builder(
65+
itemCount: children.length,
66+
itemBuilder: (_, idx) => children[idx]
67+
),
68+
),
69+
Breakpoints.medium: SlotLayout.from(
70+
key: const Key('body1'),
71+
builder: (_) => GridView.count(
72+
crossAxisCount: 2,
73+
children: children
74+
),
75+
),
76+
},
77+
),
78+
bottomNavigation: SlotLayout(
79+
config: {
80+
Breakpoints.small: SlotLayout.from(
81+
key: const Key('botnav'),
82+
inAnimation: bottomToTop,
83+
builder: (_) => AdaptiveScaffold.toBottomNavigationBar(destinations: destinations),
84+
),
85+
},
86+
),
87+
)
88+
```
89+
##
90+
Both of the examples shown here produce the same output:
91+
!["Example of a display made with AdaptiveScaffold"](example/demo_files/adaptiveScaffold.gif)
92+
93+
## Additional information
94+
You can find more information on this package and its usage in the public [design doc](https://docs.google.com/document/d/1qhrpTWYs5f67X8v32NCCNTRMIjSrVHuaMEFAul-Q_Ms/edit?usp=sharing)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
12+
# IntelliJ related
13+
*.iml
14+
*.ipr
15+
*.iws
16+
.idea/
17+
18+
# The .vscode folder contains launch configuration and tasks you configure in
19+
# VS Code which you may wish to be included in version control, so this line
20+
# is commented out by default.
21+
#.vscode/
22+
23+
# Flutter/Dart/Pub related
24+
**/doc/api/
25+
.dart_tool/
26+
.flutter-plugins
27+
.flutter-plugins-dependencies
28+
.packages
29+
.pub-cache/
30+
.pub/
31+
/build/
32+
33+
# Web related
34+
lib/generated_plugin_registrant.dart
35+
36+
# Exceptions to above rules.
37+
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled.
5+
6+
version:
7+
revision: 57f2ff0d286c95e6c2385abc29efc9e2d298797c
8+
channel: sliverQuickDocumentationFix
9+
10+
project_type: app
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: 57f2ff0d286c95e6c2385abc29efc9e2d298797c
17+
base_revision: 57f2ff0d286c95e6c2385abc29efc9e2d298797c
18+
- platform: windows
19+
create_revision: 57f2ff0d286c95e6c2385abc29efc9e2d298797c
20+
base_revision: 57f2ff0d286c95e6c2385abc29efc9e2d298797c
21+
22+
# User provided section
23+
24+
# List of Local paths (relative to this file) that should be
25+
# ignored by the migrate tool.
26+
#
27+
# Files that are not part of the templates will be ignored by default.
28+
unmanaged_files:
29+
- 'lib/main.dart'
30+
- 'ios/Runner.xcodeproj/project.pbxproj'
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Examples
2+
There are several examples listed in this directory:
3+
You can run the following commands in the example directory to see the appropriate demos:
4+
5+
`flutter run` to see a more fully fledged functional usage of the AdaptiveLayout suite and some AdaptiveScaffold static methods.
6+
7+
`flutter run lib/adaptive_layout_demo.dart` to see a simple usage of AdaptiveLayout.
8+
9+
`flutter run lib/adaptive_scaffold_demo.dart` to see a simple usage of AdaptiveScaffold.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
gradle-wrapper.jar
2+
/.gradle
3+
/captures/
4+
/gradlew
5+
/gradlew.bat
6+
/local.properties
7+
GeneratedPluginRegistrant.java

0 commit comments

Comments
 (0)