Commit d5f93445 authored by 林生雨's avatar 林生雨

w

parent e3d6dfc3
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import 'dart:convert'; import 'dart:convert';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_common/commonModel/live/BaseModel.dart'; import 'package:flutter_common/commonModel/live/BaseModel.dart';
import 'package:flutter_common/commonModel/live/LiveData.dart'; import 'package:flutter_common/commonModel/live/LiveData.dart';
import 'package:flutter_common/commonModel/toast/NativeToast.dart'; import 'package:flutter_common/commonModel/toast/NativeToast.dart';
...@@ -21,6 +22,7 @@ import 'package:pull_to_refresh/pull_to_refresh.dart'; ...@@ -21,6 +22,7 @@ import 'package:pull_to_refresh/pull_to_refresh.dart';
class PlanModel extends BaseModel { class PlanModel extends BaseModel {
final String PLAN_MODEL_BUFFER = "PLAN_MODEL_BUFFER"; final String PLAN_MODEL_BUFFER = "PLAN_MODEL_BUFFER";
final String PLAN_MODEL_LIST_BUFFER = "PLAN_MODEL_LIST_BUFFER";
LiveData<List> managerLive = new LiveData(); LiveData<List> managerLive = new LiveData();
LiveData<List<double>> posLive = new LiveData(); LiveData<List<double>> posLive = new LiveData();
LiveData<List<double>> backLive = new LiveData(); LiveData<List<double>> backLive = new LiveData();
...@@ -66,7 +68,7 @@ class PlanModel extends BaseModel { ...@@ -66,7 +68,7 @@ class PlanModel extends BaseModel {
if (call != null) { if (call != null) {
call(); call();
} }
refreshFeed(true); refreshFeed(true, needCache: needCache);
return; return;
} }
ClueApiImpl.getInstance() ClueApiImpl.getInstance()
...@@ -82,7 +84,7 @@ class PlanModel extends BaseModel { ...@@ -82,7 +84,7 @@ class PlanModel extends BaseModel {
if (call != null) { if (call != null) {
call(); call();
} }
refreshFeed(true); refreshFeed(true, needCache: needCache);
CacheManager.getInstance() CacheManager.getInstance()
.get(MEMORY_CACHE) .get(MEMORY_CACHE)
.save(PLAN_MODEL_BUFFER, json.encode(event.toJson())); .save(PLAN_MODEL_BUFFER, json.encode(event.toJson()));
...@@ -110,11 +112,31 @@ class PlanModel extends BaseModel { ...@@ -110,11 +112,31 @@ class PlanModel extends BaseModel {
refreshFeed(true); refreshFeed(true);
} }
void refreshFeed(bool clear, {RefreshController controller}) { void refreshFeed(bool clear,
{RefreshController controller, bool needCache = false}) {
if (clear) { if (clear) {
page = 1; page = 1;
feedDatas.clear(); feedDatas.clear();
} }
if (needCache
&&CacheManager.getInstance().get(MEMORY_CACHE).get(PLAN_MODEL_LIST_BUFFER)!=null) {
var event = PlanFeedBean.fromJson(json.decode(
CacheManager.getInstance().get(MEMORY_CACHE).get(PLAN_MODEL_LIST_BUFFER)));
if (event.data.plans == null || event.data.plans.isEmpty) {
if (page == 1) {
feedsLive.notifyView(Pair(EMPTY, []));
} else {
feedsLive.notifyView(Pair(ENDLOADING, []));
}
} else {
feedDatas.addAll(event.data.plans);
feedsLive.notifyView(Pair(ENDLOADING, feedDatas));
}
WidgetsBinding.instance.addPostFrameCallback((_) {
SimpleEventBus.instance()
.notifyListener("BaseNestedScrollViewRefreshIndicator", "refresh");
});
}
ClueApiImpl.getInstance() ClueApiImpl.getInstance()
.getPlanFeed(DioUtil.getInstance().getDio(), tag_id, order_by, .getPlanFeed(DioUtil.getInstance().getDio(), tag_id, order_by,
current_city_id, min_price, max_price, rank_type, page) current_city_id, min_price, max_price, rank_type, page)
...@@ -129,6 +151,10 @@ class PlanModel extends BaseModel { ...@@ -129,6 +151,10 @@ class PlanModel extends BaseModel {
} else { } else {
feedDatas.addAll(event.data.plans); feedDatas.addAll(event.data.plans);
feedsLive.notifyView(Pair(ENDLOADING, feedDatas)); feedsLive.notifyView(Pair(ENDLOADING, feedDatas));
event.data.plans=feedDatas;
CacheManager.getInstance()
.get(MEMORY_CACHE)
.save(PLAN_MODEL_LIST_BUFFER, json.encode(event.toJson()));
} }
controller?.refreshCompleted(); controller?.refreshCompleted();
} else { } else {
...@@ -140,6 +166,7 @@ class PlanModel extends BaseModel { ...@@ -140,6 +166,7 @@ class PlanModel extends BaseModel {
.addToDispose(rxDispose) .addToDispose(rxDispose)
.onError((err) { .onError((err) {
PrintUtil.printBug(err); PrintUtil.printBug(err);
print("PLANERROR ${err}");
feedsLive.notifyView(Pair(FAIL, null)); feedsLive.notifyView(Pair(FAIL, null));
controller?.refreshFailed(); controller?.refreshFailed();
}); });
......
...@@ -242,7 +242,10 @@ class PlanState extends BaseState<PlanPage> with TickerProviderStateMixin { ...@@ -242,7 +242,10 @@ class PlanState extends BaseState<PlanPage> with TickerProviderStateMixin {
), ),
); );
}, },
) ),
baseSliverBack((){
Navigator.pop(context);
}),
], ],
), ),
); );
......
...@@ -79,6 +79,12 @@ class MainManager { ...@@ -79,6 +79,12 @@ class MainManager {
// } else { // } else {
innerSetData(map, COOKIE); innerSetData(map, COOKIE);
// } // }
if (map[USER_ID] == null || "${map[USER_ID]}".isEmpty) {
CacheManager.getInstance().get(MEMORY_CACHE).save(USER_ID, null);
}
if (map[COOKIE] == null || "${map[COOKIE]}".isEmpty) {
CacheManager.getInstance().get(MEMORY_CACHE).save(COOKIE, null);
}
print( print(
"LSY QQWWEERRTTYY ${CacheManager.getInstance().get(MEMORY_CACHE).get(COOKIE)}" "LSY QQWWEERRTTYY ${CacheManager.getInstance().get(MEMORY_CACHE).get(COOKIE)}"
" ${CacheManager.getInstance().get(MEMORY_CACHE).get(COOKIE) is String}"); " ${CacheManager.getInstance().get(MEMORY_CACHE).get(COOKIE) is String}");
...@@ -89,8 +95,6 @@ class MainManager { ...@@ -89,8 +95,6 @@ class MainManager {
void innerSetData(Map<String, dynamic> map, String str) { void innerSetData(Map<String, dynamic> map, String str) {
if (map[str] != null && "${map[str]}".isNotEmpty) { if (map[str] != null && "${map[str]}".isNotEmpty) {
CacheManager.getInstance().get(MEMORY_CACHE).save(str, "${map[str]}"); CacheManager.getInstance().get(MEMORY_CACHE).save(str, "${map[str]}");
} else {
CacheManager.getInstance().get(MEMORY_CACHE).save(str, null);
} }
} }
......
...@@ -29,96 +29,96 @@ class DioInterceptorManager { ...@@ -29,96 +29,96 @@ class DioInterceptorManager {
} }
if (CacheManager.getInstance().get(MEMORY_CACHE).get(COOKIE) != null) { if (CacheManager.getInstance().get(MEMORY_CACHE).get(COOKIE) != null) {
opt.headers[HttpHeaders.cookieHeader] = opt.headers[HttpHeaders.cookieHeader] =
CacheManager.getInstance().get(MEMORY_CACHE).get(COOKIE); "${CacheManager.getInstance().get(MEMORY_CACHE).get(COOKIE)}";
} }
if (opt.queryParameters == null) { if (opt.queryParameters == null) {
opt.queryParameters = Map<String, dynamic>(); opt.queryParameters = Map<String, dynamic>();
} }
if (CacheManager.getInstance().get(MEMORY_CACHE).get(APP_NAME) != null) { if (CacheManager.getInstance().get(MEMORY_CACHE).get(APP_NAME) != null) {
opt.queryParameters[APP_NAME] = opt.queryParameters[APP_NAME] =
CacheManager.getInstance().get(MEMORY_CACHE).get(APP_NAME); "${CacheManager.getInstance().get(MEMORY_CACHE).get(APP_NAME)}";
} }
if (CacheManager.getInstance().get(MEMORY_CACHE).get(VERSION) != null) { if (CacheManager.getInstance().get(MEMORY_CACHE).get(VERSION) != null) {
opt.queryParameters[VERSION] = opt.queryParameters[VERSION] =
CacheManager.getInstance().get(MEMORY_CACHE).get(VERSION); "${CacheManager.getInstance().get(MEMORY_CACHE).get(VERSION)}";
} }
if (CacheManager.getInstance().get(MEMORY_CACHE).get(PLATFORM) != null) { if (CacheManager.getInstance().get(MEMORY_CACHE).get(PLATFORM) != null) {
opt.queryParameters[PLATFORM] = opt.queryParameters[PLATFORM] =
CacheManager.getInstance().get(MEMORY_CACHE).get(PLATFORM); "${CacheManager.getInstance().get(MEMORY_CACHE).get(PLATFORM)}";
} }
if (CacheManager.getInstance().get(MEMORY_CACHE).get(DEVICE_ID) != null) { if (CacheManager.getInstance().get(MEMORY_CACHE).get(DEVICE_ID) != null) {
opt.queryParameters[DEVICE_ID] = opt.queryParameters[DEVICE_ID] =
CacheManager.getInstance().get(MEMORY_CACHE).get(DEVICE_ID); "${CacheManager.getInstance().get(MEMORY_CACHE).get(DEVICE_ID)}";
} }
if (CacheManager.getInstance().get(MEMORY_CACHE).get(OS_VERSION) != if (CacheManager.getInstance().get(MEMORY_CACHE).get(OS_VERSION) !=
null) { null) {
opt.queryParameters[OS_VERSION] = opt.queryParameters[OS_VERSION] =
CacheManager.getInstance().get(MEMORY_CACHE).get(OS_VERSION); "${CacheManager.getInstance().get(MEMORY_CACHE).get(OS_VERSION)}";
} }
if (CacheManager.getInstance().get(MEMORY_CACHE).get(MODEL) != null) { if (CacheManager.getInstance().get(MEMORY_CACHE).get(MODEL) != null) {
opt.queryParameters[MODEL] = opt.queryParameters[MODEL] =
CacheManager.getInstance().get(MEMORY_CACHE).get(MODEL); "${CacheManager.getInstance().get(MEMORY_CACHE).get(MODEL)}";
} }
if (CacheManager.getInstance().get(MEMORY_CACHE).get(SCREEN) != null) { if (CacheManager.getInstance().get(MEMORY_CACHE).get(SCREEN) != null) {
opt.queryParameters[SCREEN] = opt.queryParameters[SCREEN] =
CacheManager.getInstance().get(MEMORY_CACHE).get(SCREEN); "${CacheManager.getInstance().get(MEMORY_CACHE).get(SCREEN)}";
} }
if (CacheManager.getInstance().get(MEMORY_CACHE).get(LAT) != null) { if (CacheManager.getInstance().get(MEMORY_CACHE).get(LAT) != null) {
opt.queryParameters[LAT] = opt.queryParameters[LAT] =
CacheManager.getInstance().get(MEMORY_CACHE).get(LAT); "${CacheManager.getInstance().get(MEMORY_CACHE).get(LAT)}";
} }
if (CacheManager.getInstance().get(MEMORY_CACHE).get(LNG) != null) { if (CacheManager.getInstance().get(MEMORY_CACHE).get(LNG) != null) {
opt.queryParameters[LNG] = opt.queryParameters[LNG] =
CacheManager.getInstance().get(MEMORY_CACHE).get(LNG); "${CacheManager.getInstance().get(MEMORY_CACHE).get(LNG)}";
} }
if (CacheManager.getInstance().get(MEMORY_CACHE).get(CHANNEL) != null) { if (CacheManager.getInstance().get(MEMORY_CACHE).get(CHANNEL) != null) {
opt.queryParameters[CHANNEL] = opt.queryParameters[CHANNEL] =
CacheManager.getInstance().get(MEMORY_CACHE).get(CHANNEL); "${CacheManager.getInstance().get(MEMORY_CACHE).get(CHANNEL)}";
} }
if (CacheManager.getInstance().get(MEMORY_CACHE).get(MANUFACTURER) != if (CacheManager.getInstance().get(MEMORY_CACHE).get(MANUFACTURER) !=
null) { null) {
opt.queryParameters[MANUFACTURER] = opt.queryParameters[MANUFACTURER] =
CacheManager.getInstance().get(MEMORY_CACHE).get(MANUFACTURER); "${CacheManager.getInstance().get(MEMORY_CACHE).get(MANUFACTURER)}";
} }
if (CacheManager.getInstance().get(MEMORY_CACHE).get(UUID) != null) { if (CacheManager.getInstance().get(MEMORY_CACHE).get(UUID) != null) {
opt.queryParameters[UUID] = opt.queryParameters[UUID] =
CacheManager.getInstance().get(MEMORY_CACHE).get(UUID); "${CacheManager.getInstance().get(MEMORY_CACHE).get(UUID)}";
} }
if (Platform.isAndroid) { if (Platform.isAndroid) {
if (CacheManager.getInstance() if (CacheManager.getInstance()
.get(MEMORY_CACHE) .get(MEMORY_CACHE)
.get(ANDROID_DEVICE_ID) != .get(ANDROID_DEVICE_ID) !=
null) { null) {
opt.queryParameters[ANDROID_DEVICE_ID] = CacheManager.getInstance() opt.queryParameters[ANDROID_DEVICE_ID] = "${CacheManager.getInstance()
.get(MEMORY_CACHE) .get(MEMORY_CACHE)
.get(ANDROID_DEVICE_ID); .get(ANDROID_DEVICE_ID)}";
} }
} else { } else {
if (CacheManager.getInstance().get(MEMORY_CACHE).get(RELEASE) != null) { if (CacheManager.getInstance().get(MEMORY_CACHE).get(RELEASE) != null) {
opt.queryParameters[RELEASE] = opt.queryParameters[RELEASE] =
CacheManager.getInstance().get(MEMORY_CACHE).get(RELEASE); "${CacheManager.getInstance().get(MEMORY_CACHE).get(RELEASE)}";
} }
if (CacheManager.getInstance().get(MEMORY_CACHE).get(IDFA) != null) { if (CacheManager.getInstance().get(MEMORY_CACHE).get(IDFA) != null) {
opt.queryParameters[IDFA] = opt.queryParameters[IDFA] =
CacheManager.getInstance().get(MEMORY_CACHE).get(IDFA); "${CacheManager.getInstance().get(MEMORY_CACHE).get(IDFA)}";
} }
if (CacheManager.getInstance().get(MEMORY_CACHE).get(IDFV) != null) { if (CacheManager.getInstance().get(MEMORY_CACHE).get(IDFV) != null) {
opt.queryParameters[IDFV] = opt.queryParameters[IDFV] =
CacheManager.getInstance().get(MEMORY_CACHE).get(IDFV); "${CacheManager.getInstance().get(MEMORY_CACHE).get(IDFV)}";
} }
if (CacheManager.getInstance().get(MEMORY_CACHE).get(IS_WIFI) != null) { if (CacheManager.getInstance().get(MEMORY_CACHE).get(IS_WIFI) != null) {
opt.queryParameters[IS_WIFI] = opt.queryParameters[IS_WIFI] =
CacheManager.getInstance().get(MEMORY_CACHE).get(IS_WIFI); "${CacheManager.getInstance().get(MEMORY_CACHE).get(IS_WIFI)}";
} }
if (CacheManager.getInstance().get(MEMORY_CACHE).get(HARDWARE_MODEL) != if (CacheManager.getInstance().get(MEMORY_CACHE).get(HARDWARE_MODEL) !=
null) { null) {
opt.queryParameters[HARDWARE_MODEL] = opt.queryParameters[HARDWARE_MODEL] =
CacheManager.getInstance().get(MEMORY_CACHE).get(HARDWARE_MODEL); "${CacheManager.getInstance().get(MEMORY_CACHE).get(HARDWARE_MODEL)}";
} }
if (CacheManager.getInstance().get(MEMORY_CACHE).get(CURRENT_CITY_ID) != if (CacheManager.getInstance().get(MEMORY_CACHE).get(CURRENT_CITY_ID) !=
null) { null) {
opt.queryParameters[CURRENT_CITY_ID] = opt.queryParameters[CURRENT_CITY_ID] =
CacheManager.getInstance().get(MEMORY_CACHE).get(CURRENT_CITY_ID); "${CacheManager.getInstance().get(MEMORY_CACHE).get(CURRENT_CITY_ID)}";
} }
} }
......
...@@ -158,10 +158,11 @@ class NestedScrollViewRefreshIndicatorState ...@@ -158,10 +158,11 @@ class NestedScrollViewRefreshIndicatorState
Animation<double> _value; Animation<double> _value;
Animation<Color> _valueColor; Animation<Color> _valueColor;
_RefreshIndicatorMode _mode;
Future<void> _pendingRefreshFuture; Future<void> _pendingRefreshFuture;
bool _isIndicatorAtTop; bool _isIndicatorAtTop=false;
double _dragOffset; double _dragOffset=0.0;
_RefreshIndicatorMode _mode=_RefreshIndicatorMode.done;
static final Animatable<double> _threeQuarterTween = static final Animatable<double> _threeQuarterTween =
Tween<double>(begin: 0.0, end: 0.75); Tween<double>(begin: 0.0, end: 0.75);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment