Skip to content

Commit

Permalink
[two_dimensional_scrollables] TableView (#4536)
Browse files Browse the repository at this point in the history
Design doc: [flutter.dev/go/table-view](https://docs.google.com/document/d/15ecTZE1g3WeswLGFWrnEgMP6SyL6jDRdxOgPsczOcV0/edit?usp=sharing&resourcekey=0-yNd_qFhiPjz6z2TgezWc0A)

Fixes flutter/flutter#87370
Fixes flutter/flutter#30770

This adds a new package: `two_dimensional_scrollables` - a package for widgets that scroll in two dimensions.

The first widget in the collection here is TableView. 

https://github.com/flutter/packages/assets/16964204/8103001a-77dc-489f-9e75-278972f66f30

TableView is built on top of the 2D scrolling foundation that lives in the Flutter framework.

Other widgets that will be included in this package in the future are TreeView and TreeTableView.
  • Loading branch information
Piinks authored Aug 17, 2023
1 parent d92cdf0 commit 4c16f3e
Show file tree
Hide file tree
Showing 142 changed files with 8,570 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,17 @@ updates:
- dependency-name: "*"
update-types: ["version-update:semver-minor", "version-update:semver-patch"]

- package-ecosystem: "gradle"
directory: "/packages/two_dimensional_scrollables/example/android/app"
commit-message:
prefix: "[2D_scrollables]"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
ignore:
- dependency-name: "*"
update-types: [ "version-update:semver-minor", "version-update:semver-patch" ]

- package-ecosystem: "gradle"
directory: "/packages/url_launcher/url_launcher_android/android"
commit-message:
Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ packages/quick_actions/** @bparrishMines
packages/rfw/** @Hixie
packages/shared_preferences/** @tarrinneal
packages/standard_message_codec/** @jonahwilliams
packages/two_dimensional_scrollables/** @Piinks
packages/url_launcher/** @stuartmorgan
packages/video_player/** @tarrinneal
packages/web_benchmarks/** @yjbanov
Expand Down
30 changes: 30 additions & 0 deletions packages/two_dimensional_scrollables/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
.packages
build/
10 changes: 10 additions & 0 deletions packages/two_dimensional_scrollables/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "0ed17dd5a24676c897b5268da976717c22e68780"
channel: "[user-branch]"

project_type: package
6 changes: 6 additions & 0 deletions packages/two_dimensional_scrollables/AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Below is a list of people and organizations that have contributed
# to the Flutter project. Names should be added to the list like so:
#
# Name/Organization <email address>

Google Inc.
3 changes: 3 additions & 0 deletions packages/two_dimensional_scrollables/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 0.0.1

* Initial release - TableView
25 changes: 25 additions & 0 deletions packages/two_dimensional_scrollables/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Copyright 2013 The Flutter Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
68 changes: 68 additions & 0 deletions packages/two_dimensional_scrollables/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Two Dimensional Scrollables

A package that provides widgets that scroll in two dimensions, built on the
two-dimensional foundation of the Flutter framework.

## Features

This package provides support for a TableView widget that scrolls in both the
vertical and horizontal axes.

### TableView

`TableView` is a subclass of `TwoDimensionalScrollView`, building its provided
children lazily in a `TwoDimensionalViewport`. This widget can

- Scroll diagonally, or lock axes
- Apply decorations to rows and columns
- Handle gestures & custom pointers for rows and columns
- Pin rows and columns

## Getting started

### Depend on it

Run this command with Flutter:

```sh
$ flutter pub add two_dimensional_scrollables
```

### Import it

Now in your Dart code, you can use:

```sh
import 'package:two_dimensional_scrollables/two_dimensional_scrollables.dart';
```

## Usage

### TableView

The code in `example/` shows a `TableView` of initially 400 cells, each varying
in sizes with a few `TableSpanDecoration`s like background colors and borders. The
`builder` constructor is called on demand for the cells that are visible in the
TableView. Additional rows can be added on demand while the vertical position
can jump between the first and last row using the buttons at the bottom of the
screen.

## Changelog

See the
[Changelog](https://github.com/flutter/packages/blob/main/packages/two_dimensional_scrollables/CHANGELOG.md)
for a list of new features and breaking changes.

## Roadmap

See the [GitHub project](https://github.com/orgs/flutter/projects/32/) for a
prioritized list of feature requests and known issues.

## Additional information

The package uses the two-dimensional foundation from the Flutter framework,
meaning most of the core functionality of 2D scrolling is not implemented here.
This also means any subclass of the foundation can create different 2D scrolling
widgets and be added to the collection. If you want to contribute to
this package, you can open a pull request in [Flutter Packages](https://github.com/flutter/packages)
and add the tag "p: two_dimensional_scrollables".
3 changes: 3 additions & 0 deletions packages/two_dimensional_scrollables/dart_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# TODO(Piinks): Web cannot support temp golden files, re-enable once mock_canvas
# makes it to stable. See
test_on: vm
44 changes: 44 additions & 0 deletions packages/two_dimensional_scrollables/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
45 changes: 45 additions & 0 deletions packages/two_dimensional_scrollables/example/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "f1fefa8315ccf7081343d50815809dc3c7d5f347"
channel: "[user-branch]"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: f1fefa8315ccf7081343d50815809dc3c7d5f347
base_revision: f1fefa8315ccf7081343d50815809dc3c7d5f347
- platform: android
create_revision: f1fefa8315ccf7081343d50815809dc3c7d5f347
base_revision: f1fefa8315ccf7081343d50815809dc3c7d5f347
- platform: ios
create_revision: f1fefa8315ccf7081343d50815809dc3c7d5f347
base_revision: f1fefa8315ccf7081343d50815809dc3c7d5f347
- platform: linux
create_revision: f1fefa8315ccf7081343d50815809dc3c7d5f347
base_revision: f1fefa8315ccf7081343d50815809dc3c7d5f347
- platform: macos
create_revision: f1fefa8315ccf7081343d50815809dc3c7d5f347
base_revision: f1fefa8315ccf7081343d50815809dc3c7d5f347
- platform: web
create_revision: f1fefa8315ccf7081343d50815809dc3c7d5f347
base_revision: f1fefa8315ccf7081343d50815809dc3c7d5f347
- platform: windows
create_revision: f1fefa8315ccf7081343d50815809dc3c7d5f347
base_revision: f1fefa8315ccf7081343d50815809dc3c7d5f347

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
3 changes: 3 additions & 0 deletions packages/two_dimensional_scrollables/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# TableView Example

A sample application that utilizes the TableView API.
13 changes: 13 additions & 0 deletions packages/two_dimensional_scrollables/example/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java

# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
**/*.keystore
**/*.jks
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
namespace 'dev.flutter.packages.two_dimensional_scrollables.example'
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.example"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
namespace 'com.example.example'
}

flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
Loading

0 comments on commit 4c16f3e

Please sign in to comment.