浏览代码

1.优化刷新组件

tags/0.0.16+9
“yanghuaxuan” 3 年前
父节点
当前提交
97b8a0c446
共有 3 个文件被更改,包括 14 次插入11 次删除
  1. +9
    -7
      lib/models/base/base_change_notifier.dart
  2. +3
    -0
      lib/models/base/skip_model.dart
  3. +2
    -4
      lib/util/turn_chain/turn_chain_util.dart

+ 9
- 7
lib/models/base/base_change_notifier.dart 查看文件

@@ -6,12 +6,15 @@ import 'package:provider/provider.dart';
class BaseChangeNotifier extends ChangeNotifier {
StreamController pageController = StreamController.broadcast();

static Map<String, String> hasKeys = Map();

///刷新通知方法
void refresh() {
pageController.add("refresh");
notifyListeners();
}


void close() {
pageController.close();
}
@@ -29,8 +32,8 @@ enum EventType {
///页面刷新辅助类
class RefreshListener {
bool isListen = false;
StreamSubscription streamSubscription;
Map<String, String> hasKeys = Map();
StreamSubscription streamSubscription;
///监听方法
///已废弃
void _listen(BuildContext context, Function(String) refresh) {
@@ -54,19 +57,18 @@ class RefreshListener {
}

///监听构造
RefreshListener.listen(BuildContext context, Function(String) refresh) {
void listen(BuildContext context, Function(String) refresh) {

BaseChangeNotifier baseChangeNotifier;
try {
baseChangeNotifier = Provider.of<BaseChangeNotifier>(context);
} catch (e, s) {
print(e);
print(s);
throw Exception(
"父页面或父控件必须添加 BaseChangeNotifier 的 Provide值才能使用RefreshListener对象");
}
if (!isListen && baseChangeNotifier != null) {
isListen = true;
baseChangeNotifier.stream.listen((event) {
streamSubscription= baseChangeNotifier.stream.listen((event) {
if (refresh != null) {
refresh(event);
}
@@ -77,7 +79,7 @@ class RefreshListener {
///关闭监听
void close() {
if (streamSubscription != null) {
streamSubscription.cancel();
streamSubscription?.cancel();
}
}
}

+ 3
- 0
lib/models/base/skip_model.dart 查看文件

@@ -4,6 +4,7 @@ class SkipModel {
String requiredTaobaoAuth;
String skipIdentifier;
String isJump;
String skipName;
Map<String, dynamic> data;

SkipModel({
@@ -26,6 +27,7 @@ class SkipModel {
requiredTaobaoAuth = json['required_taobao_auth']?.toString();
skipIdentifier = json['skip_identifier'];
isJump = json['is_jump']?.toString();
skipName=json['skip_name'];
}

Map<String, dynamic> toJson() {
@@ -36,6 +38,7 @@ class SkipModel {
data['skip_identifier'] = this.skipIdentifier;
data['is_jump'] = this.isJump;
data['data'] = this.data;
data['skip_name']=this.skipName;
return data;
}
}

+ 2
- 4
lib/util/turn_chain/turn_chain_util.dart 查看文件

@@ -231,10 +231,8 @@ class TurnChainUtil {
RouterUtil.openWebview(webUrl, context);
rlt = true;
} else {
tradeResult = await FlutterAlibc.openByUrl(
url: openAppUrl,
schemeType: provider == GlobalConfig.PROVIDER_TM ? AlibcSchemeType.AlibcSchemeTmall : AlibcSchemeType.AlibcSchemeTaoBao,
);

tradeResult = await FlutterAlibc.openByUrl(url: openAppUrl,schemeType: provider==GlobalConfig.PROVIDER_TB?AlibcSchemeType.AlibcSchemeTaoBao:AlibcSchemeType.AlibcSchemeTmall,);
rlt = true;
}
}


正在加载...
取消
保存