From eb0dc79ba148325a9d2510ac4e8ddd752bdb992e Mon Sep 17 00:00:00 2001 From: Casey Rogers Date: Sun, 24 Sep 2023 02:49:56 -0700 Subject: [PATCH] adds an exposed sheet contorller to the better feedback controller (#239) --- feedback/example/android/build.gradle | 2 +- feedback/lib/src/feedback_bottom_sheet.dart | 1 + feedback/lib/src/feedback_controller.dart | 11 +++++++++-- feedback/lib/src/feedback_widget.dart | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/feedback/example/android/build.gradle b/feedback/example/android/build.gradle index 022a2c39..314de755 100644 --- a/feedback/example/android/build.gradle +++ b/feedback/example/android/build.gradle @@ -26,6 +26,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/feedback/lib/src/feedback_bottom_sheet.dart b/feedback/lib/src/feedback_bottom_sheet.dart index f6f00942..5a0dd79b 100644 --- a/feedback/lib/src/feedback_bottom_sheet.dart +++ b/feedback/lib/src/feedback_bottom_sheet.dart @@ -103,6 +103,7 @@ class _DraggableFeedbackSheetState extends State<_DraggableFeedbackSheet> { ), Expanded( child: DraggableScrollableSheet( + controller: BetterFeedback.of(context).sheetController, snap: true, minChildSize: collapsedHeight, initialChildSize: collapsedHeight, diff --git a/feedback/lib/src/feedback_controller.dart b/feedback/lib/src/feedback_controller.dart index 760b98a0..f8f68f9b 100644 --- a/feedback/lib/src/feedback_controller.dart +++ b/feedback/lib/src/feedback_controller.dart @@ -1,11 +1,11 @@ -import 'package:feedback/src/better_feedback.dart'; +import 'package:feedback/feedback.dart'; import 'package:flutter/material.dart'; /// Controls the state of the feeback ui. class FeedbackController extends ChangeNotifier { bool _isVisible = false; - /// Wether the feedback ui is currently visible. + /// Whether the feedback ui is currently visible. bool get isVisible => _isVisible; /// This function is called when the user submits his feedback. @@ -27,4 +27,11 @@ class FeedbackController extends ChangeNotifier { _isVisible = false; notifyListeners(); } + + /// The draggable scrollable sheet controller used by better feedback. + /// + /// The controller is only attached if [FeedbackThemeData.sheetIsDraggable] is + /// true and feedback is currently displayed. + final DraggableScrollableController sheetController = + DraggableScrollableController(); } diff --git a/feedback/lib/src/feedback_widget.dart b/feedback/lib/src/feedback_widget.dart index a625ca81..30c94886 100644 --- a/feedback/lib/src/feedback_widget.dart +++ b/feedback/lib/src/feedback_widget.dart @@ -57,7 +57,7 @@ class FeedbackWidgetState extends State // rebuilding the feedback sheet mid-drag cancels the drag. // TODO(caseycrogers): replace `sheetProgress` with a direct reference to // `DraggableScrollableController` when the latter gets into production. - // See: https://github.com/flutter/flutter/pull/92440. + // See: https://github.com/flutter/flutter/pull/135366. ValueNotifier sheetProgress = ValueNotifier(0); @visibleForTesting