diff --git a/example/ios/Flutter/ephemeral/flutter_lldb_helper.py b/example/ios/Flutter/ephemeral/flutter_lldb_helper.py new file mode 100644 index 0000000..a88caf9 --- /dev/null +++ b/example/ios/Flutter/ephemeral/flutter_lldb_helper.py @@ -0,0 +1,32 @@ +# +# Generated file, do not edit. +# + +import lldb + +def handle_new_rx_page(frame: lldb.SBFrame, bp_loc, extra_args, intern_dict): + """Intercept NOTIFY_DEBUGGER_ABOUT_RX_PAGES and touch the pages.""" + base = frame.register["x0"].GetValueAsAddress() + page_len = frame.register["x1"].GetValueAsUnsigned() + + # Note: NOTIFY_DEBUGGER_ABOUT_RX_PAGES will check contents of the + # first page to see if handled it correctly. This makes diagnosing + # misconfiguration (e.g. missing breakpoint) easier. + data = bytearray(page_len) + data[0:8] = b'IHELPED!' + + error = lldb.SBError() + frame.GetThread().GetProcess().WriteMemory(base, data, error) + if not error.Success(): + print(f'Failed to write into {base}[+{page_len}]', error) + return + +def __lldb_init_module(debugger: lldb.SBDebugger, _): + target = debugger.GetDummyTarget() + # Caveat: must use BreakpointCreateByRegEx here and not + # BreakpointCreateByName. For some reasons callback function does not + # get carried over from dummy target for the later. + bp = target.BreakpointCreateByRegex("^NOTIFY_DEBUGGER_ABOUT_RX_PAGES$") + bp.SetScriptCallbackFunction('{}.handle_new_rx_page'.format(__name__)) + bp.SetAutoContinue(True) + print("-- LLDB integration loaded --") diff --git a/example/ios/Flutter/ephemeral/flutter_lldbinit b/example/ios/Flutter/ephemeral/flutter_lldbinit new file mode 100644 index 0000000..e3ba6fb --- /dev/null +++ b/example/ios/Flutter/ephemeral/flutter_lldbinit @@ -0,0 +1,5 @@ +# +# Generated file, do not edit. +# + +command script import --relative-to-command-file flutter_lldb_helper.py diff --git a/example/lib/main_demo.dart b/example/lib/main_demo.dart index afb1b97..093eede 100644 --- a/example/lib/main_demo.dart +++ b/example/lib/main_demo.dart @@ -267,7 +267,7 @@ class SlideAction extends StatelessWidget { backgroundColor: color, foregroundColor: Colors.white, onPressed: (_) { - print(icon); + debugPrint(icon.toString()); }, icon: icon, label: 'hello', @@ -291,7 +291,7 @@ class Tile extends StatelessWidget { return ActionTypeListener( child: GestureDetector( onTap: () { - print('$text'); + debugPrint('Tile tapped: $text'); }, onLongPress: () => Slidable.of(context)!.openEndActionPane(), child: Container( diff --git a/example/lib/main_issue_251.dart b/example/lib/main_issue_251.dart index 6f6b0da..b5043fc 100644 --- a/example/lib/main_issue_251.dart +++ b/example/lib/main_issue_251.dart @@ -68,7 +68,7 @@ class _ListItemState extends State { startActionPane: ActionPane( closeThreshold: 0.5, openThreshold: 0.6, - extentRatio: 0.5, + //extentRatio: 0.5, motion: const BehindMotion(), children: [RememberedArea(colorNotifier: colorNotifier)], ), diff --git a/lib/flutter_slidable.dart b/lib/flutter_slidable.dart index 7665b26..1d845cd 100644 --- a/lib/flutter_slidable.dart +++ b/lib/flutter_slidable.dart @@ -2,16 +2,10 @@ library flutter_slidable; export 'src/action_pane_motions.dart'; export 'src/actions.dart'; -export 'src/auto_close_behavior.dart' - show SlidableAutoCloseBehavior, SlidableAutoCloseNotification; -export 'src/controller.dart' - show ResizeRequest, SlidableController, ActionPaneType; +export 'src/auto_close_behavior.dart' show SlidableAutoCloseBehavior, SlidableAutoCloseNotification; +export 'src/controller.dart' show ResizeRequest, SlidableController, ActionPaneType; export 'src/dismissible_pane.dart'; export 'src/dismissible_pane_motions.dart'; export 'src/notifications.dart'; -export 'src/notifications_old.dart' - show - SlidableNotification, - SlidableRatioNotification, - SlidableNotificationListener; +export 'src/notifications_old.dart' show SlidableNotification, SlidableRatioNotification, SlidableNotificationListener; export 'src/slidable.dart'; diff --git a/lib/src/actions.dart b/lib/src/actions.dart index 91140e8..852386f 100644 --- a/lib/src/actions.dart +++ b/lib/src/actions.dart @@ -84,11 +84,8 @@ class CustomSlidableAction extends StatelessWidget { @override Widget build(BuildContext context) { - final effectiveForegroundColor = foregroundColor ?? - (ThemeData.estimateBrightnessForColor(backgroundColor) == - Brightness.light - ? Colors.black - : Colors.white); + final effectiveForegroundColor = + foregroundColor ?? (ThemeData.estimateBrightnessForColor(backgroundColor) == Brightness.light ? Colors.black : Colors.white); return Expanded( flex: flex, @@ -140,8 +137,10 @@ class SlidableAction extends StatelessWidget { this.autoClose = _kAutoClose, required this.onPressed, this.icon, + this.iconSize = 24.0, this.spacing = 4, this.label, + this.labelStyle, this.borderRadius = BorderRadius.zero, this.padding, }) : assert(flex > 0), @@ -165,6 +164,9 @@ class SlidableAction extends StatelessWidget { /// An icon to display above the [label]. final IconData? icon; + /// The size of the [icon] if set. + final double iconSize; + /// The space between [icon] and [label] if both set. /// /// Defaults to 4. @@ -173,6 +175,11 @@ class SlidableAction extends StatelessWidget { /// A label to display below the [icon]. final String? label; + /// The style of the [label] if set. + /// + /// If null, the [label] will use the default text style of the current theme + final TextStyle? labelStyle; + /// Padding of the OutlinedButton final BorderRadius borderRadius; @@ -185,7 +192,10 @@ class SlidableAction extends StatelessWidget { if (icon != null) { children.add( - Icon(icon), + Icon( + icon, + size: iconSize, + ), ); } @@ -200,6 +210,11 @@ class SlidableAction extends StatelessWidget { Text( label!, overflow: TextOverflow.ellipsis, + style: labelStyle ?? + Theme.of(context).textTheme.bodyMedium?.copyWith( + color: + foregroundColor ?? (ThemeData.estimateBrightnessForColor(backgroundColor) == Brightness.light ? Colors.black : Colors.white), + ), ), ); } diff --git a/lib/src/auto_close_behavior.dart b/lib/src/auto_close_behavior.dart index b86cc84..e3abec6 100644 --- a/lib/src/auto_close_behavior.dart +++ b/lib/src/auto_close_behavior.dart @@ -32,8 +32,7 @@ class SlidableAutoCloseBehavior extends StatefulWidget { final Widget child; @override - State createState() => - _SlidableAutoCloseBehaviorState(); + State createState() => _SlidableAutoCloseBehaviorState(); } class _SlidableAutoCloseBehaviorState extends State { @@ -48,10 +47,8 @@ class _SlidableAutoCloseBehaviorState extends State { child: SlidableGroupBehavior( onNotification: (notification) { final key = notification.groupTag; - final previousOpenForThatTag = - openSlidables.putIfAbsent(key, () => 0); - final openForThatTag = - previousOpenForThatTag + (notification.enabled ? 1 : -1); + final previousOpenForThatTag = openSlidables.putIfAbsent(key, () => 0); + final openForThatTag = previousOpenForThatTag + (notification.enabled ? 1 : -1); openSlidables[key] = openForThatTag; if (openForThatTag == 0 || previousOpenForThatTag == 0) { return notification; @@ -77,8 +74,7 @@ class _SlidableAutoCloseData extends InheritedWidget { @override bool updateShouldNotify(_SlidableAutoCloseData oldWidget) { - return oldWidget.closeWhenOpened != closeWhenOpened || - oldWidget.closeWhenTapped != closeWhenTapped; + return oldWidget.closeWhenOpened != closeWhenOpened || oldWidget.closeWhenTapped != closeWhenTapped; } static _SlidableAutoCloseData? of(BuildContext context) { @@ -205,9 +201,7 @@ class SlidableAutoCloseBehaviorListener extends StatelessWidget { Widget build(BuildContext context) { return SlidableGroupBehaviorListener( onNotification: (SlidableAutoCloseNotification notification) { - if (groupTag == notification.groupTag && - (notification.closeSelf || notification.controller != controller) && - !controller.closing) { + if (groupTag == notification.groupTag && (notification.closeSelf || notification.controller != controller) && !controller.closing) { controller.close(); } }, @@ -238,8 +232,7 @@ class SlidableAutoCloseNotificationSender extends StatelessWidget { final Widget child; void _handleStatusChanged(BuildContext context, AnimationStatus status) { - final moving = - status == AnimationStatus.forward || status == AnimationStatus.reverse; + final moving = status == AnimationStatus.forward || status == AnimationStatus.reverse; if (moving && !controller.closing) { SlidableGroupNotification.dispatch( context, @@ -343,12 +336,10 @@ class SlidableAutoCloseBarrierNotificationSender extends StatefulWidget { final Widget child; @override - State createState() => - _SlidableAutoCloseBarrierNotificationSenderState(); + State createState() => _SlidableAutoCloseBarrierNotificationSenderState(); } -class _SlidableAutoCloseBarrierNotificationSenderState - extends State { +class _SlidableAutoCloseBarrierNotificationSenderState extends State { SlidableGroupNotificationDispatcher? dispatcher; void _handleStatusChanged(AnimationStatus status) { @@ -356,8 +347,7 @@ class _SlidableAutoCloseBarrierNotificationSenderState final willBarrierBeEnabled = status != AnimationStatus.dismissed; final barrierEnabled = dispatcher != null; if (willBarrierBeEnabled != barrierEnabled) { - dispatcher = SlidableGroupNotification.createDispatcher< - SlidableAutoCloseBarrierNotification>( + dispatcher = SlidableGroupNotification.createDispatcher( context, assertParentExists: false, ); @@ -434,12 +424,10 @@ class SlidableAutoCloseBarrierBehaviorListener extends StatefulWidget { final Widget child; @override - _SlidableAutoCloseBarrierBehaviorListenerState createState() => - _SlidableAutoCloseBarrierBehaviorListenerState(); + _SlidableAutoCloseBarrierBehaviorListenerState createState() => _SlidableAutoCloseBarrierBehaviorListenerState(); } -class _SlidableAutoCloseBarrierBehaviorListenerState - extends State { +class _SlidableAutoCloseBarrierBehaviorListenerState extends State { bool absorbing = false; void handleOnTap() { @@ -498,12 +486,10 @@ class _SlidableNotificationSender extends StatefulWidget { final bool enabled; @override - _SlidableNotificationSenderState createState() => - _SlidableNotificationSenderState(); + _SlidableNotificationSenderState createState() => _SlidableNotificationSenderState(); } -class _SlidableNotificationSenderState - extends State<_SlidableNotificationSender> { +class _SlidableNotificationSenderState extends State<_SlidableNotificationSender> { @override void initState() { super.initState(); @@ -513,8 +499,7 @@ class _SlidableNotificationSenderState @override void didUpdateWidget(_SlidableNotificationSender oldWidget) { super.didUpdateWidget(oldWidget); - if (oldWidget.controller != widget.controller || - oldWidget.onStatusChanged != widget.onStatusChanged) { + if (oldWidget.controller != widget.controller || oldWidget.onStatusChanged != widget.onStatusChanged) { removeListeners(oldWidget); addListeners(widget); }