Skip to content

Commit 82533af

Browse files
Optimize cross-platform effects
1 parent bde2fc7 commit 82533af

31 files changed

Lines changed: 2819 additions & 1259 deletions

assets/Lofter-asset.zip

2.9 MB
Binary file not shown.

assets/icon/code.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,15 @@ static const String linkDarkIcon = "assets/icon/link_dark.png";
2929
static const String linkGreyIcon = "assets/icon/link_grey.png";
3030
static const String linkLightIcon = "assets/icon/link_light.png";
3131
static const String linkPrimaryIcon = "assets/icon/link_primary.png";
32+
static const String linkWhiteIcon = "assets/icon/link_white.png";
3233
static const String mineDarkIcon = "assets/icon/mine_dark.png";
3334
static const String mineDarkSelectedIcon = "assets/icon/mine_dark_selected.png";
3435
static const String mineLightIcon = "assets/icon/mine_light.png";
3536
static const String mineLightSelectedIcon = "assets/icon/mine_light_selected.png";
37+
static const String orderDownDarkIcon = "assets/icon/order_down_dark.png";
38+
static const String orderDownLightIcon = "assets/icon/order_down_light.png";
39+
static const String orderUpDarkIcon = "assets/icon/order_up_dark.png";
40+
static const String orderUpLightIcon = "assets/icon/order_up_light.png";
3641
static const String searchDarkIcon = "assets/icon/search_dark.png";
3742
static const String searchGreyIcon = "assets/icon/search_grey.png";
3843
static const String searchLightIcon = "assets/icon/search_light.png";

assets/icon/order_down_dark.png

463 Bytes
Loading

assets/icon/order_down_light.png

462 Bytes
Loading

assets/icon/order_up_dark.png

470 Bytes
Loading

assets/icon/order_up_light.png

472 Bytes
Loading

