diff --git a/README.md b/README.md index 86afa3f..31b1bed 100644 --- a/README.md +++ b/README.md @@ -2,30 +2,35 @@ A widget that can be dragged and scrolled in a single gesture and snapped to a list of extents. - - Example of a SlidingSheet + + Example of a SlidingSheet -Click [here](https://github.com/bnxm/sliding_sheet/blob/master/example/lib/main.dart) to view the full example. +Click [here](https://github.com/flutterwtf/sliding_sheet/blob/master/example/lib/main.dart) to view the full example. + +The package is a fork of [this](https://github.com/tchigher/sliding-sheet) repository. ## Installing Add it to your `pubspec.yaml` file: + ```yaml dependencies: - sliding_sheet: ^0.5.0 + wtf_sliding_sheet: ^0.6.0 ``` + Install packages from the command line -``` + +```shell flutter packages get ``` -If you like this package, consider supporting it by giving it a star on [GitHub](https://github.com/bnxm/sliding_sheet) and a like on [pub.dev](https://pub.dev/packages/sliding_sheet) :heart: +If you like this package, consider supporting it by giving it a star on [GitHub](https://github.com/flutterwtf/sliding_sheet) and a like on [pub.dev](https://pub.dev/packages/wtf_sliding_sheet) :heart: ## Usage There are two ways in which you can use a `SlidingSheet`: either as a permanent (or persistent) `Widget` in your -widget tree or as a `BottomSheetDialog`. +widget tree or as a `BottomSheetDialog`. ### As a Widget @@ -72,15 +77,16 @@ Widget build(BuildContext context) { } ``` -#### Result: -Example +**Result:** + +Example ### As a BottomSheetDialog This method can be used to show a `SlidingSheet` as a `BottomSheetDialog` by calling the `showSlidingBottomSheet` function and returning and instance of `SlidingSheetDialog`. ```dart -void showAsBottomSheet() async { +void showAsBottomSheet(BuildContext context) async { final result = await showSlidingBottomSheet( context, builder: (context) { @@ -103,7 +109,7 @@ void showAsBottomSheet() async { padding: const EdgeInsets.all(16), child: Text( 'This is the content of the sheet', - style: Theme.of(context).textTheme.body1, + style: Theme.of(context).textTheme.bodyMedium, ), ), ), @@ -118,15 +124,17 @@ void showAsBottomSheet() async { print(result); // This is the result. } ``` -#### Result: -Example + +**Result:** + +Example ### Snapping A `SlidingSheet` can snap to multiple extents or to no at all. You can customize the snapping behavior by passing an instance of `SnapSpec` to the `SlidingSheet`. - Parameter | Description + Parameter | Description --- | --- snap | If true, the `SlidingSheet` will snap to the provided `snappings`. If false, the `SlidingSheet` will slide from minExtent to maxExtent and then begin to scroll, if the content is bigger than the available height. snappings | The extents that the `SlidingSheet` will snap to, when the user ends a drag interaction. The minimum and maximum values will represent the bounds in which the `SlidingSheet` will slide until it reaches the maximum from which on it will scroll. @@ -134,19 +142,19 @@ positioning | Can be set to one of these three values: `SnapPositioning.relative onSnap | A callback function that gets invoked when the `SlidingSheet` snaps to an extent.

- SnapPositioning.relativeToAvailableSpace with a snap of 0.5 - SnapPositioning.relativeToSheetHeight with a snap of 0.5 - SnapPositioning.pixelOffset with a snap of 100 + SnapPositioning.relativeToAvailableSpace with a snap of 0.5 + SnapPositioning.relativeToSheetHeight with a snap of 0.5 + SnapPositioning.pixelOffset with a snap of 100

There are also some prebuild snaps you can facilitate to snap for example to headers or footers as shown in the example. - Snap | Description + Snap | Description --- | --- -SnapSpec.headerFooterSnap | The snap extent that makes header and footer fully visible without account for vertical padding on the `SlidingSheet`. -SnapSpec.headerSnap | The snap extent that makes the header fully visible without account for top padding on the `SlidingSheet`. -SnapSpec.footerSnap | The snap extent that makes the footer fully visible without account for bottom padding on the `SlidingSheet`. -SnapSpec.expanded | The snap extent that expands the whole `SlidingSheet`. +`SnapSpec.headerFooterSnap` | The snap extent that makes header and footer fully visible without account for vertical padding on the `SlidingSheet`. +`SnapSpec.headerSnap` | The snap extent that makes the header fully visible without account for top padding on the `SlidingSheet`. +`SnapSpec.footerSnap` | The snap extent that makes the footer fully visible without account for bottom padding on the `SlidingSheet`. +`SnapSpec.expanded` | The snap extent that expands the whole `SlidingSheet`. ### SheetController @@ -154,7 +162,7 @@ The `SheetController` can be used to change the state of a `SlidingSheet` manual Note that you can also use the static `SheetController.of(context)` method to obtain an instance of the `SheetController` of the closest `SlidingSheet`. This also works if you didn't assign a `SheetController` explicitly on the `SlidingSheet`. - Method | Description + Method | Description --- | --- `expand()` | Expands the `SlidingSheet` to the maximum extent. `collapse()` | Collapses the `SlidingSheet` to the minimum extent. @@ -192,7 +200,7 @@ Widget build(BuildContext context) { child: Center( child: Text( 'This is the content of the sheet', - style: Theme.of(context).textTheme.body1, + style: Theme.of(context).textTheme.bodyMedium, ), ), ); @@ -205,7 +213,7 @@ Widget build(BuildContext context) { alignment: Alignment.center, child: Text( 'This is the header', - style: Theme.of(context).textTheme.body1.copyWith(color: Colors.white), + style: Theme.of(context).textTheme.bodyMedium.copyWith(color: Colors.white), ), ); }, @@ -217,7 +225,7 @@ Widget build(BuildContext context) { alignment: Alignment.center, child: Text( 'This is the footer', - style: Theme.of(context).textTheme.body1.copyWith(color: Colors.black), + style: Theme.of(context).textTheme.bodyMedium.copyWith(color: Colors.black), ), ); }, @@ -227,8 +235,10 @@ Widget build(BuildContext context) { ); } ``` -#### Result: -Simple header/footer example + +**Result:** + +Simple header/footer example ### ListViews and Columns @@ -240,22 +250,33 @@ In order to change the UI when the sheet gets interacted with, you can pass a ca For rebuilding individual children of a `SlidingSheet` (e.g. elevating the header when content gets scrolled under it), you can also use the `SheetListenerBuilder`: -~~~dart +```dart return SheetListenerBuilder( // buildWhen can be used to only rebuild the widget when needed. - buildWhen: (oldState, newState) => oldState.isAtTop != newState.isAtTop, - builder: (context, state) { - return AnimatedContainer( - elevation: !state.isAtTop ? elevation : 0.0, - duration: const Duration(milliseconds: 400), - child: child, + buildWhen: (oldState, newState) => + oldState.progress != newState.progress, + builder: (context, SheetState state) { + return Material( + elevation: state.progress * 20 + 1, + color: Colors.lightBlue, + borderRadius: BorderRadius.vertical( + top: Radius.circular(16), + ), + child: SizedBox( + height: 60, + child: Center( + child: const Text('Header'), + ), + ), ); }, ); -~~~ +``` -The example for instance decreases the corner radius of the `SlidingSheet` as it gets dragged to the top and increases the headers top padding by the status bar height. Also, when content gets scrolled under the header it elevates. +**Result:** -Because these are common Material behaviors, `SlidingSheet` supports those out of the box, which can be achieved by setting the `avoidStatusBar` field to `true`, `cornerRadiusOnFullscreen` to `0` and `liftOnScrollHeaderElevation` to the elevation. +Example of Material Effects -Example of Material Effects \ No newline at end of file +The [example](https://github.com/flutterwtf/sliding_sheet/blob/master/example/lib/main.dart) for instance decreases the corner radius of the `SlidingSheet` as it gets dragged to the top and increases the headers top padding by the status bar height. Also, when content gets scrolled under the header it elevates. + +Because these are common Material behaviors, `SlidingSheet` supports those out of the box, which can be achieved by setting the `avoidStatusBar` field to `true`, `cornerRadiusOnFullscreen` to `0` and `liftOnScrollHeaderElevation` to the elevation. diff --git a/analysis_options.yaml b/analysis_options.yaml index 34886a1..d1fa785 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -327,13 +327,6 @@ linter: # https://dart-lang.github.io/linter/lints/implementation_imports.html - implementation_imports - # Although there are some false positives, this lint generally catches unnecessary checks - # - https://github.com/dart-lang/linter/issues/811 - # - # pedantic: disabled - # https://dart-lang.github.io/linter/lints/invariant_booleans.html - - invariant_booleans - # Type check for Iterable.contains(other) where other is! T # otherwise contains will always report false. Those errors are usually very hard to catch. # https://dart-lang.github.io/linter/lints/iterable_contains_unrelated_type.html diff --git a/example/.metadata b/example/.metadata index 0958d28..fdbb572 100644 --- a/example/.metadata +++ b/example/.metadata @@ -1,10 +1,30 @@ # 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. +# This file should be version controlled. version: - revision: e70236e36ce1d32067dc68eb55519ec3e14b6b01 - channel: beta + revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72 + channel: stable project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72 + base_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72 + - platform: android + create_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72 + base_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72 + + # 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' diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml new file mode 100644 index 0000000..61b6c4d --- /dev/null +++ b/example/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/example/android/.gitignore b/example/android/.gitignore index bc2100d..6f56801 100644 --- a/example/android/.gitignore +++ b/example/android/.gitignore @@ -5,3 +5,9 @@ gradle-wrapper.jar /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 diff --git a/example/android/.project b/example/android/.project deleted file mode 100644 index 3964dd3..0000000 --- a/example/android/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - android - Project android created by Buildship. - - - - - org.eclipse.buildship.core.gradleprojectbuilder - - - - - - org.eclipse.buildship.core.gradleprojectnature - - diff --git a/example/android/.settings/org.eclipse.buildship.core.prefs b/example/android/.settings/org.eclipse.buildship.core.prefs deleted file mode 100644 index e889521..0000000 --- a/example/android/.settings/org.eclipse.buildship.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -connection.project.dir= -eclipse.preferences.version=1 diff --git a/example/android/app/.classpath b/example/android/app/.classpath deleted file mode 100644 index eb19361..0000000 --- a/example/android/app/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/example/android/app/.project b/example/android/app/.project deleted file mode 100644 index ac485d7..0000000 --- a/example/android/app/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - app - Project app created by Buildship. - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.buildship.core.gradleprojectbuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.buildship.core.gradleprojectnature - - diff --git a/example/android/app/.settings/org.eclipse.buildship.core.prefs b/example/android/app/.settings/org.eclipse.buildship.core.prefs deleted file mode 100644 index b1886ad..0000000 --- a/example/android/app/.settings/org.eclipse.buildship.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -connection.project.dir=.. -eclipse.preferences.version=1 diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 0f6a5e5..b52183a 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -26,24 +26,31 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 28 + compileSdkVersion flutter.compileSdkVersion + ndkVersion flutter.ndkVersion - sourceSets { - main.java.srcDirs += 'src/main/kotlin' + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' } - lintOptions { - disable 'InvalidPackage' + 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" - minSdkVersion 16 - targetSdkVersion 28 + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { @@ -61,7 +68,4 @@ flutter { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - testImplementation 'junit:junit:4.12' - androidTestImplementation 'androidx.test:runner:1.1.1' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' } diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml index c208884..45d523a 100644 --- a/example/android/app/src/debug/AndroidManifest.xml +++ b/example/android/app/src/debug/AndroidManifest.xml @@ -1,6 +1,7 @@ - diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 6cf423b..3f41384 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,30 +1,34 @@ - - - - - + + android:name="io.flutter.embedding.android.NormalTheme" + android:resource="@style/NormalTheme" + /> + + diff --git a/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt b/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt index e2c0fd3..e793a00 100644 --- a/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt +++ b/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt @@ -1,13 +1,6 @@ package com.example.example -import android.os.Bundle - -import io.flutter.app.FlutterActivity -import io.flutter.plugins.GeneratedPluginRegistrant +import io.flutter.embedding.android.FlutterActivity class MainActivity: FlutterActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - GeneratedPluginRegistrant.registerWith(this) - } } diff --git a/example/android/app/src/main/res/drawable-v21/launch_background.xml b/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/example/android/app/src/main/res/values-night/styles.xml b/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..06952be --- /dev/null +++ b/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/example/android/app/src/main/res/values/styles.xml b/example/android/app/src/main/res/values/styles.xml index 00fa441..cb1ef88 100644 --- a/example/android/app/src/main/res/values/styles.xml +++ b/example/android/app/src/main/res/values/styles.xml @@ -1,8 +1,18 @@ - + + diff --git a/example/android/app/src/profile/AndroidManifest.xml b/example/android/app/src/profile/AndroidManifest.xml index c208884..45d523a 100644 --- a/example/android/app/src/profile/AndroidManifest.xml +++ b/example/android/app/src/profile/AndroidManifest.xml @@ -1,6 +1,7 @@ - diff --git a/example/android/build.gradle b/example/android/build.gradle index 3100ad2..58a8c74 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.3.50' + ext.kotlin_version = '1.7.10' repositories { google() - jcenter() + mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.0' + classpath 'com.android.tools.build:gradle:7.2.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -14,7 +14,7 @@ buildscript { allprojects { repositories { google() - jcenter() + mavenCentral() } } diff --git a/example/android/gradle.properties b/example/android/gradle.properties index 38c8d45..94adc3a 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -1,4 +1,3 @@ org.gradle.jvmargs=-Xmx1536M -android.enableR8=true android.useAndroidX=true android.enableJetifier=true diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 889312e..3c472b9 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Fri Jun 23 08:50:38 CEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https://services.gradle.org/distributions/gradle-6.4.1-all.zip \ No newline at end of file +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip diff --git a/example/android/settings.gradle b/example/android/settings.gradle index 5a2f14f..44e62bc 100644 --- a/example/android/settings.gradle +++ b/example/android/settings.gradle @@ -1,15 +1,11 @@ include ':app' -def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() -def plugins = new Properties() -def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') -if (pluginsFile.exists()) { - pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } -} +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } -plugins.each { name, path -> - def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() - include ":$name" - project(":$name").projectDir = pluginDirectory -} +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/example/lib/main.dart b/example/lib/main.dart index 365efe4..fc541df 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,19 +1,19 @@ import 'dart:async'; -import 'package:charts_flutter/flutter.dart' as charts; +import 'package:community_charts_flutter/community_charts_flutter.dart' + as charts; import 'package:example/util/util.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; - -import 'package:sliding_sheet/sliding_sheet.dart'; +import 'package:wtf_sliding_sheet/wtf_sliding_sheet.dart'; // ignore_for_file: public_member_api_docs const Color mapsBlue = Color(0xFF4185F3); void main() => runApp( - MaterialApp( + const MaterialApp( title: 'Example App', debugShowCheckedModeBanner: false, home: Example(), @@ -21,8 +21,10 @@ void main() => runApp( ); class Example extends StatefulWidget { + const Example({super.key}); + @override - _ExampleState createState() => _ExampleState(); + State createState() => _ExampleState(); } class _ExampleState extends State { @@ -79,17 +81,14 @@ class _ExampleState extends State { color: Colors.grey.shade300, width: 3, ), - snapSpec: SnapSpec( + snapSpec: const SnapSpec( snap: true, positioning: SnapPositioning.relativeToAvailableSpace, - snappings: const [ + snappings: [ SnapSpec.headerFooterSnap, 0.6, SnapSpec.expanded, ], - onSnap: (state, snap) { - print('Snapped to $snap'); - }, ), parallaxSpec: const ParallaxSpec( enabled: true, @@ -165,8 +164,7 @@ class _ExampleState extends State { Icon icon, Text text, VoidCallback onTap, { - BorderSide border, - Color color, + BorderSide? border, }) { final child = Row( mainAxisSize: MainAxisSize.min, @@ -185,13 +183,13 @@ class _ExampleState extends State { return border == null ? ElevatedButton( onPressed: onTap, - child: child, style: ElevatedButton.styleFrom(shape: shape), + child: child, ) : OutlinedButton( onPressed: onTap, - child: child, style: OutlinedButton.styleFrom(shape: shape), + child: child, ); } @@ -216,7 +214,7 @@ class _ExampleState extends State { ), () async { // Inherit from context... - await SheetController.of(context).hide(); + await SheetController.of(context)?.hide(); Future.delayed( const Duration(milliseconds: 1500), () { @@ -225,11 +223,11 @@ class _ExampleState extends State { }, ); }, - color: mapsBlue, ), const SizedBox(width: 8), SheetListenerBuilder( - buildWhen: (oldState, newState) => oldState.isExpanded != newState.isExpanded, + buildWhen: (oldState, newState) => + oldState.isExpanded != newState.isExpanded, builder: (context, state) { final isExpanded = state.isExpanded; @@ -245,7 +243,6 @@ class _ExampleState extends State { !isExpanded ? () => controller.scrollTo(state.maxScrollExtent) : controller.collapse, - color: Colors.white, border: BorderSide( color: Colors.grey.shade400, width: 2, @@ -354,11 +351,11 @@ class _ExampleState extends State { '2 seconds', ), Step( - "Add the newest version of 'sliding_sheet' to your dependencies.", + "Add the newest version of 'wtf_sliding_sheet' to your dependencies.", '5 seconds', ), Step( - "Run 'flutter packages get' in the terminal.", + "Run 'flutter pub get' in the terminal.", '4 seconds', ), Step( @@ -388,7 +385,7 @@ class _ExampleState extends State { Row( children: [ Text( - '${step.time}', + step.time, style: textStyle.copyWith( color: Colors.grey, fontSize: 15, @@ -424,7 +421,9 @@ class _ExampleState extends State { Traffic(0.6, '16:30'), ], colorFn: (traffic, __) { - if (traffic.time == '14:30') return charts.Color.fromHex(code: '#F0BA64'); + if (traffic.time == '14:30') { + return charts.Color.fromHex(code: '#F0BA64'); + } return charts.MaterialPalette.gray.shade300; }, domainFn: (Traffic traffic, _) => traffic.time, @@ -512,8 +511,6 @@ class _ExampleState extends State { // if (backButton) { // Navigator.pop(context); // } - - print('Dismiss prevented'); }, builder: (context, state) { return Container( @@ -523,7 +520,7 @@ class _ExampleState extends State { children: [ Text( 'Confirm purchase', - style: textTheme.headline4.copyWith( + style: textTheme.headlineMedium?.copyWith( color: Colors.white, fontWeight: FontWeight.bold, ), @@ -536,7 +533,7 @@ class _ExampleState extends State { 'Lorem ipsum dolor sit amet, consectetur adipiscing ' 'elit. Praesent sagittis tellus lacus, et pulvinar ' 'orci eleifend in.', - style: textTheme.subtitle1.copyWith( + style: textTheme.titleMedium?.copyWith( color: Colors.white, fontWeight: FontWeight.bold, ), @@ -565,7 +562,7 @@ class _ExampleState extends State { onPressed: () => Navigator.pop(context), child: Text( 'Cancel', - style: textTheme.subtitle1.copyWith( + style: textTheme.titleMedium?.copyWith( color: Colors.white, fontWeight: FontWeight.bold, ), @@ -576,14 +573,14 @@ class _ExampleState extends State { onPressed: () { if (!isDismissable) { isDismissable = true; - SheetController.of(context).rebuild(); + SheetController.of(context)?.rebuild(); } else { Navigator.pop(context); } }, child: Text( 'Approve', - style: textTheme.subtitle1.copyWith( + style: textTheme.titleMedium?.copyWith( color: Colors.white, fontWeight: FontWeight.bold, ), diff --git a/example/lib/util/custom_container.dart b/example/lib/util/custom_container.dart index 00d6a77..036f91d 100644 --- a/example/lib/util/custom_container.dart +++ b/example/lib/util/custom_container.dart @@ -2,8 +2,6 @@ import 'dart:math'; import 'package:flutter/material.dart'; -// ignore_for_file: public_member_api_docs - enum ShadowDirection { topLeft, top, @@ -19,27 +17,28 @@ enum ShadowDirection { class CustomContainer extends StatelessWidget { final double borderRadius; final double elevation; - final double height; - final double width; - final Border border; - final BorderRadius customBorders; - final EdgeInsets margin; + final double? height; + final double? width; + final Border? border; + final BorderRadius? customBorders; + final EdgeInsets? margin; final EdgeInsets padding; - final Widget child; + final Widget? child; final Color color; final Color shadowColor; - final List boxShadows; - final VoidCallback onTap; - final VoidCallback onLongPress; - final VoidCallback onDoubleTap; + final List? boxShadows; + final VoidCallback? onTap; + final VoidCallback? onLongPress; + final VoidCallback? onDoubleTap; final BoxShape boxShape; - final AlignmentGeometry alignment; + final AlignmentGeometry? alignment; final ShadowDirection shadowDirection; - final Color rippleColor; + final Color? rippleColor; final bool animate; final Duration duration; + const CustomContainer({ - Key key, + Key? key, this.child, this.border, this.color = Colors.transparent, @@ -63,20 +62,20 @@ class CustomContainer extends StatelessWidget { this.padding = const EdgeInsets.all(0), }) : super(key: key); - static const double WRAP = -1; - static const double EXPAND = -2; + static const double wrap = -1; + static const double expand = -2; bool get circle => boxShape == BoxShape.circle; @override Widget build(BuildContext context) { final theme = Theme.of(context); - final w = width == null || width == EXPAND + final w = width == null || width == expand ? double.infinity - : width == WRAP + : width == wrap ? null : width; - final h = height == EXPAND ? double.infinity : height; + final h = height == expand ? double.infinity : height; final br = customBorders ?? BorderRadius.circular( boxShape == BoxShape.rectangle @@ -93,7 +92,8 @@ class CustomContainer extends StatelessWidget { child: child, ); - if (boxShape == BoxShape.circle || (customBorders != null || borderRadius > 0.0)) { + if (boxShape == BoxShape.circle || + (customBorders != null || borderRadius > 0.0)) { content = ClipRRect( borderRadius: br, child: content, @@ -103,10 +103,16 @@ class CustomContainer extends StatelessWidget { content = Material( color: Colors.transparent, type: MaterialType.transparency, - shape: circle ? const CircleBorder() : RoundedRectangleBorder(borderRadius: br), + shape: circle + ? const CircleBorder() + : RoundedRectangleBorder(borderRadius: br), child: InkWell( - splashColor: onTap != null ? rippleColor ?? theme.splashColor : Colors.transparent, - customBorder: circle ? const CircleBorder() : RoundedRectangleBorder(borderRadius: br), + splashColor: onTap != null + ? rippleColor ?? theme.splashColor + : Colors.transparent, + customBorder: circle + ? const CircleBorder() + : RoundedRectangleBorder(borderRadius: br), onTap: onTap, onLongPress: onLongPress, onDoubleTap: onDoubleTap, @@ -114,16 +120,17 @@ class CustomContainer extends StatelessWidget { ), ); - final List boxShadow = boxShadows ?? elevation != 0 - ? [ - BoxShadow( - color: shadowColor ?? Colors.black12, - offset: _getShadowOffset(min(elevation / 5.0, 1.0)), - blurRadius: elevation, - spreadRadius: 0, - ), - ] - : const []; + final List boxShadow = boxShadows ?? + (elevation != 0 + ? [ + BoxShadow( + color: shadowColor, + offset: _getShadowOffset(min(elevation / 5.0, 1.0)), + blurRadius: elevation, + spreadRadius: 0, + ), + ] + : const []); final boxDecoration = BoxDecoration( color: color, @@ -159,31 +166,22 @@ class CustomContainer extends StatelessWidget { switch (shadowDirection) { case ShadowDirection.topLeft: return Offset(-1 * xm, -1 * ym); - break; case ShadowDirection.top: return Offset(0, -1 * ym); - break; case ShadowDirection.topRight: return Offset(xm, -1 * ym); - break; case ShadowDirection.right: return Offset(xm, 0); - break; case ShadowDirection.bottomRight: return Offset(xm, ym); - break; case ShadowDirection.bottom: return Offset(0, ym); - break; case ShadowDirection.bottomLeft: return Offset(-1 * xm, ym); - break; case ShadowDirection.left: return Offset(-1 * xm, 0); - break; default: return Offset.zero; - break; } } } diff --git a/example/pubspec.lock b/example/pubspec.lock index 235ce30..d28c723 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -25,22 +25,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.1" - charts_common: - dependency: transitive - description: - name: charts_common - sha256: c5fe2078107211b563c11193dfb5c0c4fe263911941cff900eda816c7f963e49 - url: "https://pub.dev" - source: hosted - version: "0.8.1" - charts_flutter: - dependency: "direct main" - description: - name: charts_flutter - sha256: b202fb13e7067d372dd735597cee690a6d97107cf3572b00d3d71300c336b0aa - url: "https://pub.dev" - source: hosted - version: "0.8.1" clock: dependency: transitive description: @@ -57,6 +41,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.17.0" + community_charts_common: + dependency: transitive + description: + name: community_charts_common + sha256: bcda2831d8c3225036102dff007e2a901a2fdfcbba604e10c78db3fe5d9362a5 + url: "https://pub.dev" + source: hosted + version: "1.0.1" + community_charts_flutter: + dependency: "direct main" + description: + name: community_charts_flutter + sha256: "2294cba46b67659109b665f2d9ffeffef93bb1540a5e7a7bcf2630b809a9363e" + url: "https://pub.dev" + source: hosted + version: "1.0.1" fake_async: dependency: transitive description: @@ -70,6 +70,14 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c + url: "https://pub.dev" + source: hosted + version: "2.0.1" flutter_test: dependency: "direct dev" description: flutter @@ -79,10 +87,10 @@ packages: dependency: transitive description: name: intl - sha256: "4691515bb3f68ebbc4776bc97a84d429bb8e8c141a77b5ab988a4b02adb1747a" + sha256: a3715e3bc90294e971cb7dc063fbf3cd9ee0ebf8604ffeafabd9e6f16abbdbe6 url: "https://pub.dev" source: hosted - version: "0.16.1" + version: "0.18.0" js: dependency: transitive description: @@ -91,14 +99,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.6.5" - logging: + lints: dependency: transitive description: - name: logging - sha256: "0520a4826042a8a5d09ddd4755623a50d37ee536d79a70452aff8c8ad7bb6c27" + name: lints + sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593" url: "https://pub.dev" source: hosted - version: "1.0.1" + version: "2.0.1" matcher: dependency: transitive description: @@ -119,10 +127,10 @@ packages: dependency: "direct main" description: name: material_design_icons_flutter - sha256: "6b527ea0ef01b9b702e3b8252cf27ca9ddc759777ea1a0483ec973e002f6386a" + sha256: "8ef8562d16e747b2d93e5da5c2508931588939c5c00ebc8e2768e803db7dfd3c" url: "https://pub.dev" source: hosted - version: "4.0.5045" + version: "6.0.7096" meta: dependency: transitive description: @@ -144,13 +152,6 @@ packages: description: flutter source: sdk version: "0.0.99" - sliding_sheet: - dependency: "direct main" - description: - path: ".." - relative: true - source: path - version: "0.5.0" source_span: dependency: transitive description: @@ -207,6 +208,13 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + wtf_sliding_sheet: + dependency: "direct main" + description: + path: ".." + relative: true + source: path + version: "0.6.0" sdks: - dart: ">=2.18.0 <3.0.0" - flutter: ">=0.1.2" + dart: ">=2.19.0 <3.0.0" + flutter: ">=2.5.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index ec3bdca..1f51c75 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -4,18 +4,21 @@ version: 1.0.0+1 publish_to: none environment: - sdk: ">=2.2.0 <3.0.0" + sdk: ">=2.19.0 <3.0.0" dependencies: + community_charts_flutter: ^1.0.1 + flutter: sdk: flutter - charts_flutter: ^0.8.1 - material_design_icons_flutter: ^4.0.5045 + + material_design_icons_flutter: ^6.0.7096 - sliding_sheet: + wtf_sliding_sheet: path: ../ dev_dependencies: + flutter_lints: ^2.0.1 flutter_test: sdk: flutter diff --git a/images/example_as_a_bottom_sheet_dialog.gif b/images/example_as_a_bottom_sheet_dialog.gif new file mode 100644 index 0000000..f9adeea Binary files /dev/null and b/images/example_as_a_bottom_sheet_dialog.gif differ diff --git a/images/example_as_a_widget.gif b/images/example_as_a_widget.gif new file mode 100644 index 0000000..29dfa0e Binary files /dev/null and b/images/example_as_a_widget.gif differ diff --git a/images/example_header_footer.gif b/images/example_header_footer.gif new file mode 100644 index 0000000..91c265d Binary files /dev/null and b/images/example_header_footer.gif differ diff --git a/images/example_material_effects.gif b/images/example_material_effects.gif new file mode 100644 index 0000000..ff0317f Binary files /dev/null and b/images/example_material_effects.gif differ diff --git a/images/example_preview.gif b/images/example_preview.gif new file mode 100644 index 0000000..8c88218 Binary files /dev/null and b/images/example_preview.gif differ diff --git a/images/example_snap_relative_to_height.png b/images/example_snap_relative_to_height.png new file mode 100644 index 0000000..4f362fb Binary files /dev/null and b/images/example_snap_relative_to_height.png differ diff --git a/images/example_snap_relative_to_space.png b/images/example_snap_relative_to_space.png new file mode 100644 index 0000000..4338253 Binary files /dev/null and b/images/example_snap_relative_to_space.png differ diff --git a/images/example_snap_to_pixel_offset.png b/images/example_snap_to_pixel_offset.png new file mode 100644 index 0000000..9ad6523 Binary files /dev/null and b/images/example_snap_to_pixel_offset.png differ diff --git a/lib/src/sheet_container.dart b/lib/src/sheet_container.dart index 593efcb..5c712cf 100644 --- a/lib/src/sheet_container.dart +++ b/lib/src/sheet_container.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:sliding_sheet/src/sheet_listener_builder.dart'; +import 'package:wtf_sliding_sheet/src/sheet_listener_builder.dart'; import 'sheet.dart'; diff --git a/lib/sliding_sheet.dart b/lib/wtf_sliding_sheet.dart similarity index 77% rename from lib/sliding_sheet.dart rename to lib/wtf_sliding_sheet.dart index d816239..4d5f262 100644 --- a/lib/sliding_sheet.dart +++ b/lib/wtf_sliding_sheet.dart @@ -1,4 +1,4 @@ -library sliding_sheet; +library wtf_sliding_sheet; export 'src/sheet.dart'; export 'src/sheet_listener_builder.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index 67da38a..e1b03c7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,8 @@ -name: sliding_sheet +name: wtf_sliding_sheet description: A widget that can be dragged and scrolled in a single gesture and snapped to a list of extents. -version: 0.5.0 -homepage: https://github.com/bnxm/sliding_sheet +version: 0.6.0 +homepage: https://github.com/flutterwtf/sliding_sheet +repository: https://github.com/flutterwtf/sliding_sheet environment: sdk: '>=2.17.0 <3.0.0'