Skip to content

Commit bf2589d

Browse files
Emre EsenEmre Esen
authored andcommitted
v1.2.0 is completed
1 parent 9ad9db8 commit bf2589d

File tree

12 files changed

+197
-107
lines changed

12 files changed

+197
-107
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## [1.2.0]- 10.12.2024
2+
* `completedMsgFuture` support for asynchronous completion messages
3+
* `dispose()` method to properly release resources
4+
* Deprecated old ProgressType values: normal and valuable
5+
6+
17
## [1.1.4] - 09.03.2024
28

39
* Added support for `useRootNavigator` parameter in the `ProgressDialog` constructor.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Progress dialog package for flutter
77
You must add the library as a dependency to your project.
88
```yaml
99
dependencies:
10-
sn_progress_dialog: ^1.1.4
10+
sn_progress_dialog: ^1.2.0
1111
```
1212
1313
You should then run `flutter packages get`

example/lib/main.dart

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,19 @@ class Home extends StatelessWidget {
3333
);
3434
for (int i = 0; i <= 100; i++) {
3535
/// You don't need to update state, just pass the value.
36-
/// Only value required
3736
pd.update(value: i);
3837
i++;
3938
await Future.delayed(Duration(milliseconds: 100));
4039
}
4140
}
4241

42+
/// Shows a progress dialog with a determinate progress bar.
4343
_valuableProgress(context) async {
4444
ProgressDialog pd = ProgressDialog(context: context);
4545

4646
pd.show(
4747
max: 100,
4848
msg: 'File Downloading...',
49-
50-
/// Assign the type of progress bar.
5149
progressType: ProgressType.valuable,
5250
);
5351
for (int i = 0; i <= 100; i++) {
@@ -57,50 +55,46 @@ class Home extends StatelessWidget {
5755
}
5856
}
5957

58+
/// Shows a progress dialog that starts with a preparation message,
59+
/// then switches to a downloading message.
6060
_preparingProgress(context) async {
6161
ProgressDialog pd = ProgressDialog(context: context);
6262

63-
/// show the state of preparation first.
6463
pd.show(
6564
max: 100,
6665
msg: 'Preparing Download...',
67-
progressType: ProgressType.valuable,
66+
progressType: ProgressType.determinate,
6867
);
6968

70-
/// Added to test late loading starts
7169
await Future.delayed(Duration(milliseconds: 3000));
7270
for (int i = 0; i <= 100; i++) {
73-
/// You can indicate here that the download has started.
7471
pd.update(value: i, msg: 'File Downloading...');
7572
i++;
7673
await Future.delayed(Duration(milliseconds: 100));
7774
}
7875
}
7976

77+
/// Shows a customizable progress dialog with a dark theme.
8078
_customProgress(context) async {
8179
ProgressDialog pd = ProgressDialog(context: context);
82-
83-
/// show the state of preparation first.
8480
pd.show(
8581
max: 100,
8682
msg: 'Preparing Download...',
87-
progressType: ProgressType.valuable,
83+
progressType: ProgressType.determinate,
8884
backgroundColor: Color(0xff212121),
8985
progressValueColor: Color(0xff3550B4),
9086
progressBgColor: Colors.white70,
9187
msgColor: Colors.white,
9288
valueColor: Colors.white);
93-
94-
/// Added to test late loading starts
9589
await Future.delayed(Duration(milliseconds: 3000));
9690
for (int i = 0; i <= 100; i++) {
97-
/// You can indicate here that the download has started.
9891
pd.update(value: i, msg: 'File Downloading...');
9992
i++;
10093
await Future.delayed(Duration(milliseconds: 100));
10194
}
10295
}
10396

97+
/// Shows a progress dialog that completes with a custom completion widget.
10498
_completedProgress(context) async {
10599
ProgressDialog pd = ProgressDialog(context: context);
106100
pd.show(
@@ -118,6 +112,7 @@ class Home extends StatelessWidget {
118112
}
119113
}
120114

115+
/// Shows a message-only progress dialog without a progress bar.
121116
_onlyMessageProgress(context) async {
122117
ProgressDialog pd = ProgressDialog(context: context);
123118
pd.show(
@@ -126,31 +121,32 @@ class Home extends StatelessWidget {
126121
hideValue: true,
127122
);
128123

129-
/** You can update the message value after a certain action **/
130124
await Future.delayed(Duration(milliseconds: 1000));
131125
pd.update(msg: "Almost done...");
132126

133127
await Future.delayed(Duration(milliseconds: 1000));
134128
pd.close();
135129
}
136130

131+
/// Shows a message-only progress dialog that completes automatically.
137132
_onlyMessageWithCompletionProgress(context) async {
138133
ProgressDialog pd = ProgressDialog(context: context);
139134
pd.show(
140135
barrierDismissible: true,
141136
msg: "Please waiting...",
142137
hideValue: true,
143-
completed: Completed(), // Set Completed
138+
completed: Completed(completionDelay: 1500), // Set Completed
144139
);
145-
146-
/** You can update the message value after a certain action **/
147140
await Future.delayed(Duration(milliseconds: 1000));
148141

142+
pd.update(msg: "Almost done...");
143+
144+
await Future.delayed(Duration(milliseconds: 1000));
149145
/**
150146
* if you can't assign value and want to use completed object. You should set the Value to 100.
151147
* The dialog will close automatically.
152148
* **/
153-
pd.update(msg: "Almost done...", value: 100);
149+
pd.update(value: 100);
154150
}
155151

156152
@override

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ packages:
110110
path: ".."
111111
relative: true
112112
source: path
113-
version: "1.1.4"
113+
version: "1.2.0"
114114
source_span:
115115
dependency: transitive
116116
description:

lib/enums/dialog_status.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// Represents the current status of the dialog.
2+
enum DialogStatus {
3+
/// Dialog is currently displayed
4+
opened,
5+
6+
/// Dialog has been closed
7+
closed,
8+
9+
/// Dialog has completed its progress
10+
completed
11+
}

lib/enums/progress_types.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
enum ProgressType {
2+
/// Indeterminate progress indicator
3+
@Deprecated(
4+
'Use indeterminate instead. This will be removed in the next major version.')
5+
normal,
6+
7+
/// Progress indicator with value
8+
@Deprecated(
9+
'Use determinate instead. This will be removed in the next major version.')
10+
valuable,
11+
12+
/// Shows an infinite spinning progress indicator without specific progress value
13+
indeterminate,
14+
15+
/// Shows progress with specific value (0-100%)
16+
determinate,
17+
}
18+
19+
extension ProgressTypeHelper on ProgressType {
20+
bool get isIndeterminate =>
21+
this == ProgressType.normal || this == ProgressType.indeterminate;
22+
23+
bool get isDeterminate =>
24+
this == ProgressType.valuable || this == ProgressType.determinate;
25+
}

lib/enums/value_position.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/// Determines the position of the progress value text.
2+
enum ValuePosition {
3+
/// Center aligned progress value
4+
center,
5+
6+
/// Right aligned progress value
7+
right
8+
}

lib/options/cancel.dart

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
import 'package:flutter/material.dart';
22

33
class Cancel {
4-
/// [cancelClicked] If you want to execute an action when the dialog is canceled, pass a void function.
5-
// (Default: null)
4+
/// Callback function that will be executed when cancel button is tapped.
65
final GestureTapCallback? cancelClicked;
76

8-
/// [cancelImage] The default does not contain any value, if the value is assigned another asset image is created.
7+
/// Custom image to use for the cancel button.
8+
/// If not provided, uses default cancel icon.
99
final AssetImage? cancelImage;
1010

11-
/// [cancelImageSize] set cancel image dimensions
12-
// (Default: 15.0)
11+
/// Size of the cancel button image in pixels.
12+
/// Defaults to 15.0.
1313
final double cancelImageSize;
1414

15-
/// [cancelImageColor] set cancel image color
16-
// (Default: black)
15+
/// Color to apply to the cancel button image.
16+
/// Defaults to Colors.black.
1717
final Color? cancelImageColor;
1818

19-
/// [autoHidden] It hides the cancel button when value and max are equal.
20-
// (Default: true)
19+
/// Whether to automatically hide the cancel button when progress completes.
20+
/// When true, the button will be hidden when progress value equals max value.
21+
/// Defaults to true.
2122
final bool autoHidden;
2223

2324
Cancel({

lib/options/completed.dart

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
import 'package:flutter/material.dart';
22

33
class Completed {
4-
/// [completedMsg] Assign the completed Message
5-
// (Default: "completed")
6-
String completedMsg;
4+
/// Future that resolves to the completion message.
5+
/// If provided, this message will override [completedMsg] when resolved.
6+
final Future<String>? completedMsgFuture;
77

8-
/// [completionDelay] The time the dialog window will wait to close
9-
// (Default: 1500 ms)
8+
/// Message to display when progress completes.
9+
/// Defaults to "Completed !".
10+
final String completedMsg;
11+
12+
/// Duration to wait before closing the dialog after completion, in milliseconds.
13+
/// Defaults to 1500ms.
1014
final int completionDelay;
1115

12-
/// [completedImage] The default does not contain any value, if the value is assigned another asset image is created.
16+
/// Custom image to display when progress completes.
17+
/// If not provided, uses default completion icon.
1318
final AssetImage? completedImage;
1419

1520
Completed({
21+
this.completedMsgFuture,
1622
this.completedMsg = "Completed !",
1723
this.completionDelay = 1500,
1824
this.completedImage,

0 commit comments

Comments
 (0)