Skip to content

Commit 79c9222

Browse files
committed
Update package documentation and version
1 parent 190223c commit 79c9222

File tree

5 files changed

+78
-29
lines changed

5 files changed

+78
-29
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## [2.4.0] - 17/11/2024
2+
3+
* **Enhancements**
4+
* new attribute: `verticalDividerColor` to customize vertical divider color
5+
16
## [2.3.1] - 07/11/2024
27

38
* **Bug Fix**

README.md

Lines changed: 6 additions & 1 deletion
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.3.1
49+
elegant_notification: ^2.4.0
5050
```
5151

5252
## Parameters
@@ -193,6 +193,11 @@ dependencies:
193193
194194
/// The options for the stacked mode
195195
final StackedOptions? stackedOptions;
196+
197+
///The color of the vertical divider between the icon and content
198+
///By default it's null, which means it will use the default divider color = Color(0xffF3F3F3)
199+
///You can customize the color by providing a specific [Color] value
200+
final Color? verticalDividerColor;
196201
`
197202
198203
````

lib/elegant_notification.dart

Lines changed: 63 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -191,35 +191,47 @@ class ElegantNotification extends StatefulWidget {
191191

192192
if (position == Alignment.centerRight) {
193193
assert(
194-
animation != AnimationType.fromLeft && animation != AnimationType.fromBottom && animation != AnimationType.fromTop,
194+
animation != AnimationType.fromLeft &&
195+
animation != AnimationType.fromBottom &&
196+
animation != AnimationType.fromTop,
195197
);
196198
} else if (position == Alignment.centerLeft) {
197199
assert(
198-
animation != AnimationType.fromRight && animation != AnimationType.fromBottom && animation != AnimationType.fromTop,
200+
animation != AnimationType.fromRight &&
201+
animation != AnimationType.fromBottom &&
202+
animation != AnimationType.fromTop,
199203
);
200204
} else if (position == Alignment.topCenter) {
201205
assert(
202-
animation != AnimationType.fromBottom && animation != AnimationType.fromLeft && animation != AnimationType.fromRight,
206+
animation != AnimationType.fromBottom &&
207+
animation != AnimationType.fromLeft &&
208+
animation != AnimationType.fromRight,
203209
);
204210
} else if (position == Alignment.topRight) {
205211
assert(
206-
animation != AnimationType.fromLeft && animation != AnimationType.fromBottom,
212+
animation != AnimationType.fromLeft &&
213+
animation != AnimationType.fromBottom,
207214
);
208215
} else if (position == Alignment.topLeft) {
209216
assert(
210-
animation != AnimationType.fromRight && animation != AnimationType.fromBottom,
217+
animation != AnimationType.fromRight &&
218+
animation != AnimationType.fromBottom,
211219
);
212220
} else if (position == Alignment.bottomCenter) {
213221
assert(
214-
animation != AnimationType.fromTop && animation != AnimationType.fromLeft && animation != AnimationType.fromRight,
222+
animation != AnimationType.fromTop &&
223+
animation != AnimationType.fromLeft &&
224+
animation != AnimationType.fromRight,
215225
);
216226
} else if (position == Alignment.bottomRight) {
217227
assert(
218-
animation != AnimationType.fromLeft && animation != AnimationType.fromTop,
228+
animation != AnimationType.fromLeft &&
229+
animation != AnimationType.fromTop,
219230
);
220231
} else if (position == Alignment.bottomLeft) {
221232
assert(
222-
animation != AnimationType.fromRight && animation != AnimationType.fromTop,
233+
animation != AnimationType.fromRight &&
234+
animation != AnimationType.fromTop,
223235
);
224236
}
225237
}
@@ -378,7 +390,9 @@ class ElegantNotification extends StatefulWidget {
378390

379391
final Key uniqueKey = UniqueKey();
380392

381-
String get internalKey => stackedOptions != null ? '${stackedOptions?.key}%${uniqueKey.toString()}' : uniqueKey.toString();
393+
String get internalKey => stackedOptions != null
394+
? '${stackedOptions?.key}%${uniqueKey.toString()}'
395+
: uniqueKey.toString();
382396

383397
///display the notification on the screen
384398
///[context] the context of the application
@@ -419,43 +433,56 @@ class ElegantNotification extends StatefulWidget {
419433
.toList()
420434
.indexWhere((element) => element == internalKey);
421435

422-
double mainContainerHeight(BuildContext context) => height ?? MediaQuery.of(context).size.height * 0.12;
423-
double mainContainerWidth(BuildContext context) => width ?? MediaQuery.of(context).size.width * 0.7;
436+
double mainContainerHeight(BuildContext context) =>
437+
height ?? MediaQuery.of(context).size.height * 0.12;
438+
double mainContainerWidth(BuildContext context) =>
439+
width ?? MediaQuery.of(context).size.width * 0.7;
424440

425441
double getTopPos(context) {
426442
if (stackedOptions?.type == StackedType.above) {
427-
return -(mainContainerHeight(context) * stackedItemPosition) + (stackedOptions?.itemOffset.dy ?? 0) * stackedItemPosition;
443+
return -(mainContainerHeight(context) * stackedItemPosition) +
444+
(stackedOptions?.itemOffset.dy ?? 0) * stackedItemPosition;
428445
} else if (stackedOptions?.type == StackedType.below) {
429-
return (mainContainerHeight(context) * stackedItemPosition) + (stackedOptions?.itemOffset.dy ?? 0) * stackedItemPosition;
446+
return (mainContainerHeight(context) * stackedItemPosition) +
447+
(stackedOptions?.itemOffset.dy ?? 0) * stackedItemPosition;
430448
} else {
431-
return (stackedOptions?.itemOffset.dy ?? 0) * (stackOverlaysLength - 1 - stackedItemPosition);
449+
return (stackedOptions?.itemOffset.dy ?? 0) *
450+
(stackOverlaysLength - 1 - stackedItemPosition);
432451
}
433452
}
434453

435454
double alignmentToLeftPos(BuildContext context) {
436455
if (position.x == 1) {
437-
return MediaQuery.of(context).size.width - mainContainerWidth(context) - notificationMargin;
456+
return MediaQuery.of(context).size.width -
457+
mainContainerWidth(context) -
458+
notificationMargin;
438459
} else if (position.x == -1) {
439460
return notificationMargin;
440461
} else {
441-
return ((position.x + 1) / 2) * MediaQuery.of(context).size.width - (mainContainerWidth(context) / 2);
462+
return ((position.x + 1) / 2) * MediaQuery.of(context).size.width -
463+
(mainContainerWidth(context) / 2);
442464
}
443465
}
444466

445467
double alignmentToTopPos(BuildContext context) {
446468
if (position.y == 1) {
447-
return MediaQuery.of(context).size.height - mainContainerHeight(context) - notificationMargin;
469+
return MediaQuery.of(context).size.height -
470+
mainContainerHeight(context) -
471+
notificationMargin;
448472
} else if (position.y == -1) {
449473
return notificationMargin;
450474
} else {
451-
return ((position.y + 1) / 2) * MediaQuery.of(context).size.height - (mainContainerHeight(context) / 2);
475+
return ((position.y + 1) / 2) * MediaQuery.of(context).size.height -
476+
(mainContainerHeight(context) / 2);
452477
}
453478
}
454479

455480
double getScale() {
456481
if (stackedOptions?.scaleFactor != null) {
457482
return clampDouble(
458-
(1 - (stackedOptions?.scaleFactor ?? 0) * (stackOverlaysLength - (stackedItemPosition + 1))),
483+
(1 -
484+
(stackedOptions?.scaleFactor ?? 0) *
485+
(stackOverlaysLength - (stackedItemPosition + 1))),
459486
0,
460487
1,
461488
);
@@ -470,7 +497,9 @@ class ElegantNotification extends StatefulWidget {
470497
builder: (context) {
471498
return AnimatedPositioned(
472499
duration: const Duration(milliseconds: 300),
473-
left: alignmentToLeftPos(context) + (stackedOptions?.itemOffset.dx ?? 0) * (stackOverlaysLength - 1 - stackedItemPosition),
500+
left: alignmentToLeftPos(context) +
501+
(stackedOptions?.itemOffset.dx ?? 0) *
502+
(stackOverlaysLength - 1 - stackedItemPosition),
474503
top: alignmentToTopPos(context) + getTopPos(context),
475504
child: AnimatedScale(
476505
duration: const Duration(
@@ -492,7 +521,8 @@ class ElegantNotification extends StatefulWidget {
492521
ElegantNotificationState createState() => ElegantNotificationState();
493522
}
494523

495-
class ElegantNotificationState extends State<ElegantNotification> with SingleTickerProviderStateMixin {
524+
class ElegantNotificationState extends State<ElegantNotification>
525+
with SingleTickerProviderStateMixin {
496526
@override
497527
void initState() {
498528
super.initState();
@@ -597,16 +627,20 @@ class ElegantNotificationState extends State<ElegantNotification> with SingleTic
597627
widget.closeOverlay();
598628
}
599629

600-
double get mainContainerHeight => widget.height ?? MediaQuery.of(context).size.height * 0.12;
601-
double get mainContainerWidth => widget.width ?? MediaQuery.of(context).size.width * 0.7;
630+
double get mainContainerHeight =>
631+
widget.height ?? MediaQuery.of(context).size.height * 0.12;
632+
double get mainContainerWidth =>
633+
widget.width ?? MediaQuery.of(context).size.width * 0.7;
602634

603635
@override
604636
Widget build(BuildContext context) {
605637
return SlideTransition(
606638
position: widget._offsetAnimation,
607639
child: Dismissible(
608640
key: widget.uniqueKey,
609-
direction: widget.isDismissable ? widget.dismissDirection : DismissDirection.none,
641+
direction: widget.isDismissable
642+
? widget.dismissDirection
643+
: DismissDirection.none,
610644
onDismissed: (direction) {
611645
widget.onDismiss?.call();
612646
widget.closeOverlay();
@@ -632,7 +666,9 @@ class ElegantNotificationState extends State<ElegantNotification> with SingleTic
632666
description: widget.description,
633667
notificationType: widget._notificationType,
634668
icon: widget.icon,
635-
displayCloseButton: widget.onNotificationPressed == null ? widget.displayCloseButton : false,
669+
displayCloseButton: widget.onNotificationPressed == null
670+
? widget.displayCloseButton
671+
: false,
636672
closeButton: widget.closeButton,
637673
onCloseButtonPressed: closeNotification,
638674
iconSize: widget.iconSize,
@@ -642,7 +678,8 @@ class ElegantNotificationState extends State<ElegantNotification> with SingleTic
642678
),
643679
if (widget.showProgressIndicator)
644680
Padding(
645-
padding: widget.progressBarPadding ?? const EdgeInsets.all(0),
681+
padding:
682+
widget.progressBarPadding ?? const EdgeInsets.all(0),
646683
child: SizedBox(
647684
width: widget.progressBarWidth,
648685
height: widget.progressBarHeight,

lib/widgets/toast_content.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ class ToastContent extends StatelessWidget {
4040
Row(
4141
children: [
4242
Padding(
43-
padding: isRtl ? const EdgeInsets.only(right: horizontalComponentPadding) : const EdgeInsets.only(left: horizontalComponentPadding),
43+
padding: isRtl
44+
? const EdgeInsets.only(right: horizontalComponentPadding)
45+
: const EdgeInsets.only(left: horizontalComponentPadding),
4446
child: _getNotificationIcon(),
4547
),
4648
const SizedBox(

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.3.1
3+
version: 2.4.0
44
homepage: 'https://github.com/koukibadr/Elegant-Notification'
55
environment:
66
sdk: '>=2.19.0 <4.0.0'

0 commit comments

Comments
 (0)