Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions example/ios/Flutter/ephemeral/flutter_lldb_helper.py
Original file line number Diff line number Diff line change
@@ -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 --")
5 changes: 5 additions & 0 deletions example/ios/Flutter/ephemeral/flutter_lldbinit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#
# Generated file, do not edit.
#

command script import --relative-to-command-file flutter_lldb_helper.py
4 changes: 2 additions & 2 deletions example/lib/main_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class SlideAction extends StatelessWidget {
backgroundColor: color,
foregroundColor: Colors.white,
onPressed: (_) {
print(icon);
debugPrint(icon.toString());
},
icon: icon,
label: 'hello',
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion example/lib/main_issue_251.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class _ListItemState extends State<ListItem> {
startActionPane: ActionPane(
closeThreshold: 0.5,
openThreshold: 0.6,
extentRatio: 0.5,
//extentRatio: 0.5,
motion: const BehindMotion(),
children: [RememberedArea(colorNotifier: colorNotifier)],
),
Expand Down
12 changes: 3 additions & 9 deletions lib/flutter_slidable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
27 changes: 21 additions & 6 deletions lib/src/actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand All @@ -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.
Expand All @@ -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;

Expand All @@ -185,7 +192,10 @@ class SlidableAction extends StatelessWidget {

if (icon != null) {
children.add(
Icon(icon),
Icon(
icon,
size: iconSize,
),
);
}

Expand All @@ -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),
),
),
);
}
Expand Down
43 changes: 14 additions & 29 deletions lib/src/auto_close_behavior.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ class SlidableAutoCloseBehavior extends StatefulWidget {
final Widget child;

@override
State<SlidableAutoCloseBehavior> createState() =>
_SlidableAutoCloseBehaviorState();
State<SlidableAutoCloseBehavior> createState() => _SlidableAutoCloseBehaviorState();
}

class _SlidableAutoCloseBehaviorState extends State<SlidableAutoCloseBehavior> {
Expand All @@ -48,10 +47,8 @@ class _SlidableAutoCloseBehaviorState extends State<SlidableAutoCloseBehavior> {
child: SlidableGroupBehavior<SlidableAutoCloseBarrierNotification>(
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;
Expand All @@ -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) {
Expand Down Expand Up @@ -205,9 +201,7 @@ class SlidableAutoCloseBehaviorListener extends StatelessWidget {
Widget build(BuildContext context) {
return SlidableGroupBehaviorListener<SlidableAutoCloseNotification>(
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();
}
},
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -343,21 +336,18 @@ class SlidableAutoCloseBarrierNotificationSender extends StatefulWidget {
final Widget child;

@override
State<SlidableAutoCloseBarrierNotificationSender> createState() =>
_SlidableAutoCloseBarrierNotificationSenderState();
State<SlidableAutoCloseBarrierNotificationSender> createState() => _SlidableAutoCloseBarrierNotificationSenderState();
}

class _SlidableAutoCloseBarrierNotificationSenderState
extends State<SlidableAutoCloseBarrierNotificationSender> {
class _SlidableAutoCloseBarrierNotificationSenderState extends State<SlidableAutoCloseBarrierNotificationSender> {
SlidableGroupNotificationDispatcher? dispatcher;

void _handleStatusChanged(AnimationStatus status) {
//TODO(romain): There is a bug if more than one try to open at the same time.
final willBarrierBeEnabled = status != AnimationStatus.dismissed;
final barrierEnabled = dispatcher != null;
if (willBarrierBeEnabled != barrierEnabled) {
dispatcher = SlidableGroupNotification.createDispatcher<
SlidableAutoCloseBarrierNotification>(
dispatcher = SlidableGroupNotification.createDispatcher<SlidableAutoCloseBarrierNotification>(
context,
assertParentExists: false,
);
Expand Down Expand Up @@ -434,12 +424,10 @@ class SlidableAutoCloseBarrierBehaviorListener extends StatefulWidget {
final Widget child;

@override
_SlidableAutoCloseBarrierBehaviorListenerState createState() =>
_SlidableAutoCloseBarrierBehaviorListenerState();
_SlidableAutoCloseBarrierBehaviorListenerState createState() => _SlidableAutoCloseBarrierBehaviorListenerState();
}

class _SlidableAutoCloseBarrierBehaviorListenerState
extends State<SlidableAutoCloseBarrierBehaviorListener> {
class _SlidableAutoCloseBarrierBehaviorListenerState extends State<SlidableAutoCloseBarrierBehaviorListener> {
bool absorbing = false;

void handleOnTap() {
Expand Down Expand Up @@ -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();
Expand All @@ -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);
}
Expand Down