Skip to content

Commit

Permalink
Merge pull request #65 from payam-zahedi/release/v1.1.0
Browse files Browse the repository at this point in the history
Release v1.1.0
  • Loading branch information
payam-zahedi authored Oct 31, 2023
2 parents c980885 + acb1671 commit c96b731
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 160 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
## 1.1.0

* add new toast style (ToastificationStyle.simple) by @mahmoud-eslami
* add toastification callbacks by @payam-zahedi

## 1.0.2

* Fix the code preview section issue by @mahmoud-eslami
* onAutoCompleteCompleted Callback exposed to user by @Shery573
* Add github stars section by @payam-zahedi

## 1.0.1

* update README.me by @payam-zahedi

## 1.0.0
Expand Down
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Overall, Toastification is a useful package for Flutter developers who want to a
Don't want to dive into the whole documentation? No problem!
Just head over to our [Toast Builder Website](https://payamzahedi.com/toastification/), where you can effortlessly customize your toast notifications, copy the generated code, and seamlessly integrate them into your project. It's the quickest way to get started with Toastification!

https://github.com/payam-zahedi/toastification/assets/47558577/0e40aefd-b768-4d13-b982-eeeefb2256e9

## Installation

To use Toastification, you need to add it to your pubspec.yaml file:
Expand Down Expand Up @@ -96,14 +98,17 @@ toastification.show(
spreadRadius: 0,
)
],
onCloseTap: () {
// Do something when the toast is closed
},
showProgressBar: true,
closeButtonShowType: CloseButtonShowType.onHover,
closeOnClick: false,
pauseOnHover: true,
dragToClose: true,
callbacks: ToastificationCallbacks(
onTap: (toastItem) => print('Toast ${toastItem.id} tapped'),
onCloseButtonTap: (toastItem) => print('Toast ${toastItem.id} close button tapped'),
onAutoCompleteCompleted: (toastItem) => print('Toast ${toastItem.id} auto complete completed'),
onDismissed: (toastItem) => print('Toast ${toastItem.id} dismissed'),
),
);
```

Expand All @@ -115,7 +120,7 @@ we have 4 predefined styles for toast messages:
<img src="https://github.com/payam-zahedi/toastification/blob/main/doc/image/styles.png?raw=true" width="100%" alt="Styles" />
</p>


additionally, we added a `ToastificationStyle.simple` style to show a simple toast message with a single line of text.

## ShowCustom Method

Expand Down
264 changes: 145 additions & 119 deletions example/lib/src/core/views/widgets/picker/toast_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,134 +49,148 @@ class ToastStylePickerState extends State<ToastStylePicker> {
child: OverlayPortal(
controller: _tooltipController,
overlayChildBuilder: (BuildContext context) {
return GestureDetector(
onTap: _tooltipController.hide,
child: Container(
color: Colors.white10,
child: CompositedTransformFollower(
link: _link,
targetAnchor: Alignment.bottomLeft,
showWhenUnlinked: false,
child: Align(
alignment: AlignmentDirectional.topStart,
child: Container(
width: _currentSize?.width ?? 200,
margin: const EdgeInsets.only(top: 2),
padding: const EdgeInsets.all(16),
decoration: ShapeDecoration(
color: theme.colorScheme.background,
shape: RoundedRectangleBorder(
side: BorderSide(
width: 1.5,
color: theme.colorScheme.outline,
return CompositedTransformFollower(
link: _link,
targetAnchor: Alignment.bottomLeft,
showWhenUnlinked: false,
child: Align(
alignment: AlignmentDirectional.topStart,
child: Container(
width: _currentSize?.width ?? 200,
margin: const EdgeInsets.only(top: 2),
padding: const EdgeInsets.all(16),
decoration: ShapeDecoration(
color: theme.colorScheme.background,
shape: RoundedRectangleBorder(
side: BorderSide(
width: 1.5,
color: theme.colorScheme.outline,
),
borderRadius: BorderRadius.circular(12),
),
shadows: const [
BoxShadow(
color: Color(0x11000000),
blurRadius: 32,
offset: Offset(0, 20),
spreadRadius: -8,
),
],
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsetsDirectional.only(start: 4),
child: Text(
'STYLE',
style: theme.textTheme.titleMedium?.copyWith(
fontSize: 12,
fontWeight: FontWeight.w500,
color:
theme.colorScheme.onSurface.withOpacity(.4),
),
borderRadius: BorderRadius.circular(12),
),
shadows: const [
BoxShadow(
color: Color(0x11000000),
blurRadius: 32,
offset: Offset(0, 20),
spreadRadius: -8,
),
],
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
const SizedBox(height: 12),
Row(
children: [
Padding(
padding:
const EdgeInsetsDirectional.only(start: 4),
child: Text(
'STYLE',
style: theme.textTheme.titleMedium?.copyWith(
fontSize: 12,
fontWeight: FontWeight.w500,
color: theme.colorScheme.onSurface
.withOpacity(.4),
Expanded(
child: _ItemHolder(
toast: FilledToastWidget(
type:
widget.type ?? ToastificationType.info,
title: 'The Title',
description: 'The Description',
),
onTap: () {
widget.onStyleChanged(
ToastificationStyle.fillColored,
);
_tooltipController.hide();
},
),
),
const SizedBox(height: 12),
Row(
children: [
Expanded(
child: _ItemHolder(
toast: FilledToastWidget(
type: widget.type ??
ToastificationType.info,
title: 'The Title',
description: 'The Description',
),
onTap: () {
widget.onStyleChanged(
ToastificationStyle.fillColored,
);
_tooltipController.hide();
},
),
const SizedBox(width: 8),
Expanded(
child: _ItemHolder(
toast: FlatToastWidget(
type:
widget.type ?? ToastificationType.info,
title: 'The Title',
description: 'The Description',
),
const SizedBox(width: 8),
Expanded(
child: _ItemHolder(
toast: FlatToastWidget(
type: widget.type ??
ToastificationType.info,
title: 'The Title',
description: 'The Description',
),
onTap: () {
widget.onStyleChanged(
ToastificationStyle.flat,
);
_tooltipController.hide();
},
),
onTap: () {
widget.onStyleChanged(
ToastificationStyle.flat,
);
_tooltipController.hide();
},
),
),
],
),
const SizedBox(height: 8),
Row(
children: [
Expanded(
child: _ItemHolder(
toast: FlatColoredToastWidget(
type:
widget.type ?? ToastificationType.info,
title: 'The Title',
description: 'The Description',
),
],
onTap: () {
widget.onStyleChanged(
ToastificationStyle.flatColored,
);
_tooltipController.hide();
},
),
),
const SizedBox(height: 8),
Row(
children: [
Expanded(
child: _ItemHolder(
toast: FlatColoredToastWidget(
type: widget.type ??
ToastificationType.info,
title: 'The Title',
description: 'The Description',
),
onTap: () {
widget.onStyleChanged(
ToastificationStyle.flatColored,
);
_tooltipController.hide();
},
),
const SizedBox(width: 8),
Expanded(
child: _ItemHolder(
toast: MinimalToastWidget(
type:
widget.type ?? ToastificationType.info,
title: 'The Title',
description: 'The Description',
),
const SizedBox(width: 8),
Expanded(
child: _ItemHolder(
toast: MinimalToastWidget(
type: widget.type ??
ToastificationType.info,
title: 'The Title',
description: 'The Description',
),
onTap: () {
widget.onStyleChanged(
ToastificationStyle.minimal,
);
_tooltipController.hide();
},
),
onTap: () {
widget.onStyleChanged(
ToastificationStyle.minimal,
);
_tooltipController.hide();
},
),
),
],
),
const SizedBox(height: 8),
Row(
children: [
Expanded(
child: _ItemHolder(
isCenter: true,
toast: SimpleToastWidget(
type:
widget.type ?? ToastificationType.info,
title: 'Simple Title Toast',
),
],
onTap: () {
widget.onStyleChanged(
ToastificationStyle.simple,
);
_tooltipController.hide();
},
),
),
],
),
),
],
),
),
),
Expand Down Expand Up @@ -209,16 +223,33 @@ class ToastStylePickerState extends State<ToastStylePicker> {

class _ItemHolder extends StatelessWidget {
const _ItemHolder({
this.isCenter = false,
required this.toast,
required this.onTap,
});

final bool isCenter;
final VoidCallback onTap;
final Widget toast;

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);

Widget child = toast;

if (isCenter) {
child = Center(
child: child,
);
} else {
child = Positioned(
top: 12,
left: 30,
right: -40,
child: child,
);
}
return SizedBox(
height: 98,
child: Stack(
Expand All @@ -235,12 +266,7 @@ class _ItemHolder extends StatelessWidget {
),
),
),
Positioned(
top: 12,
left: 30,
right: -40,
child: toast,
),
child,
Positioned.fill(
child: Material(
borderRadius: BorderRadius.circular(12),
Expand Down
4 changes: 0 additions & 4 deletions example/lib/src/features/home/controllers/toast_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ class ToastDetailControllerNotifier extends StateNotifier<ToastDetail> {
state = state.copyWith(animationType: animationType);
}

void changeOnCloseTap(VoidCallback? onCloseTap) {
state = state.copyWith(onCloseTap: onCloseTap);
}

void changeNewestOnTop(bool newestOnTop) {
state = state.copyWith(newestOnTop: newestOnTop);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class ToastDetail with _$ToastDetail {
@Default(Duration(seconds: 4)) Duration? autoCloseDuration,
Duration? animationDuration,
@Default(BounceAnimationType()) AnimationType animationType,
VoidCallback? onCloseTap,
@Default(CloseButtonShowType.always)
CloseButtonShowType closeButtonShowType,
@Default(true) bool newestOnTop,
Expand Down
Loading

0 comments on commit c96b731

Please sign in to comment.