Skip to content

Commit

Permalink
Merge pull request #155 from MMMzq/global-style
Browse files Browse the repository at this point in the history
Supports global configuration
  • Loading branch information
MMMzq authored Sep 12, 2023
2 parents 061f9f0 + dd08049 commit f7f090e
Show file tree
Hide file tree
Showing 29 changed files with 2,107 additions and 736 deletions.
3 changes: 2 additions & 1 deletion .pubignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/example/build
/example/android
/example/ios
/example/web
/example/web
/build
460 changes: 234 additions & 226 deletions API.md

Large diffs are not rendered by default.

278 changes: 278 additions & 0 deletions API_zh.md

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [4.1.0]
* feat: Support global configuration
* docs: Add English API documentation and English comments

## [4.0.4]
* feat: Added margin param to showNotification

Expand Down
29 changes: 25 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ A really easy to use flutter toast library!

- Pure flutter implementation

- Supports global configuration


### 🐼Online Demo

Expand All @@ -48,19 +50,19 @@ Loading|Text|CustomWidget

### 🐮Getting started

#### 1. add dependencies into you project pubspec.yaml file
#### 1. Add dependencies into you project pubspec.yaml file
``` yaml
dependencies:
bot_toast: ^3.0.5
# bot_toast: ^4.0.0 #null safety
```

#### 2. import BotToast lib
#### 2. Import BotToast Lib
``` dart
import 'package:bot_toast/bot_toast.dart';
```

#### 3. initialization BotToast
#### 3. Initialization BotToast
``` dart
MaterialApp(
title: 'BotToast Demo',
Expand All @@ -85,7 +87,7 @@ MaterialApp(
)
```

#### 4. use BotToast
#### 4. Use BotToast
``` dart
var cancel = BotToast.showText(text:"xxxx"); //popup a text toast;
...
Expand Down Expand Up @@ -132,6 +134,25 @@ var cancel = BotToast.showAnimationWidget(...)
cancel(); //close
```

#### 5. Modify Global Configuration

``` dart
/// For example: Globally change the animation duration for standard notifications to 1 second.
BotToast.defaultOption.notification.animationDuration = const Duration(seconds: 1);
/// For more default options, refer to the following configurations:
/// [BotToast.defaultOption.simpleNotification] corresponds to the default values of [showSimpleNotification].
/// [BotToast.defaultOption.notification] corresponds to the default values of [showNotification].
/// [BotToast.defaultOption.customNotification] corresponds to the default values of [showCustomNotification].
/// [BotToast.defaultOption.text] corresponds to the default values of [showText].
/// [BotToast.defaultOption.customText] corresponds to the default values of [showCustomText].
/// [BotToast.defaultOption.loading] corresponds to the default values of [showLoading].
/// [BotToast.defaultOption.customLoading] corresponds to the default values of [showCustomLoading].
/// [BotToast.defaultOption.attached] corresponds to the default values of [showAttachedWidget].
/// [BotToast.defaultOption.animation] corresponds to the default values of [showAnimationWidget].
/// [BotToast.defaultOption.enhanced] corresponds to the default values of [showEnhancedWidget].
```

### 🐼3.0 version

#### Major changes:
Expand Down
23 changes: 22 additions & 1 deletion README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ BotToast 🤖

- 纯flutter实现

- 支持全局配置



### 🐼在线demo
Expand Down Expand Up @@ -139,6 +141,25 @@ cancel(); //关闭

<br>

#### 5. 修改全局配置

``` dart
///例如:全局修改标准通知的动画时间为 1 秒。
BotToast.defaultOption.notification.animationDuration=const Duration(seconds: 1);
///更多默认选项参考下述配置
///[BotToast.defaultOption.simpleNotification] 对应 [showSimpleNotification] 的默认值
///[BotToast.defaultOption.notification] 对应 [showNotification] 的默认值
///[BotToast.defaultOption.customNotification] 对应 [showCustomNotification] 的默认值
///[BotToast.defaultOption.text] 对应 [showText] 的默认值
///[BotToast.defaultOption.customText] 对应 [showCustomText] 的默认值
///[BotToast.defaultOption.loading] 对应 [showLoading] 的默认值
///[BotToast.defaultOption.customLoading] 对应 [showCustomLoading] 的默认值
///[BotToast.defaultOption.attached] 对应 [showAttachedWidget] 的默认值
///[BotToast.defaultOption.animation] 对应 [showAnimationWidget] 的默认值
///[BotToast.defaultOption.enhanced] 对应 [showEnhancedWidget] 的默认值
```

### 🐼3.0版本

