Skip to content

Commit 1959f97

Browse files
authored
Merge pull request #161 from koukibadr/feat-add-vertical-divider-width-attribute
feat: add vertical divider width attribute
2 parents 897523f + 78d99c6 commit 1959f97

File tree

6 files changed

+42
-7
lines changed

6 files changed

+42
-7
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
## [2.5.0] - 03/05/2025
2+
3+
* **Changes**
4+
* Add `onLongPress` callback to the notification widget [PR#160](https://github.com/koukibadr/Elegant-Notification/pull/160)
5+
* Add `longPressDuration` to customize the long press duration [PR#160](https://github.com/koukibadr/Elegant-Notification/pull/160)
6+
* Implement long press detection and animation handling while long press interaction [PR#160](https://github.com/koukibadr/Elegant-Notification/pull/160)
7+
* Add `verticalDividerWidth` attribute to customize the vertical divider width [PR#161](https://github.com/koukibadr/Elegant-Notification/pull/161)
8+
9+
* **Enhancement**
10+
* Update the package example to demonstrate the new long press feature [PR#160](https://github.com/koukibadr/Elegant-Notification/pull/160)
11+
* Update padding rendering on notification icon widget [PR#160](https://github.com/koukibadr/Elegant-Notification/pull/160)
12+
* Update close icon rendering on notification widget [PR#160](https://github.com/koukibadr/Elegant-Notification/pull/160)
13+
* Refactor closing timer initialization and closing to avoid null check operator error [PR#160](https://github.com/koukibadr/Elegant-Notification/pull/160)
14+
* Add `autoDismiss` check on `timer.cancel()` method to avoid null check operator error [PR#160](https://github.com/koukibadr/Elegant-Notification/pull/160)
15+
116
## [2.4.5] - 16/04/2025
217

318
* **Changes**

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ To use this elegant notification package you need to add the dependency in `pubs
4646

4747
```yaml
4848
dependencies:
49-
elegant_notification: ^2.4.5
49+
elegant_notification: ^2.5.0
5050
```
5151

5252
## Parameters
@@ -158,13 +158,20 @@ dependencies:
158158
/// Function invoked when the user taps on the notification
159159
final void Function()? onNotificationPressed;
160160
161+
/// Function invoked when the user taps on the notification
162+
final void Function()? onLongPress;
163+
164+
/// The long press duration of the notification
165+
/// By default it's set to `Duration(seconds: 2)`
166+
final Duration longPressDuration;
167+
161168
/// Function invoked when tapping outside the notification
162169
/// Or when pressing the back button of the phone
163170
/// Or when tapping on the screen
164171
final Function()? onDismiss;
165172
166173
/// Define whether the notification will be dismissed automatically or not
167-
/// By default `autoDimiss == false`
174+
/// By default `autoDismiss = true`
168175
final bool autoDismiss;
169176
170177
/// The direction of the dismissible widget

example/lib/main.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// ignore_for_file: avoid_print
2+
13
import 'package:elegant_notification/elegant_notification.dart';
24
import 'package:elegant_notification/resources/arrays.dart';
35
import 'package:elegant_notification/resources/stacked_options.dart';
@@ -236,7 +238,7 @@ class ExampleApp extends StatelessWidget {
236238
showProgressIndicator: false,
237239
autoDismiss: false,
238240
onLongPress: () {
239-
print("Hello world");
241+
print('Hello world');
240242
},
241243
onDismiss: () {},
242244
).show(context);
@@ -357,7 +359,7 @@ class ExampleApp extends StatelessWidget {
357359
progressIndicatorBackground: Colors.green[100]!,
358360
longPressDuration: const Duration(seconds: 4),
359361
onLongPress: () {
360-
print("Hello world");
362+
print('Hello world');
361363
},
362364
).show(context);
363365
},

lib/elegant_notification.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class ElegantNotification extends StatefulWidget {
5353
this.shadow,
5454
this.onLongPress,
5555
this.longPressDuration = const Duration(seconds: 2),
56+
this.verticalDividerWidth = 1,
5657
}) : super(key: key) {
5758
_notificationType = NotificationType.custom;
5859
checkAssertions();
@@ -98,6 +99,7 @@ class ElegantNotification extends StatefulWidget {
9899
this.border,
99100
this.onLongPress,
100101
this.longPressDuration = const Duration(seconds: 2),
102+
this.verticalDividerWidth = 1,
101103
}) {
102104
_notificationType = NotificationType.success;
103105
progressIndicatorColor = _notificationType.color;
@@ -144,6 +146,7 @@ class ElegantNotification extends StatefulWidget {
144146
this.border,
145147
this.onLongPress,
146148
this.longPressDuration = const Duration(seconds: 2),
149+
this.verticalDividerWidth = 1,
147150
}) {
148151
_notificationType = NotificationType.error;
149152
progressIndicatorColor = _notificationType.color;
@@ -190,6 +193,7 @@ class ElegantNotification extends StatefulWidget {
190193
this.border,
191194
this.onLongPress,
192195
this.longPressDuration = const Duration(seconds: 2),
196+
this.verticalDividerWidth = 1,
193197
}) {
194198
_notificationType = NotificationType.info;
195199
progressIndicatorColor = _notificationType.color;
@@ -287,6 +291,10 @@ class ElegantNotification extends StatefulWidget {
287291
/// You can customize the color by providing a specific [Color] value
288292
final Color verticalDividerColor;
289293

294+
/// The vertical divider width
295+
/// By default it's set to 1
296+
final double verticalDividerWidth;
297+
290298
/// The notification icon, by default it's null.
291299
/// When it's null and using success, info and error the default icon is displayed
292300
/// When using the default constructor and icon is null nothing is rendered
@@ -389,7 +397,7 @@ class ElegantNotification extends StatefulWidget {
389397
final Function()? onDismiss;
390398

391399
/// Define whether the notification will be dismissed automatically or not
392-
/// By default `autoDimiss = true`
400+
/// By default `autoDismiss = true`
393401
final bool autoDismiss;
394402

395403
/// The direction of the dismissible widget
@@ -698,6 +706,7 @@ class ElegantNotificationState extends State<ElegantNotification>
698706
iconSize: widget.iconSize,
699707
action: widget.action,
700708
verticalDividerColor: widget.verticalDividerColor,
709+
verticalDividerWidth: widget.verticalDividerWidth,
701710
),
702711
),
703712
if (widget.showProgressIndicator)

lib/widgets/toast_content.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class ToastContent extends StatelessWidget {
1111
required this.displayCloseButton,
1212
required this.onCloseButtonPressed,
1313
required this.verticalDividerColor,
14+
required this.verticalDividerWidth,
1415
this.closeButton,
1516
this.icon,
1617
this.iconSize = 20,
@@ -27,6 +28,7 @@ class ToastContent extends StatelessWidget {
2728
final Widget Function(void Function() dismissNotification)? closeButton;
2829
final Widget? action;
2930
final Color verticalDividerColor;
31+
final double verticalDividerWidth;
3032

3133
bool get displayIcon =>
3234
notificationType != NotificationType.custom || icon != null;
@@ -50,7 +52,7 @@ class ToastContent extends StatelessWidget {
5052
bottom: 20,
5153
),
5254
child: Container(
53-
width: 1,
55+
width: verticalDividerWidth,
5456
color: verticalDividerColor,
5557
),
5658
),

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: elegant_notification
22
description: 'A new flutter package to display notifications on top of the screen, full customizable with built-in themes'
3-
version: 2.4.5
3+
version: 2.5.0
44
homepage: 'https://github.com/koukibadr/Elegant-Notification'
55
environment:
66
sdk: '>=2.19.0 <4.0.0'

0 commit comments

Comments
 (0)