Skip to content

Commit

Permalink
v0.2.1 pre1
Browse files Browse the repository at this point in the history
  • Loading branch information
thl committed Jun 11, 2019
1 parent 777f6e7 commit 321bb14
Show file tree
Hide file tree
Showing 30 changed files with 867 additions and 544 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ ps:作者Futter版本
[✓] Flutter (Channel beta, v1.6.3, locale zh-Hans-CN)
```

### 关于开源!!!
项目正在整理开源中!
如无法运行,请自行回滚到该节点。
```
git reset --hard 777f6e7fc221b30abf480c94d686c955fe661b0e
```

### [更新说明](./CHANGELOGS.md)

### v0.2.1 (2019.05.08)
Expand Down
1 change: 1 addition & 0 deletions lib/blocs/bloc_index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export 'application_bloc.dart';
export 'main_bloc.dart';
export 'com_list_bloc.dart';
export 'tab_bloc.dart';
export 'collect_bloc.dart';
77 changes: 77 additions & 0 deletions lib/blocs/collect_bloc.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import 'dart:collection';

import 'package:flutter_wanandroid/blocs/bloc_provider.dart';
import 'package:flutter_wanandroid/data/protocol/models.dart';
import 'package:flutter_wanandroid/data/repository/collect_repository.dart';
import 'package:flutter_wanandroid/event/event.dart';
import 'package:flutter_wanandroid/utils/util_index.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:rxdart/rxdart.dart';

class CollectBloc implements BlocBase {
BehaviorSubject<List<ReposModel>> _collectListBs =
BehaviorSubject<List<ReposModel>>();

Sink<List<ReposModel>> get _collectListSink => _collectListBs.sink;

Stream<List<ReposModel>> get collectListStream =>
_collectListBs.stream.asBroadcastStream();

List<ReposModel> _collectList;
int _collectPage = 0;

CollectRepository _collectRepository = new CollectRepository();

@override
Future getData({String labelId, int page}) {
return getCollectList(labelId, page);
}

@override
Future onLoadMore({String labelId}) {
int _page = ++_collectPage;
return getData(labelId: labelId, page: _page);
}

@override
Future onRefresh({String labelId, bool isReload}) {
LogUtil.e("CollectBloc onRefresh...... $labelId");
_collectPage = 0;
if (isReload == true) {
_collectListSink.add(null);
}
return getData(labelId: labelId, page: _collectPage);
}

Future getCollectList(String labelId, int page) {
return _collectRepository.getCollectList(page).then((list) {
if (_collectList == null) {
_collectList = new List();
}
if (page == 0) {
_collectList.clear();
}
_collectList.addAll(list);
_collectListSink.add(UnmodifiableListView<ReposModel>(_collectList));
_homeEventSink?.add(new StatusEvent(
labelId,
ObjectUtil.isEmpty(list)
? RefreshStatus.noMore
: RefreshStatus.idle));
}).catchError((_) {
if (ObjectUtil.isEmpty(_collectList)) {
_collectListBs.sink.addError("error");
}
_collectPage--;
_homeEventSink?.add(new StatusEvent(labelId, RefreshStatus.failed));
});
}

Sink<StatusEvent> _homeEventSink;


@override
void dispose() {
_collectListBs.close();
}
}
9 changes: 9 additions & 0 deletions lib/common/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class Constant {
static const String wan_android = "http://www.wanandroid.com/";

static const int type_sys_update = 1;
static const int type_refresh_all = 5;

static const String key_theme_color = 'key_theme_color';
static const String key_guide = 'key_guide';
static const String key_splash_model = 'key_splash_models';
Expand All @@ -18,3 +20,10 @@ class AppConfig {
static const String version = '0.1.5';
static const bool isDebug = true;
}

class LoadStatus {
static const int fail = -1;
static const int loading = 0;
static const int success = 1;
static const int empty = 2;
}
4 changes: 3 additions & 1 deletion lib/common/component_index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ export 'dart:convert';

export 'package:flutter_wanandroid/blocs/bloc_index.dart';
export 'package:flutter_wanandroid/ui/widgets/widget_index.dart';
export 'package:flutter_wanandroid/res/res_index.dart';
export 'package:flutter_wanandroid/res/index.dart';
export 'package:flutter_wanandroid/utils/util_index.dart';

export 'package:base_library/base_library.dart';

export 'package:flutter_wanandroid/common/common.dart';
export 'package:flutter_wanandroid/common/sp_helper.dart';
export 'package:flutter_wanandroid/event/event.dart';
Expand Down
4 changes: 4 additions & 0 deletions lib/common/sp_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:common_utils/common_utils.dart';
import 'package:flustars/flustars.dart';
import 'package:flutter_wanandroid/common/common.dart';
import 'package:flutter_wanandroid/data/protocol/models.dart';
import 'package:flutter_wanandroid/models/models.dart';

class SpHelper {
Expand Down Expand Up @@ -53,6 +54,9 @@ class SpHelper {
case VersionModel:
obj = VersionModel.fromJson(map);
break;
case UserModel:
obj = UserModel.fromJson(map);
break;
default:
break;
}
Expand Down
10 changes: 7 additions & 3 deletions lib/data/api/apis.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ class WanAndroidApi {
/// 在某个公众号中搜索历史文章 http://wanandroid.com/wxarticle/list/405/1/json?k=Java
static const String WXARTICLE_LIST = "wxarticle/list";

static const String USER_REGISTER = "user/register"; //注册
static const String USER_LOGIN = "user/login"; //登录
static const String USER_LOGOUT = "user/logout"; //退出
static const String user_register = "user/register"; //注册
static const String user_login = "user/login"; //登录
static const String user_logout = "user/logout"; //退出

static const String lg_collect_list = "lg/collect/list"; //收藏文章列表
static const String lg_collect = "lg/collect"; //收藏站内文章
static const String lg_uncollect_originid = "lg/uncollect_originId"; //取消收藏

static String getPath({String path: '', int page, String resType: 'json'}) {
StringBuffer sb = new StringBuffer(path);
Expand Down
Loading

0 comments on commit 321bb14

Please sign in to comment.