#### 主要改动:
Expand Down Expand Up @@ -186,7 +207,7 @@ MaterialApp(
<br>

### 📃主要Api文档
[主要Api文档](API.md)
[主要Api文档](API_zh.md)



2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>9.0</string>
<string>11.0</string>
</dict>
</plist>
11 changes: 7 additions & 4 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -184,10 +184,12 @@
/* Begin PBXShellScriptBuildPhase section */
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
Expand All @@ -198,6 +200,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -284,7 +287,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -361,7 +364,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -408,7 +411,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
2 changes: 2 additions & 0 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
54 changes: 27 additions & 27 deletions example/lib/attached_toast/attached_toast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class AttachedToast extends StatefulWidget {
}

class _AttachedToastState extends State<AttachedToast> {
BuildContext targetContext;
Offset target;
// BuildContext targetContext;
// Offset target;
double verticalOffset = 0;
double horizontalOffset = 0;
int second = 4;
Expand All @@ -24,7 +24,7 @@ class _AttachedToastState extends State<AttachedToast> {

double buttonAlign = 0;

CancelFunc show({BuildContext context, Offset target}) {
CancelFunc show({BuildContext? context, Offset? target}) {
return BotToast.showAttachedWidget(
target: target,
targetContext: context,
Expand Down Expand Up @@ -142,27 +142,27 @@ class _AttachedToastState extends State<AttachedToast> {
child: Radio(
value: PreferDirection.topLeft,
groupValue: preferDirection,
onChanged: (PreferDirection value) {
onChanged: (PreferDirection? value) {
setState(() {
preferDirection = value;
preferDirection = value!;
});
})),
Expanded(
child: Radio(
value: PreferDirection.topCenter,
groupValue: preferDirection,
onChanged: (PreferDirection value) {
onChanged: (PreferDirection? value) {
setState(() {
preferDirection = value;
preferDirection = value!;
});
})),
Expanded(
child: Radio(
value: PreferDirection.topRight,
groupValue: preferDirection,
onChanged: (PreferDirection value) {
onChanged: (PreferDirection? value) {
setState(() {
preferDirection = value;
preferDirection = value!;
});
})),
const Spacer(),
Expand Down Expand Up @@ -195,9 +195,9 @@ class _AttachedToastState extends State<AttachedToast> {
child: Radio(
value: PreferDirection.leftTop,
groupValue: preferDirection,
onChanged: (PreferDirection value) {
onChanged: (PreferDirection? value) {
setState(() {
preferDirection = value;
preferDirection = value!;
});
})),
const Spacer(),
Expand All @@ -207,9 +207,9 @@ class _AttachedToastState extends State<AttachedToast> {
child: Radio(
value: PreferDirection.rightTop,
groupValue: preferDirection,
onChanged: (PreferDirection value) {
onChanged: (PreferDirection? value) {
setState(() {
preferDirection = value;
preferDirection = value!;
});
})),
],
Expand Down Expand Up @@ -237,9 +237,9 @@ class _AttachedToastState extends State<AttachedToast> {
child: Radio(
value: PreferDirection.leftCenter,
groupValue: preferDirection,
onChanged: (PreferDirection value) {
onChanged: (PreferDirection? value) {
setState(() {
preferDirection = value;
preferDirection = value!;
});
})),
const Spacer(),
Expand All @@ -249,9 +249,9 @@ class _AttachedToastState extends State<AttachedToast> {
child: Radio(
value: PreferDirection.rightCenter,
groupValue: preferDirection,
onChanged: (PreferDirection value) {
onChanged: (PreferDirection? value) {
setState(() {
preferDirection = value;
preferDirection = value!;
});
})),
],
Expand Down Expand Up @@ -279,9 +279,9 @@ class _AttachedToastState extends State<AttachedToast> {
child: Radio(
value: PreferDirection.leftBottom,
groupValue: preferDirection,
onChanged: (PreferDirection value) {
onChanged: (PreferDirection? value) {
setState(() {
preferDirection = value;
preferDirection = value!;
});
})),
const Spacer(),
Expand All @@ -291,9 +291,9 @@ class _AttachedToastState extends State<AttachedToast> {
child: Radio(
value: PreferDirection.rightBottom,
groupValue: preferDirection,
onChanged: (PreferDirection value) {
onChanged: (PreferDirection? value) {
setState(() {
preferDirection = value;
preferDirection = value!;
});
})),
],
Expand Down Expand Up @@ -322,27 +322,27 @@ class _AttachedToastState extends State<AttachedToast> {
child: Radio(
value: PreferDirection.bottomLeft,
groupValue: preferDirection,
onChanged: (PreferDirection value) {
onChanged: (PreferDirection? value) {
setState(() {
preferDirection = value;
preferDirection = value!;
});
})),
Expanded(
child: Radio(
value: PreferDirection.bottomCenter,
groupValue: preferDirection,
onChanged: (PreferDirection value) {
onChanged: (PreferDirection? value) {
setState(() {
preferDirection = value;
preferDirection = value!;
});
})),
Expanded(
child: Radio(
value: PreferDirection.bottomRight,
groupValue: preferDirection,
onChanged: (PreferDirection value) {
onChanged: (PreferDirection? value) {
setState(() {
preferDirection = value;
preferDirection = value!;
});
})),
const Spacer(),
Expand Down
Loading

0 comments on commit f7f090e

Please sign in to comment.