lib/Api/post_api.dart

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,28 @@ class PostApi {
4444
required String blogName,
4545
}) async {
4646
String blogDomain = Utils.getBlogDomain(blogName);
47-
return RequestUtil.post(
48-
"/oldapi/post/detail.api",
49-
data: {
50-
"supportposttypes": "supportposttypes",
47+
Map<String, dynamic> data = {
48+
"supportposttypes": "1,2,3,4,5,6",
49+
"postid": postId,
50+
"requestType": 0,
51+
"offset": 0,
52+
"postdigestnew": 1,
53+
"checkpwd": 1,
54+
"needgetpoststat": 1,
55+
};
56+
if (Utils.isNotEmpty(blogDomain)) {
57+
data.addAll({
5158
"blogdomain": blogDomain,
52-
"postid": postId,
5359
"blogId": blogId,
54-
"requestType": 0,
55-
"offset": 0,
56-
"postdigestnew": 1,
57-
"checkpwd": 1,
58-
"needgetpoststat": 1,
59-
},
60+
});
61+
} else {
62+
data.addAll({
63+
"targetblogid": blogId,
64+
});
65+
}
66+
return RequestUtil.post(
67+
"/oldapi/post/detail.api",
68+
data: data,
6069
options: Options(contentType: Headers.formUrlEncodedContentType),
6170
);
6271
}
@@ -184,9 +193,7 @@ class PostApi {
184193
"postId": "$postId",
185194
"blogId": "$blogId",
186195
"postType": postType,
187-
"time": DateTime
188-
.now()
189-
.millisecondsSinceEpoch,
196+
"time": DateTime.now().millisecondsSinceEpoch,
190197
};
191198
if (collectionId != 0) {
192199
item.addAll({
@@ -197,9 +204,7 @@ class PostApi {
197204
"/datacollect/v1/upload",
198205
domainType: DomainType.da,
199206
data: {
200-
"time": DateTime
201-
.now()
202-
.millisecondsSinceEpoch,
207+
"time": DateTime.now().millisecondsSinceEpoch,
203208
"list": [
204209
{
205210
"userId": userId,

lib/Models/enums.dart

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'package:tuple/tuple.dart';
22

3-
double kLoadExtentOffset = 400;
3+
double kLoadExtentOffset = 600;
44

55
enum TokenType {
66
none,
@@ -107,4 +107,41 @@ extension Index on int {
107107
return MultiWindowType.Unknown;
108108
}
109109
}
110-
}
110+
}
111+
112+
enum DoubleTapAction {
113+
none('none', '无操作'),
114+
like('like', '喜欢'),
115+
recommend('recommend', '推荐'),
116+
download('download', '下载当前图片'),
117+
downloadAll('downloadAll', '下载所有图片'),
118+
copyLink('copyLink', '复制帖子链接');
119+
120+
const DoubleTapAction(this.key, this.label);
121+
122+
final String key;
123+
final String label;
124+
}
125+
126+
enum DownloadSuccessAction {
127+
none('none', '无操作'),
128+
unlike('unlike', '取消喜欢'),
129+
unrecommend('unrecommend', '取消推荐');
130+
131+
const DownloadSuccessAction(this.key, this.label);
132+
133+
final String key;
134+
final String label;
135+
}
136+
137+
extension DoubleTapEnumExtension on DoubleTapAction {
138+
List<Tuple2<String, DoubleTapAction>> get tuples {
139+
return DoubleTapAction.values.map((e) => Tuple2(e.label, e)).toList();
140+
}
141+
}
142+
143+
extension DownloadSuccessEnumExtension on DownloadSuccessAction {
144+
List<Tuple2<String, DownloadSuccessAction>> get tuples {
145+
return DownloadSuccessAction.values.map((e) => Tuple2(e.label, e)).toList();
146+
}
147+
}

lib/Screens/Info/collection_screen.dart

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ class _CollectionScreenState extends State<CollectionScreen>
4848
final List<FullPostCollection> _collectionList = [];
4949
bool _loading = false;
5050
final EasyRefreshController _refreshController = EasyRefreshController();
51-
final ScrollController _scrollController = ScrollController();
5251
bool _noMore = false;
5352

5453
@override
@@ -63,13 +62,6 @@ class _CollectionScreenState extends State<CollectionScreen>
6362
if (widget.infoMode != InfoMode.me) {
6463
_onRefresh();
6564
}
66-
_scrollController.addListener(() {
67-
if (!_noMore &&
68-
_scrollController.position.pixels >
69-
_scrollController.position.maxScrollExtent - kLoadExtentOffset) {
70-
_onLoad();
71-
}
72-
});
7365
}
7466

7567
_fetchGrain({bool refresh = false}) async {
@@ -85,7 +77,7 @@ class _CollectionScreenState extends State<CollectionScreen>
8577
.then((value) {
8678
try {
8779
if (value['meta']['status'] != 200) {
88-
IToast.showTop( value['meta']['desc'] ?? value['meta']['msg']);
80+
IToast.showTop(value['meta']['desc'] ?? value['meta']['msg']);
8981
return IndicatorResult.fail;
9082
} else {
9183
List<FullPostCollection> tmp = [];
@@ -111,7 +103,7 @@ class _CollectionScreenState extends State<CollectionScreen>
111103
}
112104
}
113105
} catch (e) {
114-
if (mounted) IToast.showTop( "加载失败");
106+
if (mounted) IToast.showTop("加载失败");
115107
return IndicatorResult.fail;
116108
} finally {
117109
if (mounted) setState(() {});
@@ -151,28 +143,31 @@ class _CollectionScreenState extends State<CollectionScreen>
151143
}
152144

153145
Widget _buildBody(ScrollPhysics physics) {
154-
return ListView.builder(
155-
physics: physics,
156-
controller: _scrollController,
157-
padding: EdgeInsets.zero,
158-
itemCount: _collectionList.length,
159-
itemBuilder: (context, index) {
160-
return _buildCollectionRow(
161-
_collectionList[index],
162-
verticalPadding: 8,
163-
onTap: () {
164-
RouteUtil.pushCupertinoRoute(
165-
context,
166-
CollectionDetailScreen(
167-
collectionId: _collectionList[index].id,
168-
blogId: _collectionList[index].blogId,
169-
blogName: "",
170-
postId: 0,
171-
),
172-
);
173-
},
174-
);
175-
},
146+
return ItemBuilder.buildLoadMoreNotification(
147+
noMore: _noMore,
148+
onLoad: _onLoad,
149+
child: ListView.builder(
150+
physics: physics,
151+
padding: const EdgeInsets.only(bottom: 20),
152+
itemCount: _collectionList.length,
153+
itemBuilder: (context, index) {
154+
return _buildCollectionRow(
155+
_collectionList[index],
156+
verticalPadding: 8,
157+
onTap: () {
158+
RouteUtil.pushCupertinoRoute(
159+
context,
160+
CollectionDetailScreen(
161+
collectionId: _collectionList[index].id,
162+
blogId: _collectionList[index].blogId,
163+
blogName: "",
164+
postId: 0,
165+
),
166+
);
167+
},
168+
);
169+
},
170+
),
176171
);
177172
}
178173

lib/Screens/Info/grain_screen.dart

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ class _GrainScreenState extends State<GrainScreen>
4848
int _total = 0;
4949
int _offset = 0;
5050
final EasyRefreshController _refreshController = EasyRefreshController();
51-
final ScrollController _scrollController = ScrollController();
5251
bool _noMore = false;
5352

5453
@override
@@ -63,13 +62,6 @@ class _GrainScreenState extends State<GrainScreen>
6362
if (widget.infoMode != InfoMode.me) {
6463
_onRefresh();
6564
}
66-
_scrollController.addListener(() {
67-
if (!_noMore &&
68-
_scrollController.position.pixels >
69-
_scrollController.position.maxScrollExtent - kLoadExtentOffset) {
70-
_onLoad();
71-
}
72-
});
7365
}
7466

7567
_fetchGrain({bool refresh = false}) async {
@@ -84,7 +76,7 @@ class _GrainScreenState extends State<GrainScreen>
8476
.then((value) {
8577
try {
8678
if (value['code'] != 0) {
87-
IToast.showTop( value['desc'] ?? value['msg']);
79+
IToast.showTop(value['desc'] ?? value['msg']);
8880
return IndicatorResult.fail;
8981
} else {
9082
_total = value['data']['total'];
@@ -105,7 +97,7 @@ class _GrainScreenState extends State<GrainScreen>
10597
}
10698
}
10799
} catch (e) {
108-
if (mounted) IToast.showTop( "加载失败");
100+
if (mounted) IToast.showTop("加载失败");
109101
return IndicatorResult.fail;
110102
} finally {
111103
if (mounted) setState(() {});
@@ -145,26 +137,29 @@ class _GrainScreenState extends State<GrainScreen>
145137
}
146138

147139
Widget _buildBody(ScrollPhysics physics) {
148-
return ListView.builder(
149-
physics: physics,
150-
controller: _scrollController,
151-
padding: EdgeInsets.zero,
152-
itemCount: _grainList.length,
153-
itemBuilder: (context, index) {
154-
return _buildGrainRow(
155-
_grainList[index],
156-
verticalPadding: 8,
157-
onTap: () {
158-
RouteUtil.pushCupertinoRoute(
159-
context,
160-
GrainDetailScreen(
161-
grainId: _grainList[index].id,
162-
blogId: _grainList[index].userId,
163-
),
164-
);
165-
},
166-
);
167-
},
140+
return ItemBuilder.buildLoadMoreNotification(
141+
noMore: _noMore,
142+
onLoad: _onLoad,
143+
child: ListView.builder(
144+
physics: physics,
145+
padding: EdgeInsets.zero,
146+
itemCount: _grainList.length,
147+
itemBuilder: (context, index) {
148+
return _buildGrainRow(
149+
_grainList[index],
150+
verticalPadding: 8,
151+
onTap: () {
152+
RouteUtil.pushCupertinoRoute(
153+
context,
154+
GrainDetailScreen(
155+
grainId: _grainList[index].id,
156+
blogId: _grainList[index].userId,
157+
),
158+
);
159+
},
160+
);
161+
},
162+
),
168163
);
169164
}
170165

0 commit comments

Comments
 (0)