提交 69f19683 authored 作者: 张国庆's avatar 张国庆

readme

上级 b717a87f
## 0.0.1 ## 0.0.1
* TODO: Describe initial release. * 应用内消息通知和公告消息通知插件
# clx_flutter_message # clx_flutter_message
An in-app messaging plugin 应用内消息通知插件
## Getting Started ## 开始使用
This project is a starting point for a Flutter ### 添加依赖
[plug-in package](https://flutter.dev/developing-packages/), 在 pubspec.yaml 文件中添加依赖
a specialized package that includes platform-specific implementation code for ```yaml
Android and/or iOS. dependencies:
clx_flutter_message:
git: https://t.clxkj.cn/openSourceLibrary/clx_flutter_message.git
```
For help getting started with Flutter development, view the ## 使用
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference. ### 导包
```dart
import 'package:clx_flutter_message/clx_flutter_message.dart';
```
### 初始化
**在main方法中配置参数**
```dart
messageConfig
..accessToken = SpUtil.getString(SPKey.userToken) ?? ""
..companyNo = getCompanyNo
..productCode=productCode
..userKey=getUserNo
..webSocketUrl=Config.socketAddress
..inAppAccessKey = inAppAccessKey
..messageManagement = MessageConfigImpl();
```
### 创建MessageConfigImpl类实现 BaseMessageConfig
```dart
class MessageConfigImpl extends BaseMessageConfig {
@override
Future<List<MessageData>> getUnReadMessage() {
// TODO: implement getUnReadMessage
throw UnimplementedError();
}
@override
Future<List<MessageData>> getUnReadNotice() {
// TODO: implement getUnReadNotice
throw UnimplementedError();
}
@override
Future<bool> ignoreAction(MessageData? message) {
// TODO: implement ignoreAction
throw UnimplementedError();
}
@override
Future<bool> markReadAction(MessageData? message) {
// TODO: implement markReadAction
throw UnimplementedError();
}
@override
void onJumpToMessagePage(String page, arguments) {
// TODO: implement onJumpToMessagePage
}
@override
Future<bool> removeMessageAction(MessageData? message) {
// TODO: implement removeMessageAction
throw UnimplementedError();
}
@override
void setMessageShowed(MessageData? message) {
// TODO: implement setMessageShowed
}
}
```
### 配置通知公告widget
```dart
NoticeDialogWidget(
decoration: BoxDecoration(
color: Colors.white,
image: DecorationImage(
image: AssetImage(
ImageLoader.getPath('notice_bg'),
),
alignment: Alignment.topCenter,
),
borderRadius: BorderRadius.circular(20),
),
buttonColor: colors.red,
cancelText: "取消"
confirmText: "确定"
)
```
### 调用连接获取消息方法
```dart
messageConfig.messageManagement?.refreshMessage(context);
```
### 关闭方法
```dart
messageConfig.messageManagement?.close();
```
\ No newline at end of file
import 'package:clx_flutter_message/util/string_util.dart'; import 'package:clx_flutter_message/util/string_util.dart';
import 'package:clx_flutter_message/util/toast_util.dart'; import 'package:clx_flutter_message/util/toast_util.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'clx_flutter_message_platform_interface.dart'; import 'clx_flutter_message_platform_interface.dart';
import 'common/constant.dart'; import 'common/constant.dart';
import 'core/model/message_config.dart'; import 'core/model/message_config.dart';
...@@ -11,6 +10,10 @@ import 'core/notice/notice_manager.dart'; ...@@ -11,6 +10,10 @@ import 'core/notice/notice_manager.dart';
import 'core/notification/notification_layout/notification_layout_widget.dart'; import 'core/notification/notification_layout/notification_layout_widget.dart';
import 'core/notification/notification_manager.dart'; import 'core/notification/notification_manager.dart';
import 'core/socket/socket_io.dart'; import 'core/socket/socket_io.dart';
export 'core/model/message_config.dart';
export 'core/model/message_data.dart';
export 'core/notice/notice_dialog_widget.dart';
export 'core/notification/notification_layout/notification_layout_widget.dart';
class ClxFlutterMessage { class ClxFlutterMessage {
Future<String?> getPlatformVersion() { Future<String?> getPlatformVersion() {
...@@ -128,9 +131,7 @@ abstract class BaseMessageConfig with NotificationManager, NoticeManager { ...@@ -128,9 +131,7 @@ abstract class BaseMessageConfig with NotificationManager, NoticeManager {
// 构造方法 // 构造方法
BaseMessageConfig() { BaseMessageConfig() {
//通过getx 注入 NotificationLayoutController
notificationLayoutController = NotificationLayoutController(); notificationLayoutController = NotificationLayoutController();
//通过getx 注入 NoticeDialogWidgetController
noticeDialogWidgetController = NoticeDialogWidgetController(); noticeDialogWidgetController = NoticeDialogWidgetController();
} }
......
import 'package:flutter/material.dart';
const btnBgColor = Color(0xFF73BC8B);
const Color overlayColor = Color(0x33FFFFFF);
const Color appMain = Color(0xFF73BC8B);
const String bizType = "in_app"; const String bizType = "in_app";
......
...@@ -3,7 +3,6 @@ import 'package:get/get.dart'; ...@@ -3,7 +3,6 @@ import 'package:get/get.dart';
import '../../clx_flutter_message.dart'; import '../../clx_flutter_message.dart';
import '../../util/string_util.dart'; import '../../util/string_util.dart';
import '../model/message_data.dart';
import '../model/message_node.dart'; import '../model/message_node.dart';
import '../widget/button_public/button_public_rect.dart'; import '../widget/button_public/button_public_rect.dart';
import '../widget/button_public/button_public_type.dart'; import '../widget/button_public/button_public_type.dart';
...@@ -16,6 +15,7 @@ class NoticeDialogWidget extends GetView<NoticeDialogWidgetController> { ...@@ -16,6 +15,7 @@ class NoticeDialogWidget extends GetView<NoticeDialogWidgetController> {
this.confirmText, this.confirmText,
this.cancelType, this.cancelType,
this.confirmType, this.confirmType,
required this.buttonColor,
}); });
// 对话框背景 decoration // 对话框背景 decoration
...@@ -31,6 +31,9 @@ class NoticeDialogWidget extends GetView<NoticeDialogWidgetController> { ...@@ -31,6 +31,9 @@ class NoticeDialogWidget extends GetView<NoticeDialogWidgetController> {
// 确认按钮类型 // 确认按钮类型
final ButtonPublicType? confirmType; final ButtonPublicType? confirmType;
// 按钮颜色
final Color buttonColor;
// 主视图 // 主视图
Widget _buildView() { Widget _buildView() {
var message = controller.headNode?.data; var message = controller.headNode?.data;
...@@ -72,6 +75,7 @@ class NoticeDialogWidget extends GetView<NoticeDialogWidgetController> { ...@@ -72,6 +75,7 @@ class NoticeDialogWidget extends GetView<NoticeDialogWidgetController> {
children: [ children: [
Expanded( Expanded(
child: ButtonPublicRect( child: ButtonPublicRect(
buttonColor: buttonColor,
type: cancelType ?? ButtonPublicType.outline, type: cancelType ?? ButtonPublicType.outline,
text: cancelText ?? '忽略', text: cancelText ?? '忽略',
onPressed: controller.ignore, onPressed: controller.ignore,
...@@ -81,6 +85,7 @@ class NoticeDialogWidget extends GetView<NoticeDialogWidgetController> { ...@@ -81,6 +85,7 @@ class NoticeDialogWidget extends GetView<NoticeDialogWidgetController> {
const SizedBox(width: 10), const SizedBox(width: 10),
Expanded( Expanded(
child: ButtonPublicRect( child: ButtonPublicRect(
buttonColor: buttonColor,
type: confirmType ?? ButtonPublicType.solid, type: confirmType ?? ButtonPublicType.solid,
text: confirmText ?? '去处理', text: confirmText ?? '去处理',
onPressed: () { onPressed: () {
......
...@@ -4,7 +4,6 @@ import 'package:flutter/material.dart'; ...@@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import '../../../clx_flutter_message.dart'; import '../../../clx_flutter_message.dart';
import '../../model/message_data.dart';
import '../../model/message_node.dart'; import '../../model/message_node.dart';
import 'widget/list_item.dart'; import 'widget/list_item.dart';
......
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../common/constant.dart';
import 'button_public_type.dart'; import 'button_public_type.dart';
/// 按钮样式 /// 按钮样式
...@@ -14,15 +13,17 @@ class ButtonPublicRect extends StatefulWidget { ...@@ -14,15 +13,17 @@ class ButtonPublicRect extends StatefulWidget {
final double borderWidth; // 边框宽度 final double borderWidth; // 边框宽度
final Color? textColor; // 按钮文本颜色 final Color? textColor; // 按钮文本颜色
final double textSize; // 按钮文本字体大小 final double textSize; // 按钮文本字体大小
final Color backgroundColor; // 按钮可点击颜色 final Color? backgroundColor; // 按钮可点击颜色
final FontWeight fontWeight; // 按钮文本字体粗细 final FontWeight fontWeight; // 按钮文本字体粗细
final double borderRadius; // 按钮圆角大小 final double borderRadius; // 按钮圆角大小
final ButtonPublicType type; // 按钮类型 final ButtonPublicType type; // 按钮类型
final Color buttonColor; //按钮颜色
const ButtonPublicRect({ const ButtonPublicRect({
super.key, super.key,
required this.text, required this.text,
required this.onPressed, required this.onPressed,
required this.buttonColor,
this.minWidth = 0.0, this.minWidth = 0.0,
this.minHeight = 48.0, this.minHeight = 48.0,
this.margin, this.margin,
...@@ -30,10 +31,10 @@ class ButtonPublicRect extends StatefulWidget { ...@@ -30,10 +31,10 @@ class ButtonPublicRect extends StatefulWidget {
this.textColor, this.textColor,
this.borderColor, this.borderColor,
this.borderWidth = 1.0, this.borderWidth = 1.0,
this.backgroundColor = btnBgColor, this.backgroundColor ,
this.fontWeight = FontWeight.bold, this.fontWeight = FontWeight.bold,
this.borderRadius = 8.0, this.borderRadius = 8.0,
this.type = ButtonPublicType.solid, this.type = ButtonPublicType.solid,
}); });
@override @override
...@@ -63,7 +64,6 @@ class _ButtonPublicRectState extends State<ButtonPublicRect> { ...@@ -63,7 +64,6 @@ class _ButtonPublicRectState extends State<ButtonPublicRect> {
return _backgroundColor(); return _backgroundColor();
}), }),
//设置水波纹颜色 //设置水波纹颜色
overlayColor: MaterialStateProperty.all(overlayColor),
shape: MaterialStateProperty.all( shape: MaterialStateProperty.all(
RoundedRectangleBorder( RoundedRectangleBorder(
borderRadius: BorderRadius.circular(widget.borderRadius)), borderRadius: BorderRadius.circular(widget.borderRadius)),
...@@ -84,7 +84,7 @@ class _ButtonPublicRectState extends State<ButtonPublicRect> { ...@@ -84,7 +84,7 @@ class _ButtonPublicRectState extends State<ButtonPublicRect> {
return widget.textColor ?? Colors.white; return widget.textColor ?? Colors.white;
case ButtonPublicType.outline: case ButtonPublicType.outline:
case ButtonPublicType.dash: case ButtonPublicType.dash:
return widget.textColor ?? widget.borderColor ?? appMain; return widget.textColor ?? widget.borderColor ?? widget.buttonColor;
default: default:
return widget.textColor ?? Colors.white; return widget.textColor ?? Colors.white;
} }
...@@ -95,12 +95,12 @@ class _ButtonPublicRectState extends State<ButtonPublicRect> { ...@@ -95,12 +95,12 @@ class _ButtonPublicRectState extends State<ButtonPublicRect> {
Color _backgroundColor() { Color _backgroundColor() {
switch (widget.type) { switch (widget.type) {
case ButtonPublicType.solid: case ButtonPublicType.solid:
return widget.backgroundColor; return widget.backgroundColor ?? widget.buttonColor;
case ButtonPublicType.outline: case ButtonPublicType.outline:
case ButtonPublicType.dash: case ButtonPublicType.dash:
return Colors.transparent; return Colors.transparent;
default: default:
return widget.backgroundColor; return widget.backgroundColor?? widget.buttonColor;
} }
} }
...@@ -109,7 +109,7 @@ class _ButtonPublicRectState extends State<ButtonPublicRect> { ...@@ -109,7 +109,7 @@ class _ButtonPublicRectState extends State<ButtonPublicRect> {
Color _borderColor() { Color _borderColor() {
switch (widget.type) { switch (widget.type) {
case ButtonPublicType.outline: case ButtonPublicType.outline:
return widget.borderColor ?? appMain; return widget.borderColor ?? widget.buttonColor;
default: default:
return Colors.transparent; return Colors.transparent;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论