mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-08-01 08:20:14 +08:00
@@ -1,4 +1,6 @@
|
||||
part of 'package:PiliPlus/common/widgets/flutter/draggable_scrollable_sheet.dart';
|
||||
|
||||
import 'package:flutter/gestures.dart' show Drag;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class DynDraggableScrollableSheet extends DraggableScrollableSheet {
|
||||
const DynDraggableScrollableSheet({
|
||||
@@ -20,34 +22,21 @@ class DynDraggableScrollableSheet extends DraggableScrollableSheet {
|
||||
_DynDraggableScrollableSheetState();
|
||||
}
|
||||
|
||||
class _DynDraggableScrollableSheetState extends _DraggableScrollableSheetState {
|
||||
class _DynDraggableScrollableSheetState extends DraggableScrollableSheetState {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_extent = _DraggableSheetExtent(
|
||||
minSize: widget.minChildSize,
|
||||
maxSize: widget.maxChildSize,
|
||||
snap: widget.snap,
|
||||
snapSizes: _impliedSnapSizes(),
|
||||
snapAnimationDuration: widget.snapAnimationDuration,
|
||||
initialSize: widget.initialChildSize,
|
||||
shouldCloseOnMinExtent: widget.shouldCloseOnMinExtent,
|
||||
);
|
||||
_scrollController = _DynDraggableScrollableSheetScrollController(
|
||||
extent: _extent,
|
||||
);
|
||||
widget.controller?._attach(_scrollController);
|
||||
void initScrollController() {
|
||||
scrollController = _DynDraggableScrollableSheetScrollController(extent: extent);
|
||||
}
|
||||
}
|
||||
|
||||
class _DynDraggableScrollableSheetScrollController
|
||||
extends _DraggableScrollableSheetScrollController {
|
||||
extends DraggableScrollableSheetScrollController {
|
||||
_DynDraggableScrollableSheetScrollController({
|
||||
required super.extent,
|
||||
});
|
||||
|
||||
@override
|
||||
_DraggableScrollableSheetScrollPosition createScrollPosition(
|
||||
DraggableScrollableSheetScrollPosition createScrollPosition(
|
||||
ScrollPhysics physics,
|
||||
ScrollContext context,
|
||||
ScrollPosition? oldPosition,
|
||||
@@ -62,7 +51,7 @@ class _DynDraggableScrollableSheetScrollController
|
||||
}
|
||||
|
||||
class _DynDraggableScrollableSheetScrollPosition
|
||||
extends _DraggableScrollableSheetScrollPosition {
|
||||
extends DraggableScrollableSheetScrollPosition {
|
||||
_DynDraggableScrollableSheetScrollPosition({
|
||||
required super.physics,
|
||||
required super.context,
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
part of 'package:PiliPlus/common/widgets/flutter/draggable_scrollable_sheet.dart';
|
||||
|
||||
class TopicDraggableScrollableSheet extends DraggableScrollableSheet {
|
||||
const TopicDraggableScrollableSheet({
|
||||
super.key,
|
||||
super.initialChildSize,
|
||||
super.minChildSize,
|
||||
super.maxChildSize,
|
||||
super.expand,
|
||||
super.snap,
|
||||
super.snapSizes,
|
||||
super.snapAnimationDuration,
|
||||
super.controller,
|
||||
super.shouldCloseOnMinExtent,
|
||||
required super.builder,
|
||||
this.initialScrollOffset = 0.0,
|
||||
});
|
||||
|
||||
final double initialScrollOffset;
|
||||
|
||||
@override
|
||||
State<DraggableScrollableSheet> createState() =>
|
||||
_TopicDraggableScrollableSheetState();
|
||||
}
|
||||
|
||||
class _TopicDraggableScrollableSheetState
|
||||
extends _DraggableScrollableSheetState {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_extent = _DraggableSheetExtent(
|
||||
minSize: widget.minChildSize,
|
||||
maxSize: widget.maxChildSize,
|
||||
snap: widget.snap,
|
||||
snapSizes: _impliedSnapSizes(),
|
||||
snapAnimationDuration: widget.snapAnimationDuration,
|
||||
initialSize: widget.initialChildSize,
|
||||
shouldCloseOnMinExtent: widget.shouldCloseOnMinExtent,
|
||||
);
|
||||
_scrollController = _TopicDraggableScrollableSheetScrollController(
|
||||
extent: _extent,
|
||||
initialScrollOffset:
|
||||
(widget as TopicDraggableScrollableSheet).initialScrollOffset,
|
||||
);
|
||||
widget.controller?._attach(_scrollController);
|
||||
}
|
||||
}
|
||||
|
||||
class _TopicDraggableScrollableSheetScrollController
|
||||
extends _DraggableScrollableSheetScrollController {
|
||||
_TopicDraggableScrollableSheetScrollController({
|
||||
required super.extent,
|
||||
this._initialScrollOffset = 0.0,
|
||||
});
|
||||
|
||||
@override
|
||||
double get initialScrollOffset => _initialScrollOffset;
|
||||
final double _initialScrollOffset;
|
||||
|
||||
@override
|
||||
_DraggableScrollableSheetScrollPosition createScrollPosition(
|
||||
ScrollPhysics physics,
|
||||
ScrollContext context,
|
||||
ScrollPosition? oldPosition,
|
||||
) {
|
||||
return _DraggableScrollableSheetScrollPosition(
|
||||
physics: physics.applyTo(const AlwaysScrollableScrollPhysics()),
|
||||
context: context,
|
||||
oldPosition: oldPosition,
|
||||
getExtent: () => extent,
|
||||
initialPixels: _initialScrollOffset,
|
||||
);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@ import 'package:PiliPlus/common/style.dart';
|
||||
import 'package:PiliPlus/common/widgets/button/icon_button.dart';
|
||||
import 'package:PiliPlus/common/widgets/button/toolbar_icon_button.dart';
|
||||
import 'package:PiliPlus/common/widgets/custom_icon.dart';
|
||||
import 'package:PiliPlus/common/widgets/flutter/draggable_scrollable_sheet.dart';
|
||||
import 'package:PiliPlus/common/widgets/draggable_sheet/dyn.dart';
|
||||
import 'package:PiliPlus/common/widgets/flutter/text_field/controller.dart';
|
||||
import 'package:PiliPlus/common/widgets/flutter/text_field/text_field.dart';
|
||||
import 'package:PiliPlus/common/widgets/pair.dart';
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/common/widgets/flutter/draggable_scrollable_sheet.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/loading_widget.dart';
|
||||
import 'package:PiliPlus/common/widgets/sliver/sliver_pinned_header.dart';
|
||||
@@ -38,7 +37,7 @@ class DynMentionPanel extends StatefulWidget {
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: min(600, context.mediaQueryShortestSide),
|
||||
),
|
||||
builder: (context) => TopicDraggableScrollableSheet(
|
||||
builder: (context) => DraggableScrollableSheet(
|
||||
expand: false,
|
||||
snap: true,
|
||||
minChildSize: 0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'package:PiliPlus/common/widgets/flutter/draggable_scrollable_sheet.dart';
|
||||
import 'package:PiliPlus/common/widgets/draggable_sheet/dyn.dart';
|
||||
import 'package:PiliPlus/common/widgets/flutter/text_field/text_field.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/common/widgets/scroll_physics.dart'
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/common/widgets/flutter/draggable_scrollable_sheet.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/loading_widget.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models_new/dynamic/dyn_topic_top/topic_item.dart';
|
||||
@@ -35,7 +34,7 @@ class SelectTopicPanel extends StatefulWidget {
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: min(600, context.mediaQueryShortestSide),
|
||||
),
|
||||
builder: (context) => TopicDraggableScrollableSheet(
|
||||
builder: (context) => DraggableScrollableSheet(
|
||||
expand: false,
|
||||
snap: true,
|
||||
minChildSize: 0,
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'dart:io' show Platform;
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:PiliPlus/common/style.dart';
|
||||
import 'package:PiliPlus/common/widgets/flutter/draggable_scrollable_sheet.dart';
|
||||
import 'package:PiliPlus/common/widgets/draggable_sheet/dyn.dart';
|
||||
import 'package:PiliPlus/common/widgets/marquee.dart';
|
||||
import 'package:PiliPlus/models/common/video/live_quality.dart';
|
||||
import 'package:PiliPlus/pages/live_room/controller.dart';
|
||||
|
||||
94
lib/scripts/draggable_scrollable_sheet.patch
Normal file
94
lib/scripts/draggable_scrollable_sheet.patch
Normal file
@@ -0,0 +1,94 @@
|
||||
diff --git a/packages/flutter/lib/src/widgets/draggable_scrollable_sheet.dart b/packages/flutter/lib/src/widgets/draggable_scrollable_sheet.dart
|
||||
index 0022f5000d2..c593779bf3e 100644
|
||||
--- a/packages/flutter/lib/src/widgets/draggable_scrollable_sheet.dart
|
||||
+++ b/packages/flutter/lib/src/widgets/draggable_scrollable_sheet.dart
|
||||
@@ -311,6 +311,7 @@ class DraggableScrollableSheet extends StatefulWidget {
|
||||
this.snapAnimationDuration,
|
||||
this.controller,
|
||||
this.shouldCloseOnMinExtent = true,
|
||||
+ this.initialScrollOffset = 0.0,
|
||||
required this.builder,
|
||||
}) : assert(minChildSize >= 0.0),
|
||||
assert(maxChildSize <= 1.0),
|
||||
@@ -318,6 +319,8 @@ class DraggableScrollableSheet extends StatefulWidget {
|
||||
assert(initialChildSize <= maxChildSize),
|
||||
assert(snapAnimationDuration == null || snapAnimationDuration > Duration.zero);
|
||||
|
||||
+ final double initialScrollOffset;
|
||||
+
|
||||
/// The initial fractional value of the parent container's height to use when
|
||||
/// displaying the widget.
|
||||
///
|
||||
@@ -644,9 +647,15 @@ class _DraggableSheetExtent {
|
||||
}
|
||||
}
|
||||
|
||||
+typedef DraggableScrollableSheetState = _DraggableScrollableSheetState;
|
||||
+
|
||||
class _DraggableScrollableSheetState extends State<DraggableScrollableSheet> {
|
||||
late _DraggableScrollableSheetScrollController _scrollController;
|
||||
+ set scrollController(_DraggableScrollableSheetScrollController controller) {
|
||||
+ _scrollController = controller;
|
||||
+ }
|
||||
late _DraggableSheetExtent _extent;
|
||||
+ _DraggableSheetExtent get extent => _extent;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -660,10 +669,17 @@ class _DraggableScrollableSheetState extends State<DraggableScrollableSheet> {
|
||||
initialSize: widget.initialChildSize,
|
||||
shouldCloseOnMinExtent: widget.shouldCloseOnMinExtent,
|
||||
);
|
||||
- _scrollController = _DraggableScrollableSheetScrollController(extent: _extent);
|
||||
+ initScrollController();
|
||||
widget.controller?._attach(_scrollController);
|
||||
}
|
||||
|
||||
+ void initScrollController() {
|
||||
+ _scrollController = _DraggableScrollableSheetScrollController(
|
||||
+ extent: _extent,
|
||||
+ initialScrollOffset: widget.initialScrollOffset,
|
||||
+ );
|
||||
+ }
|
||||
+
|
||||
List<double> _impliedSnapSizes() {
|
||||
for (var index = 0; index < (widget.snapSizes?.length ?? 0); index += 1) {
|
||||
final double snapSize = widget.snapSizes![index];
|
||||
@@ -799,8 +815,11 @@ class _DraggableScrollableSheetState extends State<DraggableScrollableSheet> {
|
||||
/// * [PrimaryScrollController], which can be used to establish a
|
||||
/// [_DraggableScrollableSheetScrollController] as the primary controller for
|
||||
/// descendants.
|
||||
+
|
||||
+typedef DraggableScrollableSheetScrollController = _DraggableScrollableSheetScrollController;
|
||||
+
|
||||
class _DraggableScrollableSheetScrollController extends ScrollController {
|
||||
- _DraggableScrollableSheetScrollController({required this.extent});
|
||||
+ _DraggableScrollableSheetScrollController({required this.extent, super.initialScrollOffset});
|
||||
|
||||
_DraggableSheetExtent extent;
|
||||
VoidCallback? onPositionDetached;
|
||||
@@ -816,6 +835,7 @@ class _DraggableScrollableSheetScrollController extends ScrollController {
|
||||
context: context,
|
||||
oldPosition: oldPosition,
|
||||
getExtent: () => extent,
|
||||
+ initialPixels: initialScrollOffset,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -861,12 +881,16 @@ class _DraggableScrollableSheetScrollController extends ScrollController {
|
||||
/// See also:
|
||||
///
|
||||
/// * [_DraggableScrollableSheetScrollController], which uses this as its [ScrollPosition].
|
||||
+
|
||||
+typedef DraggableScrollableSheetScrollPosition = _DraggableScrollableSheetScrollPosition;
|
||||
+
|
||||
class _DraggableScrollableSheetScrollPosition extends ScrollPositionWithSingleContext {
|
||||
_DraggableScrollableSheetScrollPosition({
|
||||
required super.physics,
|
||||
required super.context,
|
||||
super.oldPosition,
|
||||
required this.getExtent,
|
||||
+ super.initialPixels,
|
||||
});
|
||||
|
||||
VoidCallback? _dragCancelCallback;
|
||||
@@ -69,6 +69,8 @@ $ScrollablePatch = "lib/scripts/scrollable.patch"
|
||||
|
||||
$ScrollableGesturePatch = "lib/scripts/scrollable_gesture.patch"
|
||||
|
||||
$DraggableScrollableSheetPatch = "lib/scripts/draggable_scrollable_sheet.patch"
|
||||
|
||||
# TODO: remove
|
||||
# https://github.com/flutter/flutter/issues/124078
|
||||
# https://github.com/flutter/flutter/pull/183261
|
||||
@@ -103,7 +105,8 @@ $patches = @($ModalBarrierPatch, $TextSelectionPatch, $MouseCursorPatch,
|
||||
$ImageAnimPatch, $LayoutBuilderPatch, $NavigationDrawerPatch,
|
||||
$PopupMenuPatch, $FABPatch, $NullSafetySelectableRegionPatch,
|
||||
$SelectableRegionPatch, $EditableTextPatch, $TextFieldPatch,
|
||||
$ScrollPositionPatch, $ScrollablePatch, $ScrollableGesturePatch)
|
||||
$ScrollPositionPatch, $ScrollablePatch, $ScrollableGesturePatch,
|
||||
$DraggableScrollableSheetPatch)
|
||||
|
||||
switch ($platform.ToLower()) {
|
||||
"android" {
|
||||
|
||||
Reference in New Issue
Block a user