mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 19:14:42 +08:00
update flutter widgets
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -21,9 +21,6 @@ import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
// Examples can assume:
|
||||
// late BuildContext context;
|
||||
|
||||
abstract class _ParentInkResponseState {
|
||||
void markChildInkResponsePressed(
|
||||
_ParentInkResponseState childState,
|
||||
@@ -144,6 +141,7 @@ class InkResponse extends StatelessWidget {
|
||||
this.onTapCancel,
|
||||
this.onDoubleTap,
|
||||
this.onLongPress,
|
||||
this.onLongPressUp,
|
||||
this.onSecondaryTap,
|
||||
this.onSecondaryTapUp,
|
||||
this.onSecondaryTapDown,
|
||||
@@ -197,6 +195,19 @@ class InkResponse extends StatelessWidget {
|
||||
/// Called when the user long-presses on this part of the material.
|
||||
final GestureLongPressCallback? onLongPress;
|
||||
|
||||
/// Called when the user lifts their finger after a long press on the button.
|
||||
///
|
||||
/// This callback is triggered at the end of a long press gesture, specifically
|
||||
/// after the user holds a long press and then releases it. It does not include
|
||||
/// position details.
|
||||
///
|
||||
/// Common use cases include performing an action only after the long press completes,
|
||||
/// such as displaying a context menu or confirming a held gesture.
|
||||
///
|
||||
/// See also:
|
||||
/// * [onLongPress], which is triggered when the long press gesture is first recognized.
|
||||
final GestureLongPressUpCallback? onLongPressUp;
|
||||
|
||||
/// Called when the user taps this part of the material with a secondary button.
|
||||
///
|
||||
/// See also:
|
||||
@@ -237,7 +248,7 @@ class InkResponse extends StatelessWidget {
|
||||
/// become highlighted and false if this part of the material has stopped
|
||||
/// being highlighted.
|
||||
///
|
||||
/// If all of [onTap], [onDoubleTap], and [onLongPress] become null while a
|
||||
/// If all of [onTap], [onDoubleTap], [onLongPress], and [onLongPressUp] become null while a
|
||||
/// gesture is ongoing, then [onTapCancel] will be fired and
|
||||
/// [onHighlightChanged] will be fired with the value false _during the
|
||||
/// build_. This means, for instance, that in that scenario [State.setState]
|
||||
@@ -493,6 +504,7 @@ class InkResponse extends StatelessWidget {
|
||||
onTapCancel: onTapCancel,
|
||||
onDoubleTap: onDoubleTap,
|
||||
onLongPress: onLongPress,
|
||||
onLongPressUp: onLongPressUp,
|
||||
onSecondaryTap: onSecondaryTap,
|
||||
onSecondaryTapUp: onSecondaryTapUp,
|
||||
onSecondaryTapDown: onSecondaryTapDown,
|
||||
@@ -550,6 +562,7 @@ class _InkResponseStateWidget extends StatefulWidget {
|
||||
this.onTapCancel,
|
||||
this.onDoubleTap,
|
||||
this.onLongPress,
|
||||
this.onLongPressUp,
|
||||
this.onSecondaryTap,
|
||||
this.onSecondaryTapUp,
|
||||
this.onSecondaryTapDown,
|
||||
@@ -588,6 +601,7 @@ class _InkResponseStateWidget extends StatefulWidget {
|
||||
final GestureTapCallback? onTapCancel;
|
||||
final GestureTapCallback? onDoubleTap;
|
||||
final GestureLongPressCallback? onLongPress;
|
||||
final GestureLongPressUpCallback? onLongPressUp;
|
||||
final GestureTapCallback? onSecondaryTap;
|
||||
final GestureTapUpCallback? onSecondaryTapUp;
|
||||
final GestureTapDownCallback? onSecondaryTapDown;
|
||||
@@ -628,6 +642,7 @@ class _InkResponseStateWidget extends StatefulWidget {
|
||||
if (onTap != null) 'tap',
|
||||
if (onDoubleTap != null) 'double tap',
|
||||
if (onLongPress != null) 'long press',
|
||||
if (onLongPressUp != null) 'long press up',
|
||||
if (onTapDown != null) 'tap down',
|
||||
if (onTapUp != null) 'tap up',
|
||||
if (onTapCancel != null) 'tap cancel',
|
||||
@@ -1099,6 +1114,12 @@ class _InkResponseState extends State<_InkResponseStateWidget>
|
||||
}
|
||||
}
|
||||
|
||||
void handleLongPressUp() {
|
||||
_currentSplash?.confirm();
|
||||
_currentSplash = null;
|
||||
widget.onLongPressUp?.call();
|
||||
}
|
||||
|
||||
void handleSecondaryTap() {
|
||||
_currentSplash?.confirm();
|
||||
_currentSplash = null;
|
||||
@@ -1140,6 +1161,7 @@ class _InkResponseState extends State<_InkResponseStateWidget>
|
||||
return widget.onTap != null ||
|
||||
widget.onDoubleTap != null ||
|
||||
widget.onLongPress != null ||
|
||||
widget.onLongPressUp != null ||
|
||||
widget.onTapUp != null ||
|
||||
widget.onTapDown != null;
|
||||
}
|
||||
@@ -1276,6 +1298,9 @@ class _InkResponseState extends State<_InkResponseStateWidget>
|
||||
onLongPress: widget.onLongPress != null
|
||||
? handleLongPress
|
||||
: null,
|
||||
onLongPressUp: widget.onLongPressUp != null
|
||||
? handleLongPressUp
|
||||
: null,
|
||||
onSecondaryTapDown: _secondaryEnabled
|
||||
? handleSecondaryTapDown
|
||||
: null,
|
||||
@@ -1387,6 +1412,7 @@ class InkWell extends InkResponse {
|
||||
super.onTap,
|
||||
super.onDoubleTap,
|
||||
super.onLongPress,
|
||||
super.onLongPressUp,
|
||||
super.onTapDown,
|
||||
super.onTapUp,
|
||||
super.onTapCancel,
|
||||
|
||||
Reference in New Issue
Block a user